blob: 8660e68942414296be7fba936dec19d839da4143 [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',
Ronald Croneb16a9d2025-09-03 09:57:29 +0200127 # Obsolete config option that we are about to remove
128 'Config: MBEDTLS_PLATFORM_GET_ENTROPY_ALT',
Minos Galanakis848333d2024-12-02 15:58:32 +0000129 # Untested aspect of the platform interface.
130 # https://github.com/Mbed-TLS/mbedtls/issues/9589
131 'Config: MBEDTLS_PLATFORM_NO_STD_FUNCTIONS',
132 # In a client-server build, test_suite_config runs in the
133 # client configuration, so it will never report
134 # MBEDTLS_PSA_CRYPTO_SPM as enabled. That's ok.
135 'Config: MBEDTLS_PSA_CRYPTO_SPM',
136 # We don't test on armv8 yet.
137 'Config: MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT',
138 'Config: MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY',
139 'Config: MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY',
140 'Config: MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY',
141 # We don't run test_suite_config when we test this.
142 # https://github.com/Mbed-TLS/mbedtls/issues/9586
143 'Config: MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND',
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200144 ],
145 'test_suite_config.psa_combinations': [
146 # We don't test this unusual, but sensible configuration.
147 # https://github.com/Mbed-TLS/mbedtls/issues/9592
148 'Config: PSA_WANT_ALG_DETERMINSTIC_ECDSA without PSA_WANT_ALG_ECDSA',
149 ],
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200150 'test_suite_pkcs12': [
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200151 # We never test with CBC/PKCS5/PKCS12 enabled but
152 # PKCS7 padding disabled.
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200153 # https://github.com/Mbed-TLS/mbedtls/issues/9580
154 'PBE Decrypt, (Invalid padding & PKCS7 padding disabled)',
155 'PBE Encrypt, pad = 8 (PKCS7 padding disabled)',
156 ],
157 'test_suite_pkcs5': [
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200158 # We never test with CBC/PKCS5/PKCS12 enabled but
159 # PKCS7 padding disabled.
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200160 # https://github.com/Mbed-TLS/mbedtls/issues/9580
161 'PBES2 Decrypt (Invalid padding & PKCS7 padding disabled)',
162 'PBES2 Encrypt, pad=6 (PKCS7 padding disabled)',
163 'PBES2 Encrypt, pad=8 (PKCS7 padding disabled)',
164 ],
Gilles Peskineeafc2752024-04-19 19:08:34 +0200165 'test_suite_psa_crypto': [
166 # We don't test this unusual, but sensible configuration.
167 # https://github.com/Mbed-TLS/mbedtls/issues/9592
168 re.compile(r'.*ECDSA.*only deterministic supported'),
169 ],
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200170 'test_suite_psa_crypto_metadata': [
171 # Algorithms declared but not supported.
172 # https://github.com/Mbed-TLS/mbedtls/issues/9579
173 'Asymmetric signature: Ed25519ph',
174 'Asymmetric signature: Ed448ph',
175 'Asymmetric signature: pure EdDSA',
176 'Cipher: XTS',
177 'MAC: CBC_MAC-3DES',
178 'MAC: CBC_MAC-AES-128',
179 'MAC: CBC_MAC-AES-192',
180 'MAC: CBC_MAC-AES-256',
181 ],
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200182 'test_suite_psa_crypto_not_supported.generated': [
Gilles Peskine5e3ed3f2024-10-11 12:00:44 +0200183 # We never test with DH key support disabled but support
Gilles Peskineab5cc9b2024-09-17 17:57:11 +0200184 # for a DH group enabled. The dependencies of these test
185 # cases don't really make sense.
186 # https://github.com/Mbed-TLS/mbedtls/issues/9574
187 re.compile(r'PSA \w+ DH_.*type not supported'),
188 # We only test partial support for DH with the 2048-bit group
189 # enabled and the other groups disabled.
190 # https://github.com/Mbed-TLS/mbedtls/issues/9575
191 'PSA generate DH_KEY_PAIR(RFC7919) 2048-bit group not supported',
192 'PSA import DH_KEY_PAIR(RFC7919) 2048-bit group not supported',
193 'PSA import DH_PUBLIC_KEY(RFC7919) 2048-bit group not supported',
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200194 ],
195 'test_suite_psa_crypto_op_fail.generated': [
Gilles Peskineeafc2752024-04-19 19:08:34 +0200196 # We don't test this unusual, but sensible configuration.
197 # https://github.com/Mbed-TLS/mbedtls/issues/9592
198 re.compile(r'.*: !ECDSA but DETERMINISTIC_ECDSA with ECC_.*'),
Gilles Peskineab5cc9b2024-09-17 17:57:11 +0200199 # We never test with the HMAC algorithm enabled but the HMAC
200 # key type disabled. Those dependencies don't really make sense.
201 # https://github.com/Mbed-TLS/mbedtls/issues/9573
202 re.compile(r'.* !HMAC with HMAC'),
Gilles Peskine13c418d2025-01-16 19:49:12 +0100203 # We don't test with ECDH disabled but the key type enabled.
204 # https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/161
205 re.compile(r'PSA key_agreement.* !ECDH with ECC_KEY_PAIR\(.*'),
206 # We don't test with FFDH disabled but the key type enabled.
207 # https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/160
208 re.compile(r'PSA key_agreement.* !FFDH with DH_KEY_PAIR\(.*'),
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200209 ],
Gilles Peskineeafc2752024-04-19 19:08:34 +0200210 'test_suite_psa_crypto_op_fail.misc': [
211 # We don't test this unusual, but sensible configuration.
212 # https://github.com/Mbed-TLS/mbedtls/issues/9592
213 'PSA sign DETERMINISTIC_ECDSA(SHA_256): !ECDSA but DETERMINISTIC_ECDSA with ECC_KEY_PAIR(SECP_R1)', #pylint: disable=line-too-long
214 ],
Gilles Peskinede2316b2024-09-17 18:32:05 +0200215 'tls13-misc': [
216 # Disabled due to OpenSSL bug.
217 # https://github.com/openssl/openssl/issues/10714
218 'TLS 1.3 O->m: resumption',
219 # Disabled due to OpenSSL command line limitation.
220 # https://github.com/Mbed-TLS/mbedtls/issues/9582
221 'TLS 1.3 m->O: resumption with early data',
222 ],
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200223 }
224
Gilles Peskine82b16722024-09-16 19:57:10 +0200225
Gilles Peskine9df375b2024-09-16 20:14:26 +0200226# The names that we give to classes derived from DriverVSReference do not
227# follow the usual naming convention, because it's more readable to use
228# underscores and parts of the configuration names. Also, these classes
229# are just there to specify some data, so they don't need repetitive
230# documentation.
231#pylint: disable=invalid-name,missing-class-docstring
232
Gilles Peskine082eade2024-10-03 18:42:37 +0200233class DriverVSReference_hash(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200234 REFERENCE = 'test_psa_crypto_config_reference_hash_use_psa'
235 DRIVER = 'test_psa_crypto_config_accel_hash_use_psa'
236 IGNORED_SUITES = [
237 'shax', 'mdx', # the software implementations that are being excluded
238 'md.psa', # purposefully depends on whether drivers are present
239 'psa_crypto_low_hash.generated', # testing the builtins
240 ]
241 IGNORED_TESTS = {
242 'test_suite_config': [
243 re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'),
244 ],
245 'test_suite_platform': [
246 # Incompatible with sanitizers (e.g. ASan). If the driver
247 # component uses a sanitizer but the reference component
248 # doesn't, we have a PASS vs SKIP mismatch.
249 'Check mbedtls_calloc overallocation',
250 ],
251 }
252
Gilles Peskine082eade2024-10-03 18:42:37 +0200253class DriverVSReference_hmac(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200254 REFERENCE = 'test_psa_crypto_config_reference_hmac'
255 DRIVER = 'test_psa_crypto_config_accel_hmac'
256 IGNORED_SUITES = [
257 # These suites require legacy hash support, which is disabled
258 # in the accelerated component.
259 'shax', 'mdx',
260 # This suite tests builtins directly, but these are missing
261 # in the accelerated case.
262 'psa_crypto_low_hash.generated',
263 ]
264 IGNORED_TESTS = {
265 'test_suite_config': [
266 re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'),
267 re.compile(r'.*\bMBEDTLS_MD_C\b')
268 ],
269 'test_suite_md': [
270 # Builtin HMAC is not supported in the accelerate component.
271 re.compile('.*HMAC.*'),
272 # Following tests make use of functions which are not available
273 # when MD_C is disabled, as it happens in the accelerated
274 # test component.
275 re.compile('generic .* Hash file .*'),
276 'MD list',
277 ],
278 'test_suite_md.psa': [
279 # "legacy only" tests require hash algorithms to be NOT
280 # accelerated, but this of course false for the accelerated
281 # test component.
282 re.compile('PSA dispatch .* legacy only'),
283 ],
284 'test_suite_platform': [
285 # Incompatible with sanitizers (e.g. ASan). If the driver
286 # component uses a sanitizer but the reference component
287 # doesn't, we have a PASS vs SKIP mismatch.
288 'Check mbedtls_calloc overallocation',
289 ],
290 }
291
Gilles Peskine082eade2024-10-03 18:42:37 +0200292class DriverVSReference_cipher_aead_cmac(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200293 REFERENCE = 'test_psa_crypto_config_reference_cipher_aead_cmac'
294 DRIVER = 'test_psa_crypto_config_accel_cipher_aead_cmac'
295 # Modules replaced by drivers.
296 IGNORED_SUITES = [
297 # low-level (block/stream) cipher modules
298 'aes', 'aria', 'camellia', 'des', 'chacha20',
Ronald Cronb5c6fcc2025-07-10 13:40:00 +0200299 # AEAD modes, CMAC and POLY1305
300 'ccm', 'chachapoly', 'cmac', 'gcm', 'poly1305',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200301 # The Cipher abstraction layer
302 'cipher',
303 ]
304 IGNORED_TESTS = {
305 'test_suite_config': [
306 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA|CHACHA20|DES)_.*'),
Ronald Cronb5c6fcc2025-07-10 13:40:00 +0200307 re.compile(r'.*\bMBEDTLS_(CCM|CHACHAPOLY|CMAC|GCM|POLY1305)_.*'),
Gilles Peskine9df375b2024-09-16 20:14:26 +0200308 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
309 re.compile(r'.*\bMBEDTLS_CIPHER_.*'),
310 ],
311 # PEM decryption is not supported so far.
312 # The rest of PEM (write, unencrypted read) works though.
313 'test_suite_pem': [
314 re.compile(r'PEM read .*(AES|DES|\bencrypt).*'),
315 ],
316 'test_suite_platform': [
317 # Incompatible with sanitizers (e.g. ASan). If the driver
318 # component uses a sanitizer but the reference component
319 # doesn't, we have a PASS vs SKIP mismatch.
320 'Check mbedtls_calloc overallocation',
321 ],
322 # Following tests depend on AES_C/DES_C but are not about
323 # them really, just need to know some error code is there.
324 'test_suite_error': [
325 'Low and high error',
326 'Single low error'
327 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200328 # The en/decryption part of PKCS#12 is not supported so far.
329 # The rest of PKCS#12 (key derivation) works though.
330 'test_suite_pkcs12': [
331 re.compile(r'PBE Encrypt, .*'),
332 re.compile(r'PBE Decrypt, .*'),
333 ],
334 # The en/decryption part of PKCS#5 is not supported so far.
335 # The rest of PKCS#5 (PBKDF2) works though.
336 'test_suite_pkcs5': [
337 re.compile(r'PBES2 Encrypt, .*'),
338 re.compile(r'PBES2 Decrypt .*'),
339 ],
340 # Encrypted keys are not supported so far.
341 # pylint: disable=line-too-long
342 'test_suite_pkparse': [
343 'Key ASN1 (Encrypted key PKCS12, trailing garbage data)',
344 'Key ASN1 (Encrypted key PKCS5, trailing garbage data)',
345 re.compile(r'Parse (RSA|EC) Key .*\(.* ([Ee]ncrypted|password).*\)'),
346 ],
347 # Encrypted keys are not supported so far.
348 'ssl-opt': [
349 'TLS: password protected server key',
350 'TLS: password protected client key',
351 'TLS: password protected server key, two certificates',
352 ],
353 }
354
Gilles Peskine082eade2024-10-03 18:42:37 +0200355class DriverVSReference_ecp_light_only(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200356 REFERENCE = 'test_psa_crypto_config_reference_ecc_ecp_light_only'
357 DRIVER = 'test_psa_crypto_config_accel_ecc_ecp_light_only'
358 IGNORED_SUITES = [
359 # Modules replaced by drivers
360 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100361 # Unit tests for the built-in implementation
362 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200363 ]
364 IGNORED_TESTS = {
365 'test_suite_config': [
366 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
367 ],
368 'test_suite_platform': [
369 # Incompatible with sanitizers (e.g. ASan). If the driver
370 # component uses a sanitizer but the reference component
371 # doesn't, we have a PASS vs SKIP mismatch.
372 'Check mbedtls_calloc overallocation',
373 ],
374 # This test wants a legacy function that takes f_rng, p_rng
375 # arguments, and uses legacy ECDSA for that. The test is
376 # really about the wrapper around the PSA RNG, not ECDSA.
377 'test_suite_random': [
378 'PSA classic wrapper: ECDSA signature (SECP256R1)',
379 ],
380 # In the accelerated test ECP_C is not set (only ECP_LIGHT is)
381 # so we must ignore disparities in the tests for which ECP_C
382 # is required.
383 'test_suite_ecp': [
384 re.compile(r'ECP check public-private .*'),
385 re.compile(r'ECP calculate public: .*'),
386 re.compile(r'ECP gen keypair .*'),
387 re.compile(r'ECP point muladd .*'),
388 re.compile(r'ECP point multiplication .*'),
389 re.compile(r'ECP test vectors .*'),
390 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200391 }
392
Gilles Peskine082eade2024-10-03 18:42:37 +0200393class DriverVSReference_no_ecp_at_all(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200394 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_ecp_at_all'
395 DRIVER = 'test_psa_crypto_config_accel_ecc_no_ecp_at_all'
396 IGNORED_SUITES = [
397 # Modules replaced by drivers
398 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100399 # Unit tests for the built-in implementation
400 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200401 ]
402 IGNORED_TESTS = {
403 'test_suite_config': [
404 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
405 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
406 ],
407 'test_suite_platform': [
408 # Incompatible with sanitizers (e.g. ASan). If the driver
409 # component uses a sanitizer but the reference component
410 # doesn't, we have a PASS vs SKIP mismatch.
411 'Check mbedtls_calloc overallocation',
412 ],
413 # See ecp_light_only
414 'test_suite_random': [
415 'PSA classic wrapper: ECDSA signature (SECP256R1)',
416 ],
417 'test_suite_pkparse': [
418 # When PK_PARSE_C and ECP_C are defined then PK_PARSE_EC_COMPRESSED
419 # is automatically enabled in build_info.h (backward compatibility)
420 # even if it is disabled in config_psa_crypto_no_ecp_at_all(). As a
421 # consequence compressed points are supported in the reference
422 # component but not in the accelerated one, so they should be skipped
423 # while checking driver's coverage.
424 re.compile(r'Parse EC Key .*compressed\)'),
425 re.compile(r'Parse Public EC Key .*compressed\)'),
426 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200427 }
428
Gilles Peskine082eade2024-10-03 18:42:37 +0200429class DriverVSReference_ecc_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200430 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_bignum'
431 DRIVER = 'test_psa_crypto_config_accel_ecc_no_bignum'
432 IGNORED_SUITES = [
433 # Modules replaced by drivers
434 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
435 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
436 'bignum.generated', 'bignum.misc',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100437 # Unit tests for the built-in implementation
438 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200439 ]
440 IGNORED_TESTS = {
441 'test_suite_config': [
442 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
443 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
444 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
445 ],
446 'test_suite_platform': [
447 # Incompatible with sanitizers (e.g. ASan). If the driver
448 # component uses a sanitizer but the reference component
449 # doesn't, we have a PASS vs SKIP mismatch.
450 'Check mbedtls_calloc overallocation',
451 ],
452 # See ecp_light_only
453 'test_suite_random': [
454 'PSA classic wrapper: ECDSA signature (SECP256R1)',
455 ],
456 # See no_ecp_at_all
457 'test_suite_pkparse': [
458 re.compile(r'Parse EC Key .*compressed\)'),
459 re.compile(r'Parse Public EC Key .*compressed\)'),
460 ],
461 'test_suite_asn1parse': [
462 'INTEGER too large for mpi',
463 ],
464 'test_suite_asn1write': [
465 re.compile(r'ASN.1 Write mpi.*'),
466 ],
467 'test_suite_debug': [
468 re.compile(r'Debug print mbedtls_mpi.*'),
469 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200470 }
471
Gilles Peskine082eade2024-10-03 18:42:37 +0200472class DriverVSReference_ecc_ffdh_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200473 REFERENCE = 'test_psa_crypto_config_reference_ecc_ffdh_no_bignum'
474 DRIVER = 'test_psa_crypto_config_accel_ecc_ffdh_no_bignum'
475 IGNORED_SUITES = [
476 # Modules replaced by drivers
Valerio Setti461899e2025-02-12 13:34:25 +0100477 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200478 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
479 'bignum.generated', 'bignum.misc',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100480 # Unit tests for the built-in implementation
481 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200482 ]
483 IGNORED_TESTS = {
Gilles Peskine9df375b2024-09-16 20:14:26 +0200484 'test_suite_config': [
485 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
Gilles Peskine9df375b2024-09-16 20:14:26 +0200486 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
Gilles Peskine9df375b2024-09-16 20:14:26 +0200487 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
488 ],
489 'test_suite_platform': [
490 # Incompatible with sanitizers (e.g. ASan). If the driver
491 # component uses a sanitizer but the reference component
492 # doesn't, we have a PASS vs SKIP mismatch.
493 'Check mbedtls_calloc overallocation',
494 ],
495 # See ecp_light_only
496 'test_suite_random': [
497 'PSA classic wrapper: ECDSA signature (SECP256R1)',
498 ],
499 # See no_ecp_at_all
500 'test_suite_pkparse': [
501 re.compile(r'Parse EC Key .*compressed\)'),
502 re.compile(r'Parse Public EC Key .*compressed\)'),
503 ],
504 'test_suite_asn1parse': [
505 'INTEGER too large for mpi',
506 ],
507 'test_suite_asn1write': [
508 re.compile(r'ASN.1 Write mpi.*'),
509 ],
510 'test_suite_debug': [
511 re.compile(r'Debug print mbedtls_mpi.*'),
512 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200513 }
514
Gilles Peskine082eade2024-10-03 18:42:37 +0200515class DriverVSReference_ffdh_alg(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200516 REFERENCE = 'test_psa_crypto_config_reference_ffdh'
517 DRIVER = 'test_psa_crypto_config_accel_ffdh'
Gilles Peskine9df375b2024-09-16 20:14:26 +0200518 IGNORED_TESTS = {
Gilles Peskine9df375b2024-09-16 20:14:26 +0200519 'test_suite_platform': [
520 # Incompatible with sanitizers (e.g. ASan). If the driver
521 # component uses a sanitizer but the reference component
522 # doesn't, we have a PASS vs SKIP mismatch.
523 'Check mbedtls_calloc overallocation',
524 ],
525 }
526
Gilles Peskine082eade2024-10-03 18:42:37 +0200527class DriverVSReference_tfm_config(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200528 REFERENCE = 'test_tfm_config_no_p256m'
529 DRIVER = 'test_tfm_config_p256m_driver_accel_ec'
530 IGNORED_SUITES = [
531 # Modules replaced by drivers
532 'asn1parse', 'asn1write',
533 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
534 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
535 'bignum.generated', 'bignum.misc',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100536 # Unit tests for the built-in implementation
537 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200538 ]
539 IGNORED_TESTS = {
540 'test_suite_config': [
541 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
542 re.compile(r'.*\bMBEDTLS_(ASN1\w+)_C\b.*'),
543 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECP)_.*'),
544 re.compile(r'.*\bMBEDTLS_PSA_P256M_DRIVER_ENABLED\b.*')
545 ],
546 'test_suite_config.crypto_combinations': [
547 'Config: ECC: Weierstrass curves only',
548 ],
549 'test_suite_platform': [
550 # Incompatible with sanitizers (e.g. ASan). If the driver
551 # component uses a sanitizer but the reference component
552 # doesn't, we have a PASS vs SKIP mismatch.
553 'Check mbedtls_calloc overallocation',
554 ],
555 # See ecp_light_only
556 'test_suite_random': [
557 'PSA classic wrapper: ECDSA signature (SECP256R1)',
558 ],
559 }
560
Gilles Peskine082eade2024-10-03 18:42:37 +0200561class DriverVSReference_rsa(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200562 REFERENCE = 'test_psa_crypto_config_reference_rsa_crypto'
563 DRIVER = 'test_psa_crypto_config_accel_rsa_crypto'
564 IGNORED_SUITES = [
565 # Modules replaced by drivers.
566 'rsa', 'pkcs1_v15', 'pkcs1_v21',
567 # We temporarily don't care about PK stuff.
568 'pk', 'pkwrite', 'pkparse'
569 ]
570 IGNORED_TESTS = {
Ronald Cron4c481142025-07-11 17:23:41 +0200571 'test_suite_bignum.misc': [
572 re.compile(r'.*\bmbedtls_mpi_is_prime.*'),
573 re.compile(r'.*\bmbedtls_mpi_gen_prime.*'),
574 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200575 'test_suite_config': [
576 re.compile(r'.*\bMBEDTLS_(PKCS1|RSA)_.*'),
577 re.compile(r'.*\bMBEDTLS_GENPRIME\b.*')
578 ],
579 'test_suite_platform': [
580 # Incompatible with sanitizers (e.g. ASan). If the driver
581 # component uses a sanitizer but the reference component
582 # doesn't, we have a PASS vs SKIP mismatch.
583 'Check mbedtls_calloc overallocation',
584 ],
585 # Following tests depend on RSA_C but are not about
586 # them really, just need to know some error code is there.
587 'test_suite_error': [
588 'Low and high error',
589 'Single high error'
590 ],
591 # Constant time operations only used for PKCS1_V15
592 'test_suite_constant_time': [
593 re.compile(r'mbedtls_ct_zeroize_if .*'),
594 re.compile(r'mbedtls_ct_memmove_left .*')
595 ],
596 'test_suite_psa_crypto': [
597 # We don't support generate_key_custom entry points
598 # in drivers yet.
599 re.compile(r'PSA generate key custom: RSA, e=.*'),
600 re.compile(r'PSA generate key ext: RSA, e=.*'),
601 ],
602 }
603
Gilles Peskine082eade2024-10-03 18:42:37 +0200604class DriverVSReference_block_cipher_dispatch(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200605 REFERENCE = 'test_full_block_cipher_legacy_dispatch'
606 DRIVER = 'test_full_block_cipher_psa_dispatch'
607 IGNORED_SUITES = [
608 # Skipped in the accelerated component
609 'aes', 'aria', 'camellia',
610 # These require AES_C, ARIA_C or CAMELLIA_C to be enabled in
611 # order for the cipher module (actually cipher_wrapper) to work
612 # properly. However these symbols are disabled in the accelerated
613 # component so we ignore them.
614 'cipher.ccm', 'cipher.gcm', 'cipher.aes', 'cipher.aria',
615 'cipher.camellia',
616 ]
617 IGNORED_TESTS = {
618 'test_suite_config': [
619 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA)_.*'),
620 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
621 ],
622 'test_suite_cmac': [
623 # Following tests require AES_C/ARIA_C/CAMELLIA_C to be enabled,
624 # but these are not available in the accelerated component.
625 'CMAC null arguments',
626 re.compile('CMAC.* (AES|ARIA|Camellia).*'),
627 ],
628 'test_suite_cipher.padding': [
629 # Following tests require AES_C/CAMELLIA_C to be enabled,
630 # but these are not available in the accelerated component.
631 re.compile('Set( non-existent)? padding with (AES|CAMELLIA).*'),
632 ],
633 'test_suite_pkcs5': [
634 # The AES part of PKCS#5 PBES2 is not yet supported.
635 # The rest of PKCS#5 (PBKDF2) works, though.
636 re.compile(r'PBES2 .* AES-.*')
637 ],
638 'test_suite_pkparse': [
639 # PEM (called by pkparse) requires AES_C in order to decrypt
640 # the key, but this is not available in the accelerated
641 # component.
642 re.compile('Parse RSA Key.*(password|AES-).*'),
643 ],
644 'test_suite_pem': [
645 # Following tests require AES_C, but this is diabled in the
646 # accelerated component.
647 re.compile('PEM read .*AES.*'),
648 'PEM read (unknown encryption algorithm)',
649 ],
650 'test_suite_error': [
651 # Following tests depend on AES_C but are not about them
652 # really, just need to know some error code is there.
653 'Single low error',
654 'Low and high error',
655 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200656 'test_suite_platform': [
657 # Incompatible with sanitizers (e.g. ASan). If the driver
658 # component uses a sanitizer but the reference component
659 # doesn't, we have a PASS vs SKIP mismatch.
660 'Check mbedtls_calloc overallocation',
661 ],
662 }
663
664#pylint: enable=invalid-name,missing-class-docstring
665
666
Przemek Stekiel6856f4c2022-11-09 10:50:29 +0100667# List of tasks with a function that can handle this task and additional arguments if required
Valerio Settidfd7ca62023-10-09 16:30:11 +0200668KNOWN_TASKS = {
Gilles Peskinef646dbf2024-09-16 19:15:29 +0200669 'analyze_coverage': CoverageTask,
Gilles Peskine9df375b2024-09-16 20:14:26 +0200670 'analyze_driver_vs_reference_hash': DriverVSReference_hash,
671 'analyze_driver_vs_reference_hmac': DriverVSReference_hmac,
672 'analyze_driver_vs_reference_cipher_aead_cmac': DriverVSReference_cipher_aead_cmac,
673 'analyze_driver_vs_reference_ecp_light_only': DriverVSReference_ecp_light_only,
674 'analyze_driver_vs_reference_no_ecp_at_all': DriverVSReference_no_ecp_at_all,
675 'analyze_driver_vs_reference_ecc_no_bignum': DriverVSReference_ecc_no_bignum,
676 'analyze_driver_vs_reference_ecc_ffdh_no_bignum': DriverVSReference_ecc_ffdh_no_bignum,
677 'analyze_driver_vs_reference_ffdh_alg': DriverVSReference_ffdh_alg,
678 'analyze_driver_vs_reference_tfm_config': DriverVSReference_tfm_config,
679 'analyze_driver_vs_reference_rsa': DriverVSReference_rsa,
680 'analyze_block_cipher_dispatch': DriverVSReference_block_cipher_dispatch,
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200681}
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200682
Gilles Peskine15c2cbf2020-06-25 18:36:28 +0200683if __name__ == '__main__':
Gilles Peskine082eade2024-10-03 18:42:37 +0200684 outcome_analysis.main(KNOWN_TASKS)