blob: 18c8bde8bd6db3e3a7eb0c69dc6e66c0efea2117 [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',
Gilles Peskine9a094432024-10-29 20:55:11 +0100431 # Unit tests for the built-in implementation
432 'psa_crypto_ecp',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200433 ]
434 IGNORED_TESTS = {
435 'test_suite_config': [
436 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
437 ],
438 'test_suite_platform': [
439 # Incompatible with sanitizers (e.g. ASan). If the driver
440 # component uses a sanitizer but the reference component
441 # doesn't, we have a PASS vs SKIP mismatch.
442 'Check mbedtls_calloc overallocation',
443 ],
444 # This test wants a legacy function that takes f_rng, p_rng
445 # arguments, and uses legacy ECDSA for that. The test is
446 # really about the wrapper around the PSA RNG, not ECDSA.
447 'test_suite_random': [
448 'PSA classic wrapper: ECDSA signature (SECP256R1)',
449 ],
450 # In the accelerated test ECP_C is not set (only ECP_LIGHT is)
451 # so we must ignore disparities in the tests for which ECP_C
452 # is required.
453 'test_suite_ecp': [
454 re.compile(r'ECP check public-private .*'),
455 re.compile(r'ECP calculate public: .*'),
456 re.compile(r'ECP gen keypair .*'),
457 re.compile(r'ECP point muladd .*'),
458 re.compile(r'ECP point multiplication .*'),
459 re.compile(r'ECP test vectors .*'),
460 ],
461 'test_suite_ssl': [
462 # This deprecated function is only present when ECP_C is On.
463 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
464 ],
465 }
466
Gilles Peskine45a32b12024-10-03 18:42:37 +0200467class DriverVSReference_no_ecp_at_all(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200468 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_ecp_at_all'
469 DRIVER = 'test_psa_crypto_config_accel_ecc_no_ecp_at_all'
470 IGNORED_SUITES = [
471 # Modules replaced by drivers
472 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine9a094432024-10-29 20:55:11 +0100473 # Unit tests for the built-in implementation
474 'psa_crypto_ecp',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200475 ]
476 IGNORED_TESTS = {
477 'test_suite_config': [
478 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
479 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
480 ],
481 'test_suite_platform': [
482 # Incompatible with sanitizers (e.g. ASan). If the driver
483 # component uses a sanitizer but the reference component
484 # doesn't, we have a PASS vs SKIP mismatch.
485 'Check mbedtls_calloc overallocation',
486 ],
487 # See ecp_light_only
488 'test_suite_random': [
489 'PSA classic wrapper: ECDSA signature (SECP256R1)',
490 ],
491 'test_suite_pkparse': [
492 # When PK_PARSE_C and ECP_C are defined then PK_PARSE_EC_COMPRESSED
493 # is automatically enabled in build_info.h (backward compatibility)
494 # even if it is disabled in config_psa_crypto_no_ecp_at_all(). As a
495 # consequence compressed points are supported in the reference
496 # component but not in the accelerated one, so they should be skipped
497 # while checking driver's coverage.
498 re.compile(r'Parse EC Key .*compressed\)'),
499 re.compile(r'Parse Public EC Key .*compressed\)'),
500 ],
501 # See ecp_light_only
502 'test_suite_ssl': [
503 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
504 ],
505 }
506
Gilles Peskine45a32b12024-10-03 18:42:37 +0200507class DriverVSReference_ecc_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200508 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_bignum'
509 DRIVER = 'test_psa_crypto_config_accel_ecc_no_bignum'
510 IGNORED_SUITES = [
511 # Modules replaced by drivers
512 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
513 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
514 'bignum.generated', 'bignum.misc',
Gilles Peskine9a094432024-10-29 20:55:11 +0100515 # Unit tests for the built-in implementation
516 'psa_crypto_ecp',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200517 ]
518 IGNORED_TESTS = {
519 'test_suite_config': [
520 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
521 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
522 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
523 ],
524 'test_suite_platform': [
525 # Incompatible with sanitizers (e.g. ASan). If the driver
526 # component uses a sanitizer but the reference component
527 # doesn't, we have a PASS vs SKIP mismatch.
528 'Check mbedtls_calloc overallocation',
529 ],
530 # See ecp_light_only
531 'test_suite_random': [
532 'PSA classic wrapper: ECDSA signature (SECP256R1)',
533 ],
534 # See no_ecp_at_all
535 'test_suite_pkparse': [
536 re.compile(r'Parse EC Key .*compressed\)'),
537 re.compile(r'Parse Public EC Key .*compressed\)'),
538 ],
539 'test_suite_asn1parse': [
540 'INTEGER too large for mpi',
541 ],
542 'test_suite_asn1write': [
543 re.compile(r'ASN.1 Write mpi.*'),
544 ],
545 'test_suite_debug': [
546 re.compile(r'Debug print mbedtls_mpi.*'),
547 ],
548 # See ecp_light_only
549 'test_suite_ssl': [
550 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
551 ],
552 }
553
Gilles Peskine45a32b12024-10-03 18:42:37 +0200554class DriverVSReference_ecc_ffdh_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200555 REFERENCE = 'test_psa_crypto_config_reference_ecc_ffdh_no_bignum'
556 DRIVER = 'test_psa_crypto_config_accel_ecc_ffdh_no_bignum'
557 IGNORED_SUITES = [
558 # Modules replaced by drivers
559 'ecp', 'ecdsa', 'ecdh', 'ecjpake', 'dhm',
560 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
561 'bignum.generated', 'bignum.misc',
Gilles Peskine9a094432024-10-29 20:55:11 +0100562 # Unit tests for the built-in implementation
563 'psa_crypto_ecp',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200564 ]
565 IGNORED_TESTS = {
566 'ssl-opt': [
567 # DHE support in TLS 1.2 requires built-in MBEDTLS_DHM_C
568 # (because it needs custom groups, which PSA does not
569 # provide), even with MBEDTLS_USE_PSA_CRYPTO.
570 re.compile(r'PSK callback:.*\bdhe-psk\b.*'),
571 ],
572 'test_suite_config': [
573 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
574 re.compile(r'.*\bMBEDTLS_DHM_C\b.*'),
575 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
576 re.compile(r'.*\bMBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED\b.*'),
577 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
578 ],
579 'test_suite_platform': [
580 # Incompatible with sanitizers (e.g. ASan). If the driver
581 # component uses a sanitizer but the reference component
582 # doesn't, we have a PASS vs SKIP mismatch.
583 'Check mbedtls_calloc overallocation',
584 ],
585 # See ecp_light_only
586 'test_suite_random': [
587 'PSA classic wrapper: ECDSA signature (SECP256R1)',
588 ],
589 # See no_ecp_at_all
590 'test_suite_pkparse': [
591 re.compile(r'Parse EC Key .*compressed\)'),
592 re.compile(r'Parse Public EC Key .*compressed\)'),
593 ],
594 'test_suite_asn1parse': [
595 'INTEGER too large for mpi',
596 ],
597 'test_suite_asn1write': [
598 re.compile(r'ASN.1 Write mpi.*'),
599 ],
600 'test_suite_debug': [
601 re.compile(r'Debug print mbedtls_mpi.*'),
602 ],
603 # See ecp_light_only
604 'test_suite_ssl': [
605 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
606 ],
607 }
608
Gilles Peskine45a32b12024-10-03 18:42:37 +0200609class DriverVSReference_ffdh_alg(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200610 REFERENCE = 'test_psa_crypto_config_reference_ffdh'
611 DRIVER = 'test_psa_crypto_config_accel_ffdh'
612 IGNORED_SUITES = ['dhm']
613 IGNORED_TESTS = {
614 'test_suite_config': [
615 re.compile(r'.*\bMBEDTLS_DHM_C\b.*'),
616 ],
617 'test_suite_platform': [
618 # Incompatible with sanitizers (e.g. ASan). If the driver
619 # component uses a sanitizer but the reference component
620 # doesn't, we have a PASS vs SKIP mismatch.
621 'Check mbedtls_calloc overallocation',
622 ],
623 }
624
Gilles Peskine45a32b12024-10-03 18:42:37 +0200625class DriverVSReference_tfm_config(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200626 REFERENCE = 'test_tfm_config_no_p256m'
627 DRIVER = 'test_tfm_config_p256m_driver_accel_ec'
628 IGNORED_SUITES = [
629 # Modules replaced by drivers
630 'asn1parse', 'asn1write',
631 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
632 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
633 'bignum.generated', 'bignum.misc',
Gilles Peskine9a094432024-10-29 20:55:11 +0100634 # Unit tests for the built-in implementation
635 'psa_crypto_ecp',
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200636 ]
637 IGNORED_TESTS = {
638 'test_suite_config': [
639 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
640 re.compile(r'.*\bMBEDTLS_(ASN1\w+)_C\b.*'),
641 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECP)_.*'),
642 re.compile(r'.*\bMBEDTLS_PSA_P256M_DRIVER_ENABLED\b.*')
643 ],
644 'test_suite_config.crypto_combinations': [
645 'Config: ECC: Weierstrass curves only',
646 ],
647 'test_suite_platform': [
648 # Incompatible with sanitizers (e.g. ASan). If the driver
649 # component uses a sanitizer but the reference component
650 # doesn't, we have a PASS vs SKIP mismatch.
651 'Check mbedtls_calloc overallocation',
652 ],
653 # See ecp_light_only
654 'test_suite_random': [
655 'PSA classic wrapper: ECDSA signature (SECP256R1)',
656 ],
657 }
658
Gilles Peskine45a32b12024-10-03 18:42:37 +0200659class DriverVSReference_rsa(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200660 REFERENCE = 'test_psa_crypto_config_reference_rsa_crypto'
661 DRIVER = 'test_psa_crypto_config_accel_rsa_crypto'
662 IGNORED_SUITES = [
663 # Modules replaced by drivers.
664 'rsa', 'pkcs1_v15', 'pkcs1_v21',
665 # We temporarily don't care about PK stuff.
666 'pk', 'pkwrite', 'pkparse'
667 ]
668 IGNORED_TESTS = {
669 'test_suite_config': [
670 re.compile(r'.*\bMBEDTLS_(PKCS1|RSA)_.*'),
671 re.compile(r'.*\bMBEDTLS_GENPRIME\b.*')
672 ],
673 'test_suite_platform': [
674 # Incompatible with sanitizers (e.g. ASan). If the driver
675 # component uses a sanitizer but the reference component
676 # doesn't, we have a PASS vs SKIP mismatch.
677 'Check mbedtls_calloc overallocation',
678 ],
679 # Following tests depend on RSA_C but are not about
680 # them really, just need to know some error code is there.
681 'test_suite_error': [
682 'Low and high error',
683 'Single high error'
684 ],
685 # Constant time operations only used for PKCS1_V15
686 'test_suite_constant_time': [
687 re.compile(r'mbedtls_ct_zeroize_if .*'),
688 re.compile(r'mbedtls_ct_memmove_left .*')
689 ],
690 'test_suite_psa_crypto': [
691 # We don't support generate_key_custom entry points
692 # in drivers yet.
693 re.compile(r'PSA generate key custom: RSA, e=.*'),
694 re.compile(r'PSA generate key ext: RSA, e=.*'),
695 ],
696 }
697
Gilles Peskine45a32b12024-10-03 18:42:37 +0200698class DriverVSReference_block_cipher_dispatch(outcome_analysis.DriverVSReference):
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200699 REFERENCE = 'test_full_block_cipher_legacy_dispatch'
700 DRIVER = 'test_full_block_cipher_psa_dispatch'
701 IGNORED_SUITES = [
702 # Skipped in the accelerated component
703 'aes', 'aria', 'camellia',
704 # These require AES_C, ARIA_C or CAMELLIA_C to be enabled in
705 # order for the cipher module (actually cipher_wrapper) to work
706 # properly. However these symbols are disabled in the accelerated
707 # component so we ignore them.
708 'cipher.ccm', 'cipher.gcm', 'cipher.aes', 'cipher.aria',
709 'cipher.camellia',
710 ]
711 IGNORED_TESTS = {
712 'test_suite_config': [
713 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA)_.*'),
714 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
715 ],
716 'test_suite_cmac': [
717 # Following tests require AES_C/ARIA_C/CAMELLIA_C to be enabled,
718 # but these are not available in the accelerated component.
719 'CMAC null arguments',
720 re.compile('CMAC.* (AES|ARIA|Camellia).*'),
721 ],
722 'test_suite_cipher.padding': [
723 # Following tests require AES_C/CAMELLIA_C to be enabled,
724 # but these are not available in the accelerated component.
725 re.compile('Set( non-existent)? padding with (AES|CAMELLIA).*'),
726 ],
727 'test_suite_pkcs5': [
728 # The AES part of PKCS#5 PBES2 is not yet supported.
729 # The rest of PKCS#5 (PBKDF2) works, though.
730 re.compile(r'PBES2 .* AES-.*')
731 ],
732 'test_suite_pkparse': [
733 # PEM (called by pkparse) requires AES_C in order to decrypt
734 # the key, but this is not available in the accelerated
735 # component.
736 re.compile('Parse RSA Key.*(password|AES-).*'),
737 ],
738 'test_suite_pem': [
739 # Following tests require AES_C, but this is diabled in the
740 # accelerated component.
741 re.compile('PEM read .*AES.*'),
742 'PEM read (unknown encryption algorithm)',
743 ],
744 'test_suite_error': [
745 # Following tests depend on AES_C but are not about them
746 # really, just need to know some error code is there.
747 'Single low error',
748 'Low and high error',
749 ],
750 'test_suite_version': [
751 # Similar to test_suite_error above.
752 'Check for MBEDTLS_AES_C when already present',
753 ],
754 'test_suite_platform': [
755 # Incompatible with sanitizers (e.g. ASan). If the driver
756 # component uses a sanitizer but the reference component
757 # doesn't, we have a PASS vs SKIP mismatch.
758 'Check mbedtls_calloc overallocation',
759 ],
760 }
761
762#pylint: enable=invalid-name,missing-class-docstring
763
764
Przemek Stekiel6856f4c2022-11-09 10:50:29 +0100765# List of tasks with a function that can handle this task and additional arguments if required
Valerio Settidfd7ca62023-10-09 16:30:11 +0200766KNOWN_TASKS = {
Gilles Peskine0316f102024-09-16 19:15:29 +0200767 'analyze_coverage': CoverageTask,
Gilles Peskine92cc8db2024-09-16 20:14:26 +0200768 'analyze_driver_vs_reference_hash': DriverVSReference_hash,
769 'analyze_driver_vs_reference_hmac': DriverVSReference_hmac,
770 'analyze_driver_vs_reference_cipher_aead_cmac': DriverVSReference_cipher_aead_cmac,
771 'analyze_driver_vs_reference_ecp_light_only': DriverVSReference_ecp_light_only,
772 'analyze_driver_vs_reference_no_ecp_at_all': DriverVSReference_no_ecp_at_all,
773 'analyze_driver_vs_reference_ecc_no_bignum': DriverVSReference_ecc_no_bignum,
774 'analyze_driver_vs_reference_ecc_ffdh_no_bignum': DriverVSReference_ecc_ffdh_no_bignum,
775 'analyze_driver_vs_reference_ffdh_alg': DriverVSReference_ffdh_alg,
776 'analyze_driver_vs_reference_tfm_config': DriverVSReference_tfm_config,
777 'analyze_driver_vs_reference_rsa': DriverVSReference_rsa,
778 'analyze_block_cipher_dispatch': DriverVSReference_block_cipher_dispatch,
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200779}
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200780
Gilles Peskine15c2cbf2020-06-25 18:36:28 +0200781if __name__ == '__main__':
Gilles Peskine45a32b12024-10-03 18:42:37 +0200782 outcome_analysis.main(KNOWN_TASKS)