blob: 720143292bed62e97442064b4dc5f124064efd1b [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 Peskined8da2fc2024-09-17 15:07:22 +020010import typing
Gilles Peskine15c2cbf2020-06-25 18:36:28 +020011
Gilles Peskine738a5972024-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 Peskine45a32b12024-10-03 18:42:37 +020016class CoverageTask(outcome_analysis.CoverageTask):
Gilles Peskine4e606db2024-10-04 16:24:26 +020017 """Justify test cases that are never executed."""
Gilles Peskine95b2b0c2024-09-16 20:23:40 +020018
Gilles Peskined8da2fc2024-09-17 15:07:22 +020019 @staticmethod
Gilles Peskine72396da2024-09-17 17:15:29 +020020 def _has_word_re(words: typing.Iterable[str],
21 exclude: typing.Optional[str] = None) -> typing.Pattern:
Gilles Peskined8da2fc2024-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 Peskine72396da2024-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 Peskined8da2fc2024-09-17 15:07:22 +020028 """
Gilles Peskine72396da2024-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 Peskine1abc8002024-10-11 12:00:44 +020034 re.DOTALL)
Gilles Peskined8da2fc2024-09-17 15:07:22 +020035
Gilles Peskined8da2fc2024-09-17 15:07:22 +020036 IGNORED_TESTS = {
Gilles Peskine419a5842024-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 Peskine419a5842024-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)',
50 # It seems that we don't run `ssl-opt.sh` with
51 # `MBEDTLS_USE_PSA_CRYPTO` enabled but `MBEDTLS_SSL_ASYNC_PRIVATE`
52 # disabled.
53 # https://github.com/Mbed-TLS/mbedtls/issues/9581
54 'Opaque key for server authentication: invalid key: decrypt with ECC key, no async',
55 'Opaque key for server authentication: invalid key: ecdh with RSA key, no async',
Minos Galanakis21e4f212025-02-27 11:45:02 +000056 # Temporary disable Handshake defragmentation tests until mbedtls
57 # pr #10011 has been merged.
58 'Handshake defragmentation on client: len=4, TLS 1.2',
59 'Handshake defragmentation on client: len=5, TLS 1.2',
60 'Handshake defragmentation on client: len=13, TLS 1.2'
Gilles Peskine419a5842024-09-17 18:32:05 +020061 ],
Gilles Peskine47243fd2024-09-17 19:46:18 +020062 'test_suite_config.mbedtls_boolean': [
63 # We never test with CBC/PKCS5/PKCS12 enabled but
64 # PKCS7 padding disabled.
65 # https://github.com/Mbed-TLS/mbedtls/issues/9580
66 'Config: !MBEDTLS_CIPHER_PADDING_PKCS7',
67 # https://github.com/Mbed-TLS/mbedtls/issues/9583
68 'Config: !MBEDTLS_ECP_NIST_OPTIM',
Gilles Peskine44fdd922024-10-10 18:19:23 +020069 # MBEDTLS_ECP_NO_FALLBACK only affects builds using a partial
70 # alternative implementation of ECP arithmetic (with
71 # MBEDTLS_ECP_INTERNAL_ALT enabled). We don't test those builds.
72 # The configuration enumeration script skips xxx_ALT options
73 # but not MBEDTLS_ECP_NO_FALLBACK, so it appears in the report,
74 # but we don't care about it.
75 'Config: MBEDTLS_ECP_NO_FALLBACK',
Gilles Peskine47243fd2024-09-17 19:46:18 +020076 # Missing coverage of test configurations.
77 # https://github.com/Mbed-TLS/mbedtls/issues/9585
78 'Config: !MBEDTLS_SSL_DTLS_ANTI_REPLAY',
79 # Missing coverage of test configurations.
80 # https://github.com/Mbed-TLS/mbedtls/issues/9585
81 'Config: !MBEDTLS_SSL_DTLS_HELLO_VERIFY',
82 # We don't run test_suite_config when we test this.
83 # https://github.com/Mbed-TLS/mbedtls/issues/9586
84 'Config: !MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED',
85 # We only test multithreading with pthreads.
86 # https://github.com/Mbed-TLS/mbedtls/issues/9584
87 'Config: !MBEDTLS_THREADING_PTHREAD',
88 # Built but not tested.
89 # https://github.com/Mbed-TLS/mbedtls/issues/9587
90 'Config: MBEDTLS_AES_USE_HARDWARE_ONLY',
91 # Untested platform-specific optimizations.
92 # https://github.com/Mbed-TLS/mbedtls/issues/9588
93 'Config: MBEDTLS_HAVE_SSE2',
94 # Obsolete configuration option, to be replaced by
95 # PSA entropy drivers.
96 # https://github.com/Mbed-TLS/mbedtls/issues/8150
97 'Config: MBEDTLS_NO_PLATFORM_ENTROPY',
98 # Untested aspect of the platform interface.
99 # https://github.com/Mbed-TLS/mbedtls/issues/9589
100 'Config: MBEDTLS_PLATFORM_NO_STD_FUNCTIONS',
101 # In a client-server build, test_suite_config runs in the
102 # client configuration, so it will never report
103 # MBEDTLS_PSA_CRYPTO_SPM as enabled. That's ok.
104 'Config: MBEDTLS_PSA_CRYPTO_SPM',
105 # We don't test on armv8 yet.
106 'Config: MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT',
107 'Config: MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY',
108 'Config: MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY',
109 'Config: MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY',
110 # We don't run test_suite_config when we test this.
111 # https://github.com/Mbed-TLS/mbedtls/issues/9586
112 'Config: MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND',
113 ],
114 'test_suite_config.psa_boolean': [
115 # We don't test with HMAC disabled.
116 # https://github.com/Mbed-TLS/mbedtls/issues/9591
117 'Config: !PSA_WANT_ALG_HMAC',
Gilles Peskine47243fd2024-09-17 19:46:18 +0200118 # The DERIVE key type is always enabled.
119 'Config: !PSA_WANT_KEY_TYPE_DERIVE',
120 # More granularity of key pair type enablement macros
121 # than we care to test.
122 # https://github.com/Mbed-TLS/mbedtls/issues/9590
123 'Config: !PSA_WANT_KEY_TYPE_DH_KEY_PAIR_EXPORT',
124 'Config: !PSA_WANT_KEY_TYPE_DH_KEY_PAIR_GENERATE',
125 'Config: !PSA_WANT_KEY_TYPE_DH_KEY_PAIR_IMPORT',
126 # More granularity of key pair type enablement macros
127 # than we care to test.
128 # https://github.com/Mbed-TLS/mbedtls/issues/9590
129 'Config: !PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT',
130 'Config: !PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT',
131 # We don't test with HMAC disabled.
132 # https://github.com/Mbed-TLS/mbedtls/issues/9591
133 'Config: !PSA_WANT_KEY_TYPE_HMAC',
134 # The PASSWORD key type is always enabled.
135 'Config: !PSA_WANT_KEY_TYPE_PASSWORD',
136 # The PASSWORD_HASH key type is always enabled.
137 'Config: !PSA_WANT_KEY_TYPE_PASSWORD_HASH',
138 # The RAW_DATA key type is always enabled.
139 'Config: !PSA_WANT_KEY_TYPE_RAW_DATA',
140 # More granularity of key pair type enablement macros
141 # than we care to test.
142 # https://github.com/Mbed-TLS/mbedtls/issues/9590
143 'Config: !PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_EXPORT',
144 'Config: !PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT',
145 # Algorithm declared but not supported.
146 'Config: PSA_WANT_ALG_CBC_MAC',
147 # Algorithm declared but not supported.
148 'Config: PSA_WANT_ALG_XTS',
149 # Family declared but not supported.
150 'Config: PSA_WANT_ECC_SECP_K1_224',
151 # More granularity of key pair type enablement macros
152 # than we care to test.
153 # https://github.com/Mbed-TLS/mbedtls/issues/9590
154 'Config: PSA_WANT_KEY_TYPE_DH_KEY_PAIR_DERIVE',
155 'Config: PSA_WANT_KEY_TYPE_ECC_KEY_PAIR',
156 'Config: PSA_WANT_KEY_TYPE_RSA_KEY_PAIR',
157 'Config: PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_DERIVE',
158 ],
159 'test_suite_config.psa_combinations': [
160 # We don't test this unusual, but sensible configuration.
161 # https://github.com/Mbed-TLS/mbedtls/issues/9592
162 'Config: PSA_WANT_ALG_DETERMINSTIC_ECDSA without PSA_WANT_ALG_ECDSA',
163 ],
Gilles Peskine1a176272024-09-17 18:33:29 +0200164 'test_suite_pkcs12': [
Gilles Peskine47243fd2024-09-17 19:46:18 +0200165 # We never test with CBC/PKCS5/PKCS12 enabled but
166 # PKCS7 padding disabled.
Gilles Peskine1a176272024-09-17 18:33:29 +0200167 # https://github.com/Mbed-TLS/mbedtls/issues/9580
168 'PBE Decrypt, (Invalid padding & PKCS7 padding disabled)',
169 'PBE Encrypt, pad = 8 (PKCS7 padding disabled)',
170 ],
171 'test_suite_pkcs5': [
Gilles Peskine47243fd2024-09-17 19:46:18 +0200172 # We never test with CBC/PKCS5/PKCS12 enabled but
173 # PKCS7 padding disabled.
Gilles Peskine1a176272024-09-17 18:33:29 +0200174 # https://github.com/Mbed-TLS/mbedtls/issues/9580
175 'PBES2 Decrypt (Invalid padding & PKCS7 padding disabled)',
176 'PBES2 Encrypt, pad=6 (PKCS7 padding disabled)',
177 'PBES2 Encrypt, pad=8 (PKCS7 padding disabled)',
178 ],
Gilles Peskine8729b102024-04-19 19:08:34 +0200179 'test_suite_psa_crypto': [
180 # We don't test this unusual, but sensible configuration.
181 # https://github.com/Mbed-TLS/mbedtls/issues/9592
182 re.compile(r'.*ECDSA.*only deterministic supported'),
183 ],
Gilles Peskine1a176272024-09-17 18:33:29 +0200184 'test_suite_psa_crypto_metadata': [
185 # Algorithms declared but not supported.
186 # https://github.com/Mbed-TLS/mbedtls/issues/9579
187 'Asymmetric signature: Ed25519ph',
188 'Asymmetric signature: Ed448ph',
189 'Asymmetric signature: pure EdDSA',
190 'Cipher: XTS',
191 'MAC: CBC_MAC-3DES',
192 'MAC: CBC_MAC-AES-128',
193 'MAC: CBC_MAC-AES-192',
194 'MAC: CBC_MAC-AES-256',
195 ],
Gilles Peskined8da2fc2024-09-17 15:07:22 +0200196 'test_suite_psa_crypto_not_supported.generated': [
Gilles Peskine1abc8002024-10-11 12:00:44 +0200197 # We never test with DH key support disabled but support
Gilles Peskine1fac3712024-09-17 17:57:11 +0200198 # for a DH group enabled. The dependencies of these test
199 # cases don't really make sense.
200 # https://github.com/Mbed-TLS/mbedtls/issues/9574
201 re.compile(r'PSA \w+ DH_.*type not supported'),
202 # We only test partial support for DH with the 2048-bit group
203 # enabled and the other groups disabled.
204 # https://github.com/Mbed-TLS/mbedtls/issues/9575
205 'PSA generate DH_KEY_PAIR(RFC7919) 2048-bit group not supported',
206 'PSA import DH_KEY_PAIR(RFC7919) 2048-bit group not supported',
207 'PSA import DH_PUBLIC_KEY(RFC7919) 2048-bit group not supported',
Gilles Peskined8da2fc2024-09-17 15:07:22 +0200208 ],
209 'test_suite_psa_crypto_op_fail.generated': [
Gilles Peskine8729b102024-04-19 19:08:34 +0200210 # We don't test this unusual, but sensible configuration.
211 # https://github.com/Mbed-TLS/mbedtls/issues/9592
212 re.compile(r'.*: !ECDSA but DETERMINISTIC_ECDSA with ECC_.*'),
Gilles Peskine1fac3712024-09-17 17:57:11 +0200213 # PBKDF2_HMAC is not in the default configuration, so we don't
214 # enable it in depends.py where we remove hashes.
215 # https://github.com/Mbed-TLS/mbedtls/issues/9576
216 re.compile(r'PSA key_derivation PBKDF2_HMAC\(\w+\): !(?!PBKDF2_HMAC\Z).*'),
Gilles Peskine1fac3712024-09-17 17:57:11 +0200217
218 # We never test with the HMAC algorithm enabled but the HMAC
219 # key type disabled. Those dependencies don't really make sense.
220 # https://github.com/Mbed-TLS/mbedtls/issues/9573
221 re.compile(r'.* !HMAC with HMAC'),
222 # There's something wrong with PSA_WANT_ALG_RSA_PSS_ANY_SALT
223 # differing from PSA_WANT_ALG_RSA_PSS.
224 # https://github.com/Mbed-TLS/mbedtls/issues/9578
225 re.compile(r'PSA sign RSA_PSS_ANY_SALT.*!(?:MD|RIPEMD|SHA).*'),
Gilles Peskinea6c1f562025-01-16 19:49:12 +0100226 # We don't test with ECDH disabled but the key type enabled.
227 # https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/161
228 re.compile(r'PSA key_agreement.* !ECDH with ECC_KEY_PAIR\(.*'),
229 # We don't test with FFDH disabled but the key type enabled.
230 # https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/160
231 re.compile(r'PSA key_agreement.* !FFDH with DH_KEY_PAIR\(.*'),
Gilles Peskined8da2fc2024-09-17 15:07:22 +0200232 ],
Gilles Peskine8729b102024-04-19 19:08:34 +0200233 'test_suite_psa_crypto_op_fail.misc': [
234 # We don't test this unusual, but sensible configuration.
235 # https://github.com/Mbed-TLS/mbedtls/issues/9592
236 'PSA sign DETERMINISTIC_ECDSA(SHA_256): !ECDSA but DETERMINISTIC_ECDSA with ECC_KEY_PAIR(SECP_R1)', #pylint: disable=line-too-long
237 ],
Gilles Peskine419a5842024-09-17 18:32:05 +0200238 'tls13-misc': [
239 # Disabled due to OpenSSL bug.
240 # https://github.com/openssl/openssl/issues/10714
241 'TLS 1.3 O->m: resumption',
242 # Disabled due to OpenSSL command line limitation.
243 # https://github.com/Mbed-TLS/mbedtls/issues/9582
244 'TLS 1.3 m->O: resumption with early data',
245 ],
Gilles Peskined8da2fc2024-09-17 15:07:22 +0200246 }
247
Gilles Peskine17e071b2024-09-16 19:57:10 +0200248
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200249# The names that we give to classes derived from DriverVSReference do not
250# follow the usual naming convention, because it's more readable to use
251# underscores and parts of the configuration names. Also, these classes
252# are just there to specify some data, so they don't need repetitive
253# documentation.
254#pylint: disable=invalid-name,missing-class-docstring
255
Gilles Peskine45a32b12024-10-03 18:42:37 +0200256class DriverVSReference_hash(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200257 REFERENCE = 'test_psa_crypto_config_reference_hash_use_psa'
258 DRIVER = 'test_psa_crypto_config_accel_hash_use_psa'
259 IGNORED_SUITES = [
260 'shax', 'mdx', # the software implementations that are being excluded
261 'md.psa', # purposefully depends on whether drivers are present
262 'psa_crypto_low_hash.generated', # testing the builtins
263 ]
264 IGNORED_TESTS = {
265 'test_suite_config': [
266 re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'),
267 ],
268 'test_suite_platform': [
269 # Incompatible with sanitizers (e.g. ASan). If the driver
270 # component uses a sanitizer but the reference component
271 # doesn't, we have a PASS vs SKIP mismatch.
272 'Check mbedtls_calloc overallocation',
273 ],
274 }
275
Gilles Peskine45a32b12024-10-03 18:42:37 +0200276class DriverVSReference_hmac(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200277 REFERENCE = 'test_psa_crypto_config_reference_hmac'
278 DRIVER = 'test_psa_crypto_config_accel_hmac'
279 IGNORED_SUITES = [
280 # These suites require legacy hash support, which is disabled
281 # in the accelerated component.
282 'shax', 'mdx',
283 # This suite tests builtins directly, but these are missing
284 # in the accelerated case.
285 'psa_crypto_low_hash.generated',
286 ]
287 IGNORED_TESTS = {
288 'test_suite_config': [
289 re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'),
290 re.compile(r'.*\bMBEDTLS_MD_C\b')
291 ],
292 'test_suite_md': [
293 # Builtin HMAC is not supported in the accelerate component.
294 re.compile('.*HMAC.*'),
295 # Following tests make use of functions which are not available
296 # when MD_C is disabled, as it happens in the accelerated
297 # test component.
298 re.compile('generic .* Hash file .*'),
299 'MD list',
300 ],
301 'test_suite_md.psa': [
302 # "legacy only" tests require hash algorithms to be NOT
303 # accelerated, but this of course false for the accelerated
304 # test component.
305 re.compile('PSA dispatch .* legacy only'),
306 ],
307 'test_suite_platform': [
308 # Incompatible with sanitizers (e.g. ASan). If the driver
309 # component uses a sanitizer but the reference component
310 # doesn't, we have a PASS vs SKIP mismatch.
311 'Check mbedtls_calloc overallocation',
312 ],
313 }
314
Gilles Peskine45a32b12024-10-03 18:42:37 +0200315class DriverVSReference_cipher_aead_cmac(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200316 REFERENCE = 'test_psa_crypto_config_reference_cipher_aead_cmac'
317 DRIVER = 'test_psa_crypto_config_accel_cipher_aead_cmac'
318 # Modules replaced by drivers.
319 IGNORED_SUITES = [
320 # low-level (block/stream) cipher modules
321 'aes', 'aria', 'camellia', 'des', 'chacha20',
322 # AEAD modes and CMAC
323 'ccm', 'chachapoly', 'cmac', 'gcm',
324 # The Cipher abstraction layer
325 'cipher',
326 ]
327 IGNORED_TESTS = {
328 'test_suite_config': [
329 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA|CHACHA20|DES)_.*'),
330 re.compile(r'.*\bMBEDTLS_(CCM|CHACHAPOLY|CMAC|GCM)_.*'),
331 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
332 re.compile(r'.*\bMBEDTLS_CIPHER_.*'),
333 ],
334 # PEM decryption is not supported so far.
335 # The rest of PEM (write, unencrypted read) works though.
336 'test_suite_pem': [
337 re.compile(r'PEM read .*(AES|DES|\bencrypt).*'),
338 ],
339 'test_suite_platform': [
340 # Incompatible with sanitizers (e.g. ASan). If the driver
341 # component uses a sanitizer but the reference component
342 # doesn't, we have a PASS vs SKIP mismatch.
343 'Check mbedtls_calloc overallocation',
344 ],
345 # Following tests depend on AES_C/DES_C but are not about
346 # them really, just need to know some error code is there.
347 'test_suite_error': [
348 'Low and high error',
349 'Single low error'
350 ],
351 # Similar to test_suite_error above.
352 'test_suite_version': [
353 'Check for MBEDTLS_AES_C when already present',
354 ],
355 # The en/decryption part of PKCS#12 is not supported so far.
356 # The rest of PKCS#12 (key derivation) works though.
357 'test_suite_pkcs12': [
358 re.compile(r'PBE Encrypt, .*'),
359 re.compile(r'PBE Decrypt, .*'),
360 ],
361 # The en/decryption part of PKCS#5 is not supported so far.
362 # The rest of PKCS#5 (PBKDF2) works though.
363 'test_suite_pkcs5': [
364 re.compile(r'PBES2 Encrypt, .*'),
365 re.compile(r'PBES2 Decrypt .*'),
366 ],
367 # Encrypted keys are not supported so far.
368 # pylint: disable=line-too-long
369 'test_suite_pkparse': [
370 'Key ASN1 (Encrypted key PKCS12, trailing garbage data)',
371 'Key ASN1 (Encrypted key PKCS5, trailing garbage data)',
372 re.compile(r'Parse (RSA|EC) Key .*\(.* ([Ee]ncrypted|password).*\)'),
373 ],
374 # Encrypted keys are not supported so far.
375 'ssl-opt': [
376 'TLS: password protected server key',
377 'TLS: password protected client key',
378 'TLS: password protected server key, two certificates',
379 ],
380 }
381
Gilles Peskine45a32b12024-10-03 18:42:37 +0200382class DriverVSReference_ecp_light_only(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200383 REFERENCE = 'test_psa_crypto_config_reference_ecc_ecp_light_only'
384 DRIVER = 'test_psa_crypto_config_accel_ecc_ecp_light_only'
385 IGNORED_SUITES = [
386 # Modules replaced by drivers
387 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine9a094432024-10-29 20:55:11 +0100388 # Unit tests for the built-in implementation
389 'psa_crypto_ecp',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200390 ]
391 IGNORED_TESTS = {
392 'test_suite_config': [
393 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
394 ],
395 'test_suite_platform': [
396 # Incompatible with sanitizers (e.g. ASan). If the driver
397 # component uses a sanitizer but the reference component
398 # doesn't, we have a PASS vs SKIP mismatch.
399 'Check mbedtls_calloc overallocation',
400 ],
401 # This test wants a legacy function that takes f_rng, p_rng
402 # arguments, and uses legacy ECDSA for that. The test is
403 # really about the wrapper around the PSA RNG, not ECDSA.
404 'test_suite_random': [
405 'PSA classic wrapper: ECDSA signature (SECP256R1)',
406 ],
407 # In the accelerated test ECP_C is not set (only ECP_LIGHT is)
408 # so we must ignore disparities in the tests for which ECP_C
409 # is required.
410 'test_suite_ecp': [
411 re.compile(r'ECP check public-private .*'),
412 re.compile(r'ECP calculate public: .*'),
413 re.compile(r'ECP gen keypair .*'),
414 re.compile(r'ECP point muladd .*'),
415 re.compile(r'ECP point multiplication .*'),
416 re.compile(r'ECP test vectors .*'),
417 ],
418 'test_suite_ssl': [
419 # This deprecated function is only present when ECP_C is On.
Valerio Setti1a0ee062025-01-22 11:03:46 +0100420 'Test configuration of EC groups through mbedtls_ssl_conf_curves()',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200421 ],
422 }
423
Gilles Peskine45a32b12024-10-03 18:42:37 +0200424class DriverVSReference_no_ecp_at_all(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200425 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_ecp_at_all'
426 DRIVER = 'test_psa_crypto_config_accel_ecc_no_ecp_at_all'
427 IGNORED_SUITES = [
428 # Modules replaced by drivers
429 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine9a094432024-10-29 20:55:11 +0100430 # Unit tests for the built-in implementation
431 'psa_crypto_ecp',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200432 ]
433 IGNORED_TESTS = {
434 'test_suite_config': [
435 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
436 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
437 ],
438 'test_suite_platform': [
439 # Incompatible with sanitizers (e.g. ASan). If the driver
440 # component uses a sanitizer but the reference component
441 # doesn't, we have a PASS vs SKIP mismatch.
442 'Check mbedtls_calloc overallocation',
443 ],
444 # See ecp_light_only
445 'test_suite_random': [
446 'PSA classic wrapper: ECDSA signature (SECP256R1)',
447 ],
448 'test_suite_pkparse': [
449 # When PK_PARSE_C and ECP_C are defined then PK_PARSE_EC_COMPRESSED
450 # is automatically enabled in build_info.h (backward compatibility)
451 # even if it is disabled in config_psa_crypto_no_ecp_at_all(). As a
452 # consequence compressed points are supported in the reference
453 # component but not in the accelerated one, so they should be skipped
454 # while checking driver's coverage.
455 re.compile(r'Parse EC Key .*compressed\)'),
456 re.compile(r'Parse Public EC Key .*compressed\)'),
457 ],
458 # See ecp_light_only
459 'test_suite_ssl': [
Valerio Setti1a0ee062025-01-22 11:03:46 +0100460 'Test configuration of EC groups through mbedtls_ssl_conf_curves()',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200461 ],
462 }
463
Gilles Peskine45a32b12024-10-03 18:42:37 +0200464class DriverVSReference_ecc_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200465 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_bignum'
466 DRIVER = 'test_psa_crypto_config_accel_ecc_no_bignum'
467 IGNORED_SUITES = [
468 # Modules replaced by drivers
469 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
470 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
471 'bignum.generated', 'bignum.misc',
Gilles Peskine9a094432024-10-29 20:55:11 +0100472 # Unit tests for the built-in implementation
473 'psa_crypto_ecp',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200474 ]
475 IGNORED_TESTS = {
476 'test_suite_config': [
477 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
478 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
479 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
480 ],
481 'test_suite_platform': [
482 # Incompatible with sanitizers (e.g. ASan). If the driver
483 # component uses a sanitizer but the reference component
484 # doesn't, we have a PASS vs SKIP mismatch.
485 'Check mbedtls_calloc overallocation',
486 ],
487 # See ecp_light_only
488 'test_suite_random': [
489 'PSA classic wrapper: ECDSA signature (SECP256R1)',
490 ],
491 # See no_ecp_at_all
492 'test_suite_pkparse': [
493 re.compile(r'Parse EC Key .*compressed\)'),
494 re.compile(r'Parse Public EC Key .*compressed\)'),
495 ],
496 'test_suite_asn1parse': [
497 'INTEGER too large for mpi',
498 ],
499 'test_suite_asn1write': [
500 re.compile(r'ASN.1 Write mpi.*'),
501 ],
502 'test_suite_debug': [
503 re.compile(r'Debug print mbedtls_mpi.*'),
504 ],
505 # See ecp_light_only
506 'test_suite_ssl': [
Valerio Setti1a0ee062025-01-22 11:03:46 +0100507 'Test configuration of EC groups through mbedtls_ssl_conf_curves()',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200508 ],
509 }
510
Gilles Peskine45a32b12024-10-03 18:42:37 +0200511class DriverVSReference_ecc_ffdh_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200512 REFERENCE = 'test_psa_crypto_config_reference_ecc_ffdh_no_bignum'
513 DRIVER = 'test_psa_crypto_config_accel_ecc_ffdh_no_bignum'
514 IGNORED_SUITES = [
515 # Modules replaced by drivers
516 'ecp', 'ecdsa', 'ecdh', 'ecjpake', 'dhm',
517 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
518 'bignum.generated', 'bignum.misc',
Gilles Peskine9a094432024-10-29 20:55:11 +0100519 # Unit tests for the built-in implementation
520 'psa_crypto_ecp',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200521 ]
522 IGNORED_TESTS = {
523 'ssl-opt': [
524 # DHE support in TLS 1.2 requires built-in MBEDTLS_DHM_C
525 # (because it needs custom groups, which PSA does not
526 # provide), even with MBEDTLS_USE_PSA_CRYPTO.
527 re.compile(r'PSK callback:.*\bdhe-psk\b.*'),
528 ],
529 'test_suite_config': [
530 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
531 re.compile(r'.*\bMBEDTLS_DHM_C\b.*'),
532 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
533 re.compile(r'.*\bMBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED\b.*'),
534 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
535 ],
536 'test_suite_platform': [
537 # Incompatible with sanitizers (e.g. ASan). If the driver
538 # component uses a sanitizer but the reference component
539 # doesn't, we have a PASS vs SKIP mismatch.
540 'Check mbedtls_calloc overallocation',
541 ],
542 # See ecp_light_only
543 'test_suite_random': [
544 'PSA classic wrapper: ECDSA signature (SECP256R1)',
545 ],
546 # See no_ecp_at_all
547 'test_suite_pkparse': [
548 re.compile(r'Parse EC Key .*compressed\)'),
549 re.compile(r'Parse Public EC Key .*compressed\)'),
550 ],
551 'test_suite_asn1parse': [
552 'INTEGER too large for mpi',
553 ],
554 'test_suite_asn1write': [
555 re.compile(r'ASN.1 Write mpi.*'),
556 ],
557 'test_suite_debug': [
558 re.compile(r'Debug print mbedtls_mpi.*'),
559 ],
560 # See ecp_light_only
561 'test_suite_ssl': [
Valerio Setti1a0ee062025-01-22 11:03:46 +0100562 'Test configuration of EC groups through mbedtls_ssl_conf_curves()',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200563 ],
564 }
565
Gilles Peskine45a32b12024-10-03 18:42:37 +0200566class DriverVSReference_ffdh_alg(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200567 REFERENCE = 'test_psa_crypto_config_reference_ffdh'
568 DRIVER = 'test_psa_crypto_config_accel_ffdh'
569 IGNORED_SUITES = ['dhm']
570 IGNORED_TESTS = {
571 'test_suite_config': [
572 re.compile(r'.*\bMBEDTLS_DHM_C\b.*'),
573 ],
574 'test_suite_platform': [
575 # Incompatible with sanitizers (e.g. ASan). If the driver
576 # component uses a sanitizer but the reference component
577 # doesn't, we have a PASS vs SKIP mismatch.
578 'Check mbedtls_calloc overallocation',
579 ],
580 }
581
Gilles Peskine45a32b12024-10-03 18:42:37 +0200582class DriverVSReference_tfm_config(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200583 REFERENCE = 'test_tfm_config_no_p256m'
584 DRIVER = 'test_tfm_config_p256m_driver_accel_ec'
585 IGNORED_SUITES = [
586 # Modules replaced by drivers
587 'asn1parse', 'asn1write',
588 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
589 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
590 'bignum.generated', 'bignum.misc',
Gilles Peskine9a094432024-10-29 20:55:11 +0100591 # Unit tests for the built-in implementation
592 'psa_crypto_ecp',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200593 ]
594 IGNORED_TESTS = {
595 'test_suite_config': [
596 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
597 re.compile(r'.*\bMBEDTLS_(ASN1\w+)_C\b.*'),
598 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECP)_.*'),
599 re.compile(r'.*\bMBEDTLS_PSA_P256M_DRIVER_ENABLED\b.*')
600 ],
601 'test_suite_config.crypto_combinations': [
602 'Config: ECC: Weierstrass curves only',
603 ],
604 'test_suite_platform': [
605 # Incompatible with sanitizers (e.g. ASan). If the driver
606 # component uses a sanitizer but the reference component
607 # doesn't, we have a PASS vs SKIP mismatch.
608 'Check mbedtls_calloc overallocation',
609 ],
610 # See ecp_light_only
611 'test_suite_random': [
612 'PSA classic wrapper: ECDSA signature (SECP256R1)',
613 ],
614 }
615
Gilles Peskine45a32b12024-10-03 18:42:37 +0200616class DriverVSReference_rsa(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200617 REFERENCE = 'test_psa_crypto_config_reference_rsa_crypto'
618 DRIVER = 'test_psa_crypto_config_accel_rsa_crypto'
619 IGNORED_SUITES = [
620 # Modules replaced by drivers.
621 'rsa', 'pkcs1_v15', 'pkcs1_v21',
622 # We temporarily don't care about PK stuff.
623 'pk', 'pkwrite', 'pkparse'
624 ]
625 IGNORED_TESTS = {
626 'test_suite_config': [
627 re.compile(r'.*\bMBEDTLS_(PKCS1|RSA)_.*'),
628 re.compile(r'.*\bMBEDTLS_GENPRIME\b.*')
629 ],
630 'test_suite_platform': [
631 # Incompatible with sanitizers (e.g. ASan). If the driver
632 # component uses a sanitizer but the reference component
633 # doesn't, we have a PASS vs SKIP mismatch.
634 'Check mbedtls_calloc overallocation',
635 ],
636 # Following tests depend on RSA_C but are not about
637 # them really, just need to know some error code is there.
638 'test_suite_error': [
639 'Low and high error',
640 'Single high error'
641 ],
642 # Constant time operations only used for PKCS1_V15
643 'test_suite_constant_time': [
644 re.compile(r'mbedtls_ct_zeroize_if .*'),
645 re.compile(r'mbedtls_ct_memmove_left .*')
646 ],
647 'test_suite_psa_crypto': [
648 # We don't support generate_key_custom entry points
649 # in drivers yet.
650 re.compile(r'PSA generate key custom: RSA, e=.*'),
651 re.compile(r'PSA generate key ext: RSA, e=.*'),
652 ],
653 }
654
Gilles Peskine45a32b12024-10-03 18:42:37 +0200655class DriverVSReference_block_cipher_dispatch(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200656 REFERENCE = 'test_full_block_cipher_legacy_dispatch'
657 DRIVER = 'test_full_block_cipher_psa_dispatch'
658 IGNORED_SUITES = [
659 # Skipped in the accelerated component
660 'aes', 'aria', 'camellia',
661 # These require AES_C, ARIA_C or CAMELLIA_C to be enabled in
662 # order for the cipher module (actually cipher_wrapper) to work
663 # properly. However these symbols are disabled in the accelerated
664 # component so we ignore them.
665 'cipher.ccm', 'cipher.gcm', 'cipher.aes', 'cipher.aria',
666 'cipher.camellia',
667 ]
668 IGNORED_TESTS = {
669 'test_suite_config': [
670 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA)_.*'),
671 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
672 ],
673 'test_suite_cmac': [
674 # Following tests require AES_C/ARIA_C/CAMELLIA_C to be enabled,
675 # but these are not available in the accelerated component.
676 'CMAC null arguments',
677 re.compile('CMAC.* (AES|ARIA|Camellia).*'),
678 ],
679 'test_suite_cipher.padding': [
680 # Following tests require AES_C/CAMELLIA_C to be enabled,
681 # but these are not available in the accelerated component.
682 re.compile('Set( non-existent)? padding with (AES|CAMELLIA).*'),
683 ],
684 'test_suite_pkcs5': [
685 # The AES part of PKCS#5 PBES2 is not yet supported.
686 # The rest of PKCS#5 (PBKDF2) works, though.
687 re.compile(r'PBES2 .* AES-.*')
688 ],
689 'test_suite_pkparse': [
690 # PEM (called by pkparse) requires AES_C in order to decrypt
691 # the key, but this is not available in the accelerated
692 # component.
693 re.compile('Parse RSA Key.*(password|AES-).*'),
694 ],
695 'test_suite_pem': [
696 # Following tests require AES_C, but this is diabled in the
697 # accelerated component.
698 re.compile('PEM read .*AES.*'),
699 'PEM read (unknown encryption algorithm)',
700 ],
701 'test_suite_error': [
702 # Following tests depend on AES_C but are not about them
703 # really, just need to know some error code is there.
704 'Single low error',
705 'Low and high error',
706 ],
707 'test_suite_version': [
708 # Similar to test_suite_error above.
709 'Check for MBEDTLS_AES_C when already present',
710 ],
711 'test_suite_platform': [
712 # Incompatible with sanitizers (e.g. ASan). If the driver
713 # component uses a sanitizer but the reference component
714 # doesn't, we have a PASS vs SKIP mismatch.
715 'Check mbedtls_calloc overallocation',
716 ],
717 }
718
719#pylint: enable=invalid-name,missing-class-docstring
720
721
Przemek Stekiel6856f4c2022-11-09 10:50:29 +0100722# List of tasks with a function that can handle this task and additional arguments if required
Valerio Settidfd7ca62023-10-09 16:30:11 +0200723KNOWN_TASKS = {
Gilles Peskine0316f102024-09-16 19:15:29 +0200724 'analyze_coverage': CoverageTask,
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200725 'analyze_driver_vs_reference_hash': DriverVSReference_hash,
726 'analyze_driver_vs_reference_hmac': DriverVSReference_hmac,
727 'analyze_driver_vs_reference_cipher_aead_cmac': DriverVSReference_cipher_aead_cmac,
728 'analyze_driver_vs_reference_ecp_light_only': DriverVSReference_ecp_light_only,
729 'analyze_driver_vs_reference_no_ecp_at_all': DriverVSReference_no_ecp_at_all,
730 'analyze_driver_vs_reference_ecc_no_bignum': DriverVSReference_ecc_no_bignum,
731 'analyze_driver_vs_reference_ecc_ffdh_no_bignum': DriverVSReference_ecc_ffdh_no_bignum,
732 'analyze_driver_vs_reference_ffdh_alg': DriverVSReference_ffdh_alg,
733 'analyze_driver_vs_reference_tfm_config': DriverVSReference_tfm_config,
734 'analyze_driver_vs_reference_rsa': DriverVSReference_rsa,
735 'analyze_block_cipher_dispatch': DriverVSReference_block_cipher_dispatch,
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200736}
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200737
Gilles Peskine15c2cbf2020-06-25 18:36:28 +0200738if __name__ == '__main__':
Gilles Peskine45a32b12024-10-03 18:42:37 +0200739 outcome_analysis.main(KNOWN_TASKS)