blob: 721ac4a7d696e603db236a56c279d190a29a930a [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
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 Peskinede2316b2024-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 Peskinede2316b2024-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)',
Gilles Peskine24b03d82024-10-04 16:22:24 +020085 # TLS doesn't use restartable ECDH yet.
86 # https://github.com/Mbed-TLS/mbedtls/issues/7294
87 re.compile(r'EC restart:.*no USE_PSA.*'),
Gilles Peskinede2316b2024-09-17 18:32:05 +020088 ],
Gilles Peskine2fd25bb2024-09-17 19:46:18 +020089 'test_suite_config.mbedtls_boolean': [
Gilles Peskine2fd25bb2024-09-17 19:46:18 +020090 # Missing coverage of test configurations.
91 # https://github.com/Mbed-TLS/mbedtls/issues/9585
92 'Config: !MBEDTLS_SSL_DTLS_ANTI_REPLAY',
93 # Missing coverage of test configurations.
94 # https://github.com/Mbed-TLS/mbedtls/issues/9585
95 'Config: !MBEDTLS_SSL_DTLS_HELLO_VERIFY',
96 # We don't run test_suite_config when we test this.
97 # https://github.com/Mbed-TLS/mbedtls/issues/9586
98 'Config: !MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED',
Gilles Peskine2fd25bb2024-09-17 19:46:18 +020099 ],
100 'test_suite_config.psa_boolean': [
101 # We don't test with HMAC disabled.
102 # https://github.com/Mbed-TLS/mbedtls/issues/9591
103 'Config: !PSA_WANT_ALG_HMAC',
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200104 # The DERIVE key type is always enabled.
105 'Config: !PSA_WANT_KEY_TYPE_DERIVE',
106 # 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_EXPORT',
110 'Config: !PSA_WANT_KEY_TYPE_DH_KEY_PAIR_GENERATE',
111 'Config: !PSA_WANT_KEY_TYPE_DH_KEY_PAIR_IMPORT',
112 # More granularity of key pair type enablement macros
113 # than we care to test.
114 # https://github.com/Mbed-TLS/mbedtls/issues/9590
115 'Config: !PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT',
116 'Config: !PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT',
117 # We don't test with HMAC disabled.
118 # https://github.com/Mbed-TLS/mbedtls/issues/9591
119 'Config: !PSA_WANT_KEY_TYPE_HMAC',
120 # The PASSWORD key type is always enabled.
121 'Config: !PSA_WANT_KEY_TYPE_PASSWORD',
122 # The PASSWORD_HASH key type is always enabled.
123 'Config: !PSA_WANT_KEY_TYPE_PASSWORD_HASH',
124 # The RAW_DATA key type is always enabled.
125 'Config: !PSA_WANT_KEY_TYPE_RAW_DATA',
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_RSA_KEY_PAIR_EXPORT',
130 'Config: !PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT',
131 # Algorithm declared but not supported.
132 'Config: PSA_WANT_ALG_CBC_MAC',
133 # Algorithm declared but not supported.
134 'Config: PSA_WANT_ALG_XTS',
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200135 # More granularity of key pair type enablement macros
136 # than we care to test.
137 # https://github.com/Mbed-TLS/mbedtls/issues/9590
138 'Config: PSA_WANT_KEY_TYPE_DH_KEY_PAIR_DERIVE',
139 'Config: PSA_WANT_KEY_TYPE_ECC_KEY_PAIR',
140 'Config: PSA_WANT_KEY_TYPE_RSA_KEY_PAIR',
141 'Config: PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_DERIVE',
Minos Galanakis848333d2024-12-02 15:58:32 +0000142 # https://github.com/Mbed-TLS/mbedtls/issues/9583
143 'Config: !MBEDTLS_ECP_NIST_OPTIM',
144 # We never test without the PSA client code. Should we?
145 # https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/112
146 'Config: !MBEDTLS_PSA_CRYPTO_CLIENT',
147 # We only test multithreading with pthreads.
148 # https://github.com/Mbed-TLS/mbedtls/issues/9584
149 'Config: !MBEDTLS_THREADING_PTHREAD',
150 # Built but not tested.
151 # https://github.com/Mbed-TLS/mbedtls/issues/9587
152 'Config: MBEDTLS_AES_USE_HARDWARE_ONLY',
153 # Untested platform-specific optimizations.
154 # https://github.com/Mbed-TLS/mbedtls/issues/9588
155 'Config: MBEDTLS_HAVE_SSE2',
156 # Obsolete configuration option, to be replaced by
157 # PSA entropy drivers.
158 # https://github.com/Mbed-TLS/mbedtls/issues/8150
159 'Config: MBEDTLS_NO_PLATFORM_ENTROPY',
160 # Untested aspect of the platform interface.
161 # https://github.com/Mbed-TLS/mbedtls/issues/9589
162 'Config: MBEDTLS_PLATFORM_NO_STD_FUNCTIONS',
163 # In a client-server build, test_suite_config runs in the
164 # client configuration, so it will never report
165 # MBEDTLS_PSA_CRYPTO_SPM as enabled. That's ok.
166 'Config: MBEDTLS_PSA_CRYPTO_SPM',
167 # We don't test on armv8 yet.
168 'Config: MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT',
169 'Config: MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY',
170 'Config: MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY',
171 'Config: MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY',
172 # We don't run test_suite_config when we test this.
173 # https://github.com/Mbed-TLS/mbedtls/issues/9586
174 'Config: MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND',
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200175 ],
176 'test_suite_config.psa_combinations': [
177 # We don't test this unusual, but sensible configuration.
178 # https://github.com/Mbed-TLS/mbedtls/issues/9592
179 'Config: PSA_WANT_ALG_DETERMINSTIC_ECDSA without PSA_WANT_ALG_ECDSA',
180 ],
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200181 'test_suite_pkcs12': [
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200182 # We never test with CBC/PKCS5/PKCS12 enabled but
183 # PKCS7 padding disabled.
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200184 # https://github.com/Mbed-TLS/mbedtls/issues/9580
185 'PBE Decrypt, (Invalid padding & PKCS7 padding disabled)',
186 'PBE Encrypt, pad = 8 (PKCS7 padding disabled)',
187 ],
188 'test_suite_pkcs5': [
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200189 # We never test with CBC/PKCS5/PKCS12 enabled but
190 # PKCS7 padding disabled.
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200191 # https://github.com/Mbed-TLS/mbedtls/issues/9580
192 'PBES2 Decrypt (Invalid padding & PKCS7 padding disabled)',
193 'PBES2 Encrypt, pad=6 (PKCS7 padding disabled)',
194 'PBES2 Encrypt, pad=8 (PKCS7 padding disabled)',
195 ],
Gilles Peskineeafc2752024-04-19 19:08:34 +0200196 'test_suite_psa_crypto': [
197 # We don't test this unusual, but sensible configuration.
198 # https://github.com/Mbed-TLS/mbedtls/issues/9592
199 re.compile(r'.*ECDSA.*only deterministic supported'),
200 ],
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200201 'test_suite_psa_crypto_metadata': [
202 # Algorithms declared but not supported.
203 # https://github.com/Mbed-TLS/mbedtls/issues/9579
204 'Asymmetric signature: Ed25519ph',
205 'Asymmetric signature: Ed448ph',
206 'Asymmetric signature: pure EdDSA',
207 'Cipher: XTS',
208 'MAC: CBC_MAC-3DES',
209 'MAC: CBC_MAC-AES-128',
210 'MAC: CBC_MAC-AES-192',
211 'MAC: CBC_MAC-AES-256',
212 ],
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200213 'test_suite_psa_crypto_not_supported.generated': [
Gilles Peskine5e3ed3f2024-10-11 12:00:44 +0200214 # We never test with DH key support disabled but support
Gilles Peskineab5cc9b2024-09-17 17:57:11 +0200215 # for a DH group enabled. The dependencies of these test
216 # cases don't really make sense.
217 # https://github.com/Mbed-TLS/mbedtls/issues/9574
218 re.compile(r'PSA \w+ DH_.*type not supported'),
219 # We only test partial support for DH with the 2048-bit group
220 # enabled and the other groups disabled.
221 # https://github.com/Mbed-TLS/mbedtls/issues/9575
222 'PSA generate DH_KEY_PAIR(RFC7919) 2048-bit group not supported',
223 'PSA import DH_KEY_PAIR(RFC7919) 2048-bit group not supported',
224 'PSA import DH_PUBLIC_KEY(RFC7919) 2048-bit group not supported',
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200225 ],
226 'test_suite_psa_crypto_op_fail.generated': [
Gilles Peskine5872c0d2024-09-17 17:15:29 +0200227 # Ignore mechanisms that are not implemented, except
228 # for test cases that assume the mechanism is not supported.
229 _has_word_re(_PSA_MECHANISMS_NOT_IMPLEMENTED,
230 exclude=(r'.*: !(?:' +
231 r'|'.join(_PSA_MECHANISMS_NOT_IMPLEMENTED) +
232 r')\b')),
Gilles Peskineab5cc9b2024-09-17 17:57:11 +0200233 # Incorrect dependency generation. To be fixed as part of the
234 # resolution of https://github.com/Mbed-TLS/mbedtls/issues/9167
235 # by forward-porting the commit
236 # "PSA test case generation: dependency inference class: operation fail"
237 # from https://github.com/Mbed-TLS/mbedtls/pull/9025 .
238 re.compile(r'.* with (?:DH|ECC)_(?:KEY_PAIR|PUBLIC_KEY)\(.*'),
Gilles Peskineeafc2752024-04-19 19:08:34 +0200239 # We don't test this unusual, but sensible configuration.
240 # https://github.com/Mbed-TLS/mbedtls/issues/9592
241 re.compile(r'.*: !ECDSA but DETERMINISTIC_ECDSA with ECC_.*'),
Gilles Peskineab5cc9b2024-09-17 17:57:11 +0200242 # We never test with the HMAC algorithm enabled but the HMAC
243 # key type disabled. Those dependencies don't really make sense.
244 # https://github.com/Mbed-TLS/mbedtls/issues/9573
245 re.compile(r'.* !HMAC with HMAC'),
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200246 ],
Gilles Peskineeafc2752024-04-19 19:08:34 +0200247 'test_suite_psa_crypto_op_fail.misc': [
248 # We don't test this unusual, but sensible configuration.
249 # https://github.com/Mbed-TLS/mbedtls/issues/9592
250 'PSA sign DETERMINISTIC_ECDSA(SHA_256): !ECDSA but DETERMINISTIC_ECDSA with ECC_KEY_PAIR(SECP_R1)', #pylint: disable=line-too-long
251 ],
Gilles Peskinede2316b2024-09-17 18:32:05 +0200252 'tls13-misc': [
253 # Disabled due to OpenSSL bug.
254 # https://github.com/openssl/openssl/issues/10714
255 'TLS 1.3 O->m: resumption',
256 # Disabled due to OpenSSL command line limitation.
257 # https://github.com/Mbed-TLS/mbedtls/issues/9582
258 'TLS 1.3 m->O: resumption with early data',
259 ],
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200260 }
261
Gilles Peskine82b16722024-09-16 19:57:10 +0200262
Gilles Peskine9df375b2024-09-16 20:14:26 +0200263# The names that we give to classes derived from DriverVSReference do not
264# follow the usual naming convention, because it's more readable to use
265# underscores and parts of the configuration names. Also, these classes
266# are just there to specify some data, so they don't need repetitive
267# documentation.
268#pylint: disable=invalid-name,missing-class-docstring
269
Gilles Peskine082eade2024-10-03 18:42:37 +0200270class DriverVSReference_hash(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200271 REFERENCE = 'test_psa_crypto_config_reference_hash_use_psa'
272 DRIVER = 'test_psa_crypto_config_accel_hash_use_psa'
273 IGNORED_SUITES = [
274 'shax', 'mdx', # the software implementations that are being excluded
275 'md.psa', # purposefully depends on whether drivers are present
276 'psa_crypto_low_hash.generated', # testing the builtins
277 ]
278 IGNORED_TESTS = {
279 'test_suite_config': [
280 re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'),
281 ],
282 'test_suite_platform': [
283 # Incompatible with sanitizers (e.g. ASan). If the driver
284 # component uses a sanitizer but the reference component
285 # doesn't, we have a PASS vs SKIP mismatch.
286 'Check mbedtls_calloc overallocation',
287 ],
288 }
289
Gilles Peskine082eade2024-10-03 18:42:37 +0200290class DriverVSReference_hmac(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200291 REFERENCE = 'test_psa_crypto_config_reference_hmac'
292 DRIVER = 'test_psa_crypto_config_accel_hmac'
293 IGNORED_SUITES = [
294 # These suites require legacy hash support, which is disabled
295 # in the accelerated component.
296 'shax', 'mdx',
297 # This suite tests builtins directly, but these are missing
298 # in the accelerated case.
299 'psa_crypto_low_hash.generated',
300 ]
301 IGNORED_TESTS = {
302 'test_suite_config': [
303 re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'),
304 re.compile(r'.*\bMBEDTLS_MD_C\b')
305 ],
306 'test_suite_md': [
307 # Builtin HMAC is not supported in the accelerate component.
308 re.compile('.*HMAC.*'),
309 # Following tests make use of functions which are not available
310 # when MD_C is disabled, as it happens in the accelerated
311 # test component.
312 re.compile('generic .* Hash file .*'),
313 'MD list',
314 ],
315 'test_suite_md.psa': [
316 # "legacy only" tests require hash algorithms to be NOT
317 # accelerated, but this of course false for the accelerated
318 # test component.
319 re.compile('PSA dispatch .* legacy only'),
320 ],
321 'test_suite_platform': [
322 # Incompatible with sanitizers (e.g. ASan). If the driver
323 # component uses a sanitizer but the reference component
324 # doesn't, we have a PASS vs SKIP mismatch.
325 'Check mbedtls_calloc overallocation',
326 ],
327 }
328
Gilles Peskine082eade2024-10-03 18:42:37 +0200329class DriverVSReference_cipher_aead_cmac(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200330 REFERENCE = 'test_psa_crypto_config_reference_cipher_aead_cmac'
331 DRIVER = 'test_psa_crypto_config_accel_cipher_aead_cmac'
332 # Modules replaced by drivers.
333 IGNORED_SUITES = [
334 # low-level (block/stream) cipher modules
335 'aes', 'aria', 'camellia', 'des', 'chacha20',
336 # AEAD modes and CMAC
337 'ccm', 'chachapoly', 'cmac', 'gcm',
338 # The Cipher abstraction layer
339 'cipher',
340 ]
341 IGNORED_TESTS = {
342 'test_suite_config': [
343 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA|CHACHA20|DES)_.*'),
344 re.compile(r'.*\bMBEDTLS_(CCM|CHACHAPOLY|CMAC|GCM)_.*'),
345 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
346 re.compile(r'.*\bMBEDTLS_CIPHER_.*'),
347 ],
348 # PEM decryption is not supported so far.
349 # The rest of PEM (write, unencrypted read) works though.
350 'test_suite_pem': [
351 re.compile(r'PEM read .*(AES|DES|\bencrypt).*'),
352 ],
353 'test_suite_platform': [
354 # Incompatible with sanitizers (e.g. ASan). If the driver
355 # component uses a sanitizer but the reference component
356 # doesn't, we have a PASS vs SKIP mismatch.
357 'Check mbedtls_calloc overallocation',
358 ],
359 # Following tests depend on AES_C/DES_C but are not about
360 # them really, just need to know some error code is there.
361 'test_suite_error': [
362 'Low and high error',
363 'Single low error'
364 ],
365 # Similar to test_suite_error above.
366 'test_suite_version': [
367 'Check for MBEDTLS_AES_C when already present',
368 ],
369 # The en/decryption part of PKCS#12 is not supported so far.
370 # The rest of PKCS#12 (key derivation) works though.
371 'test_suite_pkcs12': [
372 re.compile(r'PBE Encrypt, .*'),
373 re.compile(r'PBE Decrypt, .*'),
374 ],
375 # The en/decryption part of PKCS#5 is not supported so far.
376 # The rest of PKCS#5 (PBKDF2) works though.
377 'test_suite_pkcs5': [
378 re.compile(r'PBES2 Encrypt, .*'),
379 re.compile(r'PBES2 Decrypt .*'),
380 ],
381 # Encrypted keys are not supported so far.
382 # pylint: disable=line-too-long
383 'test_suite_pkparse': [
384 'Key ASN1 (Encrypted key PKCS12, trailing garbage data)',
385 'Key ASN1 (Encrypted key PKCS5, trailing garbage data)',
386 re.compile(r'Parse (RSA|EC) Key .*\(.* ([Ee]ncrypted|password).*\)'),
387 ],
388 # Encrypted keys are not supported so far.
389 'ssl-opt': [
390 'TLS: password protected server key',
391 'TLS: password protected client key',
392 'TLS: password protected server key, two certificates',
393 ],
394 }
395
Gilles Peskine082eade2024-10-03 18:42:37 +0200396class DriverVSReference_ecp_light_only(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200397 REFERENCE = 'test_psa_crypto_config_reference_ecc_ecp_light_only'
398 DRIVER = 'test_psa_crypto_config_accel_ecc_ecp_light_only'
399 IGNORED_SUITES = [
400 # Modules replaced by drivers
401 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100402 # Unit tests for the built-in implementation
403 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200404 ]
405 IGNORED_TESTS = {
406 'test_suite_config': [
407 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
408 ],
409 'test_suite_platform': [
410 # Incompatible with sanitizers (e.g. ASan). If the driver
411 # component uses a sanitizer but the reference component
412 # doesn't, we have a PASS vs SKIP mismatch.
413 'Check mbedtls_calloc overallocation',
414 ],
415 # This test wants a legacy function that takes f_rng, p_rng
416 # arguments, and uses legacy ECDSA for that. The test is
417 # really about the wrapper around the PSA RNG, not ECDSA.
418 'test_suite_random': [
419 'PSA classic wrapper: ECDSA signature (SECP256R1)',
420 ],
421 # In the accelerated test ECP_C is not set (only ECP_LIGHT is)
422 # so we must ignore disparities in the tests for which ECP_C
423 # is required.
424 'test_suite_ecp': [
425 re.compile(r'ECP check public-private .*'),
426 re.compile(r'ECP calculate public: .*'),
427 re.compile(r'ECP gen keypair .*'),
428 re.compile(r'ECP point muladd .*'),
429 re.compile(r'ECP point multiplication .*'),
430 re.compile(r'ECP test vectors .*'),
431 ],
432 'test_suite_ssl': [
433 # This deprecated function is only present when ECP_C is On.
434 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
435 ],
436 }
437
Gilles Peskine082eade2024-10-03 18:42:37 +0200438class DriverVSReference_no_ecp_at_all(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200439 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_ecp_at_all'
440 DRIVER = 'test_psa_crypto_config_accel_ecc_no_ecp_at_all'
441 IGNORED_SUITES = [
442 # Modules replaced by drivers
443 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100444 # Unit tests for the built-in implementation
445 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200446 ]
447 IGNORED_TESTS = {
448 'test_suite_config': [
449 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
450 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
451 ],
452 'test_suite_platform': [
453 # Incompatible with sanitizers (e.g. ASan). If the driver
454 # component uses a sanitizer but the reference component
455 # doesn't, we have a PASS vs SKIP mismatch.
456 'Check mbedtls_calloc overallocation',
457 ],
458 # See ecp_light_only
459 'test_suite_random': [
460 'PSA classic wrapper: ECDSA signature (SECP256R1)',
461 ],
462 'test_suite_pkparse': [
463 # When PK_PARSE_C and ECP_C are defined then PK_PARSE_EC_COMPRESSED
464 # is automatically enabled in build_info.h (backward compatibility)
465 # even if it is disabled in config_psa_crypto_no_ecp_at_all(). As a
466 # consequence compressed points are supported in the reference
467 # component but not in the accelerated one, so they should be skipped
468 # while checking driver's coverage.
469 re.compile(r'Parse EC Key .*compressed\)'),
470 re.compile(r'Parse Public EC Key .*compressed\)'),
471 ],
472 # See ecp_light_only
473 'test_suite_ssl': [
474 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
475 ],
476 }
477
Gilles Peskine082eade2024-10-03 18:42:37 +0200478class DriverVSReference_ecc_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200479 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_bignum'
480 DRIVER = 'test_psa_crypto_config_accel_ecc_no_bignum'
481 IGNORED_SUITES = [
482 # Modules replaced by drivers
483 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
484 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
485 'bignum.generated', 'bignum.misc',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100486 # Unit tests for the built-in implementation
487 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200488 ]
489 IGNORED_TESTS = {
490 'test_suite_config': [
491 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
492 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
493 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
494 ],
495 'test_suite_platform': [
496 # Incompatible with sanitizers (e.g. ASan). If the driver
497 # component uses a sanitizer but the reference component
498 # doesn't, we have a PASS vs SKIP mismatch.
499 'Check mbedtls_calloc overallocation',
500 ],
501 # See ecp_light_only
502 'test_suite_random': [
503 'PSA classic wrapper: ECDSA signature (SECP256R1)',
504 ],
505 # See no_ecp_at_all
506 'test_suite_pkparse': [
507 re.compile(r'Parse EC Key .*compressed\)'),
508 re.compile(r'Parse Public EC Key .*compressed\)'),
509 ],
510 'test_suite_asn1parse': [
511 'INTEGER too large for mpi',
512 ],
513 'test_suite_asn1write': [
514 re.compile(r'ASN.1 Write mpi.*'),
515 ],
516 'test_suite_debug': [
517 re.compile(r'Debug print mbedtls_mpi.*'),
518 ],
519 # See ecp_light_only
520 'test_suite_ssl': [
521 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
522 ],
523 }
524
Gilles Peskine082eade2024-10-03 18:42:37 +0200525class DriverVSReference_ecc_ffdh_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200526 REFERENCE = 'test_psa_crypto_config_reference_ecc_ffdh_no_bignum'
527 DRIVER = 'test_psa_crypto_config_accel_ecc_ffdh_no_bignum'
528 IGNORED_SUITES = [
529 # Modules replaced by drivers
530 'ecp', 'ecdsa', 'ecdh', 'ecjpake', 'dhm',
531 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
532 'bignum.generated', 'bignum.misc',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100533 # Unit tests for the built-in implementation
534 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200535 ]
536 IGNORED_TESTS = {
537 'ssl-opt': [
538 # DHE support in TLS 1.2 requires built-in MBEDTLS_DHM_C
539 # (because it needs custom groups, which PSA does not
540 # provide), even with MBEDTLS_USE_PSA_CRYPTO.
541 re.compile(r'PSK callback:.*\bdhe-psk\b.*'),
542 ],
543 'test_suite_config': [
544 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
545 re.compile(r'.*\bMBEDTLS_DHM_C\b.*'),
546 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
547 re.compile(r'.*\bMBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED\b.*'),
548 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
549 ],
550 'test_suite_platform': [
551 # Incompatible with sanitizers (e.g. ASan). If the driver
552 # component uses a sanitizer but the reference component
553 # doesn't, we have a PASS vs SKIP mismatch.
554 'Check mbedtls_calloc overallocation',
555 ],
556 # See ecp_light_only
557 'test_suite_random': [
558 'PSA classic wrapper: ECDSA signature (SECP256R1)',
559 ],
560 # See no_ecp_at_all
561 'test_suite_pkparse': [
562 re.compile(r'Parse EC Key .*compressed\)'),
563 re.compile(r'Parse Public EC Key .*compressed\)'),
564 ],
565 'test_suite_asn1parse': [
566 'INTEGER too large for mpi',
567 ],
568 'test_suite_asn1write': [
569 re.compile(r'ASN.1 Write mpi.*'),
570 ],
571 'test_suite_debug': [
572 re.compile(r'Debug print mbedtls_mpi.*'),
573 ],
574 # See ecp_light_only
575 'test_suite_ssl': [
576 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
577 ],
578 }
579
Gilles Peskine082eade2024-10-03 18:42:37 +0200580class DriverVSReference_ffdh_alg(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200581 REFERENCE = 'test_psa_crypto_config_reference_ffdh'
582 DRIVER = 'test_psa_crypto_config_accel_ffdh'
583 IGNORED_SUITES = ['dhm']
584 IGNORED_TESTS = {
585 'test_suite_config': [
586 re.compile(r'.*\bMBEDTLS_DHM_C\b.*'),
587 ],
588 'test_suite_platform': [
589 # Incompatible with sanitizers (e.g. ASan). If the driver
590 # component uses a sanitizer but the reference component
591 # doesn't, we have a PASS vs SKIP mismatch.
592 'Check mbedtls_calloc overallocation',
593 ],
594 }
595
Gilles Peskine082eade2024-10-03 18:42:37 +0200596class DriverVSReference_tfm_config(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200597 REFERENCE = 'test_tfm_config_no_p256m'
598 DRIVER = 'test_tfm_config_p256m_driver_accel_ec'
599 IGNORED_SUITES = [
600 # Modules replaced by drivers
601 'asn1parse', 'asn1write',
602 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
603 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
604 'bignum.generated', 'bignum.misc',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100605 # Unit tests for the built-in implementation
606 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200607 ]
608 IGNORED_TESTS = {
609 'test_suite_config': [
610 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
611 re.compile(r'.*\bMBEDTLS_(ASN1\w+)_C\b.*'),
612 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECP)_.*'),
613 re.compile(r'.*\bMBEDTLS_PSA_P256M_DRIVER_ENABLED\b.*')
614 ],
615 'test_suite_config.crypto_combinations': [
616 'Config: ECC: Weierstrass curves only',
617 ],
618 'test_suite_platform': [
619 # Incompatible with sanitizers (e.g. ASan). If the driver
620 # component uses a sanitizer but the reference component
621 # doesn't, we have a PASS vs SKIP mismatch.
622 'Check mbedtls_calloc overallocation',
623 ],
624 # See ecp_light_only
625 'test_suite_random': [
626 'PSA classic wrapper: ECDSA signature (SECP256R1)',
627 ],
628 }
629
Gilles Peskine082eade2024-10-03 18:42:37 +0200630class DriverVSReference_rsa(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200631 REFERENCE = 'test_psa_crypto_config_reference_rsa_crypto'
632 DRIVER = 'test_psa_crypto_config_accel_rsa_crypto'
633 IGNORED_SUITES = [
634 # Modules replaced by drivers.
635 'rsa', 'pkcs1_v15', 'pkcs1_v21',
636 # We temporarily don't care about PK stuff.
637 'pk', 'pkwrite', 'pkparse'
638 ]
639 IGNORED_TESTS = {
640 'test_suite_config': [
641 re.compile(r'.*\bMBEDTLS_(PKCS1|RSA)_.*'),
642 re.compile(r'.*\bMBEDTLS_GENPRIME\b.*')
643 ],
644 'test_suite_platform': [
645 # Incompatible with sanitizers (e.g. ASan). If the driver
646 # component uses a sanitizer but the reference component
647 # doesn't, we have a PASS vs SKIP mismatch.
648 'Check mbedtls_calloc overallocation',
649 ],
650 # Following tests depend on RSA_C but are not about
651 # them really, just need to know some error code is there.
652 'test_suite_error': [
653 'Low and high error',
654 'Single high error'
655 ],
656 # Constant time operations only used for PKCS1_V15
657 'test_suite_constant_time': [
658 re.compile(r'mbedtls_ct_zeroize_if .*'),
659 re.compile(r'mbedtls_ct_memmove_left .*')
660 ],
661 'test_suite_psa_crypto': [
662 # We don't support generate_key_custom entry points
663 # in drivers yet.
664 re.compile(r'PSA generate key custom: RSA, e=.*'),
665 re.compile(r'PSA generate key ext: RSA, e=.*'),
666 ],
667 }
668
Gilles Peskine082eade2024-10-03 18:42:37 +0200669class DriverVSReference_block_cipher_dispatch(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200670 REFERENCE = 'test_full_block_cipher_legacy_dispatch'
671 DRIVER = 'test_full_block_cipher_psa_dispatch'
672 IGNORED_SUITES = [
673 # Skipped in the accelerated component
674 'aes', 'aria', 'camellia',
675 # These require AES_C, ARIA_C or CAMELLIA_C to be enabled in
676 # order for the cipher module (actually cipher_wrapper) to work
677 # properly. However these symbols are disabled in the accelerated
678 # component so we ignore them.
679 'cipher.ccm', 'cipher.gcm', 'cipher.aes', 'cipher.aria',
680 'cipher.camellia',
681 ]
682 IGNORED_TESTS = {
683 'test_suite_config': [
684 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA)_.*'),
685 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
686 ],
687 'test_suite_cmac': [
688 # Following tests require AES_C/ARIA_C/CAMELLIA_C to be enabled,
689 # but these are not available in the accelerated component.
690 'CMAC null arguments',
691 re.compile('CMAC.* (AES|ARIA|Camellia).*'),
692 ],
693 'test_suite_cipher.padding': [
694 # Following tests require AES_C/CAMELLIA_C to be enabled,
695 # but these are not available in the accelerated component.
696 re.compile('Set( non-existent)? padding with (AES|CAMELLIA).*'),
697 ],
698 'test_suite_pkcs5': [
699 # The AES part of PKCS#5 PBES2 is not yet supported.
700 # The rest of PKCS#5 (PBKDF2) works, though.
701 re.compile(r'PBES2 .* AES-.*')
702 ],
703 'test_suite_pkparse': [
704 # PEM (called by pkparse) requires AES_C in order to decrypt
705 # the key, but this is not available in the accelerated
706 # component.
707 re.compile('Parse RSA Key.*(password|AES-).*'),
708 ],
709 'test_suite_pem': [
710 # Following tests require AES_C, but this is diabled in the
711 # accelerated component.
712 re.compile('PEM read .*AES.*'),
713 'PEM read (unknown encryption algorithm)',
714 ],
715 'test_suite_error': [
716 # Following tests depend on AES_C but are not about them
717 # really, just need to know some error code is there.
718 'Single low error',
719 'Low and high error',
720 ],
721 'test_suite_version': [
722 # Similar to test_suite_error above.
723 'Check for MBEDTLS_AES_C when already present',
724 ],
725 'test_suite_platform': [
726 # Incompatible with sanitizers (e.g. ASan). If the driver
727 # component uses a sanitizer but the reference component
728 # doesn't, we have a PASS vs SKIP mismatch.
729 'Check mbedtls_calloc overallocation',
730 ],
731 }
732
733#pylint: enable=invalid-name,missing-class-docstring
734
735
Przemek Stekiel6856f4c2022-11-09 10:50:29 +0100736# List of tasks with a function that can handle this task and additional arguments if required
Valerio Settidfd7ca62023-10-09 16:30:11 +0200737KNOWN_TASKS = {
Gilles Peskinef646dbf2024-09-16 19:15:29 +0200738 'analyze_coverage': CoverageTask,
Gilles Peskine9df375b2024-09-16 20:14:26 +0200739 'analyze_driver_vs_reference_hash': DriverVSReference_hash,
740 'analyze_driver_vs_reference_hmac': DriverVSReference_hmac,
741 'analyze_driver_vs_reference_cipher_aead_cmac': DriverVSReference_cipher_aead_cmac,
742 'analyze_driver_vs_reference_ecp_light_only': DriverVSReference_ecp_light_only,
743 'analyze_driver_vs_reference_no_ecp_at_all': DriverVSReference_no_ecp_at_all,
744 'analyze_driver_vs_reference_ecc_no_bignum': DriverVSReference_ecc_no_bignum,
745 'analyze_driver_vs_reference_ecc_ffdh_no_bignum': DriverVSReference_ecc_ffdh_no_bignum,
746 'analyze_driver_vs_reference_ffdh_alg': DriverVSReference_ffdh_alg,
747 'analyze_driver_vs_reference_tfm_config': DriverVSReference_tfm_config,
748 'analyze_driver_vs_reference_rsa': DriverVSReference_rsa,
749 'analyze_block_cipher_dispatch': DriverVSReference_block_cipher_dispatch,
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200750}
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200751
Gilles Peskine15c2cbf2020-06-25 18:36:28 +0200752if __name__ == '__main__':
Gilles Peskine082eade2024-10-03 18:42:37 +0200753 outcome_analysis.main(KNOWN_TASKS)