blob: 21845137f8e5c24616cf7eca1da3c0e99a769c1b [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',
Felix Conway133f7aa2025-03-19 14:38:47 +0000127 # Obsolete configuration options, to be replaced by
Minos Galanakis848333d2024-12-02 15:58:32 +0000128 # PSA entropy drivers.
129 # https://github.com/Mbed-TLS/mbedtls/issues/8150
Felix Conway133f7aa2025-03-19 14:38:47 +0000130 'Config: MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES',
Minos Galanakis848333d2024-12-02 15:58:32 +0000131 # Untested aspect of the platform interface.
132 # https://github.com/Mbed-TLS/mbedtls/issues/9589
133 'Config: MBEDTLS_PLATFORM_NO_STD_FUNCTIONS',
134 # In a client-server build, test_suite_config runs in the
135 # client configuration, so it will never report
136 # MBEDTLS_PSA_CRYPTO_SPM as enabled. That's ok.
137 'Config: MBEDTLS_PSA_CRYPTO_SPM',
138 # We don't test on armv8 yet.
139 'Config: MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT',
140 'Config: MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY',
141 'Config: MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY',
142 'Config: MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY',
143 # We don't run test_suite_config when we test this.
144 # https://github.com/Mbed-TLS/mbedtls/issues/9586
145 'Config: MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND',
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200146 ],
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 Peskineb0ec85d2024-09-17 18:33:29 +0200152 'test_suite_pkcs12': [
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200153 # We never test with CBC/PKCS5/PKCS12 enabled but
154 # PKCS7 padding disabled.
Gilles Peskineb0ec85d2024-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 Peskine2fd25bb2024-09-17 19:46:18 +0200160 # We never test with CBC/PKCS5/PKCS12 enabled but
161 # PKCS7 padding disabled.
Gilles Peskineb0ec85d2024-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 Peskineeafc2752024-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 Peskineb0ec85d2024-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 Peskine2a71fac2024-09-17 15:07:22 +0200184 'test_suite_psa_crypto_not_supported.generated': [
Gilles Peskine5e3ed3f2024-10-11 12:00:44 +0200185 # We never test with DH key support disabled but support
Gilles Peskineab5cc9b2024-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 Peskine2a71fac2024-09-17 15:07:22 +0200196 ],
197 'test_suite_psa_crypto_op_fail.generated': [
Gilles Peskineeafc2752024-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 Peskineab5cc9b2024-09-17 17:57:11 +0200201 # We never test with the HMAC algorithm enabled but the HMAC
202 # key type disabled. Those dependencies don't really make sense.
203 # https://github.com/Mbed-TLS/mbedtls/issues/9573
204 re.compile(r'.* !HMAC with HMAC'),
Gilles Peskine13c418d2025-01-16 19:49:12 +0100205 # We don't test with ECDH disabled but the key type enabled.
206 # https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/161
207 re.compile(r'PSA key_agreement.* !ECDH with ECC_KEY_PAIR\(.*'),
208 # We don't test with FFDH disabled but the key type enabled.
209 # https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/160
210 re.compile(r'PSA key_agreement.* !FFDH with DH_KEY_PAIR\(.*'),
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200211 ],
Gilles Peskineeafc2752024-04-19 19:08:34 +0200212 'test_suite_psa_crypto_op_fail.misc': [
213 # We don't test this unusual, but sensible configuration.
214 # https://github.com/Mbed-TLS/mbedtls/issues/9592
215 'PSA sign DETERMINISTIC_ECDSA(SHA_256): !ECDSA but DETERMINISTIC_ECDSA with ECC_KEY_PAIR(SECP_R1)', #pylint: disable=line-too-long
216 ],
Gilles Peskinede2316b2024-09-17 18:32:05 +0200217 'tls13-misc': [
218 # Disabled due to OpenSSL bug.
219 # https://github.com/openssl/openssl/issues/10714
220 'TLS 1.3 O->m: resumption',
221 # Disabled due to OpenSSL command line limitation.
222 # https://github.com/Mbed-TLS/mbedtls/issues/9582
223 'TLS 1.3 m->O: resumption with early data',
224 ],
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200225 }
226
Gilles Peskine82b16722024-09-16 19:57:10 +0200227
Gilles Peskine9df375b2024-09-16 20:14:26 +0200228# The names that we give to classes derived from DriverVSReference do not
229# follow the usual naming convention, because it's more readable to use
230# underscores and parts of the configuration names. Also, these classes
231# are just there to specify some data, so they don't need repetitive
232# documentation.
233#pylint: disable=invalid-name,missing-class-docstring
234
Gilles Peskine082eade2024-10-03 18:42:37 +0200235class DriverVSReference_hash(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200236 REFERENCE = 'test_psa_crypto_config_reference_hash_use_psa'
237 DRIVER = 'test_psa_crypto_config_accel_hash_use_psa'
238 IGNORED_SUITES = [
239 'shax', 'mdx', # the software implementations that are being excluded
240 'md.psa', # purposefully depends on whether drivers are present
241 'psa_crypto_low_hash.generated', # testing the builtins
242 ]
243 IGNORED_TESTS = {
244 'test_suite_config': [
245 re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'),
246 ],
247 'test_suite_platform': [
248 # Incompatible with sanitizers (e.g. ASan). If the driver
249 # component uses a sanitizer but the reference component
250 # doesn't, we have a PASS vs SKIP mismatch.
251 'Check mbedtls_calloc overallocation',
252 ],
253 }
254
Gilles Peskine082eade2024-10-03 18:42:37 +0200255class DriverVSReference_hmac(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200256 REFERENCE = 'test_psa_crypto_config_reference_hmac'
257 DRIVER = 'test_psa_crypto_config_accel_hmac'
258 IGNORED_SUITES = [
259 # These suites require legacy hash support, which is disabled
260 # in the accelerated component.
261 'shax', 'mdx',
262 # This suite tests builtins directly, but these are missing
263 # in the accelerated case.
264 'psa_crypto_low_hash.generated',
265 ]
266 IGNORED_TESTS = {
267 'test_suite_config': [
268 re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'),
269 re.compile(r'.*\bMBEDTLS_MD_C\b')
270 ],
271 'test_suite_md': [
272 # Builtin HMAC is not supported in the accelerate component.
273 re.compile('.*HMAC.*'),
274 # Following tests make use of functions which are not available
275 # when MD_C is disabled, as it happens in the accelerated
276 # test component.
277 re.compile('generic .* Hash file .*'),
278 'MD list',
279 ],
280 'test_suite_md.psa': [
281 # "legacy only" tests require hash algorithms to be NOT
282 # accelerated, but this of course false for the accelerated
283 # test component.
284 re.compile('PSA dispatch .* legacy only'),
285 ],
286 'test_suite_platform': [
287 # Incompatible with sanitizers (e.g. ASan). If the driver
288 # component uses a sanitizer but the reference component
289 # doesn't, we have a PASS vs SKIP mismatch.
290 'Check mbedtls_calloc overallocation',
291 ],
292 }
293
Gilles Peskine082eade2024-10-03 18:42:37 +0200294class DriverVSReference_cipher_aead_cmac(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200295 REFERENCE = 'test_psa_crypto_config_reference_cipher_aead_cmac'
296 DRIVER = 'test_psa_crypto_config_accel_cipher_aead_cmac'
297 # Modules replaced by drivers.
298 IGNORED_SUITES = [
299 # low-level (block/stream) cipher modules
300 'aes', 'aria', 'camellia', 'des', 'chacha20',
301 # AEAD modes and CMAC
302 'ccm', 'chachapoly', 'cmac', 'gcm',
303 # The Cipher abstraction layer
304 'cipher',
305 ]
306 IGNORED_TESTS = {
307 'test_suite_config': [
308 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA|CHACHA20|DES)_.*'),
309 re.compile(r'.*\bMBEDTLS_(CCM|CHACHAPOLY|CMAC|GCM)_.*'),
310 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
311 re.compile(r'.*\bMBEDTLS_CIPHER_.*'),
312 ],
313 # PEM decryption is not supported so far.
314 # The rest of PEM (write, unencrypted read) works though.
315 'test_suite_pem': [
316 re.compile(r'PEM read .*(AES|DES|\bencrypt).*'),
317 ],
318 'test_suite_platform': [
319 # Incompatible with sanitizers (e.g. ASan). If the driver
320 # component uses a sanitizer but the reference component
321 # doesn't, we have a PASS vs SKIP mismatch.
322 'Check mbedtls_calloc overallocation',
323 ],
324 # Following tests depend on AES_C/DES_C but are not about
325 # them really, just need to know some error code is there.
326 'test_suite_error': [
327 'Low and high error',
328 'Single low error'
329 ],
330 # Similar to test_suite_error above.
331 'test_suite_version': [
332 'Check for MBEDTLS_AES_C when already present',
333 ],
334 # The en/decryption part of PKCS#12 is not supported so far.
335 # The rest of PKCS#12 (key derivation) works though.
336 'test_suite_pkcs12': [
337 re.compile(r'PBE Encrypt, .*'),
338 re.compile(r'PBE Decrypt, .*'),
339 ],
340 # The en/decryption part of PKCS#5 is not supported so far.
341 # The rest of PKCS#5 (PBKDF2) works though.
342 'test_suite_pkcs5': [
343 re.compile(r'PBES2 Encrypt, .*'),
344 re.compile(r'PBES2 Decrypt .*'),
345 ],
346 # Encrypted keys are not supported so far.
347 # pylint: disable=line-too-long
348 'test_suite_pkparse': [
349 'Key ASN1 (Encrypted key PKCS12, trailing garbage data)',
350 'Key ASN1 (Encrypted key PKCS5, trailing garbage data)',
351 re.compile(r'Parse (RSA|EC) Key .*\(.* ([Ee]ncrypted|password).*\)'),
352 ],
353 # Encrypted keys are not supported so far.
354 'ssl-opt': [
355 'TLS: password protected server key',
356 'TLS: password protected client key',
357 'TLS: password protected server key, two certificates',
358 ],
359 }
360
Gilles Peskine082eade2024-10-03 18:42:37 +0200361class DriverVSReference_ecp_light_only(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200362 REFERENCE = 'test_psa_crypto_config_reference_ecc_ecp_light_only'
363 DRIVER = 'test_psa_crypto_config_accel_ecc_ecp_light_only'
364 IGNORED_SUITES = [
365 # Modules replaced by drivers
366 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100367 # Unit tests for the built-in implementation
368 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200369 ]
370 IGNORED_TESTS = {
371 'test_suite_config': [
372 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
373 ],
374 'test_suite_platform': [
375 # Incompatible with sanitizers (e.g. ASan). If the driver
376 # component uses a sanitizer but the reference component
377 # doesn't, we have a PASS vs SKIP mismatch.
378 'Check mbedtls_calloc overallocation',
379 ],
380 # This test wants a legacy function that takes f_rng, p_rng
381 # arguments, and uses legacy ECDSA for that. The test is
382 # really about the wrapper around the PSA RNG, not ECDSA.
383 'test_suite_random': [
384 'PSA classic wrapper: ECDSA signature (SECP256R1)',
385 ],
386 # In the accelerated test ECP_C is not set (only ECP_LIGHT is)
387 # so we must ignore disparities in the tests for which ECP_C
388 # is required.
389 'test_suite_ecp': [
390 re.compile(r'ECP check public-private .*'),
391 re.compile(r'ECP calculate public: .*'),
392 re.compile(r'ECP gen keypair .*'),
393 re.compile(r'ECP point muladd .*'),
394 re.compile(r'ECP point multiplication .*'),
395 re.compile(r'ECP test vectors .*'),
396 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200397 }
398
Gilles Peskine082eade2024-10-03 18:42:37 +0200399class DriverVSReference_no_ecp_at_all(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200400 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_ecp_at_all'
401 DRIVER = 'test_psa_crypto_config_accel_ecc_no_ecp_at_all'
402 IGNORED_SUITES = [
403 # Modules replaced by drivers
404 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100405 # Unit tests for the built-in implementation
406 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200407 ]
408 IGNORED_TESTS = {
409 'test_suite_config': [
410 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
411 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
412 ],
413 'test_suite_platform': [
414 # Incompatible with sanitizers (e.g. ASan). If the driver
415 # component uses a sanitizer but the reference component
416 # doesn't, we have a PASS vs SKIP mismatch.
417 'Check mbedtls_calloc overallocation',
418 ],
419 # See ecp_light_only
420 'test_suite_random': [
421 'PSA classic wrapper: ECDSA signature (SECP256R1)',
422 ],
423 'test_suite_pkparse': [
424 # When PK_PARSE_C and ECP_C are defined then PK_PARSE_EC_COMPRESSED
425 # is automatically enabled in build_info.h (backward compatibility)
426 # even if it is disabled in config_psa_crypto_no_ecp_at_all(). As a
427 # consequence compressed points are supported in the reference
428 # component but not in the accelerated one, so they should be skipped
429 # while checking driver's coverage.
430 re.compile(r'Parse EC Key .*compressed\)'),
431 re.compile(r'Parse Public EC Key .*compressed\)'),
432 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200433 }
434
Gilles Peskine082eade2024-10-03 18:42:37 +0200435class DriverVSReference_ecc_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200436 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_bignum'
437 DRIVER = 'test_psa_crypto_config_accel_ecc_no_bignum'
438 IGNORED_SUITES = [
439 # Modules replaced by drivers
440 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
441 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
442 'bignum.generated', 'bignum.misc',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100443 # Unit tests for the built-in implementation
444 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200445 ]
446 IGNORED_TESTS = {
447 'test_suite_config': [
448 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
449 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
450 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
451 ],
452 'test_suite_platform': [
453 # Incompatible with sanitizers (e.g. ASan). If the driver
454 # component uses a sanitizer but the reference component
455 # doesn't, we have a PASS vs SKIP mismatch.
456 'Check mbedtls_calloc overallocation',
457 ],
458 # See ecp_light_only
459 'test_suite_random': [
460 'PSA classic wrapper: ECDSA signature (SECP256R1)',
461 ],
462 # See no_ecp_at_all
463 'test_suite_pkparse': [
464 re.compile(r'Parse EC Key .*compressed\)'),
465 re.compile(r'Parse Public EC Key .*compressed\)'),
466 ],
467 'test_suite_asn1parse': [
468 'INTEGER too large for mpi',
469 ],
470 'test_suite_asn1write': [
471 re.compile(r'ASN.1 Write mpi.*'),
472 ],
473 'test_suite_debug': [
474 re.compile(r'Debug print mbedtls_mpi.*'),
475 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200476 }
477
Gilles Peskine082eade2024-10-03 18:42:37 +0200478class DriverVSReference_ecc_ffdh_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200479 REFERENCE = 'test_psa_crypto_config_reference_ecc_ffdh_no_bignum'
480 DRIVER = 'test_psa_crypto_config_accel_ecc_ffdh_no_bignum'
481 IGNORED_SUITES = [
482 # Modules replaced by drivers
Valerio Setti461899e2025-02-12 13:34:25 +0100483 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200484 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
485 'bignum.generated', 'bignum.misc',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100486 # Unit tests for the built-in implementation
487 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200488 ]
489 IGNORED_TESTS = {
Gilles Peskine9df375b2024-09-16 20:14:26 +0200490 'test_suite_config': [
491 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
Gilles Peskine9df375b2024-09-16 20:14:26 +0200492 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
Gilles Peskine9df375b2024-09-16 20:14:26 +0200493 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
494 ],
495 'test_suite_platform': [
496 # Incompatible with sanitizers (e.g. ASan). If the driver
497 # component uses a sanitizer but the reference component
498 # doesn't, we have a PASS vs SKIP mismatch.
499 'Check mbedtls_calloc overallocation',
500 ],
501 # See ecp_light_only
502 'test_suite_random': [
503 'PSA classic wrapper: ECDSA signature (SECP256R1)',
504 ],
505 # See no_ecp_at_all
506 'test_suite_pkparse': [
507 re.compile(r'Parse EC Key .*compressed\)'),
508 re.compile(r'Parse Public EC Key .*compressed\)'),
509 ],
510 'test_suite_asn1parse': [
511 'INTEGER too large for mpi',
512 ],
513 'test_suite_asn1write': [
514 re.compile(r'ASN.1 Write mpi.*'),
515 ],
516 'test_suite_debug': [
517 re.compile(r'Debug print mbedtls_mpi.*'),
518 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200519 }
520
Gilles Peskine082eade2024-10-03 18:42:37 +0200521class DriverVSReference_ffdh_alg(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200522 REFERENCE = 'test_psa_crypto_config_reference_ffdh'
523 DRIVER = 'test_psa_crypto_config_accel_ffdh'
Gilles Peskine9df375b2024-09-16 20:14:26 +0200524 IGNORED_TESTS = {
Gilles Peskine9df375b2024-09-16 20:14:26 +0200525 'test_suite_platform': [
526 # Incompatible with sanitizers (e.g. ASan). If the driver
527 # component uses a sanitizer but the reference component
528 # doesn't, we have a PASS vs SKIP mismatch.
529 'Check mbedtls_calloc overallocation',
530 ],
531 }
532
Gilles Peskine082eade2024-10-03 18:42:37 +0200533class DriverVSReference_tfm_config(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200534 REFERENCE = 'test_tfm_config_no_p256m'
535 DRIVER = 'test_tfm_config_p256m_driver_accel_ec'
536 IGNORED_SUITES = [
537 # Modules replaced by drivers
538 'asn1parse', 'asn1write',
539 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
540 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
541 'bignum.generated', 'bignum.misc',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100542 # Unit tests for the built-in implementation
543 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200544 ]
545 IGNORED_TESTS = {
546 'test_suite_config': [
547 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
548 re.compile(r'.*\bMBEDTLS_(ASN1\w+)_C\b.*'),
549 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECP)_.*'),
550 re.compile(r'.*\bMBEDTLS_PSA_P256M_DRIVER_ENABLED\b.*')
551 ],
552 'test_suite_config.crypto_combinations': [
553 'Config: ECC: Weierstrass curves only',
554 ],
555 'test_suite_platform': [
556 # Incompatible with sanitizers (e.g. ASan). If the driver
557 # component uses a sanitizer but the reference component
558 # doesn't, we have a PASS vs SKIP mismatch.
559 'Check mbedtls_calloc overallocation',
560 ],
561 # See ecp_light_only
562 'test_suite_random': [
563 'PSA classic wrapper: ECDSA signature (SECP256R1)',
564 ],
565 }
566
Gilles Peskine082eade2024-10-03 18:42:37 +0200567class DriverVSReference_rsa(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200568 REFERENCE = 'test_psa_crypto_config_reference_rsa_crypto'
569 DRIVER = 'test_psa_crypto_config_accel_rsa_crypto'
570 IGNORED_SUITES = [
571 # Modules replaced by drivers.
572 'rsa', 'pkcs1_v15', 'pkcs1_v21',
573 # We temporarily don't care about PK stuff.
574 'pk', 'pkwrite', 'pkparse'
575 ]
576 IGNORED_TESTS = {
577 'test_suite_config': [
578 re.compile(r'.*\bMBEDTLS_(PKCS1|RSA)_.*'),
579 re.compile(r'.*\bMBEDTLS_GENPRIME\b.*')
580 ],
581 'test_suite_platform': [
582 # Incompatible with sanitizers (e.g. ASan). If the driver
583 # component uses a sanitizer but the reference component
584 # doesn't, we have a PASS vs SKIP mismatch.
585 'Check mbedtls_calloc overallocation',
586 ],
587 # Following tests depend on RSA_C but are not about
588 # them really, just need to know some error code is there.
589 'test_suite_error': [
590 'Low and high error',
591 'Single high error'
592 ],
593 # Constant time operations only used for PKCS1_V15
594 'test_suite_constant_time': [
595 re.compile(r'mbedtls_ct_zeroize_if .*'),
596 re.compile(r'mbedtls_ct_memmove_left .*')
597 ],
598 'test_suite_psa_crypto': [
599 # We don't support generate_key_custom entry points
600 # in drivers yet.
601 re.compile(r'PSA generate key custom: RSA, e=.*'),
602 re.compile(r'PSA generate key ext: RSA, e=.*'),
603 ],
604 }
605
Gilles Peskine082eade2024-10-03 18:42:37 +0200606class DriverVSReference_block_cipher_dispatch(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200607 REFERENCE = 'test_full_block_cipher_legacy_dispatch'
608 DRIVER = 'test_full_block_cipher_psa_dispatch'
609 IGNORED_SUITES = [
610 # Skipped in the accelerated component
611 'aes', 'aria', 'camellia',
612 # These require AES_C, ARIA_C or CAMELLIA_C to be enabled in
613 # order for the cipher module (actually cipher_wrapper) to work
614 # properly. However these symbols are disabled in the accelerated
615 # component so we ignore them.
616 'cipher.ccm', 'cipher.gcm', 'cipher.aes', 'cipher.aria',
617 'cipher.camellia',
618 ]
619 IGNORED_TESTS = {
620 'test_suite_config': [
621 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA)_.*'),
622 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
623 ],
624 'test_suite_cmac': [
625 # Following tests require AES_C/ARIA_C/CAMELLIA_C to be enabled,
626 # but these are not available in the accelerated component.
627 'CMAC null arguments',
628 re.compile('CMAC.* (AES|ARIA|Camellia).*'),
629 ],
630 'test_suite_cipher.padding': [
631 # Following tests require AES_C/CAMELLIA_C to be enabled,
632 # but these are not available in the accelerated component.
633 re.compile('Set( non-existent)? padding with (AES|CAMELLIA).*'),
634 ],
635 'test_suite_pkcs5': [
636 # The AES part of PKCS#5 PBES2 is not yet supported.
637 # The rest of PKCS#5 (PBKDF2) works, though.
638 re.compile(r'PBES2 .* AES-.*')
639 ],
640 'test_suite_pkparse': [
641 # PEM (called by pkparse) requires AES_C in order to decrypt
642 # the key, but this is not available in the accelerated
643 # component.
644 re.compile('Parse RSA Key.*(password|AES-).*'),
645 ],
646 'test_suite_pem': [
647 # Following tests require AES_C, but this is diabled in the
648 # accelerated component.
649 re.compile('PEM read .*AES.*'),
650 'PEM read (unknown encryption algorithm)',
651 ],
652 'test_suite_error': [
653 # Following tests depend on AES_C but are not about them
654 # really, just need to know some error code is there.
655 'Single low error',
656 'Low and high error',
657 ],
658 'test_suite_version': [
659 # Similar to test_suite_error above.
660 'Check for MBEDTLS_AES_C when already present',
661 ],
662 'test_suite_platform': [
663 # Incompatible with sanitizers (e.g. ASan). If the driver
664 # component uses a sanitizer but the reference component
665 # doesn't, we have a PASS vs SKIP mismatch.
666 'Check mbedtls_calloc overallocation',
667 ],
668 }
669
670#pylint: enable=invalid-name,missing-class-docstring
671
672
Przemek Stekiel6856f4c2022-11-09 10:50:29 +0100673# List of tasks with a function that can handle this task and additional arguments if required
Valerio Settidfd7ca62023-10-09 16:30:11 +0200674KNOWN_TASKS = {
Gilles Peskinef646dbf2024-09-16 19:15:29 +0200675 'analyze_coverage': CoverageTask,
Gilles Peskine9df375b2024-09-16 20:14:26 +0200676 'analyze_driver_vs_reference_hash': DriverVSReference_hash,
677 'analyze_driver_vs_reference_hmac': DriverVSReference_hmac,
678 'analyze_driver_vs_reference_cipher_aead_cmac': DriverVSReference_cipher_aead_cmac,
679 'analyze_driver_vs_reference_ecp_light_only': DriverVSReference_ecp_light_only,
680 'analyze_driver_vs_reference_no_ecp_at_all': DriverVSReference_no_ecp_at_all,
681 'analyze_driver_vs_reference_ecc_no_bignum': DriverVSReference_ecc_no_bignum,
682 'analyze_driver_vs_reference_ecc_ffdh_no_bignum': DriverVSReference_ecc_ffdh_no_bignum,
683 'analyze_driver_vs_reference_ffdh_alg': DriverVSReference_ffdh_alg,
684 'analyze_driver_vs_reference_tfm_config': DriverVSReference_tfm_config,
685 'analyze_driver_vs_reference_rsa': DriverVSReference_rsa,
686 'analyze_block_cipher_dispatch': DriverVSReference_block_cipher_dispatch,
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200687}
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200688
Gilles Peskine15c2cbf2020-06-25 18:36:28 +0200689if __name__ == '__main__':
Gilles Peskine082eade2024-10-03 18:42:37 +0200690 outcome_analysis.main(KNOWN_TASKS)