blob: 7704170fe2c8d13bd1cd36b44a07f43eaa3b67f3 [file] [log] [blame]
Gilles Peskine15c2cbf2020-06-25 18:36:28 +02001#!/usr/bin/env python3
2
3"""Analyze the test outcomes from a full CI run.
4
5This script can also run on outcomes from a partial run, but the results are
6less likely to be useful.
7"""
8
Przemek Stekiel85c54ea2022-11-17 11:50:23 +01009import re
Gilles Peskined8da2fc2024-09-17 15:07:22 +020010import typing
Gilles Peskine15c2cbf2020-06-25 18:36:28 +020011
Gilles Peskine738a5972024-10-03 18:52:58 +020012import scripts_path # pylint: disable=unused-import
13from mbedtls_framework import outcome_analysis
Gilles Peskine8d3c70a2020-06-25 18:37:43 +020014
Pengyu Lvc2e8f3a2023-11-28 17:22:04 +080015
Gilles Peskine45a32b12024-10-03 18:42:37 +020016class CoverageTask(outcome_analysis.CoverageTask):
Gilles Peskine4e606db2024-10-04 16:24:26 +020017 """Justify test cases that are never executed."""
Gilles Peskine95b2b0c2024-09-16 20:23:40 +020018
Gilles Peskined8da2fc2024-09-17 15:07:22 +020019 @staticmethod
Gilles Peskine72396da2024-09-17 17:15:29 +020020 def _has_word_re(words: typing.Iterable[str],
21 exclude: typing.Optional[str] = None) -> typing.Pattern:
Gilles Peskined8da2fc2024-09-17 15:07:22 +020022 """Construct a regex that matches if any of the words appears.
23
24 The occurrence must start and end at a word boundary.
Gilles Peskine72396da2024-09-17 17:15:29 +020025
26 If exclude is specified, strings containing a match for that
27 regular expression will not match the returned pattern.
Gilles Peskined8da2fc2024-09-17 15:07:22 +020028 """
Gilles Peskine72396da2024-09-17 17:15:29 +020029 exclude_clause = r''
30 if exclude:
31 exclude_clause = r'(?!.*' + exclude + ')'
32 return re.compile(exclude_clause +
33 r'.*\b(?:' + r'|'.join(words) + r')\b.*',
Gilles Peskine1abc8002024-10-11 12:00:44 +020034 re.DOTALL)
Gilles Peskined8da2fc2024-09-17 15:07:22 +020035
Gilles Peskined8da2fc2024-09-17 15:07:22 +020036 IGNORED_TESTS = {
Gilles Peskine9d54be52025-03-03 14:10:08 +010037 'handshake-generated': [
38 # Temporary disable Handshake defragmentation tests until mbedtls
39 # pr #10011 has been merged.
40 'Handshake defragmentation on client: len=4, TLS 1.2',
41 'Handshake defragmentation on client: len=5, TLS 1.2',
42 'Handshake defragmentation on client: len=13, TLS 1.2'
43 ],
Gilles Peskine419a5842024-09-17 18:32:05 +020044 'ssl-opt': [
45 # We don't run ssl-opt.sh with Valgrind on the CI because
46 # it's extremely slow. We don't intend to change this.
47 'DTLS client reconnect from same port: reconnect, nbio, valgrind',
Gilles Peskine419a5842024-09-17 18:32:05 +020048 # We don't have IPv6 in our CI environment.
49 # https://github.com/Mbed-TLS/mbedtls-test/issues/176
50 'DTLS cookie: enabled, IPv6',
51 # Disabled due to OpenSSL bug.
52 # https://github.com/openssl/openssl/issues/18887
53 'DTLS fragmenting: 3d, openssl client, DTLS 1.2',
54 # We don't run ssl-opt.sh with Valgrind on the CI because
55 # it's extremely slow. We don't intend to change this.
56 'DTLS fragmenting: proxy MTU: auto-reduction (with valgrind)',
57 # It seems that we don't run `ssl-opt.sh` with
58 # `MBEDTLS_USE_PSA_CRYPTO` enabled but `MBEDTLS_SSL_ASYNC_PRIVATE`
59 # disabled.
60 # https://github.com/Mbed-TLS/mbedtls/issues/9581
61 'Opaque key for server authentication: invalid key: decrypt with ECC key, no async',
62 'Opaque key for server authentication: invalid key: ecdh with RSA key, no async',
63 ],
Gilles Peskine47243fd2024-09-17 19:46:18 +020064 'test_suite_config.mbedtls_boolean': [
65 # We never test with CBC/PKCS5/PKCS12 enabled but
66 # PKCS7 padding disabled.
67 # https://github.com/Mbed-TLS/mbedtls/issues/9580
68 'Config: !MBEDTLS_CIPHER_PADDING_PKCS7',
69 # https://github.com/Mbed-TLS/mbedtls/issues/9583
70 'Config: !MBEDTLS_ECP_NIST_OPTIM',
Gilles Peskine44fdd922024-10-10 18:19:23 +020071 # MBEDTLS_ECP_NO_FALLBACK only affects builds using a partial
72 # alternative implementation of ECP arithmetic (with
73 # MBEDTLS_ECP_INTERNAL_ALT enabled). We don't test those builds.
74 # The configuration enumeration script skips xxx_ALT options
75 # but not MBEDTLS_ECP_NO_FALLBACK, so it appears in the report,
76 # but we don't care about it.
77 'Config: MBEDTLS_ECP_NO_FALLBACK',
Gilles Peskine47243fd2024-09-17 19:46:18 +020078 # Missing coverage of test configurations.
79 # https://github.com/Mbed-TLS/mbedtls/issues/9585
80 'Config: !MBEDTLS_SSL_DTLS_ANTI_REPLAY',
81 # Missing coverage of test configurations.
82 # https://github.com/Mbed-TLS/mbedtls/issues/9585
83 'Config: !MBEDTLS_SSL_DTLS_HELLO_VERIFY',
84 # We don't run test_suite_config when we test this.
85 # https://github.com/Mbed-TLS/mbedtls/issues/9586
86 'Config: !MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED',
87 # We only test multithreading with pthreads.
88 # https://github.com/Mbed-TLS/mbedtls/issues/9584
89 'Config: !MBEDTLS_THREADING_PTHREAD',
90 # Built but not tested.
91 # https://github.com/Mbed-TLS/mbedtls/issues/9587
92 'Config: MBEDTLS_AES_USE_HARDWARE_ONLY',
93 # Untested platform-specific optimizations.
94 # https://github.com/Mbed-TLS/mbedtls/issues/9588
95 'Config: MBEDTLS_HAVE_SSE2',
96 # Obsolete configuration option, to be replaced by
97 # PSA entropy drivers.
98 # https://github.com/Mbed-TLS/mbedtls/issues/8150
99 'Config: MBEDTLS_NO_PLATFORM_ENTROPY',
100 # Untested aspect of the platform interface.
101 # https://github.com/Mbed-TLS/mbedtls/issues/9589
102 'Config: MBEDTLS_PLATFORM_NO_STD_FUNCTIONS',
103 # In a client-server build, test_suite_config runs in the
104 # client configuration, so it will never report
105 # MBEDTLS_PSA_CRYPTO_SPM as enabled. That's ok.
106 'Config: MBEDTLS_PSA_CRYPTO_SPM',
107 # We don't test on armv8 yet.
108 'Config: MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT',
109 'Config: MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY',
110 'Config: MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY',
111 'Config: MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY',
112 # We don't run test_suite_config when we test this.
113 # https://github.com/Mbed-TLS/mbedtls/issues/9586
114 'Config: MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND',
115 ],
116 'test_suite_config.psa_boolean': [
117 # We don't test with HMAC disabled.
118 # https://github.com/Mbed-TLS/mbedtls/issues/9591
119 'Config: !PSA_WANT_ALG_HMAC',
Gilles Peskine47243fd2024-09-17 19:46:18 +0200120 # The DERIVE key type is always enabled.
121 'Config: !PSA_WANT_KEY_TYPE_DERIVE',
122 # More granularity of key pair type enablement macros
123 # than we care to test.
124 # https://github.com/Mbed-TLS/mbedtls/issues/9590
125 'Config: !PSA_WANT_KEY_TYPE_DH_KEY_PAIR_EXPORT',
126 'Config: !PSA_WANT_KEY_TYPE_DH_KEY_PAIR_GENERATE',
127 'Config: !PSA_WANT_KEY_TYPE_DH_KEY_PAIR_IMPORT',
128 # More granularity of key pair type enablement macros
129 # than we care to test.
130 # https://github.com/Mbed-TLS/mbedtls/issues/9590
131 'Config: !PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT',
132 'Config: !PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT',
133 # We don't test with HMAC disabled.
134 # https://github.com/Mbed-TLS/mbedtls/issues/9591
135 'Config: !PSA_WANT_KEY_TYPE_HMAC',
136 # The PASSWORD key type is always enabled.
137 'Config: !PSA_WANT_KEY_TYPE_PASSWORD',
138 # The PASSWORD_HASH key type is always enabled.
139 'Config: !PSA_WANT_KEY_TYPE_PASSWORD_HASH',
140 # The RAW_DATA key type is always enabled.
141 'Config: !PSA_WANT_KEY_TYPE_RAW_DATA',
142 # More granularity of key pair type enablement macros
143 # than we care to test.
144 # https://github.com/Mbed-TLS/mbedtls/issues/9590
145 'Config: !PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_EXPORT',
146 'Config: !PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT',
147 # Algorithm declared but not supported.
148 'Config: PSA_WANT_ALG_CBC_MAC',
149 # Algorithm declared but not supported.
150 'Config: PSA_WANT_ALG_XTS',
151 # Family declared but not supported.
152 'Config: PSA_WANT_ECC_SECP_K1_224',
153 # More granularity of key pair type enablement macros
154 # than we care to test.
155 # https://github.com/Mbed-TLS/mbedtls/issues/9590
156 'Config: PSA_WANT_KEY_TYPE_DH_KEY_PAIR_DERIVE',
157 'Config: PSA_WANT_KEY_TYPE_ECC_KEY_PAIR',
158 'Config: PSA_WANT_KEY_TYPE_RSA_KEY_PAIR',
159 'Config: PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_DERIVE',
160 ],
161 'test_suite_config.psa_combinations': [
162 # We don't test this unusual, but sensible configuration.
163 # https://github.com/Mbed-TLS/mbedtls/issues/9592
164 'Config: PSA_WANT_ALG_DETERMINSTIC_ECDSA without PSA_WANT_ALG_ECDSA',
165 ],
Gilles Peskine1a176272024-09-17 18:33:29 +0200166 'test_suite_pkcs12': [
Gilles Peskine47243fd2024-09-17 19:46:18 +0200167 # We never test with CBC/PKCS5/PKCS12 enabled but
168 # PKCS7 padding disabled.
Gilles Peskine1a176272024-09-17 18:33:29 +0200169 # https://github.com/Mbed-TLS/mbedtls/issues/9580
170 'PBE Decrypt, (Invalid padding & PKCS7 padding disabled)',
171 'PBE Encrypt, pad = 8 (PKCS7 padding disabled)',
172 ],
173 'test_suite_pkcs5': [
Gilles Peskine47243fd2024-09-17 19:46:18 +0200174 # We never test with CBC/PKCS5/PKCS12 enabled but
175 # PKCS7 padding disabled.
Gilles Peskine1a176272024-09-17 18:33:29 +0200176 # https://github.com/Mbed-TLS/mbedtls/issues/9580
177 'PBES2 Decrypt (Invalid padding & PKCS7 padding disabled)',
178 'PBES2 Encrypt, pad=6 (PKCS7 padding disabled)',
179 'PBES2 Encrypt, pad=8 (PKCS7 padding disabled)',
180 ],
Gilles Peskine8729b102024-04-19 19:08:34 +0200181 'test_suite_psa_crypto': [
182 # We don't test this unusual, but sensible configuration.
183 # https://github.com/Mbed-TLS/mbedtls/issues/9592
184 re.compile(r'.*ECDSA.*only deterministic supported'),
185 ],
Gilles Peskine1a176272024-09-17 18:33:29 +0200186 'test_suite_psa_crypto_metadata': [
187 # Algorithms declared but not supported.
188 # https://github.com/Mbed-TLS/mbedtls/issues/9579
189 'Asymmetric signature: Ed25519ph',
190 'Asymmetric signature: Ed448ph',
191 'Asymmetric signature: pure EdDSA',
192 'Cipher: XTS',
193 'MAC: CBC_MAC-3DES',
194 'MAC: CBC_MAC-AES-128',
195 'MAC: CBC_MAC-AES-192',
196 'MAC: CBC_MAC-AES-256',
197 ],
Gilles Peskined8da2fc2024-09-17 15:07:22 +0200198 'test_suite_psa_crypto_not_supported.generated': [
Gilles Peskine1abc8002024-10-11 12:00:44 +0200199 # We never test with DH key support disabled but support
Gilles Peskine1fac3712024-09-17 17:57:11 +0200200 # for a DH group enabled. The dependencies of these test
201 # cases don't really make sense.
202 # https://github.com/Mbed-TLS/mbedtls/issues/9574
203 re.compile(r'PSA \w+ DH_.*type not supported'),
204 # We only test partial support for DH with the 2048-bit group
205 # enabled and the other groups disabled.
206 # https://github.com/Mbed-TLS/mbedtls/issues/9575
207 'PSA generate DH_KEY_PAIR(RFC7919) 2048-bit group not supported',
208 'PSA import DH_KEY_PAIR(RFC7919) 2048-bit group not supported',
209 'PSA import DH_PUBLIC_KEY(RFC7919) 2048-bit group not supported',
Gilles Peskined8da2fc2024-09-17 15:07:22 +0200210 ],
211 'test_suite_psa_crypto_op_fail.generated': [
Gilles Peskine8729b102024-04-19 19:08:34 +0200212 # We don't test this unusual, but sensible configuration.
213 # https://github.com/Mbed-TLS/mbedtls/issues/9592
214 re.compile(r'.*: !ECDSA but DETERMINISTIC_ECDSA with ECC_.*'),
Gilles Peskine1fac3712024-09-17 17:57:11 +0200215 # PBKDF2_HMAC is not in the default configuration, so we don't
216 # enable it in depends.py where we remove hashes.
217 # https://github.com/Mbed-TLS/mbedtls/issues/9576
218 re.compile(r'PSA key_derivation PBKDF2_HMAC\(\w+\): !(?!PBKDF2_HMAC\Z).*'),
Gilles Peskine1fac3712024-09-17 17:57:11 +0200219
220 # We never test with the HMAC algorithm enabled but the HMAC
221 # key type disabled. Those dependencies don't really make sense.
222 # https://github.com/Mbed-TLS/mbedtls/issues/9573
223 re.compile(r'.* !HMAC with HMAC'),
224 # There's something wrong with PSA_WANT_ALG_RSA_PSS_ANY_SALT
225 # differing from PSA_WANT_ALG_RSA_PSS.
226 # https://github.com/Mbed-TLS/mbedtls/issues/9578
227 re.compile(r'PSA sign RSA_PSS_ANY_SALT.*!(?:MD|RIPEMD|SHA).*'),
Gilles Peskinea6c1f562025-01-16 19:49:12 +0100228 # We don't test with ECDH disabled but the key type enabled.
229 # https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/161
230 re.compile(r'PSA key_agreement.* !ECDH with ECC_KEY_PAIR\(.*'),
231 # We don't test with FFDH disabled but the key type enabled.
232 # https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/160
233 re.compile(r'PSA key_agreement.* !FFDH with DH_KEY_PAIR\(.*'),
Gilles Peskined8da2fc2024-09-17 15:07:22 +0200234 ],
Gilles Peskine8729b102024-04-19 19:08:34 +0200235 'test_suite_psa_crypto_op_fail.misc': [
236 # We don't test this unusual, but sensible configuration.
237 # https://github.com/Mbed-TLS/mbedtls/issues/9592
238 'PSA sign DETERMINISTIC_ECDSA(SHA_256): !ECDSA but DETERMINISTIC_ECDSA with ECC_KEY_PAIR(SECP_R1)', #pylint: disable=line-too-long
239 ],
Gilles Peskine419a5842024-09-17 18:32:05 +0200240 'tls13-misc': [
241 # Disabled due to OpenSSL bug.
242 # https://github.com/openssl/openssl/issues/10714
243 'TLS 1.3 O->m: resumption',
244 # Disabled due to OpenSSL command line limitation.
245 # https://github.com/Mbed-TLS/mbedtls/issues/9582
246 'TLS 1.3 m->O: resumption with early data',
247 ],
Gilles Peskined8da2fc2024-09-17 15:07:22 +0200248 }
249
Gilles Peskine17e071b2024-09-16 19:57:10 +0200250
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200251# The names that we give to classes derived from DriverVSReference do not
252# follow the usual naming convention, because it's more readable to use
253# underscores and parts of the configuration names. Also, these classes
254# are just there to specify some data, so they don't need repetitive
255# documentation.
256#pylint: disable=invalid-name,missing-class-docstring
257
Gilles Peskine45a32b12024-10-03 18:42:37 +0200258class DriverVSReference_hash(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200259 REFERENCE = 'test_psa_crypto_config_reference_hash_use_psa'
260 DRIVER = 'test_psa_crypto_config_accel_hash_use_psa'
261 IGNORED_SUITES = [
262 'shax', 'mdx', # the software implementations that are being excluded
263 'md.psa', # purposefully depends on whether drivers are present
264 'psa_crypto_low_hash.generated', # testing the builtins
265 ]
266 IGNORED_TESTS = {
267 'test_suite_config': [
268 re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'),
269 ],
270 'test_suite_platform': [
271 # Incompatible with sanitizers (e.g. ASan). If the driver
272 # component uses a sanitizer but the reference component
273 # doesn't, we have a PASS vs SKIP mismatch.
274 'Check mbedtls_calloc overallocation',
275 ],
276 }
277
Gilles Peskine45a32b12024-10-03 18:42:37 +0200278class DriverVSReference_hmac(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200279 REFERENCE = 'test_psa_crypto_config_reference_hmac'
280 DRIVER = 'test_psa_crypto_config_accel_hmac'
281 IGNORED_SUITES = [
282 # These suites require legacy hash support, which is disabled
283 # in the accelerated component.
284 'shax', 'mdx',
285 # This suite tests builtins directly, but these are missing
286 # in the accelerated case.
287 'psa_crypto_low_hash.generated',
288 ]
289 IGNORED_TESTS = {
290 'test_suite_config': [
291 re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'),
292 re.compile(r'.*\bMBEDTLS_MD_C\b')
293 ],
294 'test_suite_md': [
295 # Builtin HMAC is not supported in the accelerate component.
296 re.compile('.*HMAC.*'),
297 # Following tests make use of functions which are not available
298 # when MD_C is disabled, as it happens in the accelerated
299 # test component.
300 re.compile('generic .* Hash file .*'),
301 'MD list',
302 ],
303 'test_suite_md.psa': [
304 # "legacy only" tests require hash algorithms to be NOT
305 # accelerated, but this of course false for the accelerated
306 # test component.
307 re.compile('PSA dispatch .* legacy only'),
308 ],
309 'test_suite_platform': [
310 # Incompatible with sanitizers (e.g. ASan). If the driver
311 # component uses a sanitizer but the reference component
312 # doesn't, we have a PASS vs SKIP mismatch.
313 'Check mbedtls_calloc overallocation',
314 ],
315 }
316
Gilles Peskine45a32b12024-10-03 18:42:37 +0200317class DriverVSReference_cipher_aead_cmac(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200318 REFERENCE = 'test_psa_crypto_config_reference_cipher_aead_cmac'
319 DRIVER = 'test_psa_crypto_config_accel_cipher_aead_cmac'
320 # Modules replaced by drivers.
321 IGNORED_SUITES = [
322 # low-level (block/stream) cipher modules
323 'aes', 'aria', 'camellia', 'des', 'chacha20',
324 # AEAD modes and CMAC
325 'ccm', 'chachapoly', 'cmac', 'gcm',
326 # The Cipher abstraction layer
327 'cipher',
328 ]
329 IGNORED_TESTS = {
330 'test_suite_config': [
331 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA|CHACHA20|DES)_.*'),
332 re.compile(r'.*\bMBEDTLS_(CCM|CHACHAPOLY|CMAC|GCM)_.*'),
333 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
334 re.compile(r'.*\bMBEDTLS_CIPHER_.*'),
335 ],
336 # PEM decryption is not supported so far.
337 # The rest of PEM (write, unencrypted read) works though.
338 'test_suite_pem': [
339 re.compile(r'PEM read .*(AES|DES|\bencrypt).*'),
340 ],
341 'test_suite_platform': [
342 # Incompatible with sanitizers (e.g. ASan). If the driver
343 # component uses a sanitizer but the reference component
344 # doesn't, we have a PASS vs SKIP mismatch.
345 'Check mbedtls_calloc overallocation',
346 ],
347 # Following tests depend on AES_C/DES_C but are not about
348 # them really, just need to know some error code is there.
349 'test_suite_error': [
350 'Low and high error',
351 'Single low error'
352 ],
353 # Similar to test_suite_error above.
354 'test_suite_version': [
355 'Check for MBEDTLS_AES_C when already present',
356 ],
357 # The en/decryption part of PKCS#12 is not supported so far.
358 # The rest of PKCS#12 (key derivation) works though.
359 'test_suite_pkcs12': [
360 re.compile(r'PBE Encrypt, .*'),
361 re.compile(r'PBE Decrypt, .*'),
362 ],
363 # The en/decryption part of PKCS#5 is not supported so far.
364 # The rest of PKCS#5 (PBKDF2) works though.
365 'test_suite_pkcs5': [
366 re.compile(r'PBES2 Encrypt, .*'),
367 re.compile(r'PBES2 Decrypt .*'),
368 ],
369 # Encrypted keys are not supported so far.
370 # pylint: disable=line-too-long
371 'test_suite_pkparse': [
372 'Key ASN1 (Encrypted key PKCS12, trailing garbage data)',
373 'Key ASN1 (Encrypted key PKCS5, trailing garbage data)',
374 re.compile(r'Parse (RSA|EC) Key .*\(.* ([Ee]ncrypted|password).*\)'),
375 ],
376 # Encrypted keys are not supported so far.
377 'ssl-opt': [
378 'TLS: password protected server key',
379 'TLS: password protected client key',
380 'TLS: password protected server key, two certificates',
381 ],
382 }
383
Gilles Peskine45a32b12024-10-03 18:42:37 +0200384class DriverVSReference_ecp_light_only(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200385 REFERENCE = 'test_psa_crypto_config_reference_ecc_ecp_light_only'
386 DRIVER = 'test_psa_crypto_config_accel_ecc_ecp_light_only'
387 IGNORED_SUITES = [
388 # Modules replaced by drivers
389 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine9a094432024-10-29 20:55:11 +0100390 # Unit tests for the built-in implementation
391 'psa_crypto_ecp',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200392 ]
393 IGNORED_TESTS = {
394 'test_suite_config': [
395 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
396 ],
397 'test_suite_platform': [
398 # Incompatible with sanitizers (e.g. ASan). If the driver
399 # component uses a sanitizer but the reference component
400 # doesn't, we have a PASS vs SKIP mismatch.
401 'Check mbedtls_calloc overallocation',
402 ],
403 # This test wants a legacy function that takes f_rng, p_rng
404 # arguments, and uses legacy ECDSA for that. The test is
405 # really about the wrapper around the PSA RNG, not ECDSA.
406 'test_suite_random': [
407 'PSA classic wrapper: ECDSA signature (SECP256R1)',
408 ],
409 # In the accelerated test ECP_C is not set (only ECP_LIGHT is)
410 # so we must ignore disparities in the tests for which ECP_C
411 # is required.
412 'test_suite_ecp': [
413 re.compile(r'ECP check public-private .*'),
414 re.compile(r'ECP calculate public: .*'),
415 re.compile(r'ECP gen keypair .*'),
416 re.compile(r'ECP point muladd .*'),
417 re.compile(r'ECP point multiplication .*'),
418 re.compile(r'ECP test vectors .*'),
419 ],
420 'test_suite_ssl': [
421 # This deprecated function is only present when ECP_C is On.
Valerio Setti1a0ee062025-01-22 11:03:46 +0100422 'Test configuration of EC groups through mbedtls_ssl_conf_curves()',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200423 ],
424 }
425
Gilles Peskine45a32b12024-10-03 18:42:37 +0200426class DriverVSReference_no_ecp_at_all(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200427 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_ecp_at_all'
428 DRIVER = 'test_psa_crypto_config_accel_ecc_no_ecp_at_all'
429 IGNORED_SUITES = [
430 # Modules replaced by drivers
431 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine9a094432024-10-29 20:55:11 +0100432 # Unit tests for the built-in implementation
433 'psa_crypto_ecp',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200434 ]
435 IGNORED_TESTS = {
436 'test_suite_config': [
437 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
438 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
439 ],
440 'test_suite_platform': [
441 # Incompatible with sanitizers (e.g. ASan). If the driver
442 # component uses a sanitizer but the reference component
443 # doesn't, we have a PASS vs SKIP mismatch.
444 'Check mbedtls_calloc overallocation',
445 ],
446 # See ecp_light_only
447 'test_suite_random': [
448 'PSA classic wrapper: ECDSA signature (SECP256R1)',
449 ],
450 'test_suite_pkparse': [
451 # When PK_PARSE_C and ECP_C are defined then PK_PARSE_EC_COMPRESSED
452 # is automatically enabled in build_info.h (backward compatibility)
453 # even if it is disabled in config_psa_crypto_no_ecp_at_all(). As a
454 # consequence compressed points are supported in the reference
455 # component but not in the accelerated one, so they should be skipped
456 # while checking driver's coverage.
457 re.compile(r'Parse EC Key .*compressed\)'),
458 re.compile(r'Parse Public EC Key .*compressed\)'),
459 ],
460 # See ecp_light_only
461 'test_suite_ssl': [
Valerio Setti1a0ee062025-01-22 11:03:46 +0100462 'Test configuration of EC groups through mbedtls_ssl_conf_curves()',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200463 ],
464 }
465
Gilles Peskine45a32b12024-10-03 18:42:37 +0200466class DriverVSReference_ecc_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200467 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_bignum'
468 DRIVER = 'test_psa_crypto_config_accel_ecc_no_bignum'
469 IGNORED_SUITES = [
470 # Modules replaced by drivers
471 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
472 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
473 'bignum.generated', 'bignum.misc',
Gilles Peskine9a094432024-10-29 20:55:11 +0100474 # Unit tests for the built-in implementation
475 'psa_crypto_ecp',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200476 ]
477 IGNORED_TESTS = {
478 'test_suite_config': [
479 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
480 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
481 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
482 ],
483 'test_suite_platform': [
484 # Incompatible with sanitizers (e.g. ASan). If the driver
485 # component uses a sanitizer but the reference component
486 # doesn't, we have a PASS vs SKIP mismatch.
487 'Check mbedtls_calloc overallocation',
488 ],
489 # See ecp_light_only
490 'test_suite_random': [
491 'PSA classic wrapper: ECDSA signature (SECP256R1)',
492 ],
493 # See no_ecp_at_all
494 'test_suite_pkparse': [
495 re.compile(r'Parse EC Key .*compressed\)'),
496 re.compile(r'Parse Public EC Key .*compressed\)'),
497 ],
498 'test_suite_asn1parse': [
499 'INTEGER too large for mpi',
500 ],
501 'test_suite_asn1write': [
502 re.compile(r'ASN.1 Write mpi.*'),
503 ],
504 'test_suite_debug': [
505 re.compile(r'Debug print mbedtls_mpi.*'),
506 ],
507 # See ecp_light_only
508 'test_suite_ssl': [
Valerio Setti1a0ee062025-01-22 11:03:46 +0100509 'Test configuration of EC groups through mbedtls_ssl_conf_curves()',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200510 ],
511 }
512
Gilles Peskine45a32b12024-10-03 18:42:37 +0200513class DriverVSReference_ecc_ffdh_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200514 REFERENCE = 'test_psa_crypto_config_reference_ecc_ffdh_no_bignum'
515 DRIVER = 'test_psa_crypto_config_accel_ecc_ffdh_no_bignum'
516 IGNORED_SUITES = [
517 # Modules replaced by drivers
518 'ecp', 'ecdsa', 'ecdh', 'ecjpake', 'dhm',
519 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
520 'bignum.generated', 'bignum.misc',
Gilles Peskine9a094432024-10-29 20:55:11 +0100521 # Unit tests for the built-in implementation
522 'psa_crypto_ecp',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200523 ]
524 IGNORED_TESTS = {
525 'ssl-opt': [
526 # DHE support in TLS 1.2 requires built-in MBEDTLS_DHM_C
527 # (because it needs custom groups, which PSA does not
528 # provide), even with MBEDTLS_USE_PSA_CRYPTO.
529 re.compile(r'PSK callback:.*\bdhe-psk\b.*'),
530 ],
531 'test_suite_config': [
532 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
533 re.compile(r'.*\bMBEDTLS_DHM_C\b.*'),
534 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
535 re.compile(r'.*\bMBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED\b.*'),
536 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
537 ],
538 'test_suite_platform': [
539 # Incompatible with sanitizers (e.g. ASan). If the driver
540 # component uses a sanitizer but the reference component
541 # doesn't, we have a PASS vs SKIP mismatch.
542 'Check mbedtls_calloc overallocation',
543 ],
544 # See ecp_light_only
545 'test_suite_random': [
546 'PSA classic wrapper: ECDSA signature (SECP256R1)',
547 ],
548 # See no_ecp_at_all
549 'test_suite_pkparse': [
550 re.compile(r'Parse EC Key .*compressed\)'),
551 re.compile(r'Parse Public EC Key .*compressed\)'),
552 ],
553 'test_suite_asn1parse': [
554 'INTEGER too large for mpi',
555 ],
556 'test_suite_asn1write': [
557 re.compile(r'ASN.1 Write mpi.*'),
558 ],
559 'test_suite_debug': [
560 re.compile(r'Debug print mbedtls_mpi.*'),
561 ],
562 # See ecp_light_only
563 'test_suite_ssl': [
Valerio Setti1a0ee062025-01-22 11:03:46 +0100564 'Test configuration of EC groups through mbedtls_ssl_conf_curves()',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200565 ],
566 }
567
Gilles Peskine45a32b12024-10-03 18:42:37 +0200568class DriverVSReference_ffdh_alg(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200569 REFERENCE = 'test_psa_crypto_config_reference_ffdh'
570 DRIVER = 'test_psa_crypto_config_accel_ffdh'
571 IGNORED_SUITES = ['dhm']
572 IGNORED_TESTS = {
573 'test_suite_config': [
574 re.compile(r'.*\bMBEDTLS_DHM_C\b.*'),
575 ],
576 'test_suite_platform': [
577 # Incompatible with sanitizers (e.g. ASan). If the driver
578 # component uses a sanitizer but the reference component
579 # doesn't, we have a PASS vs SKIP mismatch.
580 'Check mbedtls_calloc overallocation',
581 ],
582 }
583
Gilles Peskine45a32b12024-10-03 18:42:37 +0200584class DriverVSReference_tfm_config(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200585 REFERENCE = 'test_tfm_config_no_p256m'
586 DRIVER = 'test_tfm_config_p256m_driver_accel_ec'
587 IGNORED_SUITES = [
588 # Modules replaced by drivers
589 'asn1parse', 'asn1write',
590 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
591 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
592 'bignum.generated', 'bignum.misc',
Gilles Peskine9a094432024-10-29 20:55:11 +0100593 # Unit tests for the built-in implementation
594 'psa_crypto_ecp',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200595 ]
596 IGNORED_TESTS = {
597 'test_suite_config': [
598 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
599 re.compile(r'.*\bMBEDTLS_(ASN1\w+)_C\b.*'),
600 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECP)_.*'),
601 re.compile(r'.*\bMBEDTLS_PSA_P256M_DRIVER_ENABLED\b.*')
602 ],
603 'test_suite_config.crypto_combinations': [
604 'Config: ECC: Weierstrass curves only',
605 ],
606 'test_suite_platform': [
607 # Incompatible with sanitizers (e.g. ASan). If the driver
608 # component uses a sanitizer but the reference component
609 # doesn't, we have a PASS vs SKIP mismatch.
610 'Check mbedtls_calloc overallocation',
611 ],
612 # See ecp_light_only
613 'test_suite_random': [
614 'PSA classic wrapper: ECDSA signature (SECP256R1)',
615 ],
616 }
617
Gilles Peskine45a32b12024-10-03 18:42:37 +0200618class DriverVSReference_rsa(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200619 REFERENCE = 'test_psa_crypto_config_reference_rsa_crypto'
620 DRIVER = 'test_psa_crypto_config_accel_rsa_crypto'
621 IGNORED_SUITES = [
622 # Modules replaced by drivers.
623 'rsa', 'pkcs1_v15', 'pkcs1_v21',
624 # We temporarily don't care about PK stuff.
625 'pk', 'pkwrite', 'pkparse'
626 ]
627 IGNORED_TESTS = {
628 'test_suite_config': [
629 re.compile(r'.*\bMBEDTLS_(PKCS1|RSA)_.*'),
630 re.compile(r'.*\bMBEDTLS_GENPRIME\b.*')
631 ],
632 'test_suite_platform': [
633 # Incompatible with sanitizers (e.g. ASan). If the driver
634 # component uses a sanitizer but the reference component
635 # doesn't, we have a PASS vs SKIP mismatch.
636 'Check mbedtls_calloc overallocation',
637 ],
638 # Following tests depend on RSA_C but are not about
639 # them really, just need to know some error code is there.
640 'test_suite_error': [
641 'Low and high error',
642 'Single high error'
643 ],
644 # Constant time operations only used for PKCS1_V15
645 'test_suite_constant_time': [
646 re.compile(r'mbedtls_ct_zeroize_if .*'),
647 re.compile(r'mbedtls_ct_memmove_left .*')
648 ],
649 'test_suite_psa_crypto': [
650 # We don't support generate_key_custom entry points
651 # in drivers yet.
652 re.compile(r'PSA generate key custom: RSA, e=.*'),
653 re.compile(r'PSA generate key ext: RSA, e=.*'),
654 ],
655 }
656
Gilles Peskine45a32b12024-10-03 18:42:37 +0200657class DriverVSReference_block_cipher_dispatch(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200658 REFERENCE = 'test_full_block_cipher_legacy_dispatch'
659 DRIVER = 'test_full_block_cipher_psa_dispatch'
660 IGNORED_SUITES = [
661 # Skipped in the accelerated component
662 'aes', 'aria', 'camellia',
663 # These require AES_C, ARIA_C or CAMELLIA_C to be enabled in
664 # order for the cipher module (actually cipher_wrapper) to work
665 # properly. However these symbols are disabled in the accelerated
666 # component so we ignore them.
667 'cipher.ccm', 'cipher.gcm', 'cipher.aes', 'cipher.aria',
668 'cipher.camellia',
669 ]
670 IGNORED_TESTS = {
671 'test_suite_config': [
672 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA)_.*'),
673 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
674 ],
675 'test_suite_cmac': [
676 # Following tests require AES_C/ARIA_C/CAMELLIA_C to be enabled,
677 # but these are not available in the accelerated component.
678 'CMAC null arguments',
679 re.compile('CMAC.* (AES|ARIA|Camellia).*'),
680 ],
681 'test_suite_cipher.padding': [
682 # Following tests require AES_C/CAMELLIA_C to be enabled,
683 # but these are not available in the accelerated component.
684 re.compile('Set( non-existent)? padding with (AES|CAMELLIA).*'),
685 ],
686 'test_suite_pkcs5': [
687 # The AES part of PKCS#5 PBES2 is not yet supported.
688 # The rest of PKCS#5 (PBKDF2) works, though.
689 re.compile(r'PBES2 .* AES-.*')
690 ],
691 'test_suite_pkparse': [
692 # PEM (called by pkparse) requires AES_C in order to decrypt
693 # the key, but this is not available in the accelerated
694 # component.
695 re.compile('Parse RSA Key.*(password|AES-).*'),
696 ],
697 'test_suite_pem': [
698 # Following tests require AES_C, but this is diabled in the
699 # accelerated component.
700 re.compile('PEM read .*AES.*'),
701 'PEM read (unknown encryption algorithm)',
702 ],
703 'test_suite_error': [
704 # Following tests depend on AES_C but are not about them
705 # really, just need to know some error code is there.
706 'Single low error',
707 'Low and high error',
708 ],
709 'test_suite_version': [
710 # Similar to test_suite_error above.
711 'Check for MBEDTLS_AES_C when already present',
712 ],
713 'test_suite_platform': [
714 # Incompatible with sanitizers (e.g. ASan). If the driver
715 # component uses a sanitizer but the reference component
716 # doesn't, we have a PASS vs SKIP mismatch.
717 'Check mbedtls_calloc overallocation',
718 ],
719 }
720
721#pylint: enable=invalid-name,missing-class-docstring
722
723
Przemek Stekiel6856f4c2022-11-09 10:50:29 +0100724# List of tasks with a function that can handle this task and additional arguments if required
Valerio Settidfd7ca62023-10-09 16:30:11 +0200725KNOWN_TASKS = {
Gilles Peskine0316f102024-09-16 19:15:29 +0200726 'analyze_coverage': CoverageTask,
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200727 'analyze_driver_vs_reference_hash': DriverVSReference_hash,
728 'analyze_driver_vs_reference_hmac': DriverVSReference_hmac,
729 'analyze_driver_vs_reference_cipher_aead_cmac': DriverVSReference_cipher_aead_cmac,
730 'analyze_driver_vs_reference_ecp_light_only': DriverVSReference_ecp_light_only,
731 'analyze_driver_vs_reference_no_ecp_at_all': DriverVSReference_no_ecp_at_all,
732 'analyze_driver_vs_reference_ecc_no_bignum': DriverVSReference_ecc_no_bignum,
733 'analyze_driver_vs_reference_ecc_ffdh_no_bignum': DriverVSReference_ecc_ffdh_no_bignum,
734 'analyze_driver_vs_reference_ffdh_alg': DriverVSReference_ffdh_alg,
735 'analyze_driver_vs_reference_tfm_config': DriverVSReference_tfm_config,
736 'analyze_driver_vs_reference_rsa': DriverVSReference_rsa,
737 'analyze_block_cipher_dispatch': DriverVSReference_block_cipher_dispatch,
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200738}
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200739
Gilles Peskine15c2cbf2020-06-25 18:36:28 +0200740if __name__ == '__main__':
Gilles Peskine45a32b12024-10-03 18:42:37 +0200741 outcome_analysis.main(KNOWN_TASKS)