blob: a6f03a83c9bb7cc9e2cd1d91b6c8934923b246af [file] [log] [blame]
Gilles Peskine15c2cbf2020-06-25 18:36:28 +02001#!/usr/bin/env python3
2
3"""Analyze the test outcomes from a full CI run.
4
5This script can also run on outcomes from a partial run, but the results are
6less likely to be useful.
7"""
8
Przemek Stekiel85c54ea2022-11-17 11:50:23 +01009import re
Gilles Peskine2a71fac2024-09-17 15:07:22 +020010import typing
Gilles Peskine15c2cbf2020-06-25 18:36:28 +020011
Gilles Peskine31467722024-10-03 18:52:58 +020012import scripts_path # pylint: disable=unused-import
13from mbedtls_framework import outcome_analysis
Gilles Peskine8d3c70a2020-06-25 18:37:43 +020014
Pengyu Lvc2e8f3a2023-11-28 17:22:04 +080015
Gilles Peskine082eade2024-10-03 18:42:37 +020016class CoverageTask(outcome_analysis.CoverageTask):
Gilles Peskine095561c2024-10-04 16:24:26 +020017 """Justify test cases that are never executed."""
Gilles Peskine3f5022e2024-09-16 20:23:40 +020018
Gilles Peskine2a71fac2024-09-17 15:07:22 +020019 @staticmethod
Gilles Peskine5872c0d2024-09-17 17:15:29 +020020 def _has_word_re(words: typing.Iterable[str],
21 exclude: typing.Optional[str] = None) -> typing.Pattern:
Gilles Peskine2a71fac2024-09-17 15:07:22 +020022 """Construct a regex that matches if any of the words appears.
23
24 The occurrence must start and end at a word boundary.
Gilles Peskine5872c0d2024-09-17 17:15:29 +020025
26 If exclude is specified, strings containing a match for that
27 regular expression will not match the returned pattern.
Gilles Peskine2a71fac2024-09-17 15:07:22 +020028 """
Gilles Peskine5872c0d2024-09-17 17:15:29 +020029 exclude_clause = r''
30 if exclude:
31 exclude_clause = r'(?!.*' + exclude + ')'
32 return re.compile(exclude_clause +
33 r'.*\b(?:' + r'|'.join(words) + r')\b.*',
Gilles Peskine5e3ed3f2024-10-11 12:00:44 +020034 re.DOTALL)
Gilles Peskine2a71fac2024-09-17 15:07:22 +020035
Gilles Peskine2a71fac2024-09-17 15:07:22 +020036 IGNORED_TESTS = {
Gilles Peskinede2316b2024-09-17 18:32:05 +020037 'ssl-opt': [
38 # We don't run ssl-opt.sh with Valgrind on the CI because
39 # it's extremely slow. We don't intend to change this.
40 'DTLS client reconnect from same port: reconnect, nbio, valgrind',
Gilles Peskinede2316b2024-09-17 18:32:05 +020041 # We don't have IPv6 in our CI environment.
42 # https://github.com/Mbed-TLS/mbedtls-test/issues/176
43 'DTLS cookie: enabled, IPv6',
44 # Disabled due to OpenSSL bug.
45 # https://github.com/openssl/openssl/issues/18887
46 'DTLS fragmenting: 3d, openssl client, DTLS 1.2',
47 # We don't run ssl-opt.sh with Valgrind on the CI because
48 # it's extremely slow. We don't intend to change this.
49 'DTLS fragmenting: proxy MTU: auto-reduction (with valgrind)',
Gilles Peskine24b03d82024-10-04 16:22:24 +020050 # TLS doesn't use restartable ECDH yet.
51 # https://github.com/Mbed-TLS/mbedtls/issues/7294
52 re.compile(r'EC restart:.*no USE_PSA.*'),
Gilles Peskinede2316b2024-09-17 18:32:05 +020053 ],
Gilles Peskine2fd25bb2024-09-17 19:46:18 +020054 'test_suite_config.mbedtls_boolean': [
Gilles Peskine2fd25bb2024-09-17 19:46:18 +020055 # Missing coverage of test configurations.
56 # https://github.com/Mbed-TLS/mbedtls/issues/9585
57 'Config: !MBEDTLS_SSL_DTLS_ANTI_REPLAY',
58 # Missing coverage of test configurations.
59 # https://github.com/Mbed-TLS/mbedtls/issues/9585
60 'Config: !MBEDTLS_SSL_DTLS_HELLO_VERIFY',
61 # We don't run test_suite_config when we test this.
62 # https://github.com/Mbed-TLS/mbedtls/issues/9586
63 'Config: !MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED',
Gilles Peskine2fd25bb2024-09-17 19:46:18 +020064 ],
Gilles Peskine3c2a1cb2025-07-15 19:09:08 +020065 'test_suite_config.crypto_combinations': [
66 # New thing in crypto. Not intended to be tested separately
67 # in mbedtls.
68 # https://github.com/Mbed-TLS/mbedtls/issues/10300
69 'Config: entropy: NV seed only',
70 ],
Gilles Peskine2fd25bb2024-09-17 19:46:18 +020071 'test_suite_config.psa_boolean': [
72 # We don't test with HMAC disabled.
73 # https://github.com/Mbed-TLS/mbedtls/issues/9591
74 'Config: !PSA_WANT_ALG_HMAC',
Gilles Peskine2fd25bb2024-09-17 19:46:18 +020075 # The DERIVE key type is always enabled.
76 'Config: !PSA_WANT_KEY_TYPE_DERIVE',
77 # More granularity of key pair type enablement macros
78 # than we care to test.
79 # https://github.com/Mbed-TLS/mbedtls/issues/9590
80 'Config: !PSA_WANT_KEY_TYPE_DH_KEY_PAIR_EXPORT',
81 'Config: !PSA_WANT_KEY_TYPE_DH_KEY_PAIR_GENERATE',
82 'Config: !PSA_WANT_KEY_TYPE_DH_KEY_PAIR_IMPORT',
83 # More granularity of key pair type enablement macros
84 # than we care to test.
85 # https://github.com/Mbed-TLS/mbedtls/issues/9590
86 'Config: !PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT',
87 'Config: !PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT',
88 # We don't test with HMAC disabled.
89 # https://github.com/Mbed-TLS/mbedtls/issues/9591
90 'Config: !PSA_WANT_KEY_TYPE_HMAC',
91 # The PASSWORD key type is always enabled.
92 'Config: !PSA_WANT_KEY_TYPE_PASSWORD',
93 # The PASSWORD_HASH key type is always enabled.
94 'Config: !PSA_WANT_KEY_TYPE_PASSWORD_HASH',
95 # The RAW_DATA key type is always enabled.
96 'Config: !PSA_WANT_KEY_TYPE_RAW_DATA',
97 # More granularity of key pair type enablement macros
98 # than we care to test.
99 # https://github.com/Mbed-TLS/mbedtls/issues/9590
100 'Config: !PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_EXPORT',
101 'Config: !PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT',
102 # Algorithm declared but not supported.
103 'Config: PSA_WANT_ALG_CBC_MAC',
104 # Algorithm declared but not supported.
105 'Config: PSA_WANT_ALG_XTS',
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200106 # More granularity of key pair type enablement macros
107 # than we care to test.
108 # https://github.com/Mbed-TLS/mbedtls/issues/9590
109 'Config: PSA_WANT_KEY_TYPE_DH_KEY_PAIR_DERIVE',
110 'Config: PSA_WANT_KEY_TYPE_ECC_KEY_PAIR',
111 'Config: PSA_WANT_KEY_TYPE_RSA_KEY_PAIR',
112 'Config: PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_DERIVE',
Minos Galanakis848333d2024-12-02 15:58:32 +0000113 # https://github.com/Mbed-TLS/mbedtls/issues/9583
114 'Config: !MBEDTLS_ECP_NIST_OPTIM',
115 # We never test without the PSA client code. Should we?
116 # https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/112
117 'Config: !MBEDTLS_PSA_CRYPTO_CLIENT',
118 # We only test multithreading with pthreads.
119 # https://github.com/Mbed-TLS/mbedtls/issues/9584
120 'Config: !MBEDTLS_THREADING_PTHREAD',
121 # Built but not tested.
122 # https://github.com/Mbed-TLS/mbedtls/issues/9587
123 'Config: MBEDTLS_AES_USE_HARDWARE_ONLY',
124 # Untested platform-specific optimizations.
125 # https://github.com/Mbed-TLS/mbedtls/issues/9588
126 'Config: MBEDTLS_HAVE_SSE2',
Felix Conway133f7aa2025-03-19 14:38:47 +0000127 # Obsolete configuration options, to be replaced by
Minos Galanakis848333d2024-12-02 15:58:32 +0000128 # PSA entropy drivers.
129 # https://github.com/Mbed-TLS/mbedtls/issues/8150
Felix Conway133f7aa2025-03-19 14:38:47 +0000130 'Config: MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES',
Ronald Croneb16a9d2025-09-03 09:57:29 +0200131 # Obsolete config option that we are about to remove
132 'Config: MBEDTLS_PLATFORM_GET_ENTROPY_ALT',
Minos Galanakis848333d2024-12-02 15:58:32 +0000133 # Untested aspect of the platform interface.
134 # https://github.com/Mbed-TLS/mbedtls/issues/9589
135 'Config: MBEDTLS_PLATFORM_NO_STD_FUNCTIONS',
136 # In a client-server build, test_suite_config runs in the
137 # client configuration, so it will never report
138 # MBEDTLS_PSA_CRYPTO_SPM as enabled. That's ok.
139 'Config: MBEDTLS_PSA_CRYPTO_SPM',
140 # We don't test on armv8 yet.
141 'Config: MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT',
142 'Config: MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY',
143 'Config: MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY',
144 'Config: MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY',
145 # We don't run test_suite_config when we test this.
146 # https://github.com/Mbed-TLS/mbedtls/issues/9586
147 'Config: MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND',
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200148 ],
149 'test_suite_config.psa_combinations': [
150 # We don't test this unusual, but sensible configuration.
151 # https://github.com/Mbed-TLS/mbedtls/issues/9592
152 'Config: PSA_WANT_ALG_DETERMINSTIC_ECDSA without PSA_WANT_ALG_ECDSA',
153 ],
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200154 'test_suite_pkcs12': [
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 'PBE Decrypt, (Invalid padding & PKCS7 padding disabled)',
159 'PBE Encrypt, pad = 8 (PKCS7 padding disabled)',
160 ],
161 'test_suite_pkcs5': [
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200162 # We never test with CBC/PKCS5/PKCS12 enabled but
163 # PKCS7 padding disabled.
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200164 # https://github.com/Mbed-TLS/mbedtls/issues/9580
165 'PBES2 Decrypt (Invalid padding & PKCS7 padding disabled)',
166 'PBES2 Encrypt, pad=6 (PKCS7 padding disabled)',
167 'PBES2 Encrypt, pad=8 (PKCS7 padding disabled)',
168 ],
Gilles Peskineeafc2752024-04-19 19:08:34 +0200169 'test_suite_psa_crypto': [
170 # We don't test this unusual, but sensible configuration.
171 # https://github.com/Mbed-TLS/mbedtls/issues/9592
172 re.compile(r'.*ECDSA.*only deterministic supported'),
173 ],
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200174 'test_suite_psa_crypto_metadata': [
175 # Algorithms declared but not supported.
176 # https://github.com/Mbed-TLS/mbedtls/issues/9579
177 'Asymmetric signature: Ed25519ph',
178 'Asymmetric signature: Ed448ph',
179 'Asymmetric signature: pure EdDSA',
180 'Cipher: XTS',
181 'MAC: CBC_MAC-3DES',
182 'MAC: CBC_MAC-AES-128',
183 'MAC: CBC_MAC-AES-192',
184 'MAC: CBC_MAC-AES-256',
185 ],
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200186 'test_suite_psa_crypto_not_supported.generated': [
Gilles Peskine5e3ed3f2024-10-11 12:00:44 +0200187 # We never test with DH key support disabled but support
Gilles Peskineab5cc9b2024-09-17 17:57:11 +0200188 # for a DH group enabled. The dependencies of these test
189 # cases don't really make sense.
190 # https://github.com/Mbed-TLS/mbedtls/issues/9574
191 re.compile(r'PSA \w+ DH_.*type not supported'),
192 # We only test partial support for DH with the 2048-bit group
193 # enabled and the other groups disabled.
194 # https://github.com/Mbed-TLS/mbedtls/issues/9575
195 'PSA generate DH_KEY_PAIR(RFC7919) 2048-bit group not supported',
196 'PSA import DH_KEY_PAIR(RFC7919) 2048-bit group not supported',
197 'PSA import DH_PUBLIC_KEY(RFC7919) 2048-bit group not supported',
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200198 ],
199 'test_suite_psa_crypto_op_fail.generated': [
Gilles Peskineeafc2752024-04-19 19:08:34 +0200200 # We don't test this unusual, but sensible configuration.
201 # https://github.com/Mbed-TLS/mbedtls/issues/9592
202 re.compile(r'.*: !ECDSA but DETERMINISTIC_ECDSA with ECC_.*'),
Gilles Peskineab5cc9b2024-09-17 17:57:11 +0200203 # We never test with the HMAC algorithm enabled but the HMAC
204 # key type disabled. Those dependencies don't really make sense.
205 # https://github.com/Mbed-TLS/mbedtls/issues/9573
206 re.compile(r'.* !HMAC with HMAC'),
Gilles Peskine13c418d2025-01-16 19:49:12 +0100207 # We don't test with ECDH disabled but the key type enabled.
208 # https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/161
209 re.compile(r'PSA key_agreement.* !ECDH with ECC_KEY_PAIR\(.*'),
210 # We don't test with FFDH disabled but the key type enabled.
211 # https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/160
212 re.compile(r'PSA key_agreement.* !FFDH with DH_KEY_PAIR\(.*'),
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200213 ],
Gilles Peskineeafc2752024-04-19 19:08:34 +0200214 'test_suite_psa_crypto_op_fail.misc': [
215 # We don't test this unusual, but sensible configuration.
216 # https://github.com/Mbed-TLS/mbedtls/issues/9592
217 'PSA sign DETERMINISTIC_ECDSA(SHA_256): !ECDSA but DETERMINISTIC_ECDSA with ECC_KEY_PAIR(SECP_R1)', #pylint: disable=line-too-long
218 ],
Gilles Peskinede2316b2024-09-17 18:32:05 +0200219 'tls13-misc': [
220 # Disabled due to OpenSSL bug.
221 # https://github.com/openssl/openssl/issues/10714
222 'TLS 1.3 O->m: resumption',
223 # Disabled due to OpenSSL command line limitation.
224 # https://github.com/Mbed-TLS/mbedtls/issues/9582
225 'TLS 1.3 m->O: resumption with early data',
226 ],
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200227 }
228
Gilles Peskine82b16722024-09-16 19:57:10 +0200229
Gilles Peskine9df375b2024-09-16 20:14:26 +0200230# The names that we give to classes derived from DriverVSReference do not
231# follow the usual naming convention, because it's more readable to use
232# underscores and parts of the configuration names. Also, these classes
233# are just there to specify some data, so they don't need repetitive
234# documentation.
235#pylint: disable=invalid-name,missing-class-docstring
236
Gilles Peskine082eade2024-10-03 18:42:37 +0200237class DriverVSReference_hash(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200238 REFERENCE = 'test_psa_crypto_config_reference_hash_use_psa'
239 DRIVER = 'test_psa_crypto_config_accel_hash_use_psa'
240 IGNORED_SUITES = [
241 'shax', 'mdx', # the software implementations that are being excluded
242 'md.psa', # purposefully depends on whether drivers are present
243 'psa_crypto_low_hash.generated', # testing the builtins
244 ]
245 IGNORED_TESTS = {
246 'test_suite_config': [
247 re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'),
248 ],
249 'test_suite_platform': [
250 # Incompatible with sanitizers (e.g. ASan). If the driver
251 # component uses a sanitizer but the reference component
252 # doesn't, we have a PASS vs SKIP mismatch.
253 'Check mbedtls_calloc overallocation',
254 ],
255 }
256
Gilles Peskine082eade2024-10-03 18:42:37 +0200257class DriverVSReference_hmac(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200258 REFERENCE = 'test_psa_crypto_config_reference_hmac'
259 DRIVER = 'test_psa_crypto_config_accel_hmac'
260 IGNORED_SUITES = [
261 # These suites require legacy hash support, which is disabled
262 # in the accelerated component.
263 'shax', 'mdx',
264 # This suite tests builtins directly, but these are missing
265 # in the accelerated case.
266 'psa_crypto_low_hash.generated',
267 ]
268 IGNORED_TESTS = {
269 'test_suite_config': [
270 re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'),
271 re.compile(r'.*\bMBEDTLS_MD_C\b')
272 ],
273 'test_suite_md': [
274 # Builtin HMAC is not supported in the accelerate component.
275 re.compile('.*HMAC.*'),
276 # Following tests make use of functions which are not available
277 # when MD_C is disabled, as it happens in the accelerated
278 # test component.
279 re.compile('generic .* Hash file .*'),
280 'MD list',
281 ],
282 'test_suite_md.psa': [
283 # "legacy only" tests require hash algorithms to be NOT
284 # accelerated, but this of course false for the accelerated
285 # test component.
286 re.compile('PSA dispatch .* legacy only'),
287 ],
288 'test_suite_platform': [
289 # Incompatible with sanitizers (e.g. ASan). If the driver
290 # component uses a sanitizer but the reference component
291 # doesn't, we have a PASS vs SKIP mismatch.
292 'Check mbedtls_calloc overallocation',
293 ],
294 }
295
Gilles Peskine082eade2024-10-03 18:42:37 +0200296class DriverVSReference_cipher_aead_cmac(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200297 REFERENCE = 'test_psa_crypto_config_reference_cipher_aead_cmac'
298 DRIVER = 'test_psa_crypto_config_accel_cipher_aead_cmac'
299 # Modules replaced by drivers.
300 IGNORED_SUITES = [
301 # low-level (block/stream) cipher modules
302 'aes', 'aria', 'camellia', 'des', 'chacha20',
Ronald Cronb5c6fcc2025-07-10 13:40:00 +0200303 # AEAD modes, CMAC and POLY1305
304 'ccm', 'chachapoly', 'cmac', 'gcm', 'poly1305',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200305 # The Cipher abstraction layer
306 'cipher',
307 ]
308 IGNORED_TESTS = {
309 'test_suite_config': [
310 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA|CHACHA20|DES)_.*'),
Ronald Cronb5c6fcc2025-07-10 13:40:00 +0200311 re.compile(r'.*\bMBEDTLS_(CCM|CHACHAPOLY|CMAC|GCM|POLY1305)_.*'),
Gilles Peskine9df375b2024-09-16 20:14:26 +0200312 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
313 re.compile(r'.*\bMBEDTLS_CIPHER_.*'),
314 ],
315 # PEM decryption is not supported so far.
316 # The rest of PEM (write, unencrypted read) works though.
317 'test_suite_pem': [
318 re.compile(r'PEM read .*(AES|DES|\bencrypt).*'),
319 ],
320 'test_suite_platform': [
321 # Incompatible with sanitizers (e.g. ASan). If the driver
322 # component uses a sanitizer but the reference component
323 # doesn't, we have a PASS vs SKIP mismatch.
324 'Check mbedtls_calloc overallocation',
325 ],
326 # Following tests depend on AES_C/DES_C but are not about
327 # them really, just need to know some error code is there.
328 'test_suite_error': [
329 'Low and high error',
330 'Single low error'
331 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200332 # The en/decryption part of PKCS#12 is not supported so far.
333 # The rest of PKCS#12 (key derivation) works though.
334 'test_suite_pkcs12': [
335 re.compile(r'PBE Encrypt, .*'),
336 re.compile(r'PBE Decrypt, .*'),
337 ],
338 # The en/decryption part of PKCS#5 is not supported so far.
339 # The rest of PKCS#5 (PBKDF2) works though.
340 'test_suite_pkcs5': [
341 re.compile(r'PBES2 Encrypt, .*'),
342 re.compile(r'PBES2 Decrypt .*'),
343 ],
344 # Encrypted keys are not supported so far.
345 # pylint: disable=line-too-long
346 'test_suite_pkparse': [
347 'Key ASN1 (Encrypted key PKCS12, trailing garbage data)',
348 'Key ASN1 (Encrypted key PKCS5, trailing garbage data)',
349 re.compile(r'Parse (RSA|EC) Key .*\(.* ([Ee]ncrypted|password).*\)'),
350 ],
351 # Encrypted keys are not supported so far.
352 'ssl-opt': [
353 'TLS: password protected server key',
354 'TLS: password protected client key',
355 'TLS: password protected server key, two certificates',
356 ],
357 }
358
Gilles Peskine082eade2024-10-03 18:42:37 +0200359class DriverVSReference_ecp_light_only(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200360 REFERENCE = 'test_psa_crypto_config_reference_ecc_ecp_light_only'
361 DRIVER = 'test_psa_crypto_config_accel_ecc_ecp_light_only'
362 IGNORED_SUITES = [
363 # Modules replaced by drivers
364 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100365 # Unit tests for the built-in implementation
366 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200367 ]
368 IGNORED_TESTS = {
369 'test_suite_config': [
370 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
371 ],
372 'test_suite_platform': [
373 # Incompatible with sanitizers (e.g. ASan). If the driver
374 # component uses a sanitizer but the reference component
375 # doesn't, we have a PASS vs SKIP mismatch.
376 'Check mbedtls_calloc overallocation',
377 ],
378 # This test wants a legacy function that takes f_rng, p_rng
379 # arguments, and uses legacy ECDSA for that. The test is
380 # really about the wrapper around the PSA RNG, not ECDSA.
381 'test_suite_random': [
382 'PSA classic wrapper: ECDSA signature (SECP256R1)',
383 ],
384 # In the accelerated test ECP_C is not set (only ECP_LIGHT is)
385 # so we must ignore disparities in the tests for which ECP_C
386 # is required.
387 'test_suite_ecp': [
388 re.compile(r'ECP check public-private .*'),
389 re.compile(r'ECP calculate public: .*'),
390 re.compile(r'ECP gen keypair .*'),
391 re.compile(r'ECP point muladd .*'),
392 re.compile(r'ECP point multiplication .*'),
393 re.compile(r'ECP test vectors .*'),
394 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200395 }
396
Gilles Peskine082eade2024-10-03 18:42:37 +0200397class DriverVSReference_no_ecp_at_all(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200398 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_ecp_at_all'
399 DRIVER = 'test_psa_crypto_config_accel_ecc_no_ecp_at_all'
400 IGNORED_SUITES = [
401 # Modules replaced by drivers
402 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100403 # Unit tests for the built-in implementation
404 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200405 ]
406 IGNORED_TESTS = {
407 'test_suite_config': [
408 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
409 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
410 ],
411 'test_suite_platform': [
412 # Incompatible with sanitizers (e.g. ASan). If the driver
413 # component uses a sanitizer but the reference component
414 # doesn't, we have a PASS vs SKIP mismatch.
415 'Check mbedtls_calloc overallocation',
416 ],
417 # See ecp_light_only
418 'test_suite_random': [
419 'PSA classic wrapper: ECDSA signature (SECP256R1)',
420 ],
421 'test_suite_pkparse': [
422 # When PK_PARSE_C and ECP_C are defined then PK_PARSE_EC_COMPRESSED
423 # is automatically enabled in build_info.h (backward compatibility)
424 # even if it is disabled in config_psa_crypto_no_ecp_at_all(). As a
425 # consequence compressed points are supported in the reference
426 # component but not in the accelerated one, so they should be skipped
427 # while checking driver's coverage.
428 re.compile(r'Parse EC Key .*compressed\)'),
429 re.compile(r'Parse Public EC Key .*compressed\)'),
430 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200431 }
432
Gilles Peskine082eade2024-10-03 18:42:37 +0200433class DriverVSReference_ecc_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200434 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_bignum'
435 DRIVER = 'test_psa_crypto_config_accel_ecc_no_bignum'
436 IGNORED_SUITES = [
437 # Modules replaced by drivers
438 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
439 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
440 'bignum.generated', 'bignum.misc',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100441 # Unit tests for the built-in implementation
442 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200443 ]
444 IGNORED_TESTS = {
445 'test_suite_config': [
446 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
447 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
448 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
449 ],
450 'test_suite_platform': [
451 # Incompatible with sanitizers (e.g. ASan). If the driver
452 # component uses a sanitizer but the reference component
453 # doesn't, we have a PASS vs SKIP mismatch.
454 'Check mbedtls_calloc overallocation',
455 ],
456 # See ecp_light_only
457 'test_suite_random': [
458 'PSA classic wrapper: ECDSA signature (SECP256R1)',
459 ],
460 # See no_ecp_at_all
461 'test_suite_pkparse': [
462 re.compile(r'Parse EC Key .*compressed\)'),
463 re.compile(r'Parse Public EC Key .*compressed\)'),
464 ],
465 'test_suite_asn1parse': [
466 'INTEGER too large for mpi',
467 ],
468 'test_suite_asn1write': [
469 re.compile(r'ASN.1 Write mpi.*'),
470 ],
471 'test_suite_debug': [
472 re.compile(r'Debug print mbedtls_mpi.*'),
473 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200474 }
475
Gilles Peskine082eade2024-10-03 18:42:37 +0200476class DriverVSReference_ecc_ffdh_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200477 REFERENCE = 'test_psa_crypto_config_reference_ecc_ffdh_no_bignum'
478 DRIVER = 'test_psa_crypto_config_accel_ecc_ffdh_no_bignum'
479 IGNORED_SUITES = [
480 # Modules replaced by drivers
Valerio Setti461899e2025-02-12 13:34:25 +0100481 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200482 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
483 'bignum.generated', 'bignum.misc',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100484 # Unit tests for the built-in implementation
485 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200486 ]
487 IGNORED_TESTS = {
Gilles Peskine9df375b2024-09-16 20:14:26 +0200488 'test_suite_config': [
489 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
Gilles Peskine9df375b2024-09-16 20:14:26 +0200490 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
Gilles Peskine9df375b2024-09-16 20:14:26 +0200491 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
492 ],
493 'test_suite_platform': [
494 # Incompatible with sanitizers (e.g. ASan). If the driver
495 # component uses a sanitizer but the reference component
496 # doesn't, we have a PASS vs SKIP mismatch.
497 'Check mbedtls_calloc overallocation',
498 ],
499 # See ecp_light_only
500 'test_suite_random': [
501 'PSA classic wrapper: ECDSA signature (SECP256R1)',
502 ],
503 # See no_ecp_at_all
504 'test_suite_pkparse': [
505 re.compile(r'Parse EC Key .*compressed\)'),
506 re.compile(r'Parse Public EC Key .*compressed\)'),
507 ],
508 'test_suite_asn1parse': [
509 'INTEGER too large for mpi',
510 ],
511 'test_suite_asn1write': [
512 re.compile(r'ASN.1 Write mpi.*'),
513 ],
514 'test_suite_debug': [
515 re.compile(r'Debug print mbedtls_mpi.*'),
516 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200517 }
518
Gilles Peskine082eade2024-10-03 18:42:37 +0200519class DriverVSReference_ffdh_alg(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200520 REFERENCE = 'test_psa_crypto_config_reference_ffdh'
521 DRIVER = 'test_psa_crypto_config_accel_ffdh'
Gilles Peskine9df375b2024-09-16 20:14:26 +0200522 IGNORED_TESTS = {
Gilles Peskine9df375b2024-09-16 20:14:26 +0200523 'test_suite_platform': [
524 # Incompatible with sanitizers (e.g. ASan). If the driver
525 # component uses a sanitizer but the reference component
526 # doesn't, we have a PASS vs SKIP mismatch.
527 'Check mbedtls_calloc overallocation',
528 ],
529 }
530
Gilles Peskine082eade2024-10-03 18:42:37 +0200531class DriverVSReference_tfm_config(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200532 REFERENCE = 'test_tfm_config_no_p256m'
533 DRIVER = 'test_tfm_config_p256m_driver_accel_ec'
534 IGNORED_SUITES = [
535 # Modules replaced by drivers
536 'asn1parse', 'asn1write',
537 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
538 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
539 'bignum.generated', 'bignum.misc',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100540 # Unit tests for the built-in implementation
541 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200542 ]
543 IGNORED_TESTS = {
544 'test_suite_config': [
545 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
546 re.compile(r'.*\bMBEDTLS_(ASN1\w+)_C\b.*'),
547 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECP)_.*'),
548 re.compile(r'.*\bMBEDTLS_PSA_P256M_DRIVER_ENABLED\b.*')
549 ],
550 'test_suite_config.crypto_combinations': [
551 'Config: ECC: Weierstrass curves only',
552 ],
553 'test_suite_platform': [
554 # Incompatible with sanitizers (e.g. ASan). If the driver
555 # component uses a sanitizer but the reference component
556 # doesn't, we have a PASS vs SKIP mismatch.
557 'Check mbedtls_calloc overallocation',
558 ],
559 # See ecp_light_only
560 'test_suite_random': [
561 'PSA classic wrapper: ECDSA signature (SECP256R1)',
562 ],
563 }
564
Gilles Peskine082eade2024-10-03 18:42:37 +0200565class DriverVSReference_rsa(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200566 REFERENCE = 'test_psa_crypto_config_reference_rsa_crypto'
567 DRIVER = 'test_psa_crypto_config_accel_rsa_crypto'
568 IGNORED_SUITES = [
569 # Modules replaced by drivers.
570 'rsa', 'pkcs1_v15', 'pkcs1_v21',
571 # We temporarily don't care about PK stuff.
572 'pk', 'pkwrite', 'pkparse'
573 ]
574 IGNORED_TESTS = {
Ronald Cron4c481142025-07-11 17:23:41 +0200575 'test_suite_bignum.misc': [
576 re.compile(r'.*\bmbedtls_mpi_is_prime.*'),
577 re.compile(r'.*\bmbedtls_mpi_gen_prime.*'),
578 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200579 'test_suite_config': [
580 re.compile(r'.*\bMBEDTLS_(PKCS1|RSA)_.*'),
581 re.compile(r'.*\bMBEDTLS_GENPRIME\b.*')
582 ],
583 'test_suite_platform': [
584 # Incompatible with sanitizers (e.g. ASan). If the driver
585 # component uses a sanitizer but the reference component
586 # doesn't, we have a PASS vs SKIP mismatch.
587 'Check mbedtls_calloc overallocation',
588 ],
589 # Following tests depend on RSA_C but are not about
590 # them really, just need to know some error code is there.
591 'test_suite_error': [
592 'Low and high error',
593 'Single high error'
594 ],
595 # Constant time operations only used for PKCS1_V15
596 'test_suite_constant_time': [
597 re.compile(r'mbedtls_ct_zeroize_if .*'),
598 re.compile(r'mbedtls_ct_memmove_left .*')
599 ],
600 'test_suite_psa_crypto': [
601 # We don't support generate_key_custom entry points
602 # in drivers yet.
603 re.compile(r'PSA generate key custom: RSA, e=.*'),
604 re.compile(r'PSA generate key ext: RSA, e=.*'),
605 ],
606 }
607
Gilles Peskine082eade2024-10-03 18:42:37 +0200608class DriverVSReference_block_cipher_dispatch(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200609 REFERENCE = 'test_full_block_cipher_legacy_dispatch'
610 DRIVER = 'test_full_block_cipher_psa_dispatch'
611 IGNORED_SUITES = [
612 # Skipped in the accelerated component
613 'aes', 'aria', 'camellia',
614 # These require AES_C, ARIA_C or CAMELLIA_C to be enabled in
615 # order for the cipher module (actually cipher_wrapper) to work
616 # properly. However these symbols are disabled in the accelerated
617 # component so we ignore them.
618 'cipher.ccm', 'cipher.gcm', 'cipher.aes', 'cipher.aria',
619 'cipher.camellia',
620 ]
621 IGNORED_TESTS = {
622 'test_suite_config': [
623 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA)_.*'),
624 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
625 ],
626 'test_suite_cmac': [
627 # Following tests require AES_C/ARIA_C/CAMELLIA_C to be enabled,
628 # but these are not available in the accelerated component.
629 'CMAC null arguments',
630 re.compile('CMAC.* (AES|ARIA|Camellia).*'),
631 ],
632 'test_suite_cipher.padding': [
633 # Following tests require AES_C/CAMELLIA_C to be enabled,
634 # but these are not available in the accelerated component.
635 re.compile('Set( non-existent)? padding with (AES|CAMELLIA).*'),
636 ],
637 'test_suite_pkcs5': [
638 # The AES part of PKCS#5 PBES2 is not yet supported.
639 # The rest of PKCS#5 (PBKDF2) works, though.
640 re.compile(r'PBES2 .* AES-.*')
641 ],
642 'test_suite_pkparse': [
643 # PEM (called by pkparse) requires AES_C in order to decrypt
644 # the key, but this is not available in the accelerated
645 # component.
646 re.compile('Parse RSA Key.*(password|AES-).*'),
647 ],
648 'test_suite_pem': [
649 # Following tests require AES_C, but this is diabled in the
650 # accelerated component.
651 re.compile('PEM read .*AES.*'),
652 'PEM read (unknown encryption algorithm)',
653 ],
654 'test_suite_error': [
655 # Following tests depend on AES_C but are not about them
656 # really, just need to know some error code is there.
657 'Single low error',
658 'Low and high error',
659 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200660 'test_suite_platform': [
661 # Incompatible with sanitizers (e.g. ASan). If the driver
662 # component uses a sanitizer but the reference component
663 # doesn't, we have a PASS vs SKIP mismatch.
664 'Check mbedtls_calloc overallocation',
665 ],
666 }
667
668#pylint: enable=invalid-name,missing-class-docstring
669
670
Przemek Stekiel6856f4c2022-11-09 10:50:29 +0100671# List of tasks with a function that can handle this task and additional arguments if required
Valerio Settidfd7ca62023-10-09 16:30:11 +0200672KNOWN_TASKS = {
Gilles Peskinef646dbf2024-09-16 19:15:29 +0200673 'analyze_coverage': CoverageTask,
Gilles Peskine9df375b2024-09-16 20:14:26 +0200674 'analyze_driver_vs_reference_hash': DriverVSReference_hash,
675 'analyze_driver_vs_reference_hmac': DriverVSReference_hmac,
676 'analyze_driver_vs_reference_cipher_aead_cmac': DriverVSReference_cipher_aead_cmac,
677 'analyze_driver_vs_reference_ecp_light_only': DriverVSReference_ecp_light_only,
678 'analyze_driver_vs_reference_no_ecp_at_all': DriverVSReference_no_ecp_at_all,
679 'analyze_driver_vs_reference_ecc_no_bignum': DriverVSReference_ecc_no_bignum,
680 'analyze_driver_vs_reference_ecc_ffdh_no_bignum': DriverVSReference_ecc_ffdh_no_bignum,
681 'analyze_driver_vs_reference_ffdh_alg': DriverVSReference_ffdh_alg,
682 'analyze_driver_vs_reference_tfm_config': DriverVSReference_tfm_config,
683 'analyze_driver_vs_reference_rsa': DriverVSReference_rsa,
684 'analyze_block_cipher_dispatch': DriverVSReference_block_cipher_dispatch,
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200685}
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200686
Gilles Peskine15c2cbf2020-06-25 18:36:28 +0200687if __name__ == '__main__':
Gilles Peskine082eade2024-10-03 18:42:37 +0200688 outcome_analysis.main(KNOWN_TASKS)