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