blob: 7b4314515111fb0f08703dd2d10a523eb27332a5 [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 Peskine419a5842024-09-17 18:32:05 +020037 'ssl-opt': [
38 # We don't run ssl-opt.sh with Valgrind on the CI because
39 # it's extremely slow. We don't intend to change this.
40 'DTLS client reconnect from same port: reconnect, nbio, valgrind',
Gilles Peskine419a5842024-09-17 18:32:05 +020041 # We don't have IPv6 in our CI environment.
42 # https://github.com/Mbed-TLS/mbedtls-test/issues/176
43 'DTLS cookie: enabled, IPv6',
44 # Disabled due to OpenSSL bug.
45 # https://github.com/openssl/openssl/issues/18887
46 'DTLS fragmenting: 3d, openssl client, DTLS 1.2',
47 # We don't run ssl-opt.sh with Valgrind on the CI because
48 # it's extremely slow. We don't intend to change this.
49 'DTLS fragmenting: proxy MTU: auto-reduction (with valgrind)',
50 # It seems that we don't run `ssl-opt.sh` with
51 # `MBEDTLS_USE_PSA_CRYPTO` enabled but `MBEDTLS_SSL_ASYNC_PRIVATE`
52 # disabled.
53 # https://github.com/Mbed-TLS/mbedtls/issues/9581
54 'Opaque key for server authentication: invalid key: decrypt with ECC key, no async',
55 'Opaque key for server authentication: invalid key: ecdh with RSA key, no async',
56 ],
Gilles Peskine47243fd2024-09-17 19:46:18 +020057 'test_suite_config.mbedtls_boolean': [
58 # We never test with CBC/PKCS5/PKCS12 enabled but
59 # PKCS7 padding disabled.
60 # https://github.com/Mbed-TLS/mbedtls/issues/9580
61 'Config: !MBEDTLS_CIPHER_PADDING_PKCS7',
62 # https://github.com/Mbed-TLS/mbedtls/issues/9583
63 'Config: !MBEDTLS_ECP_NIST_OPTIM',
Gilles Peskine44fdd922024-10-10 18:19:23 +020064 # MBEDTLS_ECP_NO_FALLBACK only affects builds using a partial
65 # alternative implementation of ECP arithmetic (with
66 # MBEDTLS_ECP_INTERNAL_ALT enabled). We don't test those builds.
67 # The configuration enumeration script skips xxx_ALT options
68 # but not MBEDTLS_ECP_NO_FALLBACK, so it appears in the report,
69 # but we don't care about it.
70 'Config: MBEDTLS_ECP_NO_FALLBACK',
Gilles Peskine47243fd2024-09-17 19:46:18 +020071 # Missing coverage of test configurations.
72 # https://github.com/Mbed-TLS/mbedtls/issues/9585
73 'Config: !MBEDTLS_SSL_DTLS_ANTI_REPLAY',
74 # Missing coverage of test configurations.
75 # https://github.com/Mbed-TLS/mbedtls/issues/9585
76 'Config: !MBEDTLS_SSL_DTLS_HELLO_VERIFY',
77 # We don't run test_suite_config when we test this.
78 # https://github.com/Mbed-TLS/mbedtls/issues/9586
79 'Config: !MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED',
80 # We only test multithreading with pthreads.
81 # https://github.com/Mbed-TLS/mbedtls/issues/9584
82 'Config: !MBEDTLS_THREADING_PTHREAD',
83 # Built but not tested.
84 # https://github.com/Mbed-TLS/mbedtls/issues/9587
85 'Config: MBEDTLS_AES_USE_HARDWARE_ONLY',
86 # Untested platform-specific optimizations.
87 # https://github.com/Mbed-TLS/mbedtls/issues/9588
88 'Config: MBEDTLS_HAVE_SSE2',
Gilles Peskine47243fd2024-09-17 19:46:18 +020089 # Untested aspect of the platform interface.
90 # https://github.com/Mbed-TLS/mbedtls/issues/9589
91 'Config: MBEDTLS_PLATFORM_NO_STD_FUNCTIONS',
92 # In a client-server build, test_suite_config runs in the
93 # client configuration, so it will never report
94 # MBEDTLS_PSA_CRYPTO_SPM as enabled. That's ok.
95 'Config: MBEDTLS_PSA_CRYPTO_SPM',
96 # We don't test on armv8 yet.
97 'Config: MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT',
98 'Config: MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY',
99 'Config: MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY',
100 'Config: MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY',
Gilles Peskine47243fd2024-09-17 19:46:18 +0200101 ],
102 'test_suite_config.psa_boolean': [
103 # We don't test with HMAC disabled.
104 # https://github.com/Mbed-TLS/mbedtls/issues/9591
105 'Config: !PSA_WANT_ALG_HMAC',
Gilles Peskine47243fd2024-09-17 19:46:18 +0200106 # The DERIVE key type is always enabled.
107 'Config: !PSA_WANT_KEY_TYPE_DERIVE',
108 # More granularity of key pair type enablement macros
109 # than we care to test.
110 # https://github.com/Mbed-TLS/mbedtls/issues/9590
111 'Config: !PSA_WANT_KEY_TYPE_DH_KEY_PAIR_EXPORT',
112 'Config: !PSA_WANT_KEY_TYPE_DH_KEY_PAIR_GENERATE',
113 'Config: !PSA_WANT_KEY_TYPE_DH_KEY_PAIR_IMPORT',
114 # More granularity of key pair type enablement macros
115 # than we care to test.
116 # https://github.com/Mbed-TLS/mbedtls/issues/9590
117 'Config: !PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT',
118 'Config: !PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT',
119 # We don't test with HMAC disabled.
120 # https://github.com/Mbed-TLS/mbedtls/issues/9591
121 'Config: !PSA_WANT_KEY_TYPE_HMAC',
122 # The PASSWORD key type is always enabled.
123 'Config: !PSA_WANT_KEY_TYPE_PASSWORD',
124 # The PASSWORD_HASH key type is always enabled.
125 'Config: !PSA_WANT_KEY_TYPE_PASSWORD_HASH',
126 # The RAW_DATA key type is always enabled.
127 'Config: !PSA_WANT_KEY_TYPE_RAW_DATA',
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_RSA_KEY_PAIR_EXPORT',
132 'Config: !PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT',
133 # Algorithm declared but not supported.
134 'Config: PSA_WANT_ALG_CBC_MAC',
135 # Algorithm declared but not supported.
136 'Config: PSA_WANT_ALG_XTS',
137 # Family declared but not supported.
138 'Config: PSA_WANT_ECC_SECP_K1_224',
139 # More granularity of key pair type enablement macros
140 # than we care to test.
141 # https://github.com/Mbed-TLS/mbedtls/issues/9590
142 'Config: PSA_WANT_KEY_TYPE_DH_KEY_PAIR_DERIVE',
143 'Config: PSA_WANT_KEY_TYPE_ECC_KEY_PAIR',
144 'Config: PSA_WANT_KEY_TYPE_RSA_KEY_PAIR',
145 'Config: PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_DERIVE',
146 ],
147 'test_suite_config.psa_combinations': [
148 # We don't test this unusual, but sensible configuration.
149 # https://github.com/Mbed-TLS/mbedtls/issues/9592
150 'Config: PSA_WANT_ALG_DETERMINSTIC_ECDSA without PSA_WANT_ALG_ECDSA',
151 ],
Gilles Peskine1a176272024-09-17 18:33:29 +0200152 'test_suite_pkcs12': [
Gilles Peskine47243fd2024-09-17 19:46:18 +0200153 # We never test with CBC/PKCS5/PKCS12 enabled but
154 # PKCS7 padding disabled.
Gilles Peskine1a176272024-09-17 18:33:29 +0200155 # https://github.com/Mbed-TLS/mbedtls/issues/9580
156 'PBE Decrypt, (Invalid padding & PKCS7 padding disabled)',
157 'PBE Encrypt, pad = 8 (PKCS7 padding disabled)',
158 ],
159 'test_suite_pkcs5': [
Gilles Peskine47243fd2024-09-17 19:46:18 +0200160 # We never test with CBC/PKCS5/PKCS12 enabled but
161 # PKCS7 padding disabled.
Gilles Peskine1a176272024-09-17 18:33:29 +0200162 # https://github.com/Mbed-TLS/mbedtls/issues/9580
163 'PBES2 Decrypt (Invalid padding & PKCS7 padding disabled)',
164 'PBES2 Encrypt, pad=6 (PKCS7 padding disabled)',
165 'PBES2 Encrypt, pad=8 (PKCS7 padding disabled)',
166 ],
Gilles Peskine8729b102024-04-19 19:08:34 +0200167 'test_suite_psa_crypto': [
168 # We don't test this unusual, but sensible configuration.
169 # https://github.com/Mbed-TLS/mbedtls/issues/9592
170 re.compile(r'.*ECDSA.*only deterministic supported'),
171 ],
Gilles Peskine1a176272024-09-17 18:33:29 +0200172 'test_suite_psa_crypto_metadata': [
173 # Algorithms declared but not supported.
174 # https://github.com/Mbed-TLS/mbedtls/issues/9579
175 'Asymmetric signature: Ed25519ph',
176 'Asymmetric signature: Ed448ph',
177 'Asymmetric signature: pure EdDSA',
178 'Cipher: XTS',
179 'MAC: CBC_MAC-3DES',
180 'MAC: CBC_MAC-AES-128',
181 'MAC: CBC_MAC-AES-192',
182 'MAC: CBC_MAC-AES-256',
183 ],
Gilles Peskined8da2fc2024-09-17 15:07:22 +0200184 'test_suite_psa_crypto_not_supported.generated': [
Gilles Peskine1abc8002024-10-11 12:00:44 +0200185 # We never test with DH key support disabled but support
Gilles Peskine1fac3712024-09-17 17:57:11 +0200186 # for a DH group enabled. The dependencies of these test
187 # cases don't really make sense.
188 # https://github.com/Mbed-TLS/mbedtls/issues/9574
189 re.compile(r'PSA \w+ DH_.*type not supported'),
190 # We only test partial support for DH with the 2048-bit group
191 # enabled and the other groups disabled.
192 # https://github.com/Mbed-TLS/mbedtls/issues/9575
193 'PSA generate DH_KEY_PAIR(RFC7919) 2048-bit group not supported',
194 'PSA import DH_KEY_PAIR(RFC7919) 2048-bit group not supported',
195 'PSA import DH_PUBLIC_KEY(RFC7919) 2048-bit group not supported',
Gilles Peskined8da2fc2024-09-17 15:07:22 +0200196 ],
197 'test_suite_psa_crypto_op_fail.generated': [
Gilles Peskine8729b102024-04-19 19:08:34 +0200198 # We don't test this unusual, but sensible configuration.
199 # https://github.com/Mbed-TLS/mbedtls/issues/9592
200 re.compile(r'.*: !ECDSA but DETERMINISTIC_ECDSA with ECC_.*'),
Gilles Peskine1fac3712024-09-17 17:57:11 +0200201 # PBKDF2_HMAC is not in the default configuration, so we don't
202 # enable it in depends.py where we remove hashes.
203 # https://github.com/Mbed-TLS/mbedtls/issues/9576
204 re.compile(r'PSA key_derivation PBKDF2_HMAC\(\w+\): !(?!PBKDF2_HMAC\Z).*'),
Gilles Peskine1fac3712024-09-17 17:57:11 +0200205
206 # We never test with the HMAC algorithm enabled but the HMAC
207 # key type disabled. Those dependencies don't really make sense.
208 # https://github.com/Mbed-TLS/mbedtls/issues/9573
209 re.compile(r'.* !HMAC with HMAC'),
210 # There's something wrong with PSA_WANT_ALG_RSA_PSS_ANY_SALT
211 # differing from PSA_WANT_ALG_RSA_PSS.
212 # https://github.com/Mbed-TLS/mbedtls/issues/9578
213 re.compile(r'PSA sign RSA_PSS_ANY_SALT.*!(?:MD|RIPEMD|SHA).*'),
Gilles Peskinea6c1f562025-01-16 19:49:12 +0100214 # We don't test with ECDH disabled but the key type enabled.
215 # https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/161
216 re.compile(r'PSA key_agreement.* !ECDH with ECC_KEY_PAIR\(.*'),
217 # We don't test with FFDH disabled but the key type enabled.
218 # https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/160
219 re.compile(r'PSA key_agreement.* !FFDH with DH_KEY_PAIR\(.*'),
Gilles Peskined8da2fc2024-09-17 15:07:22 +0200220 ],
Gilles Peskine8729b102024-04-19 19:08:34 +0200221 'test_suite_psa_crypto_op_fail.misc': [
222 # We don't test this unusual, but sensible configuration.
223 # https://github.com/Mbed-TLS/mbedtls/issues/9592
224 'PSA sign DETERMINISTIC_ECDSA(SHA_256): !ECDSA but DETERMINISTIC_ECDSA with ECC_KEY_PAIR(SECP_R1)', #pylint: disable=line-too-long
225 ],
Gilles Peskine419a5842024-09-17 18:32:05 +0200226 'tls13-misc': [
227 # Disabled due to OpenSSL bug.
228 # https://github.com/openssl/openssl/issues/10714
229 'TLS 1.3 O->m: resumption',
230 # Disabled due to OpenSSL command line limitation.
231 # https://github.com/Mbed-TLS/mbedtls/issues/9582
232 'TLS 1.3 m->O: resumption with early data',
233 ],
Gilles Peskined8da2fc2024-09-17 15:07:22 +0200234 }
235
Gilles Peskine17e071b2024-09-16 19:57:10 +0200236
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200237# The names that we give to classes derived from DriverVSReference do not
238# follow the usual naming convention, because it's more readable to use
239# underscores and parts of the configuration names. Also, these classes
240# are just there to specify some data, so they don't need repetitive
241# documentation.
242#pylint: disable=invalid-name,missing-class-docstring
243
Gilles Peskine45a32b12024-10-03 18:42:37 +0200244class DriverVSReference_hash(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200245 REFERENCE = 'test_psa_crypto_config_reference_hash_use_psa'
246 DRIVER = 'test_psa_crypto_config_accel_hash_use_psa'
247 IGNORED_SUITES = [
248 'shax', 'mdx', # the software implementations that are being excluded
249 'md.psa', # purposefully depends on whether drivers are present
250 'psa_crypto_low_hash.generated', # testing the builtins
251 ]
252 IGNORED_TESTS = {
253 'test_suite_config': [
254 re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'),
255 ],
256 'test_suite_platform': [
257 # Incompatible with sanitizers (e.g. ASan). If the driver
258 # component uses a sanitizer but the reference component
259 # doesn't, we have a PASS vs SKIP mismatch.
260 'Check mbedtls_calloc overallocation',
261 ],
262 }
263
Gilles Peskine45a32b12024-10-03 18:42:37 +0200264class DriverVSReference_hmac(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200265 REFERENCE = 'test_psa_crypto_config_reference_hmac'
266 DRIVER = 'test_psa_crypto_config_accel_hmac'
267 IGNORED_SUITES = [
268 # These suites require legacy hash support, which is disabled
269 # in the accelerated component.
270 'shax', 'mdx',
271 # This suite tests builtins directly, but these are missing
272 # in the accelerated case.
273 'psa_crypto_low_hash.generated',
274 ]
275 IGNORED_TESTS = {
276 'test_suite_config': [
277 re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'),
278 re.compile(r'.*\bMBEDTLS_MD_C\b')
279 ],
280 'test_suite_md': [
281 # Builtin HMAC is not supported in the accelerate component.
282 re.compile('.*HMAC.*'),
283 # Following tests make use of functions which are not available
284 # when MD_C is disabled, as it happens in the accelerated
285 # test component.
286 re.compile('generic .* Hash file .*'),
287 'MD list',
288 ],
289 'test_suite_md.psa': [
290 # "legacy only" tests require hash algorithms to be NOT
291 # accelerated, but this of course false for the accelerated
292 # test component.
293 re.compile('PSA dispatch .* legacy only'),
294 ],
295 'test_suite_platform': [
296 # Incompatible with sanitizers (e.g. ASan). If the driver
297 # component uses a sanitizer but the reference component
298 # doesn't, we have a PASS vs SKIP mismatch.
299 'Check mbedtls_calloc overallocation',
300 ],
301 }
302
Gilles Peskine45a32b12024-10-03 18:42:37 +0200303class DriverVSReference_cipher_aead_cmac(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200304 REFERENCE = 'test_psa_crypto_config_reference_cipher_aead_cmac'
305 DRIVER = 'test_psa_crypto_config_accel_cipher_aead_cmac'
306 # Modules replaced by drivers.
307 IGNORED_SUITES = [
308 # low-level (block/stream) cipher modules
309 'aes', 'aria', 'camellia', 'des', 'chacha20',
310 # AEAD modes and CMAC
311 'ccm', 'chachapoly', 'cmac', 'gcm',
312 # The Cipher abstraction layer
313 'cipher',
314 ]
315 IGNORED_TESTS = {
316 'test_suite_config': [
317 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA|CHACHA20|DES)_.*'),
318 re.compile(r'.*\bMBEDTLS_(CCM|CHACHAPOLY|CMAC|GCM)_.*'),
319 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
320 re.compile(r'.*\bMBEDTLS_CIPHER_.*'),
321 ],
322 # PEM decryption is not supported so far.
323 # The rest of PEM (write, unencrypted read) works though.
324 'test_suite_pem': [
325 re.compile(r'PEM read .*(AES|DES|\bencrypt).*'),
326 ],
327 'test_suite_platform': [
328 # Incompatible with sanitizers (e.g. ASan). If the driver
329 # component uses a sanitizer but the reference component
330 # doesn't, we have a PASS vs SKIP mismatch.
331 'Check mbedtls_calloc overallocation',
332 ],
333 # Following tests depend on AES_C/DES_C but are not about
334 # them really, just need to know some error code is there.
335 'test_suite_error': [
336 'Low and high error',
337 'Single low error'
338 ],
339 # Similar to test_suite_error above.
340 'test_suite_version': [
341 'Check for MBEDTLS_AES_C when already present',
342 ],
343 # The en/decryption part of PKCS#12 is not supported so far.
344 # The rest of PKCS#12 (key derivation) works though.
345 'test_suite_pkcs12': [
346 re.compile(r'PBE Encrypt, .*'),
347 re.compile(r'PBE Decrypt, .*'),
348 ],
349 # The en/decryption part of PKCS#5 is not supported so far.
350 # The rest of PKCS#5 (PBKDF2) works though.
351 'test_suite_pkcs5': [
352 re.compile(r'PBES2 Encrypt, .*'),
353 re.compile(r'PBES2 Decrypt .*'),
354 ],
355 # Encrypted keys are not supported so far.
356 # pylint: disable=line-too-long
357 'test_suite_pkparse': [
358 'Key ASN1 (Encrypted key PKCS12, trailing garbage data)',
359 'Key ASN1 (Encrypted key PKCS5, trailing garbage data)',
360 re.compile(r'Parse (RSA|EC) Key .*\(.* ([Ee]ncrypted|password).*\)'),
361 ],
362 # Encrypted keys are not supported so far.
363 'ssl-opt': [
364 'TLS: password protected server key',
365 'TLS: password protected client key',
366 'TLS: password protected server key, two certificates',
367 ],
368 }
369
Gilles Peskine45a32b12024-10-03 18:42:37 +0200370class DriverVSReference_ecp_light_only(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200371 REFERENCE = 'test_psa_crypto_config_reference_ecc_ecp_light_only'
372 DRIVER = 'test_psa_crypto_config_accel_ecc_ecp_light_only'
373 IGNORED_SUITES = [
374 # Modules replaced by drivers
375 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine9a094432024-10-29 20:55:11 +0100376 # Unit tests for the built-in implementation
377 'psa_crypto_ecp',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200378 ]
379 IGNORED_TESTS = {
380 'test_suite_config': [
381 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
382 ],
383 'test_suite_platform': [
384 # Incompatible with sanitizers (e.g. ASan). If the driver
385 # component uses a sanitizer but the reference component
386 # doesn't, we have a PASS vs SKIP mismatch.
387 'Check mbedtls_calloc overallocation',
388 ],
389 # This test wants a legacy function that takes f_rng, p_rng
390 # arguments, and uses legacy ECDSA for that. The test is
391 # really about the wrapper around the PSA RNG, not ECDSA.
392 'test_suite_random': [
393 'PSA classic wrapper: ECDSA signature (SECP256R1)',
394 ],
395 # In the accelerated test ECP_C is not set (only ECP_LIGHT is)
396 # so we must ignore disparities in the tests for which ECP_C
397 # is required.
398 'test_suite_ecp': [
399 re.compile(r'ECP check public-private .*'),
400 re.compile(r'ECP calculate public: .*'),
401 re.compile(r'ECP gen keypair .*'),
402 re.compile(r'ECP point muladd .*'),
403 re.compile(r'ECP point multiplication .*'),
404 re.compile(r'ECP test vectors .*'),
405 ],
406 'test_suite_ssl': [
407 # This deprecated function is only present when ECP_C is On.
Valerio Setti1a0ee062025-01-22 11:03:46 +0100408 'Test configuration of EC groups through mbedtls_ssl_conf_curves()',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200409 ],
410 }
411
Gilles Peskine45a32b12024-10-03 18:42:37 +0200412class DriverVSReference_no_ecp_at_all(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200413 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_ecp_at_all'
414 DRIVER = 'test_psa_crypto_config_accel_ecc_no_ecp_at_all'
415 IGNORED_SUITES = [
416 # Modules replaced by drivers
417 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine9a094432024-10-29 20:55:11 +0100418 # Unit tests for the built-in implementation
419 'psa_crypto_ecp',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200420 ]
421 IGNORED_TESTS = {
422 'test_suite_config': [
423 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
424 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
425 ],
426 'test_suite_platform': [
427 # Incompatible with sanitizers (e.g. ASan). If the driver
428 # component uses a sanitizer but the reference component
429 # doesn't, we have a PASS vs SKIP mismatch.
430 'Check mbedtls_calloc overallocation',
431 ],
432 # See ecp_light_only
433 'test_suite_random': [
434 'PSA classic wrapper: ECDSA signature (SECP256R1)',
435 ],
436 'test_suite_pkparse': [
437 # When PK_PARSE_C and ECP_C are defined then PK_PARSE_EC_COMPRESSED
438 # is automatically enabled in build_info.h (backward compatibility)
439 # even if it is disabled in config_psa_crypto_no_ecp_at_all(). As a
440 # consequence compressed points are supported in the reference
441 # component but not in the accelerated one, so they should be skipped
442 # while checking driver's coverage.
443 re.compile(r'Parse EC Key .*compressed\)'),
444 re.compile(r'Parse Public EC Key .*compressed\)'),
445 ],
446 # See ecp_light_only
447 'test_suite_ssl': [
Valerio Setti1a0ee062025-01-22 11:03:46 +0100448 'Test configuration of EC groups through mbedtls_ssl_conf_curves()',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200449 ],
450 }
451
Gilles Peskine45a32b12024-10-03 18:42:37 +0200452class DriverVSReference_ecc_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200453 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_bignum'
454 DRIVER = 'test_psa_crypto_config_accel_ecc_no_bignum'
455 IGNORED_SUITES = [
456 # Modules replaced by drivers
457 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
458 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
459 'bignum.generated', 'bignum.misc',
Gilles Peskine9a094432024-10-29 20:55:11 +0100460 # Unit tests for the built-in implementation
461 'psa_crypto_ecp',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200462 ]
463 IGNORED_TESTS = {
464 'test_suite_config': [
465 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
466 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
467 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
468 ],
469 'test_suite_platform': [
470 # Incompatible with sanitizers (e.g. ASan). If the driver
471 # component uses a sanitizer but the reference component
472 # doesn't, we have a PASS vs SKIP mismatch.
473 'Check mbedtls_calloc overallocation',
474 ],
475 # See ecp_light_only
476 'test_suite_random': [
477 'PSA classic wrapper: ECDSA signature (SECP256R1)',
478 ],
479 # See no_ecp_at_all
480 'test_suite_pkparse': [
481 re.compile(r'Parse EC Key .*compressed\)'),
482 re.compile(r'Parse Public EC Key .*compressed\)'),
483 ],
484 'test_suite_asn1parse': [
485 'INTEGER too large for mpi',
486 ],
487 'test_suite_asn1write': [
488 re.compile(r'ASN.1 Write mpi.*'),
489 ],
490 'test_suite_debug': [
491 re.compile(r'Debug print mbedtls_mpi.*'),
492 ],
493 # See ecp_light_only
494 'test_suite_ssl': [
Valerio Setti1a0ee062025-01-22 11:03:46 +0100495 'Test configuration of EC groups through mbedtls_ssl_conf_curves()',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200496 ],
497 }
498
Gilles Peskine45a32b12024-10-03 18:42:37 +0200499class DriverVSReference_ecc_ffdh_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200500 REFERENCE = 'test_psa_crypto_config_reference_ecc_ffdh_no_bignum'
501 DRIVER = 'test_psa_crypto_config_accel_ecc_ffdh_no_bignum'
502 IGNORED_SUITES = [
503 # Modules replaced by drivers
504 'ecp', 'ecdsa', 'ecdh', 'ecjpake', 'dhm',
505 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
506 'bignum.generated', 'bignum.misc',
Gilles Peskine9a094432024-10-29 20:55:11 +0100507 # Unit tests for the built-in implementation
508 'psa_crypto_ecp',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200509 ]
510 IGNORED_TESTS = {
511 'ssl-opt': [
512 # DHE support in TLS 1.2 requires built-in MBEDTLS_DHM_C
513 # (because it needs custom groups, which PSA does not
514 # provide), even with MBEDTLS_USE_PSA_CRYPTO.
515 re.compile(r'PSK callback:.*\bdhe-psk\b.*'),
516 ],
517 'test_suite_config': [
518 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
519 re.compile(r'.*\bMBEDTLS_DHM_C\b.*'),
520 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
521 re.compile(r'.*\bMBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED\b.*'),
522 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
523 ],
524 'test_suite_platform': [
525 # Incompatible with sanitizers (e.g. ASan). If the driver
526 # component uses a sanitizer but the reference component
527 # doesn't, we have a PASS vs SKIP mismatch.
528 'Check mbedtls_calloc overallocation',
529 ],
530 # See ecp_light_only
531 'test_suite_random': [
532 'PSA classic wrapper: ECDSA signature (SECP256R1)',
533 ],
534 # See no_ecp_at_all
535 'test_suite_pkparse': [
536 re.compile(r'Parse EC Key .*compressed\)'),
537 re.compile(r'Parse Public EC Key .*compressed\)'),
538 ],
539 'test_suite_asn1parse': [
540 'INTEGER too large for mpi',
541 ],
542 'test_suite_asn1write': [
543 re.compile(r'ASN.1 Write mpi.*'),
544 ],
545 'test_suite_debug': [
546 re.compile(r'Debug print mbedtls_mpi.*'),
547 ],
548 # See ecp_light_only
549 'test_suite_ssl': [
Valerio Setti1a0ee062025-01-22 11:03:46 +0100550 'Test configuration of EC groups through mbedtls_ssl_conf_curves()',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200551 ],
552 }
553
Gilles Peskine45a32b12024-10-03 18:42:37 +0200554class DriverVSReference_ffdh_alg(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200555 REFERENCE = 'test_psa_crypto_config_reference_ffdh'
556 DRIVER = 'test_psa_crypto_config_accel_ffdh'
557 IGNORED_SUITES = ['dhm']
558 IGNORED_TESTS = {
559 'test_suite_config': [
560 re.compile(r'.*\bMBEDTLS_DHM_C\b.*'),
561 ],
562 'test_suite_platform': [
563 # Incompatible with sanitizers (e.g. ASan). If the driver
564 # component uses a sanitizer but the reference component
565 # doesn't, we have a PASS vs SKIP mismatch.
566 'Check mbedtls_calloc overallocation',
567 ],
568 }
569
Gilles Peskine45a32b12024-10-03 18:42:37 +0200570class DriverVSReference_tfm_config(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200571 REFERENCE = 'test_tfm_config_no_p256m'
572 DRIVER = 'test_tfm_config_p256m_driver_accel_ec'
573 IGNORED_SUITES = [
574 # Modules replaced by drivers
575 'asn1parse', 'asn1write',
576 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
577 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
578 'bignum.generated', 'bignum.misc',
Gilles Peskine9a094432024-10-29 20:55:11 +0100579 # Unit tests for the built-in implementation
580 'psa_crypto_ecp',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200581 ]
582 IGNORED_TESTS = {
583 'test_suite_config': [
584 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
585 re.compile(r'.*\bMBEDTLS_(ASN1\w+)_C\b.*'),
586 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECP)_.*'),
587 re.compile(r'.*\bMBEDTLS_PSA_P256M_DRIVER_ENABLED\b.*')
588 ],
589 'test_suite_config.crypto_combinations': [
590 'Config: ECC: Weierstrass curves only',
591 ],
592 'test_suite_platform': [
593 # Incompatible with sanitizers (e.g. ASan). If the driver
594 # component uses a sanitizer but the reference component
595 # doesn't, we have a PASS vs SKIP mismatch.
596 'Check mbedtls_calloc overallocation',
597 ],
598 # See ecp_light_only
599 'test_suite_random': [
600 'PSA classic wrapper: ECDSA signature (SECP256R1)',
601 ],
602 }
603
Gilles Peskine45a32b12024-10-03 18:42:37 +0200604class DriverVSReference_rsa(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200605 REFERENCE = 'test_psa_crypto_config_reference_rsa_crypto'
606 DRIVER = 'test_psa_crypto_config_accel_rsa_crypto'
607 IGNORED_SUITES = [
608 # Modules replaced by drivers.
609 'rsa', 'pkcs1_v15', 'pkcs1_v21',
610 # We temporarily don't care about PK stuff.
611 'pk', 'pkwrite', 'pkparse'
612 ]
613 IGNORED_TESTS = {
614 'test_suite_config': [
615 re.compile(r'.*\bMBEDTLS_(PKCS1|RSA)_.*'),
616 re.compile(r'.*\bMBEDTLS_GENPRIME\b.*')
617 ],
618 'test_suite_platform': [
619 # Incompatible with sanitizers (e.g. ASan). If the driver
620 # component uses a sanitizer but the reference component
621 # doesn't, we have a PASS vs SKIP mismatch.
622 'Check mbedtls_calloc overallocation',
623 ],
624 # Following tests depend on RSA_C but are not about
625 # them really, just need to know some error code is there.
626 'test_suite_error': [
627 'Low and high error',
628 'Single high error'
629 ],
630 # Constant time operations only used for PKCS1_V15
631 'test_suite_constant_time': [
632 re.compile(r'mbedtls_ct_zeroize_if .*'),
633 re.compile(r'mbedtls_ct_memmove_left .*')
634 ],
635 'test_suite_psa_crypto': [
636 # We don't support generate_key_custom entry points
637 # in drivers yet.
638 re.compile(r'PSA generate key custom: RSA, e=.*'),
639 re.compile(r'PSA generate key ext: RSA, e=.*'),
640 ],
641 }
642
Gilles Peskine45a32b12024-10-03 18:42:37 +0200643class DriverVSReference_block_cipher_dispatch(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200644 REFERENCE = 'test_full_block_cipher_legacy_dispatch'
645 DRIVER = 'test_full_block_cipher_psa_dispatch'
646 IGNORED_SUITES = [
647 # Skipped in the accelerated component
648 'aes', 'aria', 'camellia',
649 # These require AES_C, ARIA_C or CAMELLIA_C to be enabled in
650 # order for the cipher module (actually cipher_wrapper) to work
651 # properly. However these symbols are disabled in the accelerated
652 # component so we ignore them.
653 'cipher.ccm', 'cipher.gcm', 'cipher.aes', 'cipher.aria',
654 'cipher.camellia',
655 ]
656 IGNORED_TESTS = {
657 'test_suite_config': [
658 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA)_.*'),
659 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
660 ],
661 'test_suite_cmac': [
662 # Following tests require AES_C/ARIA_C/CAMELLIA_C to be enabled,
663 # but these are not available in the accelerated component.
664 'CMAC null arguments',
665 re.compile('CMAC.* (AES|ARIA|Camellia).*'),
666 ],
Gilles Peskinebeb53af2025-08-08 13:35:46 +0200667 'test_suite_cipher.constant_time': [
668 # Like with test_suite_cipher.aes and such, these tests call
669 # cipher_wrapper in a way that requires the block cipher to
670 # be built in.
671 re.compile('.*(AES|ARIA|CAMELLIA).*(encrypt|decrypt).*', re.I),
672 ],
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200673 'test_suite_cipher.padding': [
674 # Following tests require AES_C/CAMELLIA_C to be enabled,
675 # but these are not available in the accelerated component.
676 re.compile('Set( non-existent)? padding with (AES|CAMELLIA).*'),
677 ],
678 'test_suite_pkcs5': [
679 # The AES part of PKCS#5 PBES2 is not yet supported.
680 # The rest of PKCS#5 (PBKDF2) works, though.
681 re.compile(r'PBES2 .* AES-.*')
682 ],
683 'test_suite_pkparse': [
684 # PEM (called by pkparse) requires AES_C in order to decrypt
685 # the key, but this is not available in the accelerated
686 # component.
687 re.compile('Parse RSA Key.*(password|AES-).*'),
688 ],
689 'test_suite_pem': [
690 # Following tests require AES_C, but this is diabled in the
691 # accelerated component.
692 re.compile('PEM read .*AES.*'),
693 'PEM read (unknown encryption algorithm)',
694 ],
695 'test_suite_error': [
696 # Following tests depend on AES_C but are not about them
697 # really, just need to know some error code is there.
698 'Single low error',
699 'Low and high error',
700 ],
701 'test_suite_version': [
702 # Similar to test_suite_error above.
703 'Check for MBEDTLS_AES_C when already present',
704 ],
705 'test_suite_platform': [
706 # Incompatible with sanitizers (e.g. ASan). If the driver
707 # component uses a sanitizer but the reference component
708 # doesn't, we have a PASS vs SKIP mismatch.
709 'Check mbedtls_calloc overallocation',
710 ],
711 }
712
713#pylint: enable=invalid-name,missing-class-docstring
714
715
Przemek Stekiel6856f4c2022-11-09 10:50:29 +0100716# List of tasks with a function that can handle this task and additional arguments if required
Valerio Settidfd7ca62023-10-09 16:30:11 +0200717KNOWN_TASKS = {
Gilles Peskine0316f102024-09-16 19:15:29 +0200718 'analyze_coverage': CoverageTask,
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200719 'analyze_driver_vs_reference_hash': DriverVSReference_hash,
720 'analyze_driver_vs_reference_hmac': DriverVSReference_hmac,
721 'analyze_driver_vs_reference_cipher_aead_cmac': DriverVSReference_cipher_aead_cmac,
722 'analyze_driver_vs_reference_ecp_light_only': DriverVSReference_ecp_light_only,
723 'analyze_driver_vs_reference_no_ecp_at_all': DriverVSReference_no_ecp_at_all,
724 'analyze_driver_vs_reference_ecc_no_bignum': DriverVSReference_ecc_no_bignum,
725 'analyze_driver_vs_reference_ecc_ffdh_no_bignum': DriverVSReference_ecc_ffdh_no_bignum,
726 'analyze_driver_vs_reference_ffdh_alg': DriverVSReference_ffdh_alg,
727 'analyze_driver_vs_reference_tfm_config': DriverVSReference_tfm_config,
728 'analyze_driver_vs_reference_rsa': DriverVSReference_rsa,
729 'analyze_block_cipher_dispatch': DriverVSReference_block_cipher_dispatch,
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200730}
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200731
Gilles Peskine15c2cbf2020-06-25 18:36:28 +0200732if __name__ == '__main__':
Gilles Peskine45a32b12024-10-03 18:42:37 +0200733 outcome_analysis.main(KNOWN_TASKS)