blob: 8cd0c160ec41233aaa3a20eacccbaa883e2ce5e3 [file] [log] [blame]
Gilles Peskine15c2cbf2020-06-25 18:36:28 +02001#!/usr/bin/env python3
2
3"""Analyze the test outcomes from a full CI run.
4
5This script can also run on outcomes from a partial run, but the results are
6less likely to be useful.
7"""
8
Przemek Stekiel85c54ea2022-11-17 11:50:23 +01009import re
Gilles Peskine2a71fac2024-09-17 15:07:22 +020010import typing
Gilles Peskine15c2cbf2020-06-25 18:36:28 +020011
Gilles Peskine31467722024-10-03 18:52:58 +020012import scripts_path # pylint: disable=unused-import
13from mbedtls_framework import outcome_analysis
Gilles Peskine8d3c70a2020-06-25 18:37:43 +020014
Pengyu Lvc2e8f3a2023-11-28 17:22:04 +080015
Gilles Peskine082eade2024-10-03 18:42:37 +020016class CoverageTask(outcome_analysis.CoverageTask):
Gilles Peskine96db2cc2024-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 Peskine3f5022e2024-09-16 20:23:40 +020020
Gilles Peskine2a71fac2024-09-17 15:07:22 +020021 @staticmethod
Gilles Peskine5872c0d2024-09-17 17:15:29 +020022 def _has_word_re(words: typing.Iterable[str],
23 exclude: typing.Optional[str] = None) -> typing.Pattern:
Gilles Peskine2a71fac2024-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 Peskine5872c0d2024-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 Peskine2a71fac2024-09-17 15:07:22 +020030 """
Gilles Peskine5872c0d2024-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 Peskine2a71fac2024-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 Peskinede2316b2024-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 Peskine2a71fac2024-09-17 15:07:22 +020095 'test_suite_psa_crypto_generate_key.generated': [
Gilles Peskine5872c0d2024-09-17 17:15:29 +020096 # Ignore mechanisms that are not implemented, except
97 # for public keys for which we always test that
98 # psa_generate_key() returns PSA_ERROR_INVALID_ARGUMENT
99 # regardless of whether the specific key type is supported.
100 _has_word_re((mech
101 for mech in _PSA_MECHANISMS_NOT_IMPLEMENTED
102 if not mech.startswith('ECC_PUB')),
103 exclude=r'ECC_PUB'),
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200104 ],
105 'test_suite_psa_crypto_not_supported.generated': [
Gilles Peskineab5cc9b2024-09-17 17:57:11 +0200106 # It is a bug that not-supported test cases aren't getting
107 # run for never-implemented key types.
108 # https://github.com/Mbed-TLS/mbedtls/issues/7915
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200109 PSA_MECHANISM_NOT_IMPLEMENTED_SEARCH_RE,
Gilles Peskineab5cc9b2024-09-17 17:57:11 +0200110 # We mever test with DH key support disabled but support
111 # for a DH group enabled. The dependencies of these test
112 # cases don't really make sense.
113 # https://github.com/Mbed-TLS/mbedtls/issues/9574
114 re.compile(r'PSA \w+ DH_.*type not supported'),
115 # We only test partial support for DH with the 2048-bit group
116 # enabled and the other groups disabled.
117 # https://github.com/Mbed-TLS/mbedtls/issues/9575
118 'PSA generate DH_KEY_PAIR(RFC7919) 2048-bit group not supported',
119 'PSA import DH_KEY_PAIR(RFC7919) 2048-bit group not supported',
120 'PSA import DH_PUBLIC_KEY(RFC7919) 2048-bit group not supported',
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200121 ],
122 'test_suite_psa_crypto_op_fail.generated': [
Gilles Peskine5872c0d2024-09-17 17:15:29 +0200123 # Ignore mechanisms that are not implemented, except
124 # for test cases that assume the mechanism is not supported.
125 _has_word_re(_PSA_MECHANISMS_NOT_IMPLEMENTED,
126 exclude=(r'.*: !(?:' +
127 r'|'.join(_PSA_MECHANISMS_NOT_IMPLEMENTED) +
128 r')\b')),
Gilles Peskineab5cc9b2024-09-17 17:57:11 +0200129 # Incorrect dependency generation. To be fixed as part of the
130 # resolution of https://github.com/Mbed-TLS/mbedtls/issues/9167
131 # by forward-porting the commit
132 # "PSA test case generation: dependency inference class: operation fail"
133 # from https://github.com/Mbed-TLS/mbedtls/pull/9025 .
134 re.compile(r'.* with (?:DH|ECC)_(?:KEY_PAIR|PUBLIC_KEY)\(.*'),
135 # PBKDF2_HMAC is not in the default configuration, so we don't
136 # enable it in depends.py where we remove hashes.
137 # https://github.com/Mbed-TLS/mbedtls/issues/9576
138 re.compile(r'PSA key_derivation PBKDF2_HMAC\(\w+\): !(?!PBKDF2_HMAC\Z).*'),
139 # We never test with TLS12_PRF or TLS12_PSK_TO_MS disabled
140 # but certain other things enabled.
141 # https://github.com/Mbed-TLS/mbedtls/issues/9577
142 re.compile(r'PSA key_derivation TLS12_PRF\(\w+\): !TLS12_PRF'),
143 re.compile(r'PSA key_derivation TLS12_PSK_TO_MS'
144 r'\((?!SHA_256|SHA_384|SHA_512)\w+\): !TLS12_PSK_TO_MS'),
145 'PSA key_derivation KEY_AGREEMENT(ECDH,TLS12_PRF(SHA_256)): !TLS12_PRF',
146 'PSA key_derivation KEY_AGREEMENT(ECDH,TLS12_PRF(SHA_384)): !TLS12_PRF',
147
148 # We never test with the HMAC algorithm enabled but the HMAC
149 # key type disabled. Those dependencies don't really make sense.
150 # https://github.com/Mbed-TLS/mbedtls/issues/9573
151 re.compile(r'.* !HMAC with HMAC'),
152 # There's something wrong with PSA_WANT_ALG_RSA_PSS_ANY_SALT
153 # differing from PSA_WANT_ALG_RSA_PSS.
154 # https://github.com/Mbed-TLS/mbedtls/issues/9578
155 re.compile(r'PSA sign RSA_PSS_ANY_SALT.*!(?:MD|RIPEMD|SHA).*'),
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200156 ],
157 'test_suite_psa_crypto_storage_format.current': [
158 PSA_MECHANISM_NOT_IMPLEMENTED_SEARCH_RE,
159 ],
160 'test_suite_psa_crypto_storage_format.v0': [
161 PSA_MECHANISM_NOT_IMPLEMENTED_SEARCH_RE,
162 ],
Gilles Peskinede2316b2024-09-17 18:32:05 +0200163 'tls13-misc': [
164 # Disabled due to OpenSSL bug.
165 # https://github.com/openssl/openssl/issues/10714
166 'TLS 1.3 O->m: resumption',
167 # Disabled due to OpenSSL command line limitation.
168 # https://github.com/Mbed-TLS/mbedtls/issues/9582
169 'TLS 1.3 m->O: resumption with early data',
170 ],
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200171 }
172
Gilles Peskine82b16722024-09-16 19:57:10 +0200173
Gilles Peskine9df375b2024-09-16 20:14:26 +0200174# The names that we give to classes derived from DriverVSReference do not
175# follow the usual naming convention, because it's more readable to use
176# underscores and parts of the configuration names. Also, these classes
177# are just there to specify some data, so they don't need repetitive
178# documentation.
179#pylint: disable=invalid-name,missing-class-docstring
180
Gilles Peskine082eade2024-10-03 18:42:37 +0200181class DriverVSReference_hash(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200182 REFERENCE = 'test_psa_crypto_config_reference_hash_use_psa'
183 DRIVER = 'test_psa_crypto_config_accel_hash_use_psa'
184 IGNORED_SUITES = [
185 'shax', 'mdx', # the software implementations that are being excluded
186 'md.psa', # purposefully depends on whether drivers are present
187 'psa_crypto_low_hash.generated', # testing the builtins
188 ]
189 IGNORED_TESTS = {
190 'test_suite_config': [
191 re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'),
192 ],
193 'test_suite_platform': [
194 # Incompatible with sanitizers (e.g. ASan). If the driver
195 # component uses a sanitizer but the reference component
196 # doesn't, we have a PASS vs SKIP mismatch.
197 'Check mbedtls_calloc overallocation',
198 ],
199 }
200
Gilles Peskine082eade2024-10-03 18:42:37 +0200201class DriverVSReference_hmac(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200202 REFERENCE = 'test_psa_crypto_config_reference_hmac'
203 DRIVER = 'test_psa_crypto_config_accel_hmac'
204 IGNORED_SUITES = [
205 # These suites require legacy hash support, which is disabled
206 # in the accelerated component.
207 'shax', 'mdx',
208 # This suite tests builtins directly, but these are missing
209 # in the accelerated case.
210 'psa_crypto_low_hash.generated',
211 ]
212 IGNORED_TESTS = {
213 'test_suite_config': [
214 re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'),
215 re.compile(r'.*\bMBEDTLS_MD_C\b')
216 ],
217 'test_suite_md': [
218 # Builtin HMAC is not supported in the accelerate component.
219 re.compile('.*HMAC.*'),
220 # Following tests make use of functions which are not available
221 # when MD_C is disabled, as it happens in the accelerated
222 # test component.
223 re.compile('generic .* Hash file .*'),
224 'MD list',
225 ],
226 'test_suite_md.psa': [
227 # "legacy only" tests require hash algorithms to be NOT
228 # accelerated, but this of course false for the accelerated
229 # test component.
230 re.compile('PSA dispatch .* legacy only'),
231 ],
232 'test_suite_platform': [
233 # Incompatible with sanitizers (e.g. ASan). If the driver
234 # component uses a sanitizer but the reference component
235 # doesn't, we have a PASS vs SKIP mismatch.
236 'Check mbedtls_calloc overallocation',
237 ],
238 }
239
Gilles Peskine082eade2024-10-03 18:42:37 +0200240class DriverVSReference_cipher_aead_cmac(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200241 REFERENCE = 'test_psa_crypto_config_reference_cipher_aead_cmac'
242 DRIVER = 'test_psa_crypto_config_accel_cipher_aead_cmac'
243 # Modules replaced by drivers.
244 IGNORED_SUITES = [
245 # low-level (block/stream) cipher modules
246 'aes', 'aria', 'camellia', 'des', 'chacha20',
247 # AEAD modes and CMAC
248 'ccm', 'chachapoly', 'cmac', 'gcm',
249 # The Cipher abstraction layer
250 'cipher',
251 ]
252 IGNORED_TESTS = {
253 'test_suite_config': [
254 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA|CHACHA20|DES)_.*'),
255 re.compile(r'.*\bMBEDTLS_(CCM|CHACHAPOLY|CMAC|GCM)_.*'),
256 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
257 re.compile(r'.*\bMBEDTLS_CIPHER_.*'),
258 ],
259 # PEM decryption is not supported so far.
260 # The rest of PEM (write, unencrypted read) works though.
261 'test_suite_pem': [
262 re.compile(r'PEM read .*(AES|DES|\bencrypt).*'),
263 ],
264 'test_suite_platform': [
265 # Incompatible with sanitizers (e.g. ASan). If the driver
266 # component uses a sanitizer but the reference component
267 # doesn't, we have a PASS vs SKIP mismatch.
268 'Check mbedtls_calloc overallocation',
269 ],
270 # Following tests depend on AES_C/DES_C but are not about
271 # them really, just need to know some error code is there.
272 'test_suite_error': [
273 'Low and high error',
274 'Single low error'
275 ],
276 # Similar to test_suite_error above.
277 'test_suite_version': [
278 'Check for MBEDTLS_AES_C when already present',
279 ],
280 # The en/decryption part of PKCS#12 is not supported so far.
281 # The rest of PKCS#12 (key derivation) works though.
282 'test_suite_pkcs12': [
283 re.compile(r'PBE Encrypt, .*'),
284 re.compile(r'PBE Decrypt, .*'),
285 ],
286 # The en/decryption part of PKCS#5 is not supported so far.
287 # The rest of PKCS#5 (PBKDF2) works though.
288 'test_suite_pkcs5': [
289 re.compile(r'PBES2 Encrypt, .*'),
290 re.compile(r'PBES2 Decrypt .*'),
291 ],
292 # Encrypted keys are not supported so far.
293 # pylint: disable=line-too-long
294 'test_suite_pkparse': [
295 'Key ASN1 (Encrypted key PKCS12, trailing garbage data)',
296 'Key ASN1 (Encrypted key PKCS5, trailing garbage data)',
297 re.compile(r'Parse (RSA|EC) Key .*\(.* ([Ee]ncrypted|password).*\)'),
298 ],
299 # Encrypted keys are not supported so far.
300 'ssl-opt': [
301 'TLS: password protected server key',
302 'TLS: password protected client key',
303 'TLS: password protected server key, two certificates',
304 ],
305 }
306
Gilles Peskine082eade2024-10-03 18:42:37 +0200307class DriverVSReference_ecp_light_only(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200308 REFERENCE = 'test_psa_crypto_config_reference_ecc_ecp_light_only'
309 DRIVER = 'test_psa_crypto_config_accel_ecc_ecp_light_only'
310 IGNORED_SUITES = [
311 # Modules replaced by drivers
312 'ecdsa', 'ecdh', 'ecjpake',
313 ]
314 IGNORED_TESTS = {
315 'test_suite_config': [
316 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
317 ],
318 'test_suite_platform': [
319 # Incompatible with sanitizers (e.g. ASan). If the driver
320 # component uses a sanitizer but the reference component
321 # doesn't, we have a PASS vs SKIP mismatch.
322 'Check mbedtls_calloc overallocation',
323 ],
324 # This test wants a legacy function that takes f_rng, p_rng
325 # arguments, and uses legacy ECDSA for that. The test is
326 # really about the wrapper around the PSA RNG, not ECDSA.
327 'test_suite_random': [
328 'PSA classic wrapper: ECDSA signature (SECP256R1)',
329 ],
330 # In the accelerated test ECP_C is not set (only ECP_LIGHT is)
331 # so we must ignore disparities in the tests for which ECP_C
332 # is required.
333 'test_suite_ecp': [
334 re.compile(r'ECP check public-private .*'),
335 re.compile(r'ECP calculate public: .*'),
336 re.compile(r'ECP gen keypair .*'),
337 re.compile(r'ECP point muladd .*'),
338 re.compile(r'ECP point multiplication .*'),
339 re.compile(r'ECP test vectors .*'),
340 ],
341 'test_suite_ssl': [
342 # This deprecated function is only present when ECP_C is On.
343 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
344 ],
345 }
346
Gilles Peskine082eade2024-10-03 18:42:37 +0200347class DriverVSReference_no_ecp_at_all(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200348 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_ecp_at_all'
349 DRIVER = 'test_psa_crypto_config_accel_ecc_no_ecp_at_all'
350 IGNORED_SUITES = [
351 # Modules replaced by drivers
352 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
353 ]
354 IGNORED_TESTS = {
355 'test_suite_config': [
356 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
357 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
358 ],
359 'test_suite_platform': [
360 # Incompatible with sanitizers (e.g. ASan). If the driver
361 # component uses a sanitizer but the reference component
362 # doesn't, we have a PASS vs SKIP mismatch.
363 'Check mbedtls_calloc overallocation',
364 ],
365 # See ecp_light_only
366 'test_suite_random': [
367 'PSA classic wrapper: ECDSA signature (SECP256R1)',
368 ],
369 'test_suite_pkparse': [
370 # When PK_PARSE_C and ECP_C are defined then PK_PARSE_EC_COMPRESSED
371 # is automatically enabled in build_info.h (backward compatibility)
372 # even if it is disabled in config_psa_crypto_no_ecp_at_all(). As a
373 # consequence compressed points are supported in the reference
374 # component but not in the accelerated one, so they should be skipped
375 # while checking driver's coverage.
376 re.compile(r'Parse EC Key .*compressed\)'),
377 re.compile(r'Parse Public EC Key .*compressed\)'),
378 ],
379 # See ecp_light_only
380 'test_suite_ssl': [
381 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
382 ],
383 }
384
Gilles Peskine082eade2024-10-03 18:42:37 +0200385class DriverVSReference_ecc_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200386 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_bignum'
387 DRIVER = 'test_psa_crypto_config_accel_ecc_no_bignum'
388 IGNORED_SUITES = [
389 # Modules replaced by drivers
390 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
391 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
392 'bignum.generated', 'bignum.misc',
393 ]
394 IGNORED_TESTS = {
395 'test_suite_config': [
396 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
397 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
398 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
399 ],
400 'test_suite_platform': [
401 # Incompatible with sanitizers (e.g. ASan). If the driver
402 # component uses a sanitizer but the reference component
403 # doesn't, we have a PASS vs SKIP mismatch.
404 'Check mbedtls_calloc overallocation',
405 ],
406 # See ecp_light_only
407 'test_suite_random': [
408 'PSA classic wrapper: ECDSA signature (SECP256R1)',
409 ],
410 # See no_ecp_at_all
411 'test_suite_pkparse': [
412 re.compile(r'Parse EC Key .*compressed\)'),
413 re.compile(r'Parse Public EC Key .*compressed\)'),
414 ],
415 'test_suite_asn1parse': [
416 'INTEGER too large for mpi',
417 ],
418 'test_suite_asn1write': [
419 re.compile(r'ASN.1 Write mpi.*'),
420 ],
421 'test_suite_debug': [
422 re.compile(r'Debug print mbedtls_mpi.*'),
423 ],
424 # See ecp_light_only
425 'test_suite_ssl': [
426 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
427 ],
428 }
429
Gilles Peskine082eade2024-10-03 18:42:37 +0200430class DriverVSReference_ecc_ffdh_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200431 REFERENCE = 'test_psa_crypto_config_reference_ecc_ffdh_no_bignum'
432 DRIVER = 'test_psa_crypto_config_accel_ecc_ffdh_no_bignum'
433 IGNORED_SUITES = [
434 # Modules replaced by drivers
435 'ecp', 'ecdsa', 'ecdh', 'ecjpake', 'dhm',
436 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
437 'bignum.generated', 'bignum.misc',
438 ]
439 IGNORED_TESTS = {
440 'ssl-opt': [
441 # DHE support in TLS 1.2 requires built-in MBEDTLS_DHM_C
442 # (because it needs custom groups, which PSA does not
443 # provide), even with MBEDTLS_USE_PSA_CRYPTO.
444 re.compile(r'PSK callback:.*\bdhe-psk\b.*'),
445 ],
446 'test_suite_config': [
447 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
448 re.compile(r'.*\bMBEDTLS_DHM_C\b.*'),
449 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
450 re.compile(r'.*\bMBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED\b.*'),
451 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
452 ],
453 'test_suite_platform': [
454 # Incompatible with sanitizers (e.g. ASan). If the driver
455 # component uses a sanitizer but the reference component
456 # doesn't, we have a PASS vs SKIP mismatch.
457 'Check mbedtls_calloc overallocation',
458 ],
459 # See ecp_light_only
460 'test_suite_random': [
461 'PSA classic wrapper: ECDSA signature (SECP256R1)',
462 ],
463 # See no_ecp_at_all
464 'test_suite_pkparse': [
465 re.compile(r'Parse EC Key .*compressed\)'),
466 re.compile(r'Parse Public EC Key .*compressed\)'),
467 ],
468 'test_suite_asn1parse': [
469 'INTEGER too large for mpi',
470 ],
471 'test_suite_asn1write': [
472 re.compile(r'ASN.1 Write mpi.*'),
473 ],
474 'test_suite_debug': [
475 re.compile(r'Debug print mbedtls_mpi.*'),
476 ],
477 # See ecp_light_only
478 'test_suite_ssl': [
479 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
480 ],
481 }
482
Gilles Peskine082eade2024-10-03 18:42:37 +0200483class DriverVSReference_ffdh_alg(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200484 REFERENCE = 'test_psa_crypto_config_reference_ffdh'
485 DRIVER = 'test_psa_crypto_config_accel_ffdh'
486 IGNORED_SUITES = ['dhm']
487 IGNORED_TESTS = {
488 'test_suite_config': [
489 re.compile(r'.*\bMBEDTLS_DHM_C\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 }
498
Gilles Peskine082eade2024-10-03 18:42:37 +0200499class DriverVSReference_tfm_config(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200500 REFERENCE = 'test_tfm_config_no_p256m'
501 DRIVER = 'test_tfm_config_p256m_driver_accel_ec'
502 IGNORED_SUITES = [
503 # Modules replaced by drivers
504 'asn1parse', 'asn1write',
505 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
506 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
507 'bignum.generated', 'bignum.misc',
508 ]
509 IGNORED_TESTS = {
510 'test_suite_config': [
511 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
512 re.compile(r'.*\bMBEDTLS_(ASN1\w+)_C\b.*'),
513 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECP)_.*'),
514 re.compile(r'.*\bMBEDTLS_PSA_P256M_DRIVER_ENABLED\b.*')
515 ],
516 'test_suite_config.crypto_combinations': [
517 'Config: ECC: Weierstrass curves only',
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 }
530
Gilles Peskine082eade2024-10-03 18:42:37 +0200531class DriverVSReference_rsa(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200532 REFERENCE = 'test_psa_crypto_config_reference_rsa_crypto'
533 DRIVER = 'test_psa_crypto_config_accel_rsa_crypto'
534 IGNORED_SUITES = [
535 # Modules replaced by drivers.
536 'rsa', 'pkcs1_v15', 'pkcs1_v21',
537 # We temporarily don't care about PK stuff.
538 'pk', 'pkwrite', 'pkparse'
539 ]
540 IGNORED_TESTS = {
541 'test_suite_config': [
542 re.compile(r'.*\bMBEDTLS_(PKCS1|RSA)_.*'),
543 re.compile(r'.*\bMBEDTLS_GENPRIME\b.*')
544 ],
545 'test_suite_platform': [
546 # Incompatible with sanitizers (e.g. ASan). If the driver
547 # component uses a sanitizer but the reference component
548 # doesn't, we have a PASS vs SKIP mismatch.
549 'Check mbedtls_calloc overallocation',
550 ],
551 # Following tests depend on RSA_C but are not about
552 # them really, just need to know some error code is there.
553 'test_suite_error': [
554 'Low and high error',
555 'Single high error'
556 ],
557 # Constant time operations only used for PKCS1_V15
558 'test_suite_constant_time': [
559 re.compile(r'mbedtls_ct_zeroize_if .*'),
560 re.compile(r'mbedtls_ct_memmove_left .*')
561 ],
562 'test_suite_psa_crypto': [
563 # We don't support generate_key_custom entry points
564 # in drivers yet.
565 re.compile(r'PSA generate key custom: RSA, e=.*'),
566 re.compile(r'PSA generate key ext: RSA, e=.*'),
567 ],
568 }
569
Gilles Peskine082eade2024-10-03 18:42:37 +0200570class DriverVSReference_block_cipher_dispatch(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200571 REFERENCE = 'test_full_block_cipher_legacy_dispatch'
572 DRIVER = 'test_full_block_cipher_psa_dispatch'
573 IGNORED_SUITES = [
574 # Skipped in the accelerated component
575 'aes', 'aria', 'camellia',
576 # These require AES_C, ARIA_C or CAMELLIA_C to be enabled in
577 # order for the cipher module (actually cipher_wrapper) to work
578 # properly. However these symbols are disabled in the accelerated
579 # component so we ignore them.
580 'cipher.ccm', 'cipher.gcm', 'cipher.aes', 'cipher.aria',
581 'cipher.camellia',
582 ]
583 IGNORED_TESTS = {
584 'test_suite_config': [
585 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA)_.*'),
586 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
587 ],
588 'test_suite_cmac': [
589 # Following tests require AES_C/ARIA_C/CAMELLIA_C to be enabled,
590 # but these are not available in the accelerated component.
591 'CMAC null arguments',
592 re.compile('CMAC.* (AES|ARIA|Camellia).*'),
593 ],
594 'test_suite_cipher.padding': [
595 # Following tests require AES_C/CAMELLIA_C to be enabled,
596 # but these are not available in the accelerated component.
597 re.compile('Set( non-existent)? padding with (AES|CAMELLIA).*'),
598 ],
599 'test_suite_pkcs5': [
600 # The AES part of PKCS#5 PBES2 is not yet supported.
601 # The rest of PKCS#5 (PBKDF2) works, though.
602 re.compile(r'PBES2 .* AES-.*')
603 ],
604 'test_suite_pkparse': [
605 # PEM (called by pkparse) requires AES_C in order to decrypt
606 # the key, but this is not available in the accelerated
607 # component.
608 re.compile('Parse RSA Key.*(password|AES-).*'),
609 ],
610 'test_suite_pem': [
611 # Following tests require AES_C, but this is diabled in the
612 # accelerated component.
613 re.compile('PEM read .*AES.*'),
614 'PEM read (unknown encryption algorithm)',
615 ],
616 'test_suite_error': [
617 # Following tests depend on AES_C but are not about them
618 # really, just need to know some error code is there.
619 'Single low error',
620 'Low and high error',
621 ],
622 'test_suite_version': [
623 # Similar to test_suite_error above.
624 'Check for MBEDTLS_AES_C when already present',
625 ],
626 'test_suite_platform': [
627 # Incompatible with sanitizers (e.g. ASan). If the driver
628 # component uses a sanitizer but the reference component
629 # doesn't, we have a PASS vs SKIP mismatch.
630 'Check mbedtls_calloc overallocation',
631 ],
632 }
633
634#pylint: enable=invalid-name,missing-class-docstring
635
636
Przemek Stekiel6856f4c2022-11-09 10:50:29 +0100637# List of tasks with a function that can handle this task and additional arguments if required
Valerio Settidfd7ca62023-10-09 16:30:11 +0200638KNOWN_TASKS = {
Gilles Peskinef646dbf2024-09-16 19:15:29 +0200639 'analyze_coverage': CoverageTask,
Gilles Peskine9df375b2024-09-16 20:14:26 +0200640 'analyze_driver_vs_reference_hash': DriverVSReference_hash,
641 'analyze_driver_vs_reference_hmac': DriverVSReference_hmac,
642 'analyze_driver_vs_reference_cipher_aead_cmac': DriverVSReference_cipher_aead_cmac,
643 'analyze_driver_vs_reference_ecp_light_only': DriverVSReference_ecp_light_only,
644 'analyze_driver_vs_reference_no_ecp_at_all': DriverVSReference_no_ecp_at_all,
645 'analyze_driver_vs_reference_ecc_no_bignum': DriverVSReference_ecc_no_bignum,
646 'analyze_driver_vs_reference_ecc_ffdh_no_bignum': DriverVSReference_ecc_ffdh_no_bignum,
647 'analyze_driver_vs_reference_ffdh_alg': DriverVSReference_ffdh_alg,
648 'analyze_driver_vs_reference_tfm_config': DriverVSReference_tfm_config,
649 'analyze_driver_vs_reference_rsa': DriverVSReference_rsa,
650 'analyze_block_cipher_dispatch': DriverVSReference_block_cipher_dispatch,
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200651}
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200652
Gilles Peskine15c2cbf2020-06-25 18:36:28 +0200653if __name__ == '__main__':
Gilles Peskine082eade2024-10-03 18:42:37 +0200654 outcome_analysis.main(KNOWN_TASKS)