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