blob: 88c450fc86052a23f26d422b3af37709dde4f141 [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 Peskine2a71fac2024-09-17 15:07:22 +020010import typing
Gilles Peskine15c2cbf2020-06-25 18:36:28 +020011
Gilles Peskine31467722024-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 Peskine082eade2024-10-03 18:42:37 +020016class CoverageTask(outcome_analysis.CoverageTask):
Gilles Peskine095561c2024-10-04 16:24:26 +020017 """Justify test cases that are never executed."""
Gilles Peskine3f5022e2024-09-16 20:23:40 +020018
Gilles Peskine2a71fac2024-09-17 15:07:22 +020019 @staticmethod
Gilles Peskine5872c0d2024-09-17 17:15:29 +020020 def _has_word_re(words: typing.Iterable[str],
21 exclude: typing.Optional[str] = None) -> typing.Pattern:
Gilles Peskine2a71fac2024-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 Peskine5872c0d2024-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 Peskine2a71fac2024-09-17 15:07:22 +020028 """
Gilles Peskine5872c0d2024-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 Peskine5e3ed3f2024-10-11 12:00:44 +020034 re.DOTALL)
Gilles Peskine2a71fac2024-09-17 15:07:22 +020035
Gilles Peskine2a71fac2024-09-17 15:07:22 +020036 IGNORED_TESTS = {
Gilles Peskinede2316b2024-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 Peskinede2316b2024-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)',
Gilles Peskine24b03d82024-10-04 16:22:24 +020050 # TLS doesn't use restartable ECDH yet.
51 # https://github.com/Mbed-TLS/mbedtls/issues/7294
52 re.compile(r'EC restart:.*no USE_PSA.*'),
Gilles Peskinede2316b2024-09-17 18:32:05 +020053 ],
Gilles Peskine2fd25bb2024-09-17 19:46:18 +020054 'test_suite_config.mbedtls_boolean': [
Gilles Peskine2fd25bb2024-09-17 19:46:18 +020055 # Missing coverage of test configurations.
56 # https://github.com/Mbed-TLS/mbedtls/issues/9585
57 'Config: !MBEDTLS_SSL_DTLS_ANTI_REPLAY',
58 # Missing coverage of test configurations.
59 # https://github.com/Mbed-TLS/mbedtls/issues/9585
60 'Config: !MBEDTLS_SSL_DTLS_HELLO_VERIFY',
61 # We don't run test_suite_config when we test this.
62 # https://github.com/Mbed-TLS/mbedtls/issues/9586
63 'Config: !MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED',
Gilles Peskine2fd25bb2024-09-17 19:46:18 +020064 ],
Gilles Peskine3c2a1cb2025-07-15 19:09:08 +020065 'test_suite_config.crypto_combinations': [
66 # New thing in crypto. Not intended to be tested separately
67 # in mbedtls.
68 # https://github.com/Mbed-TLS/mbedtls/issues/10300
69 'Config: entropy: NV seed only',
70 ],
Gilles Peskine2fd25bb2024-09-17 19:46:18 +020071 'test_suite_config.psa_boolean': [
72 # We don't test with HMAC disabled.
73 # https://github.com/Mbed-TLS/mbedtls/issues/9591
74 'Config: !PSA_WANT_ALG_HMAC',
Gilles Peskine2fd25bb2024-09-17 19:46:18 +020075 # The DERIVE key type is always enabled.
76 'Config: !PSA_WANT_KEY_TYPE_DERIVE',
77 # More granularity of key pair type enablement macros
78 # than we care to test.
79 # https://github.com/Mbed-TLS/mbedtls/issues/9590
80 'Config: !PSA_WANT_KEY_TYPE_DH_KEY_PAIR_EXPORT',
81 'Config: !PSA_WANT_KEY_TYPE_DH_KEY_PAIR_GENERATE',
82 'Config: !PSA_WANT_KEY_TYPE_DH_KEY_PAIR_IMPORT',
83 # More granularity of key pair type enablement macros
84 # than we care to test.
85 # https://github.com/Mbed-TLS/mbedtls/issues/9590
86 'Config: !PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT',
87 'Config: !PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT',
88 # We don't test with HMAC disabled.
89 # https://github.com/Mbed-TLS/mbedtls/issues/9591
90 'Config: !PSA_WANT_KEY_TYPE_HMAC',
91 # The PASSWORD key type is always enabled.
92 'Config: !PSA_WANT_KEY_TYPE_PASSWORD',
93 # The PASSWORD_HASH key type is always enabled.
94 'Config: !PSA_WANT_KEY_TYPE_PASSWORD_HASH',
95 # The RAW_DATA key type is always enabled.
96 'Config: !PSA_WANT_KEY_TYPE_RAW_DATA',
97 # More granularity of key pair type enablement macros
98 # than we care to test.
99 # https://github.com/Mbed-TLS/mbedtls/issues/9590
100 'Config: !PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_EXPORT',
101 'Config: !PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT',
102 # Algorithm declared but not supported.
103 'Config: PSA_WANT_ALG_CBC_MAC',
104 # Algorithm declared but not supported.
105 'Config: PSA_WANT_ALG_XTS',
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200106 # More granularity of key pair type enablement macros
107 # than we care to test.
108 # https://github.com/Mbed-TLS/mbedtls/issues/9590
109 'Config: PSA_WANT_KEY_TYPE_DH_KEY_PAIR_DERIVE',
110 'Config: PSA_WANT_KEY_TYPE_ECC_KEY_PAIR',
111 'Config: PSA_WANT_KEY_TYPE_RSA_KEY_PAIR',
112 'Config: PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_DERIVE',
Minos Galanakis848333d2024-12-02 15:58:32 +0000113 # https://github.com/Mbed-TLS/mbedtls/issues/9583
114 'Config: !MBEDTLS_ECP_NIST_OPTIM',
115 # We never test without the PSA client code. Should we?
116 # https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/112
117 'Config: !MBEDTLS_PSA_CRYPTO_CLIENT',
118 # We only test multithreading with pthreads.
119 # https://github.com/Mbed-TLS/mbedtls/issues/9584
120 'Config: !MBEDTLS_THREADING_PTHREAD',
121 # Built but not tested.
122 # https://github.com/Mbed-TLS/mbedtls/issues/9587
123 'Config: MBEDTLS_AES_USE_HARDWARE_ONLY',
124 # Untested platform-specific optimizations.
125 # https://github.com/Mbed-TLS/mbedtls/issues/9588
126 'Config: MBEDTLS_HAVE_SSE2',
Minos Galanakis848333d2024-12-02 15:58:32 +0000127 # Untested aspect of the platform interface.
128 # https://github.com/Mbed-TLS/mbedtls/issues/9589
129 'Config: MBEDTLS_PLATFORM_NO_STD_FUNCTIONS',
130 # In a client-server build, test_suite_config runs in the
131 # client configuration, so it will never report
132 # MBEDTLS_PSA_CRYPTO_SPM as enabled. That's ok.
133 'Config: MBEDTLS_PSA_CRYPTO_SPM',
134 # We don't test on armv8 yet.
135 'Config: MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT',
136 'Config: MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY',
137 'Config: MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY',
138 'Config: MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY',
139 # We don't run test_suite_config when we test this.
140 # https://github.com/Mbed-TLS/mbedtls/issues/9586
141 'Config: MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND',
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200142 ],
143 'test_suite_config.psa_combinations': [
144 # We don't test this unusual, but sensible configuration.
145 # https://github.com/Mbed-TLS/mbedtls/issues/9592
146 'Config: PSA_WANT_ALG_DETERMINSTIC_ECDSA without PSA_WANT_ALG_ECDSA',
147 ],
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200148 'test_suite_pkcs12': [
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200149 # We never test with CBC/PKCS5/PKCS12 enabled but
150 # PKCS7 padding disabled.
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200151 # https://github.com/Mbed-TLS/mbedtls/issues/9580
152 'PBE Decrypt, (Invalid padding & PKCS7 padding disabled)',
153 'PBE Encrypt, pad = 8 (PKCS7 padding disabled)',
154 ],
155 'test_suite_pkcs5': [
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200156 # We never test with CBC/PKCS5/PKCS12 enabled but
157 # PKCS7 padding disabled.
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200158 # https://github.com/Mbed-TLS/mbedtls/issues/9580
159 'PBES2 Decrypt (Invalid padding & PKCS7 padding disabled)',
160 'PBES2 Encrypt, pad=6 (PKCS7 padding disabled)',
161 'PBES2 Encrypt, pad=8 (PKCS7 padding disabled)',
162 ],
Gilles Peskineeafc2752024-04-19 19:08:34 +0200163 'test_suite_psa_crypto': [
164 # We don't test this unusual, but sensible configuration.
165 # https://github.com/Mbed-TLS/mbedtls/issues/9592
166 re.compile(r'.*ECDSA.*only deterministic supported'),
167 ],
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200168 'test_suite_psa_crypto_metadata': [
169 # Algorithms declared but not supported.
170 # https://github.com/Mbed-TLS/mbedtls/issues/9579
171 'Asymmetric signature: Ed25519ph',
172 'Asymmetric signature: Ed448ph',
173 'Asymmetric signature: pure EdDSA',
174 'Cipher: XTS',
175 'MAC: CBC_MAC-3DES',
176 'MAC: CBC_MAC-AES-128',
177 'MAC: CBC_MAC-AES-192',
178 'MAC: CBC_MAC-AES-256',
179 ],
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200180 'test_suite_psa_crypto_not_supported.generated': [
Gilles Peskine5e3ed3f2024-10-11 12:00:44 +0200181 # We never test with DH key support disabled but support
Gilles Peskineab5cc9b2024-09-17 17:57:11 +0200182 # for a DH group enabled. The dependencies of these test
183 # cases don't really make sense.
184 # https://github.com/Mbed-TLS/mbedtls/issues/9574
185 re.compile(r'PSA \w+ DH_.*type not supported'),
186 # We only test partial support for DH with the 2048-bit group
187 # enabled and the other groups disabled.
188 # https://github.com/Mbed-TLS/mbedtls/issues/9575
189 'PSA generate DH_KEY_PAIR(RFC7919) 2048-bit group not supported',
190 'PSA import DH_KEY_PAIR(RFC7919) 2048-bit group not supported',
191 'PSA import DH_PUBLIC_KEY(RFC7919) 2048-bit group not supported',
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200192 ],
193 'test_suite_psa_crypto_op_fail.generated': [
Gilles Peskineeafc2752024-04-19 19:08:34 +0200194 # We don't test this unusual, but sensible configuration.
195 # https://github.com/Mbed-TLS/mbedtls/issues/9592
196 re.compile(r'.*: !ECDSA but DETERMINISTIC_ECDSA with ECC_.*'),
Gilles Peskineab5cc9b2024-09-17 17:57:11 +0200197 # We never test with the HMAC algorithm enabled but the HMAC
198 # key type disabled. Those dependencies don't really make sense.
199 # https://github.com/Mbed-TLS/mbedtls/issues/9573
200 re.compile(r'.* !HMAC with HMAC'),
Gilles Peskine13c418d2025-01-16 19:49:12 +0100201 # We don't test with ECDH disabled but the key type enabled.
202 # https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/161
203 re.compile(r'PSA key_agreement.* !ECDH with ECC_KEY_PAIR\(.*'),
204 # We don't test with FFDH disabled but the key type enabled.
205 # https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/160
206 re.compile(r'PSA key_agreement.* !FFDH with DH_KEY_PAIR\(.*'),
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200207 ],
Gilles Peskineeafc2752024-04-19 19:08:34 +0200208 'test_suite_psa_crypto_op_fail.misc': [
209 # We don't test this unusual, but sensible configuration.
210 # https://github.com/Mbed-TLS/mbedtls/issues/9592
211 'PSA sign DETERMINISTIC_ECDSA(SHA_256): !ECDSA but DETERMINISTIC_ECDSA with ECC_KEY_PAIR(SECP_R1)', #pylint: disable=line-too-long
212 ],
Gilles Peskinede2316b2024-09-17 18:32:05 +0200213 'tls13-misc': [
214 # Disabled due to OpenSSL bug.
215 # https://github.com/openssl/openssl/issues/10714
216 'TLS 1.3 O->m: resumption',
217 # Disabled due to OpenSSL command line limitation.
218 # https://github.com/Mbed-TLS/mbedtls/issues/9582
219 'TLS 1.3 m->O: resumption with early data',
220 ],
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200221 }
222
Gilles Peskine82b16722024-09-16 19:57:10 +0200223
Gilles Peskine9df375b2024-09-16 20:14:26 +0200224# The names that we give to classes derived from DriverVSReference do not
225# follow the usual naming convention, because it's more readable to use
226# underscores and parts of the configuration names. Also, these classes
227# are just there to specify some data, so they don't need repetitive
228# documentation.
229#pylint: disable=invalid-name,missing-class-docstring
230
Gilles Peskine082eade2024-10-03 18:42:37 +0200231class DriverVSReference_hash(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200232 REFERENCE = 'test_psa_crypto_config_reference_hash_use_psa'
233 DRIVER = 'test_psa_crypto_config_accel_hash_use_psa'
234 IGNORED_SUITES = [
235 'shax', 'mdx', # the software implementations that are being excluded
236 'md.psa', # purposefully depends on whether drivers are present
237 'psa_crypto_low_hash.generated', # testing the builtins
238 ]
239 IGNORED_TESTS = {
240 'test_suite_config': [
241 re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'),
242 ],
243 'test_suite_platform': [
244 # Incompatible with sanitizers (e.g. ASan). If the driver
245 # component uses a sanitizer but the reference component
246 # doesn't, we have a PASS vs SKIP mismatch.
247 'Check mbedtls_calloc overallocation',
248 ],
249 }
250
Gilles Peskine082eade2024-10-03 18:42:37 +0200251class DriverVSReference_hmac(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200252 REFERENCE = 'test_psa_crypto_config_reference_hmac'
253 DRIVER = 'test_psa_crypto_config_accel_hmac'
254 IGNORED_SUITES = [
255 # These suites require legacy hash support, which is disabled
256 # in the accelerated component.
257 'shax', 'mdx',
258 # This suite tests builtins directly, but these are missing
259 # in the accelerated case.
260 'psa_crypto_low_hash.generated',
261 ]
262 IGNORED_TESTS = {
263 'test_suite_config': [
264 re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'),
265 re.compile(r'.*\bMBEDTLS_MD_C\b')
266 ],
267 'test_suite_md': [
268 # Builtin HMAC is not supported in the accelerate component.
269 re.compile('.*HMAC.*'),
270 # Following tests make use of functions which are not available
271 # when MD_C is disabled, as it happens in the accelerated
272 # test component.
273 re.compile('generic .* Hash file .*'),
274 'MD list',
275 ],
276 'test_suite_md.psa': [
277 # "legacy only" tests require hash algorithms to be NOT
278 # accelerated, but this of course false for the accelerated
279 # test component.
280 re.compile('PSA dispatch .* legacy only'),
281 ],
282 'test_suite_platform': [
283 # Incompatible with sanitizers (e.g. ASan). If the driver
284 # component uses a sanitizer but the reference component
285 # doesn't, we have a PASS vs SKIP mismatch.
286 'Check mbedtls_calloc overallocation',
287 ],
288 }
289
Gilles Peskine082eade2024-10-03 18:42:37 +0200290class DriverVSReference_cipher_aead_cmac(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200291 REFERENCE = 'test_psa_crypto_config_reference_cipher_aead_cmac'
292 DRIVER = 'test_psa_crypto_config_accel_cipher_aead_cmac'
293 # Modules replaced by drivers.
294 IGNORED_SUITES = [
295 # low-level (block/stream) cipher modules
296 'aes', 'aria', 'camellia', 'des', 'chacha20',
Ronald Cronb5c6fcc2025-07-10 13:40:00 +0200297 # AEAD modes, CMAC and POLY1305
298 'ccm', 'chachapoly', 'cmac', 'gcm', 'poly1305',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200299 # The Cipher abstraction layer
300 'cipher',
301 ]
302 IGNORED_TESTS = {
303 'test_suite_config': [
304 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA|CHACHA20|DES)_.*'),
Ronald Cronb5c6fcc2025-07-10 13:40:00 +0200305 re.compile(r'.*\bMBEDTLS_(CCM|CHACHAPOLY|CMAC|GCM|POLY1305)_.*'),
Gilles Peskine9df375b2024-09-16 20:14:26 +0200306 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
307 re.compile(r'.*\bMBEDTLS_CIPHER_.*'),
308 ],
309 # PEM decryption is not supported so far.
310 # The rest of PEM (write, unencrypted read) works though.
311 'test_suite_pem': [
312 re.compile(r'PEM read .*(AES|DES|\bencrypt).*'),
313 ],
314 'test_suite_platform': [
315 # Incompatible with sanitizers (e.g. ASan). If the driver
316 # component uses a sanitizer but the reference component
317 # doesn't, we have a PASS vs SKIP mismatch.
318 'Check mbedtls_calloc overallocation',
319 ],
320 # Following tests depend on AES_C/DES_C but are not about
321 # them really, just need to know some error code is there.
322 'test_suite_error': [
323 'Low and high error',
324 'Single low error'
325 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200326 # The en/decryption part of PKCS#12 is not supported so far.
327 # The rest of PKCS#12 (key derivation) works though.
328 'test_suite_pkcs12': [
329 re.compile(r'PBE Encrypt, .*'),
330 re.compile(r'PBE Decrypt, .*'),
331 ],
332 # The en/decryption part of PKCS#5 is not supported so far.
333 # The rest of PKCS#5 (PBKDF2) works though.
334 'test_suite_pkcs5': [
335 re.compile(r'PBES2 Encrypt, .*'),
336 re.compile(r'PBES2 Decrypt .*'),
337 ],
338 # Encrypted keys are not supported so far.
339 # pylint: disable=line-too-long
340 'test_suite_pkparse': [
341 'Key ASN1 (Encrypted key PKCS12, trailing garbage data)',
342 'Key ASN1 (Encrypted key PKCS5, trailing garbage data)',
343 re.compile(r'Parse (RSA|EC) Key .*\(.* ([Ee]ncrypted|password).*\)'),
344 ],
345 # Encrypted keys are not supported so far.
346 'ssl-opt': [
347 'TLS: password protected server key',
348 'TLS: password protected client key',
349 'TLS: password protected server key, two certificates',
350 ],
351 }
352
Gilles Peskine082eade2024-10-03 18:42:37 +0200353class DriverVSReference_ecp_light_only(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200354 REFERENCE = 'test_psa_crypto_config_reference_ecc_ecp_light_only'
355 DRIVER = 'test_psa_crypto_config_accel_ecc_ecp_light_only'
356 IGNORED_SUITES = [
357 # Modules replaced by drivers
358 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100359 # Unit tests for the built-in implementation
360 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200361 ]
362 IGNORED_TESTS = {
363 'test_suite_config': [
364 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
365 ],
366 'test_suite_platform': [
367 # Incompatible with sanitizers (e.g. ASan). If the driver
368 # component uses a sanitizer but the reference component
369 # doesn't, we have a PASS vs SKIP mismatch.
370 'Check mbedtls_calloc overallocation',
371 ],
372 # This test wants a legacy function that takes f_rng, p_rng
373 # arguments, and uses legacy ECDSA for that. The test is
374 # really about the wrapper around the PSA RNG, not ECDSA.
375 'test_suite_random': [
376 'PSA classic wrapper: ECDSA signature (SECP256R1)',
377 ],
378 # In the accelerated test ECP_C is not set (only ECP_LIGHT is)
379 # so we must ignore disparities in the tests for which ECP_C
380 # is required.
381 'test_suite_ecp': [
382 re.compile(r'ECP check public-private .*'),
383 re.compile(r'ECP calculate public: .*'),
384 re.compile(r'ECP gen keypair .*'),
385 re.compile(r'ECP point muladd .*'),
386 re.compile(r'ECP point multiplication .*'),
387 re.compile(r'ECP test vectors .*'),
388 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200389 }
390
Gilles Peskine082eade2024-10-03 18:42:37 +0200391class DriverVSReference_no_ecp_at_all(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200392 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_ecp_at_all'
393 DRIVER = 'test_psa_crypto_config_accel_ecc_no_ecp_at_all'
394 IGNORED_SUITES = [
395 # Modules replaced by drivers
396 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100397 # Unit tests for the built-in implementation
398 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200399 ]
400 IGNORED_TESTS = {
401 'test_suite_config': [
402 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
403 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
404 ],
405 'test_suite_platform': [
406 # Incompatible with sanitizers (e.g. ASan). If the driver
407 # component uses a sanitizer but the reference component
408 # doesn't, we have a PASS vs SKIP mismatch.
409 'Check mbedtls_calloc overallocation',
410 ],
411 # See ecp_light_only
412 'test_suite_random': [
413 'PSA classic wrapper: ECDSA signature (SECP256R1)',
414 ],
415 'test_suite_pkparse': [
416 # When PK_PARSE_C and ECP_C are defined then PK_PARSE_EC_COMPRESSED
417 # is automatically enabled in build_info.h (backward compatibility)
418 # even if it is disabled in config_psa_crypto_no_ecp_at_all(). As a
419 # consequence compressed points are supported in the reference
420 # component but not in the accelerated one, so they should be skipped
421 # while checking driver's coverage.
422 re.compile(r'Parse EC Key .*compressed\)'),
423 re.compile(r'Parse Public EC Key .*compressed\)'),
424 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200425 }
426
Gilles Peskine082eade2024-10-03 18:42:37 +0200427class DriverVSReference_ecc_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200428 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_bignum'
429 DRIVER = 'test_psa_crypto_config_accel_ecc_no_bignum'
430 IGNORED_SUITES = [
431 # Modules replaced by drivers
432 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
433 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
434 'bignum.generated', 'bignum.misc',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100435 # Unit tests for the built-in implementation
436 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200437 ]
438 IGNORED_TESTS = {
439 'test_suite_config': [
440 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
441 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
442 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
443 ],
444 'test_suite_platform': [
445 # Incompatible with sanitizers (e.g. ASan). If the driver
446 # component uses a sanitizer but the reference component
447 # doesn't, we have a PASS vs SKIP mismatch.
448 'Check mbedtls_calloc overallocation',
449 ],
450 # See ecp_light_only
451 'test_suite_random': [
452 'PSA classic wrapper: ECDSA signature (SECP256R1)',
453 ],
454 # See no_ecp_at_all
455 'test_suite_pkparse': [
456 re.compile(r'Parse EC Key .*compressed\)'),
457 re.compile(r'Parse Public EC Key .*compressed\)'),
458 ],
459 'test_suite_asn1parse': [
460 'INTEGER too large for mpi',
461 ],
462 'test_suite_asn1write': [
463 re.compile(r'ASN.1 Write mpi.*'),
464 ],
465 'test_suite_debug': [
466 re.compile(r'Debug print mbedtls_mpi.*'),
467 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200468 }
469
Gilles Peskine082eade2024-10-03 18:42:37 +0200470class DriverVSReference_ecc_ffdh_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200471 REFERENCE = 'test_psa_crypto_config_reference_ecc_ffdh_no_bignum'
472 DRIVER = 'test_psa_crypto_config_accel_ecc_ffdh_no_bignum'
473 IGNORED_SUITES = [
474 # Modules replaced by drivers
Valerio Setti461899e2025-02-12 13:34:25 +0100475 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200476 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
477 'bignum.generated', 'bignum.misc',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100478 # Unit tests for the built-in implementation
479 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200480 ]
481 IGNORED_TESTS = {
Gilles Peskine9df375b2024-09-16 20:14:26 +0200482 'test_suite_config': [
483 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
Gilles Peskine9df375b2024-09-16 20:14:26 +0200484 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
Gilles Peskine9df375b2024-09-16 20:14:26 +0200485 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
486 ],
487 'test_suite_platform': [
488 # Incompatible with sanitizers (e.g. ASan). If the driver
489 # component uses a sanitizer but the reference component
490 # doesn't, we have a PASS vs SKIP mismatch.
491 'Check mbedtls_calloc overallocation',
492 ],
493 # See ecp_light_only
494 'test_suite_random': [
495 'PSA classic wrapper: ECDSA signature (SECP256R1)',
496 ],
497 # See no_ecp_at_all
498 'test_suite_pkparse': [
499 re.compile(r'Parse EC Key .*compressed\)'),
500 re.compile(r'Parse Public EC Key .*compressed\)'),
501 ],
502 'test_suite_asn1parse': [
503 'INTEGER too large for mpi',
504 ],
505 'test_suite_asn1write': [
506 re.compile(r'ASN.1 Write mpi.*'),
507 ],
508 'test_suite_debug': [
509 re.compile(r'Debug print mbedtls_mpi.*'),
510 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200511 }
512
Gilles Peskine082eade2024-10-03 18:42:37 +0200513class DriverVSReference_ffdh_alg(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200514 REFERENCE = 'test_psa_crypto_config_reference_ffdh'
515 DRIVER = 'test_psa_crypto_config_accel_ffdh'
Gilles Peskine9df375b2024-09-16 20:14:26 +0200516 IGNORED_TESTS = {
Gilles Peskine9df375b2024-09-16 20:14:26 +0200517 'test_suite_platform': [
518 # Incompatible with sanitizers (e.g. ASan). If the driver
519 # component uses a sanitizer but the reference component
520 # doesn't, we have a PASS vs SKIP mismatch.
521 'Check mbedtls_calloc overallocation',
522 ],
523 }
524
Gilles Peskine082eade2024-10-03 18:42:37 +0200525class DriverVSReference_tfm_config(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200526 REFERENCE = 'test_tfm_config_no_p256m'
527 DRIVER = 'test_tfm_config_p256m_driver_accel_ec'
528 IGNORED_SUITES = [
529 # Modules replaced by drivers
530 'asn1parse', 'asn1write',
531 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
532 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
533 'bignum.generated', 'bignum.misc',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100534 # Unit tests for the built-in implementation
535 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200536 ]
537 IGNORED_TESTS = {
538 'test_suite_config': [
539 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
540 re.compile(r'.*\bMBEDTLS_(ASN1\w+)_C\b.*'),
541 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECP)_.*'),
542 re.compile(r'.*\bMBEDTLS_PSA_P256M_DRIVER_ENABLED\b.*')
543 ],
544 'test_suite_config.crypto_combinations': [
545 'Config: ECC: Weierstrass curves only',
546 ],
547 'test_suite_platform': [
548 # Incompatible with sanitizers (e.g. ASan). If the driver
549 # component uses a sanitizer but the reference component
550 # doesn't, we have a PASS vs SKIP mismatch.
551 'Check mbedtls_calloc overallocation',
552 ],
553 # See ecp_light_only
554 'test_suite_random': [
555 'PSA classic wrapper: ECDSA signature (SECP256R1)',
556 ],
557 }
558
Gilles Peskine082eade2024-10-03 18:42:37 +0200559class DriverVSReference_rsa(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200560 REFERENCE = 'test_psa_crypto_config_reference_rsa_crypto'
561 DRIVER = 'test_psa_crypto_config_accel_rsa_crypto'
562 IGNORED_SUITES = [
563 # Modules replaced by drivers.
564 'rsa', 'pkcs1_v15', 'pkcs1_v21',
565 # We temporarily don't care about PK stuff.
566 'pk', 'pkwrite', 'pkparse'
567 ]
568 IGNORED_TESTS = {
Ronald Cron4c481142025-07-11 17:23:41 +0200569 'test_suite_bignum.misc': [
570 re.compile(r'.*\bmbedtls_mpi_is_prime.*'),
571 re.compile(r'.*\bmbedtls_mpi_gen_prime.*'),
572 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200573 'test_suite_config': [
574 re.compile(r'.*\bMBEDTLS_(PKCS1|RSA)_.*'),
575 re.compile(r'.*\bMBEDTLS_GENPRIME\b.*')
576 ],
577 'test_suite_platform': [
578 # Incompatible with sanitizers (e.g. ASan). If the driver
579 # component uses a sanitizer but the reference component
580 # doesn't, we have a PASS vs SKIP mismatch.
581 'Check mbedtls_calloc overallocation',
582 ],
583 # Following tests depend on RSA_C but are not about
584 # them really, just need to know some error code is there.
585 'test_suite_error': [
586 'Low and high error',
587 'Single high error'
588 ],
589 # Constant time operations only used for PKCS1_V15
590 'test_suite_constant_time': [
591 re.compile(r'mbedtls_ct_zeroize_if .*'),
592 re.compile(r'mbedtls_ct_memmove_left .*')
593 ],
594 'test_suite_psa_crypto': [
595 # We don't support generate_key_custom entry points
596 # in drivers yet.
597 re.compile(r'PSA generate key custom: RSA, e=.*'),
598 re.compile(r'PSA generate key ext: RSA, e=.*'),
599 ],
600 }
601
Gilles Peskine082eade2024-10-03 18:42:37 +0200602class DriverVSReference_block_cipher_dispatch(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200603 REFERENCE = 'test_full_block_cipher_legacy_dispatch'
604 DRIVER = 'test_full_block_cipher_psa_dispatch'
605 IGNORED_SUITES = [
606 # Skipped in the accelerated component
607 'aes', 'aria', 'camellia',
608 # These require AES_C, ARIA_C or CAMELLIA_C to be enabled in
609 # order for the cipher module (actually cipher_wrapper) to work
610 # properly. However these symbols are disabled in the accelerated
611 # component so we ignore them.
612 'cipher.ccm', 'cipher.gcm', 'cipher.aes', 'cipher.aria',
613 'cipher.camellia',
614 ]
615 IGNORED_TESTS = {
616 'test_suite_config': [
617 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA)_.*'),
618 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
619 ],
620 'test_suite_cmac': [
621 # Following tests require AES_C/ARIA_C/CAMELLIA_C to be enabled,
622 # but these are not available in the accelerated component.
623 'CMAC null arguments',
624 re.compile('CMAC.* (AES|ARIA|Camellia).*'),
625 ],
626 'test_suite_cipher.padding': [
627 # Following tests require AES_C/CAMELLIA_C to be enabled,
628 # but these are not available in the accelerated component.
629 re.compile('Set( non-existent)? padding with (AES|CAMELLIA).*'),
630 ],
631 'test_suite_pkcs5': [
632 # The AES part of PKCS#5 PBES2 is not yet supported.
633 # The rest of PKCS#5 (PBKDF2) works, though.
634 re.compile(r'PBES2 .* AES-.*')
635 ],
636 'test_suite_pkparse': [
637 # PEM (called by pkparse) requires AES_C in order to decrypt
638 # the key, but this is not available in the accelerated
639 # component.
640 re.compile('Parse RSA Key.*(password|AES-).*'),
641 ],
642 'test_suite_pem': [
643 # Following tests require AES_C, but this is diabled in the
644 # accelerated component.
645 re.compile('PEM read .*AES.*'),
646 'PEM read (unknown encryption algorithm)',
647 ],
648 'test_suite_error': [
649 # Following tests depend on AES_C but are not about them
650 # really, just need to know some error code is there.
651 'Single low error',
652 'Low and high error',
653 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200654 'test_suite_platform': [
655 # Incompatible with sanitizers (e.g. ASan). If the driver
656 # component uses a sanitizer but the reference component
657 # doesn't, we have a PASS vs SKIP mismatch.
658 'Check mbedtls_calloc overallocation',
659 ],
660 }
661
662#pylint: enable=invalid-name,missing-class-docstring
663
664
Przemek Stekiel6856f4c2022-11-09 10:50:29 +0100665# List of tasks with a function that can handle this task and additional arguments if required
Valerio Settidfd7ca62023-10-09 16:30:11 +0200666KNOWN_TASKS = {
Gilles Peskinef646dbf2024-09-16 19:15:29 +0200667 'analyze_coverage': CoverageTask,
Gilles Peskine9df375b2024-09-16 20:14:26 +0200668 'analyze_driver_vs_reference_hash': DriverVSReference_hash,
669 'analyze_driver_vs_reference_hmac': DriverVSReference_hmac,
670 'analyze_driver_vs_reference_cipher_aead_cmac': DriverVSReference_cipher_aead_cmac,
671 'analyze_driver_vs_reference_ecp_light_only': DriverVSReference_ecp_light_only,
672 'analyze_driver_vs_reference_no_ecp_at_all': DriverVSReference_no_ecp_at_all,
673 'analyze_driver_vs_reference_ecc_no_bignum': DriverVSReference_ecc_no_bignum,
674 'analyze_driver_vs_reference_ecc_ffdh_no_bignum': DriverVSReference_ecc_ffdh_no_bignum,
675 'analyze_driver_vs_reference_ffdh_alg': DriverVSReference_ffdh_alg,
676 'analyze_driver_vs_reference_tfm_config': DriverVSReference_tfm_config,
677 'analyze_driver_vs_reference_rsa': DriverVSReference_rsa,
678 'analyze_block_cipher_dispatch': DriverVSReference_block_cipher_dispatch,
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200679}
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200680
Gilles Peskine15c2cbf2020-06-25 18:36:28 +0200681if __name__ == '__main__':
Gilles Peskine082eade2024-10-03 18:42:37 +0200682 outcome_analysis.main(KNOWN_TASKS)