blob: 7a5c506a95965a9eb261ca36261815744dfb2c16 [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.*'),
Minos Galanakis19dbbe02025-02-27 11:45:02 +000053 # Temporary disable Handshake defragmentation tests until mbedtls
54 # pr #10011 has been merged.
55 'Handshake defragmentation on client: len=4, TLS 1.2',
56 'Handshake defragmentation on client: len=5, TLS 1.2',
57 'Handshake defragmentation on client: len=13, TLS 1.2'
Gilles Peskinede2316b2024-09-17 18:32:05 +020058 ],
Gilles Peskine2fd25bb2024-09-17 19:46:18 +020059 'test_suite_config.mbedtls_boolean': [
Gilles Peskine2fd25bb2024-09-17 19:46:18 +020060 # Missing coverage of test configurations.
61 # https://github.com/Mbed-TLS/mbedtls/issues/9585
62 'Config: !MBEDTLS_SSL_DTLS_ANTI_REPLAY',
63 # Missing coverage of test configurations.
64 # https://github.com/Mbed-TLS/mbedtls/issues/9585
65 'Config: !MBEDTLS_SSL_DTLS_HELLO_VERIFY',
66 # We don't run test_suite_config when we test this.
67 # https://github.com/Mbed-TLS/mbedtls/issues/9586
68 'Config: !MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED',
Gilles Peskine2fd25bb2024-09-17 19:46:18 +020069 ],
70 'test_suite_config.psa_boolean': [
71 # We don't test with HMAC disabled.
72 # https://github.com/Mbed-TLS/mbedtls/issues/9591
73 'Config: !PSA_WANT_ALG_HMAC',
Gilles Peskine2fd25bb2024-09-17 19:46:18 +020074 # The DERIVE key type is always enabled.
75 'Config: !PSA_WANT_KEY_TYPE_DERIVE',
76 # More granularity of key pair type enablement macros
77 # than we care to test.
78 # https://github.com/Mbed-TLS/mbedtls/issues/9590
79 'Config: !PSA_WANT_KEY_TYPE_DH_KEY_PAIR_EXPORT',
80 'Config: !PSA_WANT_KEY_TYPE_DH_KEY_PAIR_GENERATE',
81 'Config: !PSA_WANT_KEY_TYPE_DH_KEY_PAIR_IMPORT',
82 # More granularity of key pair type enablement macros
83 # than we care to test.
84 # https://github.com/Mbed-TLS/mbedtls/issues/9590
85 'Config: !PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT',
86 'Config: !PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT',
87 # We don't test with HMAC disabled.
88 # https://github.com/Mbed-TLS/mbedtls/issues/9591
89 'Config: !PSA_WANT_KEY_TYPE_HMAC',
90 # The PASSWORD key type is always enabled.
91 'Config: !PSA_WANT_KEY_TYPE_PASSWORD',
92 # The PASSWORD_HASH key type is always enabled.
93 'Config: !PSA_WANT_KEY_TYPE_PASSWORD_HASH',
94 # The RAW_DATA key type is always enabled.
95 'Config: !PSA_WANT_KEY_TYPE_RAW_DATA',
96 # More granularity of key pair type enablement macros
97 # than we care to test.
98 # https://github.com/Mbed-TLS/mbedtls/issues/9590
99 'Config: !PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_EXPORT',
100 'Config: !PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT',
101 # Algorithm declared but not supported.
102 'Config: PSA_WANT_ALG_CBC_MAC',
103 # Algorithm declared but not supported.
104 'Config: PSA_WANT_ALG_XTS',
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200105 # More granularity of key pair type enablement macros
106 # than we care to test.
107 # https://github.com/Mbed-TLS/mbedtls/issues/9590
108 'Config: PSA_WANT_KEY_TYPE_DH_KEY_PAIR_DERIVE',
109 'Config: PSA_WANT_KEY_TYPE_ECC_KEY_PAIR',
110 'Config: PSA_WANT_KEY_TYPE_RSA_KEY_PAIR',
111 'Config: PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_DERIVE',
Minos Galanakis848333d2024-12-02 15:58:32 +0000112 # https://github.com/Mbed-TLS/mbedtls/issues/9583
113 'Config: !MBEDTLS_ECP_NIST_OPTIM',
114 # We never test without the PSA client code. Should we?
115 # https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/112
116 'Config: !MBEDTLS_PSA_CRYPTO_CLIENT',
117 # We only test multithreading with pthreads.
118 # https://github.com/Mbed-TLS/mbedtls/issues/9584
119 'Config: !MBEDTLS_THREADING_PTHREAD',
120 # Built but not tested.
121 # https://github.com/Mbed-TLS/mbedtls/issues/9587
122 'Config: MBEDTLS_AES_USE_HARDWARE_ONLY',
123 # Untested platform-specific optimizations.
124 # https://github.com/Mbed-TLS/mbedtls/issues/9588
125 'Config: MBEDTLS_HAVE_SSE2',
126 # Obsolete configuration option, to be replaced by
127 # PSA entropy drivers.
128 # https://github.com/Mbed-TLS/mbedtls/issues/8150
129 'Config: MBEDTLS_NO_PLATFORM_ENTROPY',
130 # Untested aspect of the platform interface.
131 # https://github.com/Mbed-TLS/mbedtls/issues/9589
132 'Config: MBEDTLS_PLATFORM_NO_STD_FUNCTIONS',
133 # In a client-server build, test_suite_config runs in the
134 # client configuration, so it will never report
135 # MBEDTLS_PSA_CRYPTO_SPM as enabled. That's ok.
136 'Config: MBEDTLS_PSA_CRYPTO_SPM',
137 # We don't test on armv8 yet.
138 'Config: MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT',
139 'Config: MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY',
140 'Config: MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY',
141 'Config: MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY',
142 # We don't run test_suite_config when we test this.
143 # https://github.com/Mbed-TLS/mbedtls/issues/9586
144 'Config: MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND',
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200145 ],
146 'test_suite_config.psa_combinations': [
147 # We don't test this unusual, but sensible configuration.
148 # https://github.com/Mbed-TLS/mbedtls/issues/9592
149 'Config: PSA_WANT_ALG_DETERMINSTIC_ECDSA without PSA_WANT_ALG_ECDSA',
150 ],
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200151 'test_suite_pkcs12': [
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200152 # We never test with CBC/PKCS5/PKCS12 enabled but
153 # PKCS7 padding disabled.
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200154 # https://github.com/Mbed-TLS/mbedtls/issues/9580
155 'PBE Decrypt, (Invalid padding & PKCS7 padding disabled)',
156 'PBE Encrypt, pad = 8 (PKCS7 padding disabled)',
157 ],
158 'test_suite_pkcs5': [
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200159 # We never test with CBC/PKCS5/PKCS12 enabled but
160 # PKCS7 padding disabled.
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200161 # https://github.com/Mbed-TLS/mbedtls/issues/9580
162 'PBES2 Decrypt (Invalid padding & PKCS7 padding disabled)',
163 'PBES2 Encrypt, pad=6 (PKCS7 padding disabled)',
164 'PBES2 Encrypt, pad=8 (PKCS7 padding disabled)',
165 ],
Gilles Peskineeafc2752024-04-19 19:08:34 +0200166 'test_suite_psa_crypto': [
167 # We don't test this unusual, but sensible configuration.
168 # https://github.com/Mbed-TLS/mbedtls/issues/9592
169 re.compile(r'.*ECDSA.*only deterministic supported'),
170 ],
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200171 'test_suite_psa_crypto_metadata': [
172 # Algorithms declared but not supported.
173 # https://github.com/Mbed-TLS/mbedtls/issues/9579
174 'Asymmetric signature: Ed25519ph',
175 'Asymmetric signature: Ed448ph',
176 'Asymmetric signature: pure EdDSA',
177 'Cipher: XTS',
178 'MAC: CBC_MAC-3DES',
179 'MAC: CBC_MAC-AES-128',
180 'MAC: CBC_MAC-AES-192',
181 'MAC: CBC_MAC-AES-256',
182 ],
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200183 'test_suite_psa_crypto_not_supported.generated': [
Gilles Peskine5e3ed3f2024-10-11 12:00:44 +0200184 # We never test with DH key support disabled but support
Gilles Peskineab5cc9b2024-09-17 17:57:11 +0200185 # for a DH group enabled. The dependencies of these test
186 # cases don't really make sense.
187 # https://github.com/Mbed-TLS/mbedtls/issues/9574
188 re.compile(r'PSA \w+ DH_.*type not supported'),
189 # We only test partial support for DH with the 2048-bit group
190 # enabled and the other groups disabled.
191 # https://github.com/Mbed-TLS/mbedtls/issues/9575
192 'PSA generate DH_KEY_PAIR(RFC7919) 2048-bit group not supported',
193 'PSA import DH_KEY_PAIR(RFC7919) 2048-bit group not supported',
194 'PSA import DH_PUBLIC_KEY(RFC7919) 2048-bit group not supported',
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200195 ],
196 'test_suite_psa_crypto_op_fail.generated': [
Gilles Peskineeafc2752024-04-19 19:08:34 +0200197 # We don't test this unusual, but sensible configuration.
198 # https://github.com/Mbed-TLS/mbedtls/issues/9592
199 re.compile(r'.*: !ECDSA but DETERMINISTIC_ECDSA with ECC_.*'),
Gilles Peskineab5cc9b2024-09-17 17:57:11 +0200200 # We never test with the HMAC algorithm enabled but the HMAC
201 # key type disabled. Those dependencies don't really make sense.
202 # https://github.com/Mbed-TLS/mbedtls/issues/9573
203 re.compile(r'.* !HMAC with HMAC'),
Gilles Peskine13c418d2025-01-16 19:49:12 +0100204 # We don't test with ECDH disabled but the key type enabled.
205 # https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/161
206 re.compile(r'PSA key_agreement.* !ECDH with ECC_KEY_PAIR\(.*'),
207 # We don't test with FFDH disabled but the key type enabled.
208 # https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/160
209 re.compile(r'PSA key_agreement.* !FFDH with DH_KEY_PAIR\(.*'),
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200210 ],
Gilles Peskineeafc2752024-04-19 19:08:34 +0200211 'test_suite_psa_crypto_op_fail.misc': [
212 # We don't test this unusual, but sensible configuration.
213 # https://github.com/Mbed-TLS/mbedtls/issues/9592
214 'PSA sign DETERMINISTIC_ECDSA(SHA_256): !ECDSA but DETERMINISTIC_ECDSA with ECC_KEY_PAIR(SECP_R1)', #pylint: disable=line-too-long
215 ],
Gilles Peskinede2316b2024-09-17 18:32:05 +0200216 'tls13-misc': [
217 # Disabled due to OpenSSL bug.
218 # https://github.com/openssl/openssl/issues/10714
219 'TLS 1.3 O->m: resumption',
220 # Disabled due to OpenSSL command line limitation.
221 # https://github.com/Mbed-TLS/mbedtls/issues/9582
222 'TLS 1.3 m->O: resumption with early data',
223 ],
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200224 }
225
Gilles Peskine82b16722024-09-16 19:57:10 +0200226
Gilles Peskine9df375b2024-09-16 20:14:26 +0200227# The names that we give to classes derived from DriverVSReference do not
228# follow the usual naming convention, because it's more readable to use
229# underscores and parts of the configuration names. Also, these classes
230# are just there to specify some data, so they don't need repetitive
231# documentation.
232#pylint: disable=invalid-name,missing-class-docstring
233
Gilles Peskine082eade2024-10-03 18:42:37 +0200234class DriverVSReference_hash(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200235 REFERENCE = 'test_psa_crypto_config_reference_hash_use_psa'
236 DRIVER = 'test_psa_crypto_config_accel_hash_use_psa'
237 IGNORED_SUITES = [
238 'shax', 'mdx', # the software implementations that are being excluded
239 'md.psa', # purposefully depends on whether drivers are present
240 'psa_crypto_low_hash.generated', # testing the builtins
241 ]
242 IGNORED_TESTS = {
243 'test_suite_config': [
244 re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'),
245 ],
246 'test_suite_platform': [
247 # Incompatible with sanitizers (e.g. ASan). If the driver
248 # component uses a sanitizer but the reference component
249 # doesn't, we have a PASS vs SKIP mismatch.
250 'Check mbedtls_calloc overallocation',
251 ],
252 }
253
Gilles Peskine082eade2024-10-03 18:42:37 +0200254class DriverVSReference_hmac(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200255 REFERENCE = 'test_psa_crypto_config_reference_hmac'
256 DRIVER = 'test_psa_crypto_config_accel_hmac'
257 IGNORED_SUITES = [
258 # These suites require legacy hash support, which is disabled
259 # in the accelerated component.
260 'shax', 'mdx',
261 # This suite tests builtins directly, but these are missing
262 # in the accelerated case.
263 'psa_crypto_low_hash.generated',
264 ]
265 IGNORED_TESTS = {
266 'test_suite_config': [
267 re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'),
268 re.compile(r'.*\bMBEDTLS_MD_C\b')
269 ],
270 'test_suite_md': [
271 # Builtin HMAC is not supported in the accelerate component.
272 re.compile('.*HMAC.*'),
273 # Following tests make use of functions which are not available
274 # when MD_C is disabled, as it happens in the accelerated
275 # test component.
276 re.compile('generic .* Hash file .*'),
277 'MD list',
278 ],
279 'test_suite_md.psa': [
280 # "legacy only" tests require hash algorithms to be NOT
281 # accelerated, but this of course false for the accelerated
282 # test component.
283 re.compile('PSA dispatch .* legacy only'),
284 ],
285 'test_suite_platform': [
286 # Incompatible with sanitizers (e.g. ASan). If the driver
287 # component uses a sanitizer but the reference component
288 # doesn't, we have a PASS vs SKIP mismatch.
289 'Check mbedtls_calloc overallocation',
290 ],
291 }
292
Gilles Peskine082eade2024-10-03 18:42:37 +0200293class DriverVSReference_cipher_aead_cmac(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200294 REFERENCE = 'test_psa_crypto_config_reference_cipher_aead_cmac'
295 DRIVER = 'test_psa_crypto_config_accel_cipher_aead_cmac'
296 # Modules replaced by drivers.
297 IGNORED_SUITES = [
298 # low-level (block/stream) cipher modules
299 'aes', 'aria', 'camellia', 'des', 'chacha20',
300 # AEAD modes and CMAC
301 'ccm', 'chachapoly', 'cmac', 'gcm',
302 # The Cipher abstraction layer
303 'cipher',
304 ]
305 IGNORED_TESTS = {
306 'test_suite_config': [
307 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA|CHACHA20|DES)_.*'),
308 re.compile(r'.*\bMBEDTLS_(CCM|CHACHAPOLY|CMAC|GCM)_.*'),
309 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
310 re.compile(r'.*\bMBEDTLS_CIPHER_.*'),
311 ],
312 # PEM decryption is not supported so far.
313 # The rest of PEM (write, unencrypted read) works though.
314 'test_suite_pem': [
315 re.compile(r'PEM read .*(AES|DES|\bencrypt).*'),
316 ],
317 'test_suite_platform': [
318 # Incompatible with sanitizers (e.g. ASan). If the driver
319 # component uses a sanitizer but the reference component
320 # doesn't, we have a PASS vs SKIP mismatch.
321 'Check mbedtls_calloc overallocation',
322 ],
323 # Following tests depend on AES_C/DES_C but are not about
324 # them really, just need to know some error code is there.
325 'test_suite_error': [
326 'Low and high error',
327 'Single low error'
328 ],
329 # Similar to test_suite_error above.
330 'test_suite_version': [
331 'Check for MBEDTLS_AES_C when already present',
332 ],
333 # The en/decryption part of PKCS#12 is not supported so far.
334 # The rest of PKCS#12 (key derivation) works though.
335 'test_suite_pkcs12': [
336 re.compile(r'PBE Encrypt, .*'),
337 re.compile(r'PBE Decrypt, .*'),
338 ],
339 # The en/decryption part of PKCS#5 is not supported so far.
340 # The rest of PKCS#5 (PBKDF2) works though.
341 'test_suite_pkcs5': [
342 re.compile(r'PBES2 Encrypt, .*'),
343 re.compile(r'PBES2 Decrypt .*'),
344 ],
345 # Encrypted keys are not supported so far.
346 # pylint: disable=line-too-long
347 'test_suite_pkparse': [
348 'Key ASN1 (Encrypted key PKCS12, trailing garbage data)',
349 'Key ASN1 (Encrypted key PKCS5, trailing garbage data)',
350 re.compile(r'Parse (RSA|EC) Key .*\(.* ([Ee]ncrypted|password).*\)'),
351 ],
352 # Encrypted keys are not supported so far.
353 'ssl-opt': [
354 'TLS: password protected server key',
355 'TLS: password protected client key',
356 'TLS: password protected server key, two certificates',
357 ],
358 }
359
Gilles Peskine082eade2024-10-03 18:42:37 +0200360class DriverVSReference_ecp_light_only(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200361 REFERENCE = 'test_psa_crypto_config_reference_ecc_ecp_light_only'
362 DRIVER = 'test_psa_crypto_config_accel_ecc_ecp_light_only'
363 IGNORED_SUITES = [
364 # Modules replaced by drivers
365 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100366 # Unit tests for the built-in implementation
367 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200368 ]
369 IGNORED_TESTS = {
370 'test_suite_config': [
371 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
372 ],
373 'test_suite_platform': [
374 # Incompatible with sanitizers (e.g. ASan). If the driver
375 # component uses a sanitizer but the reference component
376 # doesn't, we have a PASS vs SKIP mismatch.
377 'Check mbedtls_calloc overallocation',
378 ],
379 # This test wants a legacy function that takes f_rng, p_rng
380 # arguments, and uses legacy ECDSA for that. The test is
381 # really about the wrapper around the PSA RNG, not ECDSA.
382 'test_suite_random': [
383 'PSA classic wrapper: ECDSA signature (SECP256R1)',
384 ],
385 # In the accelerated test ECP_C is not set (only ECP_LIGHT is)
386 # so we must ignore disparities in the tests for which ECP_C
387 # is required.
388 'test_suite_ecp': [
389 re.compile(r'ECP check public-private .*'),
390 re.compile(r'ECP calculate public: .*'),
391 re.compile(r'ECP gen keypair .*'),
392 re.compile(r'ECP point muladd .*'),
393 re.compile(r'ECP point multiplication .*'),
394 re.compile(r'ECP test vectors .*'),
395 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200396 }
397
Gilles Peskine082eade2024-10-03 18:42:37 +0200398class DriverVSReference_no_ecp_at_all(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200399 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_ecp_at_all'
400 DRIVER = 'test_psa_crypto_config_accel_ecc_no_ecp_at_all'
401 IGNORED_SUITES = [
402 # Modules replaced by drivers
403 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100404 # Unit tests for the built-in implementation
405 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200406 ]
407 IGNORED_TESTS = {
408 'test_suite_config': [
409 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
410 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
411 ],
412 'test_suite_platform': [
413 # Incompatible with sanitizers (e.g. ASan). If the driver
414 # component uses a sanitizer but the reference component
415 # doesn't, we have a PASS vs SKIP mismatch.
416 'Check mbedtls_calloc overallocation',
417 ],
418 # See ecp_light_only
419 'test_suite_random': [
420 'PSA classic wrapper: ECDSA signature (SECP256R1)',
421 ],
422 'test_suite_pkparse': [
423 # When PK_PARSE_C and ECP_C are defined then PK_PARSE_EC_COMPRESSED
424 # is automatically enabled in build_info.h (backward compatibility)
425 # even if it is disabled in config_psa_crypto_no_ecp_at_all(). As a
426 # consequence compressed points are supported in the reference
427 # component but not in the accelerated one, so they should be skipped
428 # while checking driver's coverage.
429 re.compile(r'Parse EC Key .*compressed\)'),
430 re.compile(r'Parse Public EC Key .*compressed\)'),
431 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200432 }
433
Gilles Peskine082eade2024-10-03 18:42:37 +0200434class DriverVSReference_ecc_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200435 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_bignum'
436 DRIVER = 'test_psa_crypto_config_accel_ecc_no_bignum'
437 IGNORED_SUITES = [
438 # Modules replaced by drivers
439 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
440 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
441 'bignum.generated', 'bignum.misc',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100442 # Unit tests for the built-in implementation
443 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200444 ]
445 IGNORED_TESTS = {
446 'test_suite_config': [
447 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
448 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
449 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
450 ],
451 'test_suite_platform': [
452 # Incompatible with sanitizers (e.g. ASan). If the driver
453 # component uses a sanitizer but the reference component
454 # doesn't, we have a PASS vs SKIP mismatch.
455 'Check mbedtls_calloc overallocation',
456 ],
457 # See ecp_light_only
458 'test_suite_random': [
459 'PSA classic wrapper: ECDSA signature (SECP256R1)',
460 ],
461 # See no_ecp_at_all
462 'test_suite_pkparse': [
463 re.compile(r'Parse EC Key .*compressed\)'),
464 re.compile(r'Parse Public EC Key .*compressed\)'),
465 ],
466 'test_suite_asn1parse': [
467 'INTEGER too large for mpi',
468 ],
469 'test_suite_asn1write': [
470 re.compile(r'ASN.1 Write mpi.*'),
471 ],
472 'test_suite_debug': [
473 re.compile(r'Debug print mbedtls_mpi.*'),
474 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200475 }
476
Gilles Peskine082eade2024-10-03 18:42:37 +0200477class DriverVSReference_ecc_ffdh_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200478 REFERENCE = 'test_psa_crypto_config_reference_ecc_ffdh_no_bignum'
479 DRIVER = 'test_psa_crypto_config_accel_ecc_ffdh_no_bignum'
480 IGNORED_SUITES = [
481 # Modules replaced by drivers
482 'ecp', 'ecdsa', 'ecdh', 'ecjpake', 'dhm',
483 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
484 'bignum.generated', 'bignum.misc',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100485 # Unit tests for the built-in implementation
486 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200487 ]
488 IGNORED_TESTS = {
Gilles Peskine9df375b2024-09-16 20:14:26 +0200489 'test_suite_config': [
490 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
491 re.compile(r'.*\bMBEDTLS_DHM_C\b.*'),
492 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'
524 IGNORED_SUITES = ['dhm']
525 IGNORED_TESTS = {
526 'test_suite_config': [
527 re.compile(r'.*\bMBEDTLS_DHM_C\b.*'),
528 ],
529 'test_suite_platform': [
530 # Incompatible with sanitizers (e.g. ASan). If the driver
531 # component uses a sanitizer but the reference component
532 # doesn't, we have a PASS vs SKIP mismatch.
533 'Check mbedtls_calloc overallocation',
534 ],
535 }
536
Gilles Peskine082eade2024-10-03 18:42:37 +0200537class DriverVSReference_tfm_config(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200538 REFERENCE = 'test_tfm_config_no_p256m'
539 DRIVER = 'test_tfm_config_p256m_driver_accel_ec'
540 IGNORED_SUITES = [
541 # Modules replaced by drivers
542 'asn1parse', 'asn1write',
543 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
544 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
545 'bignum.generated', 'bignum.misc',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100546 # Unit tests for the built-in implementation
547 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200548 ]
549 IGNORED_TESTS = {
550 'test_suite_config': [
551 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
552 re.compile(r'.*\bMBEDTLS_(ASN1\w+)_C\b.*'),
553 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECP)_.*'),
554 re.compile(r'.*\bMBEDTLS_PSA_P256M_DRIVER_ENABLED\b.*')
555 ],
556 'test_suite_config.crypto_combinations': [
557 'Config: ECC: Weierstrass curves only',
558 ],
559 'test_suite_platform': [
560 # Incompatible with sanitizers (e.g. ASan). If the driver
561 # component uses a sanitizer but the reference component
562 # doesn't, we have a PASS vs SKIP mismatch.
563 'Check mbedtls_calloc overallocation',
564 ],
565 # See ecp_light_only
566 'test_suite_random': [
567 'PSA classic wrapper: ECDSA signature (SECP256R1)',
568 ],
569 }
570
Gilles Peskine082eade2024-10-03 18:42:37 +0200571class DriverVSReference_rsa(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200572 REFERENCE = 'test_psa_crypto_config_reference_rsa_crypto'
573 DRIVER = 'test_psa_crypto_config_accel_rsa_crypto'
574 IGNORED_SUITES = [
575 # Modules replaced by drivers.
576 'rsa', 'pkcs1_v15', 'pkcs1_v21',
577 # We temporarily don't care about PK stuff.
578 'pk', 'pkwrite', 'pkparse'
579 ]
580 IGNORED_TESTS = {
581 'test_suite_config': [
582 re.compile(r'.*\bMBEDTLS_(PKCS1|RSA)_.*'),
583 re.compile(r'.*\bMBEDTLS_GENPRIME\b.*')
584 ],
585 'test_suite_platform': [
586 # Incompatible with sanitizers (e.g. ASan). If the driver
587 # component uses a sanitizer but the reference component
588 # doesn't, we have a PASS vs SKIP mismatch.
589 'Check mbedtls_calloc overallocation',
590 ],
591 # Following tests depend on RSA_C but are not about
592 # them really, just need to know some error code is there.
593 'test_suite_error': [
594 'Low and high error',
595 'Single high error'
596 ],
597 # Constant time operations only used for PKCS1_V15
598 'test_suite_constant_time': [
599 re.compile(r'mbedtls_ct_zeroize_if .*'),
600 re.compile(r'mbedtls_ct_memmove_left .*')
601 ],
602 'test_suite_psa_crypto': [
603 # We don't support generate_key_custom entry points
604 # in drivers yet.
605 re.compile(r'PSA generate key custom: RSA, e=.*'),
606 re.compile(r'PSA generate key ext: RSA, e=.*'),
607 ],
608 }
609
Gilles Peskine082eade2024-10-03 18:42:37 +0200610class DriverVSReference_block_cipher_dispatch(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200611 REFERENCE = 'test_full_block_cipher_legacy_dispatch'
612 DRIVER = 'test_full_block_cipher_psa_dispatch'
613 IGNORED_SUITES = [
614 # Skipped in the accelerated component
615 'aes', 'aria', 'camellia',
616 # These require AES_C, ARIA_C or CAMELLIA_C to be enabled in
617 # order for the cipher module (actually cipher_wrapper) to work
618 # properly. However these symbols are disabled in the accelerated
619 # component so we ignore them.
620 'cipher.ccm', 'cipher.gcm', 'cipher.aes', 'cipher.aria',
621 'cipher.camellia',
622 ]
623 IGNORED_TESTS = {
624 'test_suite_config': [
625 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA)_.*'),
626 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
627 ],
628 'test_suite_cmac': [
629 # Following tests require AES_C/ARIA_C/CAMELLIA_C to be enabled,
630 # but these are not available in the accelerated component.
631 'CMAC null arguments',
632 re.compile('CMAC.* (AES|ARIA|Camellia).*'),
633 ],
634 'test_suite_cipher.padding': [
635 # Following tests require AES_C/CAMELLIA_C to be enabled,
636 # but these are not available in the accelerated component.
637 re.compile('Set( non-existent)? padding with (AES|CAMELLIA).*'),
638 ],
639 'test_suite_pkcs5': [
640 # The AES part of PKCS#5 PBES2 is not yet supported.
641 # The rest of PKCS#5 (PBKDF2) works, though.
642 re.compile(r'PBES2 .* AES-.*')
643 ],
644 'test_suite_pkparse': [
645 # PEM (called by pkparse) requires AES_C in order to decrypt
646 # the key, but this is not available in the accelerated
647 # component.
648 re.compile('Parse RSA Key.*(password|AES-).*'),
649 ],
650 'test_suite_pem': [
651 # Following tests require AES_C, but this is diabled in the
652 # accelerated component.
653 re.compile('PEM read .*AES.*'),
654 'PEM read (unknown encryption algorithm)',
655 ],
656 'test_suite_error': [
657 # Following tests depend on AES_C but are not about them
658 # really, just need to know some error code is there.
659 'Single low error',
660 'Low and high error',
661 ],
662 'test_suite_version': [
663 # Similar to test_suite_error above.
664 'Check for MBEDTLS_AES_C when already present',
665 ],
666 'test_suite_platform': [
667 # Incompatible with sanitizers (e.g. ASan). If the driver
668 # component uses a sanitizer but the reference component
669 # doesn't, we have a PASS vs SKIP mismatch.
670 'Check mbedtls_calloc overallocation',
671 ],
672 }
673
674#pylint: enable=invalid-name,missing-class-docstring
675
676
Przemek Stekiel6856f4c2022-11-09 10:50:29 +0100677# List of tasks with a function that can handle this task and additional arguments if required
Valerio Settidfd7ca62023-10-09 16:30:11 +0200678KNOWN_TASKS = {
Gilles Peskinef646dbf2024-09-16 19:15:29 +0200679 'analyze_coverage': CoverageTask,
Gilles Peskine9df375b2024-09-16 20:14:26 +0200680 'analyze_driver_vs_reference_hash': DriverVSReference_hash,
681 'analyze_driver_vs_reference_hmac': DriverVSReference_hmac,
682 'analyze_driver_vs_reference_cipher_aead_cmac': DriverVSReference_cipher_aead_cmac,
683 'analyze_driver_vs_reference_ecp_light_only': DriverVSReference_ecp_light_only,
684 'analyze_driver_vs_reference_no_ecp_at_all': DriverVSReference_no_ecp_at_all,
685 'analyze_driver_vs_reference_ecc_no_bignum': DriverVSReference_ecc_no_bignum,
686 'analyze_driver_vs_reference_ecc_ffdh_no_bignum': DriverVSReference_ecc_ffdh_no_bignum,
687 'analyze_driver_vs_reference_ffdh_alg': DriverVSReference_ffdh_alg,
688 'analyze_driver_vs_reference_tfm_config': DriverVSReference_tfm_config,
689 'analyze_driver_vs_reference_rsa': DriverVSReference_rsa,
690 'analyze_block_cipher_dispatch': DriverVSReference_block_cipher_dispatch,
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200691}
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200692
Gilles Peskine15c2cbf2020-06-25 18:36:28 +0200693if __name__ == '__main__':
Gilles Peskine082eade2024-10-03 18:42:37 +0200694 outcome_analysis.main(KNOWN_TASKS)