blob: 36d58b9d0d4e2ef60dafdfc330587240e1eaeca4 [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',
121 # Obsolete configuration option, to be replaced by
122 # PSA entropy drivers.
123 # https://github.com/Mbed-TLS/mbedtls/issues/8150
124 'Config: MBEDTLS_NO_PLATFORM_ENTROPY',
125 # Untested aspect of the platform interface.
126 # https://github.com/Mbed-TLS/mbedtls/issues/9589
127 'Config: MBEDTLS_PLATFORM_NO_STD_FUNCTIONS',
128 # In a client-server build, test_suite_config runs in the
129 # client configuration, so it will never report
130 # MBEDTLS_PSA_CRYPTO_SPM as enabled. That's ok.
131 'Config: MBEDTLS_PSA_CRYPTO_SPM',
132 # We don't test on armv8 yet.
133 'Config: MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT',
134 'Config: MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY',
135 'Config: MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY',
136 'Config: MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY',
137 # We don't run test_suite_config when we test this.
138 # https://github.com/Mbed-TLS/mbedtls/issues/9586
139 'Config: MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND',
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200140 ],
141 'test_suite_config.psa_combinations': [
142 # We don't test this unusual, but sensible configuration.
143 # https://github.com/Mbed-TLS/mbedtls/issues/9592
144 'Config: PSA_WANT_ALG_DETERMINSTIC_ECDSA without PSA_WANT_ALG_ECDSA',
145 ],
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200146 'test_suite_pkcs12': [
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200147 # We never test with CBC/PKCS5/PKCS12 enabled but
148 # PKCS7 padding disabled.
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200149 # https://github.com/Mbed-TLS/mbedtls/issues/9580
150 'PBE Decrypt, (Invalid padding & PKCS7 padding disabled)',
151 'PBE Encrypt, pad = 8 (PKCS7 padding disabled)',
152 ],
153 'test_suite_pkcs5': [
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200154 # We never test with CBC/PKCS5/PKCS12 enabled but
155 # PKCS7 padding disabled.
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200156 # https://github.com/Mbed-TLS/mbedtls/issues/9580
157 'PBES2 Decrypt (Invalid padding & PKCS7 padding disabled)',
158 'PBES2 Encrypt, pad=6 (PKCS7 padding disabled)',
159 'PBES2 Encrypt, pad=8 (PKCS7 padding disabled)',
160 ],
Gilles Peskineeafc2752024-04-19 19:08:34 +0200161 'test_suite_psa_crypto': [
162 # We don't test this unusual, but sensible configuration.
163 # https://github.com/Mbed-TLS/mbedtls/issues/9592
164 re.compile(r'.*ECDSA.*only deterministic supported'),
165 ],
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200166 'test_suite_psa_crypto_metadata': [
167 # Algorithms declared but not supported.
168 # https://github.com/Mbed-TLS/mbedtls/issues/9579
169 'Asymmetric signature: Ed25519ph',
170 'Asymmetric signature: Ed448ph',
171 'Asymmetric signature: pure EdDSA',
172 'Cipher: XTS',
173 'MAC: CBC_MAC-3DES',
174 'MAC: CBC_MAC-AES-128',
175 'MAC: CBC_MAC-AES-192',
176 'MAC: CBC_MAC-AES-256',
177 ],
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200178 'test_suite_psa_crypto_not_supported.generated': [
Gilles Peskine5e3ed3f2024-10-11 12:00:44 +0200179 # We never test with DH key support disabled but support
Gilles Peskineab5cc9b2024-09-17 17:57:11 +0200180 # for a DH group enabled. The dependencies of these test
181 # cases don't really make sense.
182 # https://github.com/Mbed-TLS/mbedtls/issues/9574
183 re.compile(r'PSA \w+ DH_.*type not supported'),
184 # We only test partial support for DH with the 2048-bit group
185 # enabled and the other groups disabled.
186 # https://github.com/Mbed-TLS/mbedtls/issues/9575
187 'PSA generate DH_KEY_PAIR(RFC7919) 2048-bit group not supported',
188 'PSA import DH_KEY_PAIR(RFC7919) 2048-bit group not supported',
189 'PSA import DH_PUBLIC_KEY(RFC7919) 2048-bit group not supported',
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200190 ],
191 'test_suite_psa_crypto_op_fail.generated': [
Gilles Peskineeafc2752024-04-19 19:08:34 +0200192 # We don't test this unusual, but sensible configuration.
193 # https://github.com/Mbed-TLS/mbedtls/issues/9592
194 re.compile(r'.*: !ECDSA but DETERMINISTIC_ECDSA with ECC_.*'),
Gilles Peskineab5cc9b2024-09-17 17:57:11 +0200195 # We never test with the HMAC algorithm enabled but the HMAC
196 # key type disabled. Those dependencies don't really make sense.
197 # https://github.com/Mbed-TLS/mbedtls/issues/9573
198 re.compile(r'.* !HMAC with HMAC'),
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200199 ],
Gilles Peskineeafc2752024-04-19 19:08:34 +0200200 'test_suite_psa_crypto_op_fail.misc': [
201 # We don't test this unusual, but sensible configuration.
202 # https://github.com/Mbed-TLS/mbedtls/issues/9592
203 'PSA sign DETERMINISTIC_ECDSA(SHA_256): !ECDSA but DETERMINISTIC_ECDSA with ECC_KEY_PAIR(SECP_R1)', #pylint: disable=line-too-long
204 ],
Gilles Peskinede2316b2024-09-17 18:32:05 +0200205 'tls13-misc': [
206 # Disabled due to OpenSSL bug.
207 # https://github.com/openssl/openssl/issues/10714
208 'TLS 1.3 O->m: resumption',
209 # Disabled due to OpenSSL command line limitation.
210 # https://github.com/Mbed-TLS/mbedtls/issues/9582
211 'TLS 1.3 m->O: resumption with early data',
212 ],
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200213 }
214
Gilles Peskine82b16722024-09-16 19:57:10 +0200215
Gilles Peskine9df375b2024-09-16 20:14:26 +0200216# The names that we give to classes derived from DriverVSReference do not
217# follow the usual naming convention, because it's more readable to use
218# underscores and parts of the configuration names. Also, these classes
219# are just there to specify some data, so they don't need repetitive
220# documentation.
221#pylint: disable=invalid-name,missing-class-docstring
222
Gilles Peskine082eade2024-10-03 18:42:37 +0200223class DriverVSReference_hash(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200224 REFERENCE = 'test_psa_crypto_config_reference_hash_use_psa'
225 DRIVER = 'test_psa_crypto_config_accel_hash_use_psa'
226 IGNORED_SUITES = [
227 'shax', 'mdx', # the software implementations that are being excluded
228 'md.psa', # purposefully depends on whether drivers are present
229 'psa_crypto_low_hash.generated', # testing the builtins
230 ]
231 IGNORED_TESTS = {
232 'test_suite_config': [
233 re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'),
234 ],
235 'test_suite_platform': [
236 # Incompatible with sanitizers (e.g. ASan). If the driver
237 # component uses a sanitizer but the reference component
238 # doesn't, we have a PASS vs SKIP mismatch.
239 'Check mbedtls_calloc overallocation',
240 ],
241 }
242
Gilles Peskine082eade2024-10-03 18:42:37 +0200243class DriverVSReference_hmac(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200244 REFERENCE = 'test_psa_crypto_config_reference_hmac'
245 DRIVER = 'test_psa_crypto_config_accel_hmac'
246 IGNORED_SUITES = [
247 # These suites require legacy hash support, which is disabled
248 # in the accelerated component.
249 'shax', 'mdx',
250 # This suite tests builtins directly, but these are missing
251 # in the accelerated case.
252 'psa_crypto_low_hash.generated',
253 ]
254 IGNORED_TESTS = {
255 'test_suite_config': [
256 re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'),
257 re.compile(r'.*\bMBEDTLS_MD_C\b')
258 ],
259 'test_suite_md': [
260 # Builtin HMAC is not supported in the accelerate component.
261 re.compile('.*HMAC.*'),
262 # Following tests make use of functions which are not available
263 # when MD_C is disabled, as it happens in the accelerated
264 # test component.
265 re.compile('generic .* Hash file .*'),
266 'MD list',
267 ],
268 'test_suite_md.psa': [
269 # "legacy only" tests require hash algorithms to be NOT
270 # accelerated, but this of course false for the accelerated
271 # test component.
272 re.compile('PSA dispatch .* legacy only'),
273 ],
274 'test_suite_platform': [
275 # Incompatible with sanitizers (e.g. ASan). If the driver
276 # component uses a sanitizer but the reference component
277 # doesn't, we have a PASS vs SKIP mismatch.
278 'Check mbedtls_calloc overallocation',
279 ],
280 }
281
Gilles Peskine082eade2024-10-03 18:42:37 +0200282class DriverVSReference_cipher_aead_cmac(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200283 REFERENCE = 'test_psa_crypto_config_reference_cipher_aead_cmac'
284 DRIVER = 'test_psa_crypto_config_accel_cipher_aead_cmac'
285 # Modules replaced by drivers.
286 IGNORED_SUITES = [
287 # low-level (block/stream) cipher modules
288 'aes', 'aria', 'camellia', 'des', 'chacha20',
289 # AEAD modes and CMAC
290 'ccm', 'chachapoly', 'cmac', 'gcm',
291 # The Cipher abstraction layer
292 'cipher',
293 ]
294 IGNORED_TESTS = {
295 'test_suite_config': [
296 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA|CHACHA20|DES)_.*'),
297 re.compile(r'.*\bMBEDTLS_(CCM|CHACHAPOLY|CMAC|GCM)_.*'),
298 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
299 re.compile(r'.*\bMBEDTLS_CIPHER_.*'),
300 ],
301 # PEM decryption is not supported so far.
302 # The rest of PEM (write, unencrypted read) works though.
303 'test_suite_pem': [
304 re.compile(r'PEM read .*(AES|DES|\bencrypt).*'),
305 ],
306 'test_suite_platform': [
307 # Incompatible with sanitizers (e.g. ASan). If the driver
308 # component uses a sanitizer but the reference component
309 # doesn't, we have a PASS vs SKIP mismatch.
310 'Check mbedtls_calloc overallocation',
311 ],
312 # Following tests depend on AES_C/DES_C but are not about
313 # them really, just need to know some error code is there.
314 'test_suite_error': [
315 'Low and high error',
316 'Single low error'
317 ],
318 # Similar to test_suite_error above.
319 'test_suite_version': [
320 'Check for MBEDTLS_AES_C when already present',
321 ],
322 # The en/decryption part of PKCS#12 is not supported so far.
323 # The rest of PKCS#12 (key derivation) works though.
324 'test_suite_pkcs12': [
325 re.compile(r'PBE Encrypt, .*'),
326 re.compile(r'PBE Decrypt, .*'),
327 ],
328 # The en/decryption part of PKCS#5 is not supported so far.
329 # The rest of PKCS#5 (PBKDF2) works though.
330 'test_suite_pkcs5': [
331 re.compile(r'PBES2 Encrypt, .*'),
332 re.compile(r'PBES2 Decrypt .*'),
333 ],
334 # Encrypted keys are not supported so far.
335 # pylint: disable=line-too-long
336 'test_suite_pkparse': [
337 'Key ASN1 (Encrypted key PKCS12, trailing garbage data)',
338 'Key ASN1 (Encrypted key PKCS5, trailing garbage data)',
339 re.compile(r'Parse (RSA|EC) Key .*\(.* ([Ee]ncrypted|password).*\)'),
340 ],
341 # Encrypted keys are not supported so far.
342 'ssl-opt': [
343 'TLS: password protected server key',
344 'TLS: password protected client key',
345 'TLS: password protected server key, two certificates',
346 ],
347 }
348
Gilles Peskine082eade2024-10-03 18:42:37 +0200349class DriverVSReference_ecp_light_only(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200350 REFERENCE = 'test_psa_crypto_config_reference_ecc_ecp_light_only'
351 DRIVER = 'test_psa_crypto_config_accel_ecc_ecp_light_only'
352 IGNORED_SUITES = [
353 # Modules replaced by drivers
354 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100355 # Unit tests for the built-in implementation
356 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200357 ]
358 IGNORED_TESTS = {
359 'test_suite_config': [
360 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
361 ],
362 'test_suite_platform': [
363 # Incompatible with sanitizers (e.g. ASan). If the driver
364 # component uses a sanitizer but the reference component
365 # doesn't, we have a PASS vs SKIP mismatch.
366 'Check mbedtls_calloc overallocation',
367 ],
368 # This test wants a legacy function that takes f_rng, p_rng
369 # arguments, and uses legacy ECDSA for that. The test is
370 # really about the wrapper around the PSA RNG, not ECDSA.
371 'test_suite_random': [
372 'PSA classic wrapper: ECDSA signature (SECP256R1)',
373 ],
374 # In the accelerated test ECP_C is not set (only ECP_LIGHT is)
375 # so we must ignore disparities in the tests for which ECP_C
376 # is required.
377 'test_suite_ecp': [
378 re.compile(r'ECP check public-private .*'),
379 re.compile(r'ECP calculate public: .*'),
380 re.compile(r'ECP gen keypair .*'),
381 re.compile(r'ECP point muladd .*'),
382 re.compile(r'ECP point multiplication .*'),
383 re.compile(r'ECP test vectors .*'),
384 ],
385 'test_suite_ssl': [
386 # This deprecated function is only present when ECP_C is On.
387 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
388 ],
389 }
390
Gilles Peskine082eade2024-10-03 18:42:37 +0200391class DriverVSReference_no_ecp_at_all(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200392 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_ecp_at_all'
393 DRIVER = 'test_psa_crypto_config_accel_ecc_no_ecp_at_all'
394 IGNORED_SUITES = [
395 # Modules replaced by drivers
396 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100397 # Unit tests for the built-in implementation
398 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200399 ]
400 IGNORED_TESTS = {
401 'test_suite_config': [
402 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
403 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
404 ],
405 'test_suite_platform': [
406 # Incompatible with sanitizers (e.g. ASan). If the driver
407 # component uses a sanitizer but the reference component
408 # doesn't, we have a PASS vs SKIP mismatch.
409 'Check mbedtls_calloc overallocation',
410 ],
411 # See ecp_light_only
412 'test_suite_random': [
413 'PSA classic wrapper: ECDSA signature (SECP256R1)',
414 ],
415 'test_suite_pkparse': [
416 # When PK_PARSE_C and ECP_C are defined then PK_PARSE_EC_COMPRESSED
417 # is automatically enabled in build_info.h (backward compatibility)
418 # even if it is disabled in config_psa_crypto_no_ecp_at_all(). As a
419 # consequence compressed points are supported in the reference
420 # component but not in the accelerated one, so they should be skipped
421 # while checking driver's coverage.
422 re.compile(r'Parse EC Key .*compressed\)'),
423 re.compile(r'Parse Public EC Key .*compressed\)'),
424 ],
425 # See ecp_light_only
426 'test_suite_ssl': [
427 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
428 ],
429 }
430
Gilles Peskine082eade2024-10-03 18:42:37 +0200431class DriverVSReference_ecc_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200432 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_bignum'
433 DRIVER = 'test_psa_crypto_config_accel_ecc_no_bignum'
434 IGNORED_SUITES = [
435 # Modules replaced by drivers
436 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
437 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
438 'bignum.generated', 'bignum.misc',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100439 # Unit tests for the built-in implementation
440 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200441 ]
442 IGNORED_TESTS = {
443 'test_suite_config': [
444 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
445 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
446 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
447 ],
448 'test_suite_platform': [
449 # Incompatible with sanitizers (e.g. ASan). If the driver
450 # component uses a sanitizer but the reference component
451 # doesn't, we have a PASS vs SKIP mismatch.
452 'Check mbedtls_calloc overallocation',
453 ],
454 # See ecp_light_only
455 'test_suite_random': [
456 'PSA classic wrapper: ECDSA signature (SECP256R1)',
457 ],
458 # See no_ecp_at_all
459 'test_suite_pkparse': [
460 re.compile(r'Parse EC Key .*compressed\)'),
461 re.compile(r'Parse Public EC Key .*compressed\)'),
462 ],
463 'test_suite_asn1parse': [
464 'INTEGER too large for mpi',
465 ],
466 'test_suite_asn1write': [
467 re.compile(r'ASN.1 Write mpi.*'),
468 ],
469 'test_suite_debug': [
470 re.compile(r'Debug print mbedtls_mpi.*'),
471 ],
472 # See ecp_light_only
473 'test_suite_ssl': [
474 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
475 ],
476 }
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
483 'ecp', 'ecdsa', 'ecdh', 'ecjpake', 'dhm',
484 '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 = {
490 'ssl-opt': [
491 # DHE support in TLS 1.2 requires built-in MBEDTLS_DHM_C
492 # (because it needs custom groups, which PSA does not
493 # provide), even with MBEDTLS_USE_PSA_CRYPTO.
494 re.compile(r'PSK callback:.*\bdhe-psk\b.*'),
495 ],
496 'test_suite_config': [
497 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
498 re.compile(r'.*\bMBEDTLS_DHM_C\b.*'),
499 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
500 re.compile(r'.*\bMBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED\b.*'),
501 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
502 ],
503 'test_suite_platform': [
504 # Incompatible with sanitizers (e.g. ASan). If the driver
505 # component uses a sanitizer but the reference component
506 # doesn't, we have a PASS vs SKIP mismatch.
507 'Check mbedtls_calloc overallocation',
508 ],
509 # See ecp_light_only
510 'test_suite_random': [
511 'PSA classic wrapper: ECDSA signature (SECP256R1)',
512 ],
513 # See no_ecp_at_all
514 'test_suite_pkparse': [
515 re.compile(r'Parse EC Key .*compressed\)'),
516 re.compile(r'Parse Public EC Key .*compressed\)'),
517 ],
518 'test_suite_asn1parse': [
519 'INTEGER too large for mpi',
520 ],
521 'test_suite_asn1write': [
522 re.compile(r'ASN.1 Write mpi.*'),
523 ],
524 'test_suite_debug': [
525 re.compile(r'Debug print mbedtls_mpi.*'),
526 ],
527 # See ecp_light_only
528 'test_suite_ssl': [
529 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
530 ],
531 }
532
Gilles Peskine082eade2024-10-03 18:42:37 +0200533class DriverVSReference_ffdh_alg(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200534 REFERENCE = 'test_psa_crypto_config_reference_ffdh'
535 DRIVER = 'test_psa_crypto_config_accel_ffdh'
536 IGNORED_SUITES = ['dhm']
537 IGNORED_TESTS = {
538 'test_suite_config': [
539 re.compile(r'.*\bMBEDTLS_DHM_C\b.*'),
540 ],
541 'test_suite_platform': [
542 # Incompatible with sanitizers (e.g. ASan). If the driver
543 # component uses a sanitizer but the reference component
544 # doesn't, we have a PASS vs SKIP mismatch.
545 'Check mbedtls_calloc overallocation',
546 ],
547 }
548
Gilles Peskine082eade2024-10-03 18:42:37 +0200549class DriverVSReference_tfm_config(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200550 REFERENCE = 'test_tfm_config_no_p256m'
551 DRIVER = 'test_tfm_config_p256m_driver_accel_ec'
552 IGNORED_SUITES = [
553 # Modules replaced by drivers
554 'asn1parse', 'asn1write',
555 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
556 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
557 'bignum.generated', 'bignum.misc',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100558 # Unit tests for the built-in implementation
559 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200560 ]
561 IGNORED_TESTS = {
562 'test_suite_config': [
563 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
564 re.compile(r'.*\bMBEDTLS_(ASN1\w+)_C\b.*'),
565 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECP)_.*'),
566 re.compile(r'.*\bMBEDTLS_PSA_P256M_DRIVER_ENABLED\b.*')
567 ],
568 'test_suite_config.crypto_combinations': [
569 'Config: ECC: Weierstrass curves only',
570 ],
571 'test_suite_platform': [
572 # Incompatible with sanitizers (e.g. ASan). If the driver
573 # component uses a sanitizer but the reference component
574 # doesn't, we have a PASS vs SKIP mismatch.
575 'Check mbedtls_calloc overallocation',
576 ],
577 # See ecp_light_only
578 'test_suite_random': [
579 'PSA classic wrapper: ECDSA signature (SECP256R1)',
580 ],
581 }
582
Gilles Peskine082eade2024-10-03 18:42:37 +0200583class DriverVSReference_rsa(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200584 REFERENCE = 'test_psa_crypto_config_reference_rsa_crypto'
585 DRIVER = 'test_psa_crypto_config_accel_rsa_crypto'
586 IGNORED_SUITES = [
587 # Modules replaced by drivers.
588 'rsa', 'pkcs1_v15', 'pkcs1_v21',
589 # We temporarily don't care about PK stuff.
590 'pk', 'pkwrite', 'pkparse'
591 ]
592 IGNORED_TESTS = {
593 'test_suite_config': [
594 re.compile(r'.*\bMBEDTLS_(PKCS1|RSA)_.*'),
595 re.compile(r'.*\bMBEDTLS_GENPRIME\b.*')
596 ],
597 'test_suite_platform': [
598 # Incompatible with sanitizers (e.g. ASan). If the driver
599 # component uses a sanitizer but the reference component
600 # doesn't, we have a PASS vs SKIP mismatch.
601 'Check mbedtls_calloc overallocation',
602 ],
603 # Following tests depend on RSA_C but are not about
604 # them really, just need to know some error code is there.
605 'test_suite_error': [
606 'Low and high error',
607 'Single high error'
608 ],
609 # Constant time operations only used for PKCS1_V15
610 'test_suite_constant_time': [
611 re.compile(r'mbedtls_ct_zeroize_if .*'),
612 re.compile(r'mbedtls_ct_memmove_left .*')
613 ],
614 'test_suite_psa_crypto': [
615 # We don't support generate_key_custom entry points
616 # in drivers yet.
617 re.compile(r'PSA generate key custom: RSA, e=.*'),
618 re.compile(r'PSA generate key ext: RSA, e=.*'),
619 ],
620 }
621
Gilles Peskine082eade2024-10-03 18:42:37 +0200622class DriverVSReference_block_cipher_dispatch(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200623 REFERENCE = 'test_full_block_cipher_legacy_dispatch'
624 DRIVER = 'test_full_block_cipher_psa_dispatch'
625 IGNORED_SUITES = [
626 # Skipped in the accelerated component
627 'aes', 'aria', 'camellia',
628 # These require AES_C, ARIA_C or CAMELLIA_C to be enabled in
629 # order for the cipher module (actually cipher_wrapper) to work
630 # properly. However these symbols are disabled in the accelerated
631 # component so we ignore them.
632 'cipher.ccm', 'cipher.gcm', 'cipher.aes', 'cipher.aria',
633 'cipher.camellia',
634 ]
635 IGNORED_TESTS = {
636 'test_suite_config': [
637 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA)_.*'),
638 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
639 ],
640 'test_suite_cmac': [
641 # Following tests require AES_C/ARIA_C/CAMELLIA_C to be enabled,
642 # but these are not available in the accelerated component.
643 'CMAC null arguments',
644 re.compile('CMAC.* (AES|ARIA|Camellia).*'),
645 ],
646 'test_suite_cipher.padding': [
647 # Following tests require AES_C/CAMELLIA_C to be enabled,
648 # but these are not available in the accelerated component.
649 re.compile('Set( non-existent)? padding with (AES|CAMELLIA).*'),
650 ],
651 'test_suite_pkcs5': [
652 # The AES part of PKCS#5 PBES2 is not yet supported.
653 # The rest of PKCS#5 (PBKDF2) works, though.
654 re.compile(r'PBES2 .* AES-.*')
655 ],
656 'test_suite_pkparse': [
657 # PEM (called by pkparse) requires AES_C in order to decrypt
658 # the key, but this is not available in the accelerated
659 # component.
660 re.compile('Parse RSA Key.*(password|AES-).*'),
661 ],
662 'test_suite_pem': [
663 # Following tests require AES_C, but this is diabled in the
664 # accelerated component.
665 re.compile('PEM read .*AES.*'),
666 'PEM read (unknown encryption algorithm)',
667 ],
668 'test_suite_error': [
669 # Following tests depend on AES_C but are not about them
670 # really, just need to know some error code is there.
671 'Single low error',
672 'Low and high error',
673 ],
674 'test_suite_version': [
675 # Similar to test_suite_error above.
676 'Check for MBEDTLS_AES_C when already present',
677 ],
678 'test_suite_platform': [
679 # Incompatible with sanitizers (e.g. ASan). If the driver
680 # component uses a sanitizer but the reference component
681 # doesn't, we have a PASS vs SKIP mismatch.
682 'Check mbedtls_calloc overallocation',
683 ],
684 }
685
686#pylint: enable=invalid-name,missing-class-docstring
687
688
Przemek Stekiel6856f4c2022-11-09 10:50:29 +0100689# List of tasks with a function that can handle this task and additional arguments if required
Valerio Settidfd7ca62023-10-09 16:30:11 +0200690KNOWN_TASKS = {
Gilles Peskinef646dbf2024-09-16 19:15:29 +0200691 'analyze_coverage': CoverageTask,
Gilles Peskine9df375b2024-09-16 20:14:26 +0200692 'analyze_driver_vs_reference_hash': DriverVSReference_hash,
693 'analyze_driver_vs_reference_hmac': DriverVSReference_hmac,
694 'analyze_driver_vs_reference_cipher_aead_cmac': DriverVSReference_cipher_aead_cmac,
695 'analyze_driver_vs_reference_ecp_light_only': DriverVSReference_ecp_light_only,
696 'analyze_driver_vs_reference_no_ecp_at_all': DriverVSReference_no_ecp_at_all,
697 'analyze_driver_vs_reference_ecc_no_bignum': DriverVSReference_ecc_no_bignum,
698 'analyze_driver_vs_reference_ecc_ffdh_no_bignum': DriverVSReference_ecc_ffdh_no_bignum,
699 'analyze_driver_vs_reference_ffdh_alg': DriverVSReference_ffdh_alg,
700 'analyze_driver_vs_reference_tfm_config': DriverVSReference_tfm_config,
701 'analyze_driver_vs_reference_rsa': DriverVSReference_rsa,
702 'analyze_block_cipher_dispatch': DriverVSReference_block_cipher_dispatch,
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200703}
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200704
Gilles Peskine15c2cbf2020-06-25 18:36:28 +0200705if __name__ == '__main__':
Gilles Peskine082eade2024-10-03 18:42:37 +0200706 outcome_analysis.main(KNOWN_TASKS)