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