blob: ad1cf37307d35193b351dab0b74a9ba7c207a053 [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',
135 # Family declared but not supported.
136 'Config: PSA_WANT_ECC_SECP_K1_224',
137 # More granularity of key pair type enablement macros
138 # than we care to test.
139 # https://github.com/Mbed-TLS/mbedtls/issues/9590
140 'Config: PSA_WANT_KEY_TYPE_DH_KEY_PAIR_DERIVE',
141 'Config: PSA_WANT_KEY_TYPE_ECC_KEY_PAIR',
142 'Config: PSA_WANT_KEY_TYPE_RSA_KEY_PAIR',
143 'Config: PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_DERIVE',
Minos Galanakis848333d2024-12-02 15:58:32 +0000144 # https://github.com/Mbed-TLS/mbedtls/issues/9583
145 'Config: !MBEDTLS_ECP_NIST_OPTIM',
146 # We never test without the PSA client code. Should we?
147 # https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/112
148 'Config: !MBEDTLS_PSA_CRYPTO_CLIENT',
149 # We only test multithreading with pthreads.
150 # https://github.com/Mbed-TLS/mbedtls/issues/9584
151 'Config: !MBEDTLS_THREADING_PTHREAD',
152 # Built but not tested.
153 # https://github.com/Mbed-TLS/mbedtls/issues/9587
154 'Config: MBEDTLS_AES_USE_HARDWARE_ONLY',
155 # Untested platform-specific optimizations.
156 # https://github.com/Mbed-TLS/mbedtls/issues/9588
157 'Config: MBEDTLS_HAVE_SSE2',
158 # Obsolete configuration option, to be replaced by
159 # PSA entropy drivers.
160 # https://github.com/Mbed-TLS/mbedtls/issues/8150
161 'Config: MBEDTLS_NO_PLATFORM_ENTROPY',
162 # Untested aspect of the platform interface.
163 # https://github.com/Mbed-TLS/mbedtls/issues/9589
164 'Config: MBEDTLS_PLATFORM_NO_STD_FUNCTIONS',
165 # In a client-server build, test_suite_config runs in the
166 # client configuration, so it will never report
167 # MBEDTLS_PSA_CRYPTO_SPM as enabled. That's ok.
168 'Config: MBEDTLS_PSA_CRYPTO_SPM',
169 # We don't test on armv8 yet.
170 'Config: MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT',
171 'Config: MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY',
172 'Config: MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY',
173 'Config: MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY',
174 # We don't run test_suite_config when we test this.
175 # https://github.com/Mbed-TLS/mbedtls/issues/9586
176 'Config: MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND',
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200177 ],
178 'test_suite_config.psa_combinations': [
179 # We don't test this unusual, but sensible configuration.
180 # https://github.com/Mbed-TLS/mbedtls/issues/9592
181 'Config: PSA_WANT_ALG_DETERMINSTIC_ECDSA without PSA_WANT_ALG_ECDSA',
182 ],
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200183 'test_suite_pkcs12': [
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200184 # We never test with CBC/PKCS5/PKCS12 enabled but
185 # PKCS7 padding disabled.
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200186 # https://github.com/Mbed-TLS/mbedtls/issues/9580
187 'PBE Decrypt, (Invalid padding & PKCS7 padding disabled)',
188 'PBE Encrypt, pad = 8 (PKCS7 padding disabled)',
189 ],
190 'test_suite_pkcs5': [
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200191 # We never test with CBC/PKCS5/PKCS12 enabled but
192 # PKCS7 padding disabled.
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200193 # https://github.com/Mbed-TLS/mbedtls/issues/9580
194 'PBES2 Decrypt (Invalid padding & PKCS7 padding disabled)',
195 'PBES2 Encrypt, pad=6 (PKCS7 padding disabled)',
196 'PBES2 Encrypt, pad=8 (PKCS7 padding disabled)',
197 ],
Gilles Peskineeafc2752024-04-19 19:08:34 +0200198 'test_suite_psa_crypto': [
199 # We don't test this unusual, but sensible configuration.
200 # https://github.com/Mbed-TLS/mbedtls/issues/9592
201 re.compile(r'.*ECDSA.*only deterministic supported'),
202 ],
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200203 'test_suite_psa_crypto_generate_key.generated': [
Gilles Peskine5872c0d2024-09-17 17:15:29 +0200204 # Ignore mechanisms that are not implemented, except
205 # for public keys for which we always test that
206 # psa_generate_key() returns PSA_ERROR_INVALID_ARGUMENT
207 # regardless of whether the specific key type is supported.
208 _has_word_re((mech
209 for mech in _PSA_MECHANISMS_NOT_IMPLEMENTED
210 if not mech.startswith('ECC_PUB')),
211 exclude=r'ECC_PUB'),
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200212 ],
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200213 'test_suite_psa_crypto_metadata': [
214 # Algorithms declared but not supported.
215 # https://github.com/Mbed-TLS/mbedtls/issues/9579
216 'Asymmetric signature: Ed25519ph',
217 'Asymmetric signature: Ed448ph',
218 'Asymmetric signature: pure EdDSA',
219 'Cipher: XTS',
220 'MAC: CBC_MAC-3DES',
221 'MAC: CBC_MAC-AES-128',
222 'MAC: CBC_MAC-AES-192',
223 'MAC: CBC_MAC-AES-256',
224 ],
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200225 'test_suite_psa_crypto_not_supported.generated': [
Gilles Peskineab5cc9b2024-09-17 17:57:11 +0200226 # It is a bug that not-supported test cases aren't getting
227 # run for never-implemented key types.
228 # https://github.com/Mbed-TLS/mbedtls/issues/7915
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200229 PSA_MECHANISM_NOT_IMPLEMENTED_SEARCH_RE,
Gilles Peskine5e3ed3f2024-10-11 12:00:44 +0200230 # We never test with DH key support disabled but support
Gilles Peskineab5cc9b2024-09-17 17:57:11 +0200231 # for a DH group enabled. The dependencies of these test
232 # cases don't really make sense.
233 # https://github.com/Mbed-TLS/mbedtls/issues/9574
234 re.compile(r'PSA \w+ DH_.*type not supported'),
235 # We only test partial support for DH with the 2048-bit group
236 # enabled and the other groups disabled.
237 # https://github.com/Mbed-TLS/mbedtls/issues/9575
238 'PSA generate DH_KEY_PAIR(RFC7919) 2048-bit group not supported',
239 'PSA import DH_KEY_PAIR(RFC7919) 2048-bit group not supported',
240 'PSA import DH_PUBLIC_KEY(RFC7919) 2048-bit group not supported',
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200241 ],
242 'test_suite_psa_crypto_op_fail.generated': [
Gilles Peskine5872c0d2024-09-17 17:15:29 +0200243 # Ignore mechanisms that are not implemented, except
244 # for test cases that assume the mechanism is not supported.
245 _has_word_re(_PSA_MECHANISMS_NOT_IMPLEMENTED,
246 exclude=(r'.*: !(?:' +
247 r'|'.join(_PSA_MECHANISMS_NOT_IMPLEMENTED) +
248 r')\b')),
Gilles Peskineab5cc9b2024-09-17 17:57:11 +0200249 # Incorrect dependency generation. To be fixed as part of the
250 # resolution of https://github.com/Mbed-TLS/mbedtls/issues/9167
251 # by forward-porting the commit
252 # "PSA test case generation: dependency inference class: operation fail"
253 # from https://github.com/Mbed-TLS/mbedtls/pull/9025 .
254 re.compile(r'.* with (?:DH|ECC)_(?:KEY_PAIR|PUBLIC_KEY)\(.*'),
Gilles Peskineeafc2752024-04-19 19:08:34 +0200255 # We don't test this unusual, but sensible configuration.
256 # https://github.com/Mbed-TLS/mbedtls/issues/9592
257 re.compile(r'.*: !ECDSA but DETERMINISTIC_ECDSA with ECC_.*'),
Gilles Peskineab5cc9b2024-09-17 17:57:11 +0200258 # We never test with the HMAC algorithm enabled but the HMAC
259 # key type disabled. Those dependencies don't really make sense.
260 # https://github.com/Mbed-TLS/mbedtls/issues/9573
261 re.compile(r'.* !HMAC with HMAC'),
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200262 ],
Gilles Peskineeafc2752024-04-19 19:08:34 +0200263 'test_suite_psa_crypto_op_fail.misc': [
264 # We don't test this unusual, but sensible configuration.
265 # https://github.com/Mbed-TLS/mbedtls/issues/9592
266 'PSA sign DETERMINISTIC_ECDSA(SHA_256): !ECDSA but DETERMINISTIC_ECDSA with ECC_KEY_PAIR(SECP_R1)', #pylint: disable=line-too-long
267 ],
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200268 'test_suite_psa_crypto_storage_format.current': [
269 PSA_MECHANISM_NOT_IMPLEMENTED_SEARCH_RE,
270 ],
271 'test_suite_psa_crypto_storage_format.v0': [
272 PSA_MECHANISM_NOT_IMPLEMENTED_SEARCH_RE,
273 ],
Gilles Peskinede2316b2024-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 Peskine2a71fac2024-09-17 15:07:22 +0200282 }
283
Gilles Peskine82b16722024-09-16 19:57:10 +0200284
Gilles Peskine9df375b2024-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 Peskine082eade2024-10-03 18:42:37 +0200292class DriverVSReference_hash(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-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 Peskine082eade2024-10-03 18:42:37 +0200312class DriverVSReference_hmac(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-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 Peskine082eade2024-10-03 18:42:37 +0200351class DriverVSReference_cipher_aead_cmac(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-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 Peskine082eade2024-10-03 18:42:37 +0200418class DriverVSReference_ecp_light_only(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-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 Peskine77587ce2024-10-29 20:55:11 +0100424 # Unit tests for the built-in implementation
425 'psa_crypto_ecp',
Gilles Peskine9df375b2024-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 Peskine082eade2024-10-03 18:42:37 +0200460class DriverVSReference_no_ecp_at_all(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-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 Peskine77587ce2024-10-29 20:55:11 +0100466 # Unit tests for the built-in implementation
467 'psa_crypto_ecp',
Gilles Peskine9df375b2024-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 Peskine082eade2024-10-03 18:42:37 +0200500class DriverVSReference_ecc_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-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 Peskine77587ce2024-10-29 20:55:11 +0100508 # Unit tests for the built-in implementation
509 'psa_crypto_ecp',
Gilles Peskine9df375b2024-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 Peskine082eade2024-10-03 18:42:37 +0200547class DriverVSReference_ecc_ffdh_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-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 Peskine77587ce2024-10-29 20:55:11 +0100555 # Unit tests for the built-in implementation
556 'psa_crypto_ecp',
Gilles Peskine9df375b2024-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 Peskine082eade2024-10-03 18:42:37 +0200602class DriverVSReference_ffdh_alg(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-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 Peskine082eade2024-10-03 18:42:37 +0200618class DriverVSReference_tfm_config(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-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 Peskine77587ce2024-10-29 20:55:11 +0100627 # Unit tests for the built-in implementation
628 'psa_crypto_ecp',
Gilles Peskine9df375b2024-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 Peskine082eade2024-10-03 18:42:37 +0200652class DriverVSReference_rsa(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-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 Peskine082eade2024-10-03 18:42:37 +0200691class DriverVSReference_block_cipher_dispatch(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-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 Peskinef646dbf2024-09-16 19:15:29 +0200760 'analyze_coverage': CoverageTask,
Gilles Peskine9df375b2024-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 Peskine082eade2024-10-03 18:42:37 +0200775 outcome_analysis.main(KNOWN_TASKS)