blob: 31d678d19c4a5d7396213fca1044c156c37f2c62 [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
36 # generate_psa_tests.py generates test cases involving cryptographic
37 # mechanisms (key types, families, algorithms) that are declared but
38 # not implemented. Until we improve the Python scripts, ignore those
39 # test cases in the analysis.
40 # https://github.com/Mbed-TLS/mbedtls/issues/9572
41 _PSA_MECHANISMS_NOT_IMPLEMENTED = [
42 r'CBC_MAC',
43 r'DETERMINISTIC_DSA',
44 r'DET_DSA',
45 r'DSA',
46 r'ECC_KEY_PAIR\(BRAINPOOL_P_R1\) (?:160|192|224|320)-bit',
47 r'ECC_KEY_PAIR\(SECP_K1\) 225-bit',
48 r'ECC_PAIR\(BP_R1\) (?:160|192|224|320)-bit',
49 r'ECC_PAIR\(SECP_K1\) 225-bit',
50 r'ECC_PUBLIC_KEY\(BRAINPOOL_P_R1\) (?:160|192|224|320)-bit',
51 r'ECC_PUBLIC_KEY\(SECP_K1\) 225-bit',
52 r'ECC_PUB\(BP_R1\) (?:160|192|224|320)-bit',
53 r'ECC_PUB\(SECP_K1\) 225-bit',
54 r'ED25519PH',
55 r'ED448PH',
56 r'PEPPER',
57 r'PURE_EDDSA',
58 r'SECP_R2',
59 r'SECT_K1',
60 r'SECT_R1',
61 r'SECT_R2',
62 r'SHAKE256_512',
63 r'SHA_512_224',
64 r'SHA_512_256',
65 r'TWISTED_EDWARDS',
66 r'XTS',
67 ]
68 PSA_MECHANISM_NOT_IMPLEMENTED_SEARCH_RE = \
69 _has_word_re(_PSA_MECHANISMS_NOT_IMPLEMENTED)
70
71 IGNORED_TESTS = {
Gilles Peskine419a5842024-09-17 18:32:05 +020072 'ssl-opt': [
73 # We don't run ssl-opt.sh with Valgrind on the CI because
74 # it's extremely slow. We don't intend to change this.
75 'DTLS client reconnect from same port: reconnect, nbio, valgrind',
Gilles Peskine419a5842024-09-17 18:32:05 +020076 # We don't have IPv6 in our CI environment.
77 # https://github.com/Mbed-TLS/mbedtls-test/issues/176
78 'DTLS cookie: enabled, IPv6',
79 # Disabled due to OpenSSL bug.
80 # https://github.com/openssl/openssl/issues/18887
81 'DTLS fragmenting: 3d, openssl client, DTLS 1.2',
82 # We don't run ssl-opt.sh with Valgrind on the CI because
83 # it's extremely slow. We don't intend to change this.
84 'DTLS fragmenting: proxy MTU: auto-reduction (with valgrind)',
85 # It seems that we don't run `ssl-opt.sh` with
86 # `MBEDTLS_USE_PSA_CRYPTO` enabled but `MBEDTLS_SSL_ASYNC_PRIVATE`
87 # disabled.
88 # https://github.com/Mbed-TLS/mbedtls/issues/9581
89 'Opaque key for server authentication: invalid key: decrypt with ECC key, no async',
90 'Opaque key for server authentication: invalid key: ecdh with RSA key, no async',
91 ],
Gilles Peskine47243fd2024-09-17 19:46:18 +020092 'test_suite_config.mbedtls_boolean': [
93 # We never test with CBC/PKCS5/PKCS12 enabled but
94 # PKCS7 padding disabled.
95 # https://github.com/Mbed-TLS/mbedtls/issues/9580
96 'Config: !MBEDTLS_CIPHER_PADDING_PKCS7',
97 # https://github.com/Mbed-TLS/mbedtls/issues/9583
98 'Config: !MBEDTLS_ECP_NIST_OPTIM',
Gilles Peskine44fdd922024-10-10 18:19:23 +020099 # MBEDTLS_ECP_NO_FALLBACK only affects builds using a partial
100 # alternative implementation of ECP arithmetic (with
101 # MBEDTLS_ECP_INTERNAL_ALT enabled). We don't test those builds.
102 # The configuration enumeration script skips xxx_ALT options
103 # but not MBEDTLS_ECP_NO_FALLBACK, so it appears in the report,
104 # but we don't care about it.
105 'Config: MBEDTLS_ECP_NO_FALLBACK',
Gilles Peskine47243fd2024-09-17 19:46:18 +0200106 # Missing coverage of test configurations.
107 # https://github.com/Mbed-TLS/mbedtls/issues/9585
108 'Config: !MBEDTLS_SSL_DTLS_ANTI_REPLAY',
109 # Missing coverage of test configurations.
110 # https://github.com/Mbed-TLS/mbedtls/issues/9585
111 'Config: !MBEDTLS_SSL_DTLS_HELLO_VERIFY',
112 # We don't run test_suite_config when we test this.
113 # https://github.com/Mbed-TLS/mbedtls/issues/9586
114 'Config: !MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED',
115 # We only test multithreading with pthreads.
116 # https://github.com/Mbed-TLS/mbedtls/issues/9584
117 'Config: !MBEDTLS_THREADING_PTHREAD',
118 # Built but not tested.
119 # https://github.com/Mbed-TLS/mbedtls/issues/9587
120 'Config: MBEDTLS_AES_USE_HARDWARE_ONLY',
121 # Untested platform-specific optimizations.
122 # https://github.com/Mbed-TLS/mbedtls/issues/9588
123 'Config: MBEDTLS_HAVE_SSE2',
124 # Obsolete configuration option, to be replaced by
125 # PSA entropy drivers.
126 # https://github.com/Mbed-TLS/mbedtls/issues/8150
127 'Config: MBEDTLS_NO_PLATFORM_ENTROPY',
128 # Untested aspect of the platform interface.
129 # https://github.com/Mbed-TLS/mbedtls/issues/9589
130 'Config: MBEDTLS_PLATFORM_NO_STD_FUNCTIONS',
131 # In a client-server build, test_suite_config runs in the
132 # client configuration, so it will never report
133 # MBEDTLS_PSA_CRYPTO_SPM as enabled. That's ok.
134 'Config: MBEDTLS_PSA_CRYPTO_SPM',
135 # We don't test on armv8 yet.
136 'Config: MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT',
137 'Config: MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY',
138 'Config: MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY',
139 'Config: MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY',
140 # We don't run test_suite_config when we test this.
141 # https://github.com/Mbed-TLS/mbedtls/issues/9586
142 'Config: MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND',
143 ],
144 'test_suite_config.psa_boolean': [
145 # We don't test with HMAC disabled.
146 # https://github.com/Mbed-TLS/mbedtls/issues/9591
147 'Config: !PSA_WANT_ALG_HMAC',
Gilles Peskine47243fd2024-09-17 19:46:18 +0200148 # The DERIVE key type is always enabled.
149 'Config: !PSA_WANT_KEY_TYPE_DERIVE',
150 # More granularity of key pair type enablement macros
151 # than we care to test.
152 # https://github.com/Mbed-TLS/mbedtls/issues/9590
153 'Config: !PSA_WANT_KEY_TYPE_DH_KEY_PAIR_EXPORT',
154 'Config: !PSA_WANT_KEY_TYPE_DH_KEY_PAIR_GENERATE',
155 'Config: !PSA_WANT_KEY_TYPE_DH_KEY_PAIR_IMPORT',
156 # More granularity of key pair type enablement macros
157 # than we care to test.
158 # https://github.com/Mbed-TLS/mbedtls/issues/9590
159 'Config: !PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT',
160 'Config: !PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT',
161 # We don't test with HMAC disabled.
162 # https://github.com/Mbed-TLS/mbedtls/issues/9591
163 'Config: !PSA_WANT_KEY_TYPE_HMAC',
164 # The PASSWORD key type is always enabled.
165 'Config: !PSA_WANT_KEY_TYPE_PASSWORD',
166 # The PASSWORD_HASH key type is always enabled.
167 'Config: !PSA_WANT_KEY_TYPE_PASSWORD_HASH',
168 # The RAW_DATA key type is always enabled.
169 'Config: !PSA_WANT_KEY_TYPE_RAW_DATA',
170 # More granularity of key pair type enablement macros
171 # than we care to test.
172 # https://github.com/Mbed-TLS/mbedtls/issues/9590
173 'Config: !PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_EXPORT',
174 'Config: !PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT',
175 # Algorithm declared but not supported.
176 'Config: PSA_WANT_ALG_CBC_MAC',
177 # Algorithm declared but not supported.
178 'Config: PSA_WANT_ALG_XTS',
179 # Family declared but not supported.
180 'Config: PSA_WANT_ECC_SECP_K1_224',
181 # More granularity of key pair type enablement macros
182 # than we care to test.
183 # https://github.com/Mbed-TLS/mbedtls/issues/9590
184 'Config: PSA_WANT_KEY_TYPE_DH_KEY_PAIR_DERIVE',
185 'Config: PSA_WANT_KEY_TYPE_ECC_KEY_PAIR',
186 'Config: PSA_WANT_KEY_TYPE_RSA_KEY_PAIR',
187 'Config: PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_DERIVE',
188 ],
189 'test_suite_config.psa_combinations': [
190 # We don't test this unusual, but sensible configuration.
191 # https://github.com/Mbed-TLS/mbedtls/issues/9592
192 'Config: PSA_WANT_ALG_DETERMINSTIC_ECDSA without PSA_WANT_ALG_ECDSA',
193 ],
Gilles Peskine1a176272024-09-17 18:33:29 +0200194 'test_suite_pkcs12': [
Gilles Peskine47243fd2024-09-17 19:46:18 +0200195 # We never test with CBC/PKCS5/PKCS12 enabled but
196 # PKCS7 padding disabled.
Gilles Peskine1a176272024-09-17 18:33:29 +0200197 # https://github.com/Mbed-TLS/mbedtls/issues/9580
198 'PBE Decrypt, (Invalid padding & PKCS7 padding disabled)',
199 'PBE Encrypt, pad = 8 (PKCS7 padding disabled)',
200 ],
201 'test_suite_pkcs5': [
Gilles Peskine47243fd2024-09-17 19:46:18 +0200202 # We never test with CBC/PKCS5/PKCS12 enabled but
203 # PKCS7 padding disabled.
Gilles Peskine1a176272024-09-17 18:33:29 +0200204 # https://github.com/Mbed-TLS/mbedtls/issues/9580
205 'PBES2 Decrypt (Invalid padding & PKCS7 padding disabled)',
206 'PBES2 Encrypt, pad=6 (PKCS7 padding disabled)',
207 'PBES2 Encrypt, pad=8 (PKCS7 padding disabled)',
208 ],
Gilles Peskine8729b102024-04-19 19:08:34 +0200209 'test_suite_psa_crypto': [
210 # We don't test this unusual, but sensible configuration.
211 # https://github.com/Mbed-TLS/mbedtls/issues/9592
212 re.compile(r'.*ECDSA.*only deterministic supported'),
213 ],
Gilles Peskine1a176272024-09-17 18:33:29 +0200214 'test_suite_psa_crypto_metadata': [
215 # Algorithms declared but not supported.
216 # https://github.com/Mbed-TLS/mbedtls/issues/9579
217 'Asymmetric signature: Ed25519ph',
218 'Asymmetric signature: Ed448ph',
219 'Asymmetric signature: pure EdDSA',
220 'Cipher: XTS',
221 'MAC: CBC_MAC-3DES',
222 'MAC: CBC_MAC-AES-128',
223 'MAC: CBC_MAC-AES-192',
224 'MAC: CBC_MAC-AES-256',
225 ],
Gilles Peskined8da2fc2024-09-17 15:07:22 +0200226 'test_suite_psa_crypto_not_supported.generated': [
Gilles Peskine1abc8002024-10-11 12:00:44 +0200227 # We never test with DH key support disabled but support
Gilles Peskine1fac3712024-09-17 17:57:11 +0200228 # for a DH group enabled. The dependencies of these test
229 # cases don't really make sense.
230 # https://github.com/Mbed-TLS/mbedtls/issues/9574
231 re.compile(r'PSA \w+ DH_.*type not supported'),
232 # We only test partial support for DH with the 2048-bit group
233 # enabled and the other groups disabled.
234 # https://github.com/Mbed-TLS/mbedtls/issues/9575
235 'PSA generate DH_KEY_PAIR(RFC7919) 2048-bit group not supported',
236 'PSA import DH_KEY_PAIR(RFC7919) 2048-bit group not supported',
237 'PSA import DH_PUBLIC_KEY(RFC7919) 2048-bit group not supported',
Gilles Peskined8da2fc2024-09-17 15:07:22 +0200238 ],
239 'test_suite_psa_crypto_op_fail.generated': [
Gilles Peskine72396da2024-09-17 17:15:29 +0200240 # Ignore mechanisms that are not implemented, except
241 # for test cases that assume the mechanism is not supported.
242 _has_word_re(_PSA_MECHANISMS_NOT_IMPLEMENTED,
243 exclude=(r'.*: !(?:' +
244 r'|'.join(_PSA_MECHANISMS_NOT_IMPLEMENTED) +
245 r')\b')),
Gilles Peskine1fac3712024-09-17 17:57:11 +0200246 # Incorrect dependency generation. To be fixed as part of the
247 # resolution of https://github.com/Mbed-TLS/mbedtls/issues/9167
248 # by forward-porting the commit
249 # "PSA test case generation: dependency inference class: operation fail"
250 # from https://github.com/Mbed-TLS/mbedtls/pull/9025 .
251 re.compile(r'.* with (?:DH|ECC)_(?:KEY_PAIR|PUBLIC_KEY)\(.*'),
Gilles Peskine8729b102024-04-19 19:08:34 +0200252 # We don't test this unusual, but sensible configuration.
253 # https://github.com/Mbed-TLS/mbedtls/issues/9592
254 re.compile(r'.*: !ECDSA but DETERMINISTIC_ECDSA with ECC_.*'),
Gilles Peskine1fac3712024-09-17 17:57:11 +0200255 # PBKDF2_HMAC is not in the default configuration, so we don't
256 # enable it in depends.py where we remove hashes.
257 # https://github.com/Mbed-TLS/mbedtls/issues/9576
258 re.compile(r'PSA key_derivation PBKDF2_HMAC\(\w+\): !(?!PBKDF2_HMAC\Z).*'),
Gilles Peskine1fac3712024-09-17 17:57:11 +0200259
260 # We never test with the HMAC algorithm enabled but the HMAC
261 # key type disabled. Those dependencies don't really make sense.
262 # https://github.com/Mbed-TLS/mbedtls/issues/9573
263 re.compile(r'.* !HMAC with HMAC'),
264 # There's something wrong with PSA_WANT_ALG_RSA_PSS_ANY_SALT
265 # differing from PSA_WANT_ALG_RSA_PSS.
266 # https://github.com/Mbed-TLS/mbedtls/issues/9578
267 re.compile(r'PSA sign RSA_PSS_ANY_SALT.*!(?:MD|RIPEMD|SHA).*'),
Gilles Peskined8da2fc2024-09-17 15:07:22 +0200268 ],
Gilles Peskine8729b102024-04-19 19:08:34 +0200269 'test_suite_psa_crypto_op_fail.misc': [
270 # We don't test this unusual, but sensible configuration.
271 # https://github.com/Mbed-TLS/mbedtls/issues/9592
272 'PSA sign DETERMINISTIC_ECDSA(SHA_256): !ECDSA but DETERMINISTIC_ECDSA with ECC_KEY_PAIR(SECP_R1)', #pylint: disable=line-too-long
273 ],
Gilles Peskine419a5842024-09-17 18:32:05 +0200274 'tls13-misc': [
275 # Disabled due to OpenSSL bug.
276 # https://github.com/openssl/openssl/issues/10714
277 'TLS 1.3 O->m: resumption',
278 # Disabled due to OpenSSL command line limitation.
279 # https://github.com/Mbed-TLS/mbedtls/issues/9582
280 'TLS 1.3 m->O: resumption with early data',
281 ],
Gilles Peskined8da2fc2024-09-17 15:07:22 +0200282 }
283
Gilles Peskine17e071b2024-09-16 19:57:10 +0200284
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200285# The names that we give to classes derived from DriverVSReference do not
286# follow the usual naming convention, because it's more readable to use
287# underscores and parts of the configuration names. Also, these classes
288# are just there to specify some data, so they don't need repetitive
289# documentation.
290#pylint: disable=invalid-name,missing-class-docstring
291
Gilles Peskine45a32b12024-10-03 18:42:37 +0200292class DriverVSReference_hash(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200293 REFERENCE = 'test_psa_crypto_config_reference_hash_use_psa'
294 DRIVER = 'test_psa_crypto_config_accel_hash_use_psa'
295 IGNORED_SUITES = [
296 'shax', 'mdx', # the software implementations that are being excluded
297 'md.psa', # purposefully depends on whether drivers are present
298 'psa_crypto_low_hash.generated', # testing the builtins
299 ]
300 IGNORED_TESTS = {
301 'test_suite_config': [
302 re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'),
303 ],
304 'test_suite_platform': [
305 # Incompatible with sanitizers (e.g. ASan). If the driver
306 # component uses a sanitizer but the reference component
307 # doesn't, we have a PASS vs SKIP mismatch.
308 'Check mbedtls_calloc overallocation',
309 ],
310 }
311
Gilles Peskine45a32b12024-10-03 18:42:37 +0200312class DriverVSReference_hmac(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200313 REFERENCE = 'test_psa_crypto_config_reference_hmac'
314 DRIVER = 'test_psa_crypto_config_accel_hmac'
315 IGNORED_SUITES = [
316 # These suites require legacy hash support, which is disabled
317 # in the accelerated component.
318 'shax', 'mdx',
319 # This suite tests builtins directly, but these are missing
320 # in the accelerated case.
321 'psa_crypto_low_hash.generated',
322 ]
323 IGNORED_TESTS = {
324 'test_suite_config': [
325 re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'),
326 re.compile(r'.*\bMBEDTLS_MD_C\b')
327 ],
328 'test_suite_md': [
329 # Builtin HMAC is not supported in the accelerate component.
330 re.compile('.*HMAC.*'),
331 # Following tests make use of functions which are not available
332 # when MD_C is disabled, as it happens in the accelerated
333 # test component.
334 re.compile('generic .* Hash file .*'),
335 'MD list',
336 ],
337 'test_suite_md.psa': [
338 # "legacy only" tests require hash algorithms to be NOT
339 # accelerated, but this of course false for the accelerated
340 # test component.
341 re.compile('PSA dispatch .* legacy only'),
342 ],
343 'test_suite_platform': [
344 # Incompatible with sanitizers (e.g. ASan). If the driver
345 # component uses a sanitizer but the reference component
346 # doesn't, we have a PASS vs SKIP mismatch.
347 'Check mbedtls_calloc overallocation',
348 ],
349 }
350
Gilles Peskine45a32b12024-10-03 18:42:37 +0200351class DriverVSReference_cipher_aead_cmac(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200352 REFERENCE = 'test_psa_crypto_config_reference_cipher_aead_cmac'
353 DRIVER = 'test_psa_crypto_config_accel_cipher_aead_cmac'
354 # Modules replaced by drivers.
355 IGNORED_SUITES = [
356 # low-level (block/stream) cipher modules
357 'aes', 'aria', 'camellia', 'des', 'chacha20',
358 # AEAD modes and CMAC
359 'ccm', 'chachapoly', 'cmac', 'gcm',
360 # The Cipher abstraction layer
361 'cipher',
362 ]
363 IGNORED_TESTS = {
364 'test_suite_config': [
365 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA|CHACHA20|DES)_.*'),
366 re.compile(r'.*\bMBEDTLS_(CCM|CHACHAPOLY|CMAC|GCM)_.*'),
367 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
368 re.compile(r'.*\bMBEDTLS_CIPHER_.*'),
369 ],
370 # PEM decryption is not supported so far.
371 # The rest of PEM (write, unencrypted read) works though.
372 'test_suite_pem': [
373 re.compile(r'PEM read .*(AES|DES|\bencrypt).*'),
374 ],
375 'test_suite_platform': [
376 # Incompatible with sanitizers (e.g. ASan). If the driver
377 # component uses a sanitizer but the reference component
378 # doesn't, we have a PASS vs SKIP mismatch.
379 'Check mbedtls_calloc overallocation',
380 ],
381 # Following tests depend on AES_C/DES_C but are not about
382 # them really, just need to know some error code is there.
383 'test_suite_error': [
384 'Low and high error',
385 'Single low error'
386 ],
387 # Similar to test_suite_error above.
388 'test_suite_version': [
389 'Check for MBEDTLS_AES_C when already present',
390 ],
391 # The en/decryption part of PKCS#12 is not supported so far.
392 # The rest of PKCS#12 (key derivation) works though.
393 'test_suite_pkcs12': [
394 re.compile(r'PBE Encrypt, .*'),
395 re.compile(r'PBE Decrypt, .*'),
396 ],
397 # The en/decryption part of PKCS#5 is not supported so far.
398 # The rest of PKCS#5 (PBKDF2) works though.
399 'test_suite_pkcs5': [
400 re.compile(r'PBES2 Encrypt, .*'),
401 re.compile(r'PBES2 Decrypt .*'),
402 ],
403 # Encrypted keys are not supported so far.
404 # pylint: disable=line-too-long
405 'test_suite_pkparse': [
406 'Key ASN1 (Encrypted key PKCS12, trailing garbage data)',
407 'Key ASN1 (Encrypted key PKCS5, trailing garbage data)',
408 re.compile(r'Parse (RSA|EC) Key .*\(.* ([Ee]ncrypted|password).*\)'),
409 ],
410 # Encrypted keys are not supported so far.
411 'ssl-opt': [
412 'TLS: password protected server key',
413 'TLS: password protected client key',
414 'TLS: password protected server key, two certificates',
415 ],
416 }
417
Gilles Peskine45a32b12024-10-03 18:42:37 +0200418class DriverVSReference_ecp_light_only(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200419 REFERENCE = 'test_psa_crypto_config_reference_ecc_ecp_light_only'
420 DRIVER = 'test_psa_crypto_config_accel_ecc_ecp_light_only'
421 IGNORED_SUITES = [
422 # Modules replaced by drivers
423 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine9a094432024-10-29 20:55:11 +0100424 # Unit tests for the built-in implementation
425 'psa_crypto_ecp',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200426 ]
427 IGNORED_TESTS = {
428 'test_suite_config': [
429 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
430 ],
431 'test_suite_platform': [
432 # Incompatible with sanitizers (e.g. ASan). If the driver
433 # component uses a sanitizer but the reference component
434 # doesn't, we have a PASS vs SKIP mismatch.
435 'Check mbedtls_calloc overallocation',
436 ],
437 # This test wants a legacy function that takes f_rng, p_rng
438 # arguments, and uses legacy ECDSA for that. The test is
439 # really about the wrapper around the PSA RNG, not ECDSA.
440 'test_suite_random': [
441 'PSA classic wrapper: ECDSA signature (SECP256R1)',
442 ],
443 # In the accelerated test ECP_C is not set (only ECP_LIGHT is)
444 # so we must ignore disparities in the tests for which ECP_C
445 # is required.
446 'test_suite_ecp': [
447 re.compile(r'ECP check public-private .*'),
448 re.compile(r'ECP calculate public: .*'),
449 re.compile(r'ECP gen keypair .*'),
450 re.compile(r'ECP point muladd .*'),
451 re.compile(r'ECP point multiplication .*'),
452 re.compile(r'ECP test vectors .*'),
453 ],
454 'test_suite_ssl': [
455 # This deprecated function is only present when ECP_C is On.
456 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
457 ],
458 }
459
Gilles Peskine45a32b12024-10-03 18:42:37 +0200460class DriverVSReference_no_ecp_at_all(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200461 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_ecp_at_all'
462 DRIVER = 'test_psa_crypto_config_accel_ecc_no_ecp_at_all'
463 IGNORED_SUITES = [
464 # Modules replaced by drivers
465 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine9a094432024-10-29 20:55:11 +0100466 # Unit tests for the built-in implementation
467 'psa_crypto_ecp',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200468 ]
469 IGNORED_TESTS = {
470 'test_suite_config': [
471 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
472 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
473 ],
474 'test_suite_platform': [
475 # Incompatible with sanitizers (e.g. ASan). If the driver
476 # component uses a sanitizer but the reference component
477 # doesn't, we have a PASS vs SKIP mismatch.
478 'Check mbedtls_calloc overallocation',
479 ],
480 # See ecp_light_only
481 'test_suite_random': [
482 'PSA classic wrapper: ECDSA signature (SECP256R1)',
483 ],
484 'test_suite_pkparse': [
485 # When PK_PARSE_C and ECP_C are defined then PK_PARSE_EC_COMPRESSED
486 # is automatically enabled in build_info.h (backward compatibility)
487 # even if it is disabled in config_psa_crypto_no_ecp_at_all(). As a
488 # consequence compressed points are supported in the reference
489 # component but not in the accelerated one, so they should be skipped
490 # while checking driver's coverage.
491 re.compile(r'Parse EC Key .*compressed\)'),
492 re.compile(r'Parse Public EC Key .*compressed\)'),
493 ],
494 # See ecp_light_only
495 'test_suite_ssl': [
496 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
497 ],
498 }
499
Gilles Peskine45a32b12024-10-03 18:42:37 +0200500class DriverVSReference_ecc_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200501 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_bignum'
502 DRIVER = 'test_psa_crypto_config_accel_ecc_no_bignum'
503 IGNORED_SUITES = [
504 # Modules replaced by drivers
505 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
506 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
507 'bignum.generated', 'bignum.misc',
Gilles Peskine9a094432024-10-29 20:55:11 +0100508 # Unit tests for the built-in implementation
509 'psa_crypto_ecp',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200510 ]
511 IGNORED_TESTS = {
512 'test_suite_config': [
513 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
514 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
515 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
516 ],
517 'test_suite_platform': [
518 # Incompatible with sanitizers (e.g. ASan). If the driver
519 # component uses a sanitizer but the reference component
520 # doesn't, we have a PASS vs SKIP mismatch.
521 'Check mbedtls_calloc overallocation',
522 ],
523 # See ecp_light_only
524 'test_suite_random': [
525 'PSA classic wrapper: ECDSA signature (SECP256R1)',
526 ],
527 # See no_ecp_at_all
528 'test_suite_pkparse': [
529 re.compile(r'Parse EC Key .*compressed\)'),
530 re.compile(r'Parse Public EC Key .*compressed\)'),
531 ],
532 'test_suite_asn1parse': [
533 'INTEGER too large for mpi',
534 ],
535 'test_suite_asn1write': [
536 re.compile(r'ASN.1 Write mpi.*'),
537 ],
538 'test_suite_debug': [
539 re.compile(r'Debug print mbedtls_mpi.*'),
540 ],
541 # See ecp_light_only
542 'test_suite_ssl': [
543 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
544 ],
545 }
546
Gilles Peskine45a32b12024-10-03 18:42:37 +0200547class DriverVSReference_ecc_ffdh_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200548 REFERENCE = 'test_psa_crypto_config_reference_ecc_ffdh_no_bignum'
549 DRIVER = 'test_psa_crypto_config_accel_ecc_ffdh_no_bignum'
550 IGNORED_SUITES = [
551 # Modules replaced by drivers
552 'ecp', 'ecdsa', 'ecdh', 'ecjpake', 'dhm',
553 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
554 'bignum.generated', 'bignum.misc',
Gilles Peskine9a094432024-10-29 20:55:11 +0100555 # Unit tests for the built-in implementation
556 'psa_crypto_ecp',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200557 ]
558 IGNORED_TESTS = {
559 'ssl-opt': [
560 # DHE support in TLS 1.2 requires built-in MBEDTLS_DHM_C
561 # (because it needs custom groups, which PSA does not
562 # provide), even with MBEDTLS_USE_PSA_CRYPTO.
563 re.compile(r'PSK callback:.*\bdhe-psk\b.*'),
564 ],
565 'test_suite_config': [
566 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
567 re.compile(r'.*\bMBEDTLS_DHM_C\b.*'),
568 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
569 re.compile(r'.*\bMBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED\b.*'),
570 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
571 ],
572 'test_suite_platform': [
573 # Incompatible with sanitizers (e.g. ASan). If the driver
574 # component uses a sanitizer but the reference component
575 # doesn't, we have a PASS vs SKIP mismatch.
576 'Check mbedtls_calloc overallocation',
577 ],
578 # See ecp_light_only
579 'test_suite_random': [
580 'PSA classic wrapper: ECDSA signature (SECP256R1)',
581 ],
582 # See no_ecp_at_all
583 'test_suite_pkparse': [
584 re.compile(r'Parse EC Key .*compressed\)'),
585 re.compile(r'Parse Public EC Key .*compressed\)'),
586 ],
587 'test_suite_asn1parse': [
588 'INTEGER too large for mpi',
589 ],
590 'test_suite_asn1write': [
591 re.compile(r'ASN.1 Write mpi.*'),
592 ],
593 'test_suite_debug': [
594 re.compile(r'Debug print mbedtls_mpi.*'),
595 ],
596 # See ecp_light_only
597 'test_suite_ssl': [
598 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
599 ],
600 }
601
Gilles Peskine45a32b12024-10-03 18:42:37 +0200602class DriverVSReference_ffdh_alg(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200603 REFERENCE = 'test_psa_crypto_config_reference_ffdh'
604 DRIVER = 'test_psa_crypto_config_accel_ffdh'
605 IGNORED_SUITES = ['dhm']
606 IGNORED_TESTS = {
607 'test_suite_config': [
608 re.compile(r'.*\bMBEDTLS_DHM_C\b.*'),
609 ],
610 'test_suite_platform': [
611 # Incompatible with sanitizers (e.g. ASan). If the driver
612 # component uses a sanitizer but the reference component
613 # doesn't, we have a PASS vs SKIP mismatch.
614 'Check mbedtls_calloc overallocation',
615 ],
616 }
617
Gilles Peskine45a32b12024-10-03 18:42:37 +0200618class DriverVSReference_tfm_config(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200619 REFERENCE = 'test_tfm_config_no_p256m'
620 DRIVER = 'test_tfm_config_p256m_driver_accel_ec'
621 IGNORED_SUITES = [
622 # Modules replaced by drivers
623 'asn1parse', 'asn1write',
624 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
625 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
626 'bignum.generated', 'bignum.misc',
Gilles Peskine9a094432024-10-29 20:55:11 +0100627 # Unit tests for the built-in implementation
628 'psa_crypto_ecp',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200629 ]
630 IGNORED_TESTS = {
631 'test_suite_config': [
632 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
633 re.compile(r'.*\bMBEDTLS_(ASN1\w+)_C\b.*'),
634 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECP)_.*'),
635 re.compile(r'.*\bMBEDTLS_PSA_P256M_DRIVER_ENABLED\b.*')
636 ],
637 'test_suite_config.crypto_combinations': [
638 'Config: ECC: Weierstrass curves only',
639 ],
640 'test_suite_platform': [
641 # Incompatible with sanitizers (e.g. ASan). If the driver
642 # component uses a sanitizer but the reference component
643 # doesn't, we have a PASS vs SKIP mismatch.
644 'Check mbedtls_calloc overallocation',
645 ],
646 # See ecp_light_only
647 'test_suite_random': [
648 'PSA classic wrapper: ECDSA signature (SECP256R1)',
649 ],
650 }
651
Gilles Peskine45a32b12024-10-03 18:42:37 +0200652class DriverVSReference_rsa(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200653 REFERENCE = 'test_psa_crypto_config_reference_rsa_crypto'
654 DRIVER = 'test_psa_crypto_config_accel_rsa_crypto'
655 IGNORED_SUITES = [
656 # Modules replaced by drivers.
657 'rsa', 'pkcs1_v15', 'pkcs1_v21',
658 # We temporarily don't care about PK stuff.
659 'pk', 'pkwrite', 'pkparse'
660 ]
661 IGNORED_TESTS = {
662 'test_suite_config': [
663 re.compile(r'.*\bMBEDTLS_(PKCS1|RSA)_.*'),
664 re.compile(r'.*\bMBEDTLS_GENPRIME\b.*')
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 # Following tests depend on RSA_C but are not about
673 # them really, just need to know some error code is there.
674 'test_suite_error': [
675 'Low and high error',
676 'Single high error'
677 ],
678 # Constant time operations only used for PKCS1_V15
679 'test_suite_constant_time': [
680 re.compile(r'mbedtls_ct_zeroize_if .*'),
681 re.compile(r'mbedtls_ct_memmove_left .*')
682 ],
683 'test_suite_psa_crypto': [
684 # We don't support generate_key_custom entry points
685 # in drivers yet.
686 re.compile(r'PSA generate key custom: RSA, e=.*'),
687 re.compile(r'PSA generate key ext: RSA, e=.*'),
688 ],
689 }
690
Gilles Peskine45a32b12024-10-03 18:42:37 +0200691class DriverVSReference_block_cipher_dispatch(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200692 REFERENCE = 'test_full_block_cipher_legacy_dispatch'
693 DRIVER = 'test_full_block_cipher_psa_dispatch'
694 IGNORED_SUITES = [
695 # Skipped in the accelerated component
696 'aes', 'aria', 'camellia',
697 # These require AES_C, ARIA_C or CAMELLIA_C to be enabled in
698 # order for the cipher module (actually cipher_wrapper) to work
699 # properly. However these symbols are disabled in the accelerated
700 # component so we ignore them.
701 'cipher.ccm', 'cipher.gcm', 'cipher.aes', 'cipher.aria',
702 'cipher.camellia',
703 ]
704 IGNORED_TESTS = {
705 'test_suite_config': [
706 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA)_.*'),
707 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
708 ],
709 'test_suite_cmac': [
710 # Following tests require AES_C/ARIA_C/CAMELLIA_C to be enabled,
711 # but these are not available in the accelerated component.
712 'CMAC null arguments',
713 re.compile('CMAC.* (AES|ARIA|Camellia).*'),
714 ],
715 'test_suite_cipher.padding': [
716 # Following tests require AES_C/CAMELLIA_C to be enabled,
717 # but these are not available in the accelerated component.
718 re.compile('Set( non-existent)? padding with (AES|CAMELLIA).*'),
719 ],
720 'test_suite_pkcs5': [
721 # The AES part of PKCS#5 PBES2 is not yet supported.
722 # The rest of PKCS#5 (PBKDF2) works, though.
723 re.compile(r'PBES2 .* AES-.*')
724 ],
725 'test_suite_pkparse': [
726 # PEM (called by pkparse) requires AES_C in order to decrypt
727 # the key, but this is not available in the accelerated
728 # component.
729 re.compile('Parse RSA Key.*(password|AES-).*'),
730 ],
731 'test_suite_pem': [
732 # Following tests require AES_C, but this is diabled in the
733 # accelerated component.
734 re.compile('PEM read .*AES.*'),
735 'PEM read (unknown encryption algorithm)',
736 ],
737 'test_suite_error': [
738 # Following tests depend on AES_C but are not about them
739 # really, just need to know some error code is there.
740 'Single low error',
741 'Low and high error',
742 ],
743 'test_suite_version': [
744 # Similar to test_suite_error above.
745 'Check for MBEDTLS_AES_C when already present',
746 ],
747 'test_suite_platform': [
748 # Incompatible with sanitizers (e.g. ASan). If the driver
749 # component uses a sanitizer but the reference component
750 # doesn't, we have a PASS vs SKIP mismatch.
751 'Check mbedtls_calloc overallocation',
752 ],
753 }
754
755#pylint: enable=invalid-name,missing-class-docstring
756
757
Przemek Stekiel6856f4c2022-11-09 10:50:29 +0100758# List of tasks with a function that can handle this task and additional arguments if required
Valerio Settidfd7ca62023-10-09 16:30:11 +0200759KNOWN_TASKS = {
Gilles Peskine0316f102024-09-16 19:15:29 +0200760 'analyze_coverage': CoverageTask,
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200761 'analyze_driver_vs_reference_hash': DriverVSReference_hash,
762 'analyze_driver_vs_reference_hmac': DriverVSReference_hmac,
763 'analyze_driver_vs_reference_cipher_aead_cmac': DriverVSReference_cipher_aead_cmac,
764 'analyze_driver_vs_reference_ecp_light_only': DriverVSReference_ecp_light_only,
765 'analyze_driver_vs_reference_no_ecp_at_all': DriverVSReference_no_ecp_at_all,
766 'analyze_driver_vs_reference_ecc_no_bignum': DriverVSReference_ecc_no_bignum,
767 'analyze_driver_vs_reference_ecc_ffdh_no_bignum': DriverVSReference_ecc_ffdh_no_bignum,
768 'analyze_driver_vs_reference_ffdh_alg': DriverVSReference_ffdh_alg,
769 'analyze_driver_vs_reference_tfm_config': DriverVSReference_tfm_config,
770 'analyze_driver_vs_reference_rsa': DriverVSReference_rsa,
771 'analyze_block_cipher_dispatch': DriverVSReference_block_cipher_dispatch,
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200772}
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200773
Gilles Peskine15c2cbf2020-06-25 18:36:28 +0200774if __name__ == '__main__':
Gilles Peskine45a32b12024-10-03 18:42:37 +0200775 outcome_analysis.main(KNOWN_TASKS)