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