blob: c7c9ed5810936965f46e516ec2a00ad8d4a9a287 [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 ],
65 'test_suite_config.psa_boolean': [
66 # We don't test with HMAC disabled.
67 # https://github.com/Mbed-TLS/mbedtls/issues/9591
68 'Config: !PSA_WANT_ALG_HMAC',
Gilles Peskine2fd25bb2024-09-17 19:46:18 +020069 # The DERIVE key type is always enabled.
70 'Config: !PSA_WANT_KEY_TYPE_DERIVE',
71 # More granularity of key pair type enablement macros
72 # than we care to test.
73 # https://github.com/Mbed-TLS/mbedtls/issues/9590
74 'Config: !PSA_WANT_KEY_TYPE_DH_KEY_PAIR_EXPORT',
75 'Config: !PSA_WANT_KEY_TYPE_DH_KEY_PAIR_GENERATE',
76 'Config: !PSA_WANT_KEY_TYPE_DH_KEY_PAIR_IMPORT',
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_ECC_KEY_PAIR_EXPORT',
81 'Config: !PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT',
82 # We don't test with HMAC disabled.
83 # https://github.com/Mbed-TLS/mbedtls/issues/9591
84 'Config: !PSA_WANT_KEY_TYPE_HMAC',
85 # The PASSWORD key type is always enabled.
86 'Config: !PSA_WANT_KEY_TYPE_PASSWORD',
87 # The PASSWORD_HASH key type is always enabled.
88 'Config: !PSA_WANT_KEY_TYPE_PASSWORD_HASH',
89 # The RAW_DATA key type is always enabled.
90 'Config: !PSA_WANT_KEY_TYPE_RAW_DATA',
91 # More granularity of key pair type enablement macros
92 # than we care to test.
93 # https://github.com/Mbed-TLS/mbedtls/issues/9590
94 'Config: !PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_EXPORT',
95 'Config: !PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT',
96 # Algorithm declared but not supported.
97 'Config: PSA_WANT_ALG_CBC_MAC',
98 # Algorithm declared but not supported.
99 'Config: PSA_WANT_ALG_XTS',
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200100 # More granularity of key pair type enablement macros
101 # than we care to test.
102 # https://github.com/Mbed-TLS/mbedtls/issues/9590
103 'Config: PSA_WANT_KEY_TYPE_DH_KEY_PAIR_DERIVE',
104 'Config: PSA_WANT_KEY_TYPE_ECC_KEY_PAIR',
105 'Config: PSA_WANT_KEY_TYPE_RSA_KEY_PAIR',
106 'Config: PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_DERIVE',
Minos Galanakis848333d2024-12-02 15:58:32 +0000107 # https://github.com/Mbed-TLS/mbedtls/issues/9583
108 'Config: !MBEDTLS_ECP_NIST_OPTIM',
109 # We never test without the PSA client code. Should we?
110 # https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/112
111 'Config: !MBEDTLS_PSA_CRYPTO_CLIENT',
112 # We only test multithreading with pthreads.
113 # https://github.com/Mbed-TLS/mbedtls/issues/9584
114 'Config: !MBEDTLS_THREADING_PTHREAD',
115 # Built but not tested.
116 # https://github.com/Mbed-TLS/mbedtls/issues/9587
117 'Config: MBEDTLS_AES_USE_HARDWARE_ONLY',
118 # Untested platform-specific optimizations.
119 # https://github.com/Mbed-TLS/mbedtls/issues/9588
120 'Config: MBEDTLS_HAVE_SSE2',
Felix Conway133f7aa2025-03-19 14:38:47 +0000121 # Obsolete configuration options, to be replaced by
Minos Galanakis848333d2024-12-02 15:58:32 +0000122 # PSA entropy drivers.
123 # https://github.com/Mbed-TLS/mbedtls/issues/8150
124 'Config: MBEDTLS_NO_PLATFORM_ENTROPY',
Felix Conway133f7aa2025-03-19 14:38:47 +0000125 'Config: MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES',
Minos Galanakis848333d2024-12-02 15:58:32 +0000126 # Untested aspect of the platform interface.
127 # https://github.com/Mbed-TLS/mbedtls/issues/9589
128 'Config: MBEDTLS_PLATFORM_NO_STD_FUNCTIONS',
129 # In a client-server build, test_suite_config runs in the
130 # client configuration, so it will never report
131 # MBEDTLS_PSA_CRYPTO_SPM as enabled. That's ok.
132 'Config: MBEDTLS_PSA_CRYPTO_SPM',
133 # We don't test on armv8 yet.
134 'Config: MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT',
135 'Config: MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY',
136 'Config: MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY',
137 'Config: MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY',
138 # We don't run test_suite_config when we test this.
139 # https://github.com/Mbed-TLS/mbedtls/issues/9586
140 'Config: MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND',
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200141 ],
142 'test_suite_config.psa_combinations': [
143 # We don't test this unusual, but sensible configuration.
144 # https://github.com/Mbed-TLS/mbedtls/issues/9592
145 'Config: PSA_WANT_ALG_DETERMINSTIC_ECDSA without PSA_WANT_ALG_ECDSA',
146 ],
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200147 'test_suite_pkcs12': [
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200148 # We never test with CBC/PKCS5/PKCS12 enabled but
149 # PKCS7 padding disabled.
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200150 # https://github.com/Mbed-TLS/mbedtls/issues/9580
151 'PBE Decrypt, (Invalid padding & PKCS7 padding disabled)',
152 'PBE Encrypt, pad = 8 (PKCS7 padding disabled)',
153 ],
154 'test_suite_pkcs5': [
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200155 # We never test with CBC/PKCS5/PKCS12 enabled but
156 # PKCS7 padding disabled.
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200157 # https://github.com/Mbed-TLS/mbedtls/issues/9580
158 'PBES2 Decrypt (Invalid padding & PKCS7 padding disabled)',
159 'PBES2 Encrypt, pad=6 (PKCS7 padding disabled)',
160 'PBES2 Encrypt, pad=8 (PKCS7 padding disabled)',
161 ],
Gilles Peskineeafc2752024-04-19 19:08:34 +0200162 'test_suite_psa_crypto': [
163 # We don't test this unusual, but sensible configuration.
164 # https://github.com/Mbed-TLS/mbedtls/issues/9592
165 re.compile(r'.*ECDSA.*only deterministic supported'),
166 ],
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200167 'test_suite_psa_crypto_metadata': [
168 # Algorithms declared but not supported.
169 # https://github.com/Mbed-TLS/mbedtls/issues/9579
170 'Asymmetric signature: Ed25519ph',
171 'Asymmetric signature: Ed448ph',
172 'Asymmetric signature: pure EdDSA',
173 'Cipher: XTS',
174 'MAC: CBC_MAC-3DES',
175 'MAC: CBC_MAC-AES-128',
176 'MAC: CBC_MAC-AES-192',
177 'MAC: CBC_MAC-AES-256',
178 ],
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200179 'test_suite_psa_crypto_not_supported.generated': [
Gilles Peskine5e3ed3f2024-10-11 12:00:44 +0200180 # We never test with DH key support disabled but support
Gilles Peskineab5cc9b2024-09-17 17:57:11 +0200181 # for a DH group enabled. The dependencies of these test
182 # cases don't really make sense.
183 # https://github.com/Mbed-TLS/mbedtls/issues/9574
184 re.compile(r'PSA \w+ DH_.*type not supported'),
185 # We only test partial support for DH with the 2048-bit group
186 # enabled and the other groups disabled.
187 # https://github.com/Mbed-TLS/mbedtls/issues/9575
188 'PSA generate DH_KEY_PAIR(RFC7919) 2048-bit group not supported',
189 'PSA import DH_KEY_PAIR(RFC7919) 2048-bit group not supported',
190 'PSA import DH_PUBLIC_KEY(RFC7919) 2048-bit group not supported',
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200191 ],
192 'test_suite_psa_crypto_op_fail.generated': [
Gilles Peskineeafc2752024-04-19 19:08:34 +0200193 # We don't test this unusual, but sensible configuration.
194 # https://github.com/Mbed-TLS/mbedtls/issues/9592
195 re.compile(r'.*: !ECDSA but DETERMINISTIC_ECDSA with ECC_.*'),
Gilles Peskineab5cc9b2024-09-17 17:57:11 +0200196 # We never test with the HMAC algorithm enabled but the HMAC
197 # key type disabled. Those dependencies don't really make sense.
198 # https://github.com/Mbed-TLS/mbedtls/issues/9573
199 re.compile(r'.* !HMAC with HMAC'),
Gilles Peskine13c418d2025-01-16 19:49:12 +0100200 # We don't test with ECDH disabled but the key type enabled.
201 # https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/161
202 re.compile(r'PSA key_agreement.* !ECDH with ECC_KEY_PAIR\(.*'),
203 # We don't test with FFDH disabled but the key type enabled.
204 # https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/160
205 re.compile(r'PSA key_agreement.* !FFDH with DH_KEY_PAIR\(.*'),
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200206 ],
Gilles Peskineeafc2752024-04-19 19:08:34 +0200207 'test_suite_psa_crypto_op_fail.misc': [
208 # We don't test this unusual, but sensible configuration.
209 # https://github.com/Mbed-TLS/mbedtls/issues/9592
210 'PSA sign DETERMINISTIC_ECDSA(SHA_256): !ECDSA but DETERMINISTIC_ECDSA with ECC_KEY_PAIR(SECP_R1)', #pylint: disable=line-too-long
211 ],
Gilles Peskinede2316b2024-09-17 18:32:05 +0200212 'tls13-misc': [
213 # Disabled due to OpenSSL bug.
214 # https://github.com/openssl/openssl/issues/10714
215 'TLS 1.3 O->m: resumption',
216 # Disabled due to OpenSSL command line limitation.
217 # https://github.com/Mbed-TLS/mbedtls/issues/9582
218 'TLS 1.3 m->O: resumption with early data',
219 ],
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200220 }
221
Gilles Peskine82b16722024-09-16 19:57:10 +0200222
Gilles Peskine9df375b2024-09-16 20:14:26 +0200223# The names that we give to classes derived from DriverVSReference do not
224# follow the usual naming convention, because it's more readable to use
225# underscores and parts of the configuration names. Also, these classes
226# are just there to specify some data, so they don't need repetitive
227# documentation.
228#pylint: disable=invalid-name,missing-class-docstring
229
Gilles Peskine082eade2024-10-03 18:42:37 +0200230class DriverVSReference_hash(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200231 REFERENCE = 'test_psa_crypto_config_reference_hash_use_psa'
232 DRIVER = 'test_psa_crypto_config_accel_hash_use_psa'
233 IGNORED_SUITES = [
234 'shax', 'mdx', # the software implementations that are being excluded
235 'md.psa', # purposefully depends on whether drivers are present
236 'psa_crypto_low_hash.generated', # testing the builtins
237 ]
238 IGNORED_TESTS = {
239 'test_suite_config': [
240 re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'),
241 ],
242 'test_suite_platform': [
243 # Incompatible with sanitizers (e.g. ASan). If the driver
244 # component uses a sanitizer but the reference component
245 # doesn't, we have a PASS vs SKIP mismatch.
246 'Check mbedtls_calloc overallocation',
247 ],
248 }
249
Gilles Peskine082eade2024-10-03 18:42:37 +0200250class DriverVSReference_hmac(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200251 REFERENCE = 'test_psa_crypto_config_reference_hmac'
252 DRIVER = 'test_psa_crypto_config_accel_hmac'
253 IGNORED_SUITES = [
254 # These suites require legacy hash support, which is disabled
255 # in the accelerated component.
256 'shax', 'mdx',
257 # This suite tests builtins directly, but these are missing
258 # in the accelerated case.
259 'psa_crypto_low_hash.generated',
260 ]
261 IGNORED_TESTS = {
262 'test_suite_config': [
263 re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'),
264 re.compile(r'.*\bMBEDTLS_MD_C\b')
265 ],
266 'test_suite_md': [
267 # Builtin HMAC is not supported in the accelerate component.
268 re.compile('.*HMAC.*'),
269 # Following tests make use of functions which are not available
270 # when MD_C is disabled, as it happens in the accelerated
271 # test component.
272 re.compile('generic .* Hash file .*'),
273 'MD list',
274 ],
275 'test_suite_md.psa': [
276 # "legacy only" tests require hash algorithms to be NOT
277 # accelerated, but this of course false for the accelerated
278 # test component.
279 re.compile('PSA dispatch .* legacy only'),
280 ],
281 'test_suite_platform': [
282 # Incompatible with sanitizers (e.g. ASan). If the driver
283 # component uses a sanitizer but the reference component
284 # doesn't, we have a PASS vs SKIP mismatch.
285 'Check mbedtls_calloc overallocation',
286 ],
287 }
288
Gilles Peskine082eade2024-10-03 18:42:37 +0200289class DriverVSReference_cipher_aead_cmac(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200290 REFERENCE = 'test_psa_crypto_config_reference_cipher_aead_cmac'
291 DRIVER = 'test_psa_crypto_config_accel_cipher_aead_cmac'
292 # Modules replaced by drivers.
293 IGNORED_SUITES = [
294 # low-level (block/stream) cipher modules
295 'aes', 'aria', 'camellia', 'des', 'chacha20',
296 # AEAD modes and CMAC
297 'ccm', 'chachapoly', 'cmac', 'gcm',
298 # The Cipher abstraction layer
299 'cipher',
300 ]
301 IGNORED_TESTS = {
302 'test_suite_config': [
303 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA|CHACHA20|DES)_.*'),
304 re.compile(r'.*\bMBEDTLS_(CCM|CHACHAPOLY|CMAC|GCM)_.*'),
305 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
306 re.compile(r'.*\bMBEDTLS_CIPHER_.*'),
307 ],
308 # PEM decryption is not supported so far.
309 # The rest of PEM (write, unencrypted read) works though.
310 'test_suite_pem': [
311 re.compile(r'PEM read .*(AES|DES|\bencrypt).*'),
312 ],
313 'test_suite_platform': [
314 # Incompatible with sanitizers (e.g. ASan). If the driver
315 # component uses a sanitizer but the reference component
316 # doesn't, we have a PASS vs SKIP mismatch.
317 'Check mbedtls_calloc overallocation',
318 ],
319 # Following tests depend on AES_C/DES_C but are not about
320 # them really, just need to know some error code is there.
321 'test_suite_error': [
322 'Low and high error',
323 'Single low error'
324 ],
325 # Similar to test_suite_error above.
326 'test_suite_version': [
327 'Check for MBEDTLS_AES_C when already present',
328 ],
329 # The en/decryption part of PKCS#12 is not supported so far.
330 # The rest of PKCS#12 (key derivation) works though.
331 'test_suite_pkcs12': [
332 re.compile(r'PBE Encrypt, .*'),
333 re.compile(r'PBE Decrypt, .*'),
334 ],
335 # The en/decryption part of PKCS#5 is not supported so far.
336 # The rest of PKCS#5 (PBKDF2) works though.
337 'test_suite_pkcs5': [
338 re.compile(r'PBES2 Encrypt, .*'),
339 re.compile(r'PBES2 Decrypt .*'),
340 ],
341 # Encrypted keys are not supported so far.
342 # pylint: disable=line-too-long
343 'test_suite_pkparse': [
344 'Key ASN1 (Encrypted key PKCS12, trailing garbage data)',
345 'Key ASN1 (Encrypted key PKCS5, trailing garbage data)',
346 re.compile(r'Parse (RSA|EC) Key .*\(.* ([Ee]ncrypted|password).*\)'),
347 ],
348 # Encrypted keys are not supported so far.
349 'ssl-opt': [
350 'TLS: password protected server key',
351 'TLS: password protected client key',
352 'TLS: password protected server key, two certificates',
353 ],
354 }
355
Gilles Peskine082eade2024-10-03 18:42:37 +0200356class DriverVSReference_ecp_light_only(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200357 REFERENCE = 'test_psa_crypto_config_reference_ecc_ecp_light_only'
358 DRIVER = 'test_psa_crypto_config_accel_ecc_ecp_light_only'
359 IGNORED_SUITES = [
360 # Modules replaced by drivers
361 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100362 # Unit tests for the built-in implementation
363 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200364 ]
365 IGNORED_TESTS = {
366 'test_suite_config': [
367 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
368 ],
369 'test_suite_platform': [
370 # Incompatible with sanitizers (e.g. ASan). If the driver
371 # component uses a sanitizer but the reference component
372 # doesn't, we have a PASS vs SKIP mismatch.
373 'Check mbedtls_calloc overallocation',
374 ],
375 # This test wants a legacy function that takes f_rng, p_rng
376 # arguments, and uses legacy ECDSA for that. The test is
377 # really about the wrapper around the PSA RNG, not ECDSA.
378 'test_suite_random': [
379 'PSA classic wrapper: ECDSA signature (SECP256R1)',
380 ],
381 # In the accelerated test ECP_C is not set (only ECP_LIGHT is)
382 # so we must ignore disparities in the tests for which ECP_C
383 # is required.
384 'test_suite_ecp': [
385 re.compile(r'ECP check public-private .*'),
386 re.compile(r'ECP calculate public: .*'),
387 re.compile(r'ECP gen keypair .*'),
388 re.compile(r'ECP point muladd .*'),
389 re.compile(r'ECP point multiplication .*'),
390 re.compile(r'ECP test vectors .*'),
391 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200392 }
393
Gilles Peskine082eade2024-10-03 18:42:37 +0200394class DriverVSReference_no_ecp_at_all(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200395 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_ecp_at_all'
396 DRIVER = 'test_psa_crypto_config_accel_ecc_no_ecp_at_all'
397 IGNORED_SUITES = [
398 # Modules replaced by drivers
399 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100400 # Unit tests for the built-in implementation
401 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200402 ]
403 IGNORED_TESTS = {
404 'test_suite_config': [
405 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
406 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
407 ],
408 'test_suite_platform': [
409 # Incompatible with sanitizers (e.g. ASan). If the driver
410 # component uses a sanitizer but the reference component
411 # doesn't, we have a PASS vs SKIP mismatch.
412 'Check mbedtls_calloc overallocation',
413 ],
414 # See ecp_light_only
415 'test_suite_random': [
416 'PSA classic wrapper: ECDSA signature (SECP256R1)',
417 ],
418 'test_suite_pkparse': [
419 # When PK_PARSE_C and ECP_C are defined then PK_PARSE_EC_COMPRESSED
420 # is automatically enabled in build_info.h (backward compatibility)
421 # even if it is disabled in config_psa_crypto_no_ecp_at_all(). As a
422 # consequence compressed points are supported in the reference
423 # component but not in the accelerated one, so they should be skipped
424 # while checking driver's coverage.
425 re.compile(r'Parse EC Key .*compressed\)'),
426 re.compile(r'Parse Public EC Key .*compressed\)'),
427 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200428 }
429
Gilles Peskine082eade2024-10-03 18:42:37 +0200430class DriverVSReference_ecc_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200431 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_bignum'
432 DRIVER = 'test_psa_crypto_config_accel_ecc_no_bignum'
433 IGNORED_SUITES = [
434 # Modules replaced by drivers
435 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
436 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
437 'bignum.generated', 'bignum.misc',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100438 # Unit tests for the built-in implementation
439 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200440 ]
441 IGNORED_TESTS = {
442 'test_suite_config': [
443 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
444 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
445 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
446 ],
447 'test_suite_platform': [
448 # Incompatible with sanitizers (e.g. ASan). If the driver
449 # component uses a sanitizer but the reference component
450 # doesn't, we have a PASS vs SKIP mismatch.
451 'Check mbedtls_calloc overallocation',
452 ],
453 # See ecp_light_only
454 'test_suite_random': [
455 'PSA classic wrapper: ECDSA signature (SECP256R1)',
456 ],
457 # See no_ecp_at_all
458 'test_suite_pkparse': [
459 re.compile(r'Parse EC Key .*compressed\)'),
460 re.compile(r'Parse Public EC Key .*compressed\)'),
461 ],
462 'test_suite_asn1parse': [
463 'INTEGER too large for mpi',
464 ],
465 'test_suite_asn1write': [
466 re.compile(r'ASN.1 Write mpi.*'),
467 ],
468 'test_suite_debug': [
469 re.compile(r'Debug print mbedtls_mpi.*'),
470 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200471 }
472
Gilles Peskine082eade2024-10-03 18:42:37 +0200473class DriverVSReference_ecc_ffdh_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200474 REFERENCE = 'test_psa_crypto_config_reference_ecc_ffdh_no_bignum'
475 DRIVER = 'test_psa_crypto_config_accel_ecc_ffdh_no_bignum'
476 IGNORED_SUITES = [
477 # Modules replaced by drivers
Valerio Setti461899e2025-02-12 13:34:25 +0100478 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200479 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
480 'bignum.generated', 'bignum.misc',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100481 # Unit tests for the built-in implementation
482 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200483 ]
484 IGNORED_TESTS = {
Gilles Peskine9df375b2024-09-16 20:14:26 +0200485 'test_suite_config': [
486 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
Gilles Peskine9df375b2024-09-16 20:14:26 +0200487 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
Gilles Peskine9df375b2024-09-16 20:14:26 +0200488 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
489 ],
490 'test_suite_platform': [
491 # Incompatible with sanitizers (e.g. ASan). If the driver
492 # component uses a sanitizer but the reference component
493 # doesn't, we have a PASS vs SKIP mismatch.
494 'Check mbedtls_calloc overallocation',
495 ],
496 # See ecp_light_only
497 'test_suite_random': [
498 'PSA classic wrapper: ECDSA signature (SECP256R1)',
499 ],
500 # See no_ecp_at_all
501 'test_suite_pkparse': [
502 re.compile(r'Parse EC Key .*compressed\)'),
503 re.compile(r'Parse Public EC Key .*compressed\)'),
504 ],
505 'test_suite_asn1parse': [
506 'INTEGER too large for mpi',
507 ],
508 'test_suite_asn1write': [
509 re.compile(r'ASN.1 Write mpi.*'),
510 ],
511 'test_suite_debug': [
512 re.compile(r'Debug print mbedtls_mpi.*'),
513 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200514 }
515
Gilles Peskine082eade2024-10-03 18:42:37 +0200516class DriverVSReference_ffdh_alg(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200517 REFERENCE = 'test_psa_crypto_config_reference_ffdh'
518 DRIVER = 'test_psa_crypto_config_accel_ffdh'
Gilles Peskine9df375b2024-09-16 20:14:26 +0200519 IGNORED_TESTS = {
Gilles Peskine9df375b2024-09-16 20:14:26 +0200520 'test_suite_platform': [
521 # Incompatible with sanitizers (e.g. ASan). If the driver
522 # component uses a sanitizer but the reference component
523 # doesn't, we have a PASS vs SKIP mismatch.
524 'Check mbedtls_calloc overallocation',
525 ],
526 }
527
Gilles Peskine082eade2024-10-03 18:42:37 +0200528class DriverVSReference_tfm_config(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200529 REFERENCE = 'test_tfm_config_no_p256m'
530 DRIVER = 'test_tfm_config_p256m_driver_accel_ec'
531 IGNORED_SUITES = [
532 # Modules replaced by drivers
533 'asn1parse', 'asn1write',
534 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
535 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
536 'bignum.generated', 'bignum.misc',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100537 # Unit tests for the built-in implementation
538 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200539 ]
540 IGNORED_TESTS = {
541 'test_suite_config': [
542 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
543 re.compile(r'.*\bMBEDTLS_(ASN1\w+)_C\b.*'),
544 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECP)_.*'),
545 re.compile(r'.*\bMBEDTLS_PSA_P256M_DRIVER_ENABLED\b.*')
546 ],
547 'test_suite_config.crypto_combinations': [
548 'Config: ECC: Weierstrass curves only',
549 ],
550 'test_suite_platform': [
551 # Incompatible with sanitizers (e.g. ASan). If the driver
552 # component uses a sanitizer but the reference component
553 # doesn't, we have a PASS vs SKIP mismatch.
554 'Check mbedtls_calloc overallocation',
555 ],
556 # See ecp_light_only
557 'test_suite_random': [
558 'PSA classic wrapper: ECDSA signature (SECP256R1)',
559 ],
560 }
561
Gilles Peskine082eade2024-10-03 18:42:37 +0200562class DriverVSReference_rsa(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200563 REFERENCE = 'test_psa_crypto_config_reference_rsa_crypto'
564 DRIVER = 'test_psa_crypto_config_accel_rsa_crypto'
565 IGNORED_SUITES = [
566 # Modules replaced by drivers.
567 'rsa', 'pkcs1_v15', 'pkcs1_v21',
568 # We temporarily don't care about PK stuff.
569 'pk', 'pkwrite', 'pkparse'
570 ]
571 IGNORED_TESTS = {
572 'test_suite_config': [
573 re.compile(r'.*\bMBEDTLS_(PKCS1|RSA)_.*'),
574 re.compile(r'.*\bMBEDTLS_GENPRIME\b.*')
575 ],
576 'test_suite_platform': [
577 # Incompatible with sanitizers (e.g. ASan). If the driver
578 # component uses a sanitizer but the reference component
579 # doesn't, we have a PASS vs SKIP mismatch.
580 'Check mbedtls_calloc overallocation',
581 ],
582 # Following tests depend on RSA_C but are not about
583 # them really, just need to know some error code is there.
584 'test_suite_error': [
585 'Low and high error',
586 'Single high error'
587 ],
588 # Constant time operations only used for PKCS1_V15
589 'test_suite_constant_time': [
590 re.compile(r'mbedtls_ct_zeroize_if .*'),
591 re.compile(r'mbedtls_ct_memmove_left .*')
592 ],
593 'test_suite_psa_crypto': [
594 # We don't support generate_key_custom entry points
595 # in drivers yet.
596 re.compile(r'PSA generate key custom: RSA, e=.*'),
597 re.compile(r'PSA generate key ext: RSA, e=.*'),
598 ],
599 }
600
Gilles Peskine082eade2024-10-03 18:42:37 +0200601class DriverVSReference_block_cipher_dispatch(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200602 REFERENCE = 'test_full_block_cipher_legacy_dispatch'
603 DRIVER = 'test_full_block_cipher_psa_dispatch'
604 IGNORED_SUITES = [
605 # Skipped in the accelerated component
606 'aes', 'aria', 'camellia',
607 # These require AES_C, ARIA_C or CAMELLIA_C to be enabled in
608 # order for the cipher module (actually cipher_wrapper) to work
609 # properly. However these symbols are disabled in the accelerated
610 # component so we ignore them.
611 'cipher.ccm', 'cipher.gcm', 'cipher.aes', 'cipher.aria',
612 'cipher.camellia',
613 ]
614 IGNORED_TESTS = {
615 'test_suite_config': [
616 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA)_.*'),
617 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
618 ],
619 'test_suite_cmac': [
620 # Following tests require AES_C/ARIA_C/CAMELLIA_C to be enabled,
621 # but these are not available in the accelerated component.
622 'CMAC null arguments',
623 re.compile('CMAC.* (AES|ARIA|Camellia).*'),
624 ],
625 'test_suite_cipher.padding': [
626 # Following tests require AES_C/CAMELLIA_C to be enabled,
627 # but these are not available in the accelerated component.
628 re.compile('Set( non-existent)? padding with (AES|CAMELLIA).*'),
629 ],
630 'test_suite_pkcs5': [
631 # The AES part of PKCS#5 PBES2 is not yet supported.
632 # The rest of PKCS#5 (PBKDF2) works, though.
633 re.compile(r'PBES2 .* AES-.*')
634 ],
635 'test_suite_pkparse': [
636 # PEM (called by pkparse) requires AES_C in order to decrypt
637 # the key, but this is not available in the accelerated
638 # component.
639 re.compile('Parse RSA Key.*(password|AES-).*'),
640 ],
641 'test_suite_pem': [
642 # Following tests require AES_C, but this is diabled in the
643 # accelerated component.
644 re.compile('PEM read .*AES.*'),
645 'PEM read (unknown encryption algorithm)',
646 ],
647 'test_suite_error': [
648 # Following tests depend on AES_C but are not about them
649 # really, just need to know some error code is there.
650 'Single low error',
651 'Low and high error',
652 ],
653 'test_suite_version': [
654 # Similar to test_suite_error above.
655 'Check for MBEDTLS_AES_C when already present',
656 ],
657 'test_suite_platform': [
658 # Incompatible with sanitizers (e.g. ASan). If the driver
659 # component uses a sanitizer but the reference component
660 # doesn't, we have a PASS vs SKIP mismatch.
661 'Check mbedtls_calloc overallocation',
662 ],
663 }
664
665#pylint: enable=invalid-name,missing-class-docstring
666
667
Przemek Stekiel6856f4c2022-11-09 10:50:29 +0100668# List of tasks with a function that can handle this task and additional arguments if required
Valerio Settidfd7ca62023-10-09 16:30:11 +0200669KNOWN_TASKS = {
Gilles Peskinef646dbf2024-09-16 19:15:29 +0200670 'analyze_coverage': CoverageTask,
Gilles Peskine9df375b2024-09-16 20:14:26 +0200671 'analyze_driver_vs_reference_hash': DriverVSReference_hash,
672 'analyze_driver_vs_reference_hmac': DriverVSReference_hmac,
673 'analyze_driver_vs_reference_cipher_aead_cmac': DriverVSReference_cipher_aead_cmac,
674 'analyze_driver_vs_reference_ecp_light_only': DriverVSReference_ecp_light_only,
675 'analyze_driver_vs_reference_no_ecp_at_all': DriverVSReference_no_ecp_at_all,
676 'analyze_driver_vs_reference_ecc_no_bignum': DriverVSReference_ecc_no_bignum,
677 'analyze_driver_vs_reference_ecc_ffdh_no_bignum': DriverVSReference_ecc_ffdh_no_bignum,
678 'analyze_driver_vs_reference_ffdh_alg': DriverVSReference_ffdh_alg,
679 'analyze_driver_vs_reference_tfm_config': DriverVSReference_tfm_config,
680 'analyze_driver_vs_reference_rsa': DriverVSReference_rsa,
681 'analyze_block_cipher_dispatch': DriverVSReference_block_cipher_dispatch,
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200682}
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200683
Gilles Peskine15c2cbf2020-06-25 18:36:28 +0200684if __name__ == '__main__':
Gilles Peskine082eade2024-10-03 18:42:37 +0200685 outcome_analysis.main(KNOWN_TASKS)