blob: 4ee0c40cf4a38fb90d15e44ae46f1a4a2d565d05 [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 = {
74 'test_suite_psa_crypto_generate_key.generated': [
Gilles Peskine5872c0d2024-09-17 17:15:29 +020075 # Ignore mechanisms that are not implemented, except
76 # for public keys for which we always test that
77 # psa_generate_key() returns PSA_ERROR_INVALID_ARGUMENT
78 # regardless of whether the specific key type is supported.
79 _has_word_re((mech
80 for mech in _PSA_MECHANISMS_NOT_IMPLEMENTED
81 if not mech.startswith('ECC_PUB')),
82 exclude=r'ECC_PUB'),
Gilles Peskine2a71fac2024-09-17 15:07:22 +020083 ],
84 'test_suite_psa_crypto_not_supported.generated': [
Gilles Peskineab5cc9b2024-09-17 17:57:11 +020085 # It is a bug that not-supported test cases aren't getting
86 # run for never-implemented key types.
87 # https://github.com/Mbed-TLS/mbedtls/issues/7915
Gilles Peskine2a71fac2024-09-17 15:07:22 +020088 PSA_MECHANISM_NOT_IMPLEMENTED_SEARCH_RE,
Gilles Peskineab5cc9b2024-09-17 17:57:11 +020089 # We mever test with DH key support disabled but support
90 # for a DH group enabled. The dependencies of these test
91 # cases don't really make sense.
92 # https://github.com/Mbed-TLS/mbedtls/issues/9574
93 re.compile(r'PSA \w+ DH_.*type not supported'),
94 # We only test partial support for DH with the 2048-bit group
95 # enabled and the other groups disabled.
96 # https://github.com/Mbed-TLS/mbedtls/issues/9575
97 'PSA generate DH_KEY_PAIR(RFC7919) 2048-bit group not supported',
98 'PSA import DH_KEY_PAIR(RFC7919) 2048-bit group not supported',
99 'PSA import DH_PUBLIC_KEY(RFC7919) 2048-bit group not supported',
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200100 ],
101 'test_suite_psa_crypto_op_fail.generated': [
Gilles Peskine5872c0d2024-09-17 17:15:29 +0200102 # Ignore mechanisms that are not implemented, except
103 # for test cases that assume the mechanism is not supported.
104 _has_word_re(_PSA_MECHANISMS_NOT_IMPLEMENTED,
105 exclude=(r'.*: !(?:' +
106 r'|'.join(_PSA_MECHANISMS_NOT_IMPLEMENTED) +
107 r')\b')),
Gilles Peskineab5cc9b2024-09-17 17:57:11 +0200108 # Incorrect dependency generation. To be fixed as part of the
109 # resolution of https://github.com/Mbed-TLS/mbedtls/issues/9167
110 # by forward-porting the commit
111 # "PSA test case generation: dependency inference class: operation fail"
112 # from https://github.com/Mbed-TLS/mbedtls/pull/9025 .
113 re.compile(r'.* with (?:DH|ECC)_(?:KEY_PAIR|PUBLIC_KEY)\(.*'),
114 # PBKDF2_HMAC is not in the default configuration, so we don't
115 # enable it in depends.py where we remove hashes.
116 # https://github.com/Mbed-TLS/mbedtls/issues/9576
117 re.compile(r'PSA key_derivation PBKDF2_HMAC\(\w+\): !(?!PBKDF2_HMAC\Z).*'),
118 # We never test with TLS12_PRF or TLS12_PSK_TO_MS disabled
119 # but certain other things enabled.
120 # https://github.com/Mbed-TLS/mbedtls/issues/9577
121 re.compile(r'PSA key_derivation TLS12_PRF\(\w+\): !TLS12_PRF'),
122 re.compile(r'PSA key_derivation TLS12_PSK_TO_MS'
123 r'\((?!SHA_256|SHA_384|SHA_512)\w+\): !TLS12_PSK_TO_MS'),
124 'PSA key_derivation KEY_AGREEMENT(ECDH,TLS12_PRF(SHA_256)): !TLS12_PRF',
125 'PSA key_derivation KEY_AGREEMENT(ECDH,TLS12_PRF(SHA_384)): !TLS12_PRF',
126
127 # We never test with the HMAC algorithm enabled but the HMAC
128 # key type disabled. Those dependencies don't really make sense.
129 # https://github.com/Mbed-TLS/mbedtls/issues/9573
130 re.compile(r'.* !HMAC with HMAC'),
131 # There's something wrong with PSA_WANT_ALG_RSA_PSS_ANY_SALT
132 # differing from PSA_WANT_ALG_RSA_PSS.
133 # https://github.com/Mbed-TLS/mbedtls/issues/9578
134 re.compile(r'PSA sign RSA_PSS_ANY_SALT.*!(?:MD|RIPEMD|SHA).*'),
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200135 ],
136 'test_suite_psa_crypto_storage_format.current': [
137 PSA_MECHANISM_NOT_IMPLEMENTED_SEARCH_RE,
138 ],
139 'test_suite_psa_crypto_storage_format.v0': [
140 PSA_MECHANISM_NOT_IMPLEMENTED_SEARCH_RE,
141 ],
142 }
143
Gilles Peskine82b16722024-09-16 19:57:10 +0200144
Gilles Peskine9df375b2024-09-16 20:14:26 +0200145# The names that we give to classes derived from DriverVSReference do not
146# follow the usual naming convention, because it's more readable to use
147# underscores and parts of the configuration names. Also, these classes
148# are just there to specify some data, so they don't need repetitive
149# documentation.
150#pylint: disable=invalid-name,missing-class-docstring
151
Gilles Peskine082eade2024-10-03 18:42:37 +0200152class DriverVSReference_hash(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200153 REFERENCE = 'test_psa_crypto_config_reference_hash_use_psa'
154 DRIVER = 'test_psa_crypto_config_accel_hash_use_psa'
155 IGNORED_SUITES = [
156 'shax', 'mdx', # the software implementations that are being excluded
157 'md.psa', # purposefully depends on whether drivers are present
158 'psa_crypto_low_hash.generated', # testing the builtins
159 ]
160 IGNORED_TESTS = {
161 'test_suite_config': [
162 re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'),
163 ],
164 'test_suite_platform': [
165 # Incompatible with sanitizers (e.g. ASan). If the driver
166 # component uses a sanitizer but the reference component
167 # doesn't, we have a PASS vs SKIP mismatch.
168 'Check mbedtls_calloc overallocation',
169 ],
170 }
171
Gilles Peskine082eade2024-10-03 18:42:37 +0200172class DriverVSReference_hmac(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200173 REFERENCE = 'test_psa_crypto_config_reference_hmac'
174 DRIVER = 'test_psa_crypto_config_accel_hmac'
175 IGNORED_SUITES = [
176 # These suites require legacy hash support, which is disabled
177 # in the accelerated component.
178 'shax', 'mdx',
179 # This suite tests builtins directly, but these are missing
180 # in the accelerated case.
181 'psa_crypto_low_hash.generated',
182 ]
183 IGNORED_TESTS = {
184 'test_suite_config': [
185 re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'),
186 re.compile(r'.*\bMBEDTLS_MD_C\b')
187 ],
188 'test_suite_md': [
189 # Builtin HMAC is not supported in the accelerate component.
190 re.compile('.*HMAC.*'),
191 # Following tests make use of functions which are not available
192 # when MD_C is disabled, as it happens in the accelerated
193 # test component.
194 re.compile('generic .* Hash file .*'),
195 'MD list',
196 ],
197 'test_suite_md.psa': [
198 # "legacy only" tests require hash algorithms to be NOT
199 # accelerated, but this of course false for the accelerated
200 # test component.
201 re.compile('PSA dispatch .* legacy only'),
202 ],
203 'test_suite_platform': [
204 # Incompatible with sanitizers (e.g. ASan). If the driver
205 # component uses a sanitizer but the reference component
206 # doesn't, we have a PASS vs SKIP mismatch.
207 'Check mbedtls_calloc overallocation',
208 ],
209 }
210
Gilles Peskine082eade2024-10-03 18:42:37 +0200211class DriverVSReference_cipher_aead_cmac(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200212 REFERENCE = 'test_psa_crypto_config_reference_cipher_aead_cmac'
213 DRIVER = 'test_psa_crypto_config_accel_cipher_aead_cmac'
214 # Modules replaced by drivers.
215 IGNORED_SUITES = [
216 # low-level (block/stream) cipher modules
217 'aes', 'aria', 'camellia', 'des', 'chacha20',
218 # AEAD modes and CMAC
219 'ccm', 'chachapoly', 'cmac', 'gcm',
220 # The Cipher abstraction layer
221 'cipher',
222 ]
223 IGNORED_TESTS = {
224 'test_suite_config': [
225 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA|CHACHA20|DES)_.*'),
226 re.compile(r'.*\bMBEDTLS_(CCM|CHACHAPOLY|CMAC|GCM)_.*'),
227 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
228 re.compile(r'.*\bMBEDTLS_CIPHER_.*'),
229 ],
230 # PEM decryption is not supported so far.
231 # The rest of PEM (write, unencrypted read) works though.
232 'test_suite_pem': [
233 re.compile(r'PEM read .*(AES|DES|\bencrypt).*'),
234 ],
235 'test_suite_platform': [
236 # Incompatible with sanitizers (e.g. ASan). If the driver
237 # component uses a sanitizer but the reference component
238 # doesn't, we have a PASS vs SKIP mismatch.
239 'Check mbedtls_calloc overallocation',
240 ],
241 # Following tests depend on AES_C/DES_C but are not about
242 # them really, just need to know some error code is there.
243 'test_suite_error': [
244 'Low and high error',
245 'Single low error'
246 ],
247 # Similar to test_suite_error above.
248 'test_suite_version': [
249 'Check for MBEDTLS_AES_C when already present',
250 ],
251 # The en/decryption part of PKCS#12 is not supported so far.
252 # The rest of PKCS#12 (key derivation) works though.
253 'test_suite_pkcs12': [
254 re.compile(r'PBE Encrypt, .*'),
255 re.compile(r'PBE Decrypt, .*'),
256 ],
257 # The en/decryption part of PKCS#5 is not supported so far.
258 # The rest of PKCS#5 (PBKDF2) works though.
259 'test_suite_pkcs5': [
260 re.compile(r'PBES2 Encrypt, .*'),
261 re.compile(r'PBES2 Decrypt .*'),
262 ],
263 # Encrypted keys are not supported so far.
264 # pylint: disable=line-too-long
265 'test_suite_pkparse': [
266 'Key ASN1 (Encrypted key PKCS12, trailing garbage data)',
267 'Key ASN1 (Encrypted key PKCS5, trailing garbage data)',
268 re.compile(r'Parse (RSA|EC) Key .*\(.* ([Ee]ncrypted|password).*\)'),
269 ],
270 # Encrypted keys are not supported so far.
271 'ssl-opt': [
272 'TLS: password protected server key',
273 'TLS: password protected client key',
274 'TLS: password protected server key, two certificates',
275 ],
276 }
277
Gilles Peskine082eade2024-10-03 18:42:37 +0200278class DriverVSReference_ecp_light_only(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200279 REFERENCE = 'test_psa_crypto_config_reference_ecc_ecp_light_only'
280 DRIVER = 'test_psa_crypto_config_accel_ecc_ecp_light_only'
281 IGNORED_SUITES = [
282 # Modules replaced by drivers
283 'ecdsa', 'ecdh', 'ecjpake',
284 ]
285 IGNORED_TESTS = {
286 'test_suite_config': [
287 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
288 ],
289 'test_suite_platform': [
290 # Incompatible with sanitizers (e.g. ASan). If the driver
291 # component uses a sanitizer but the reference component
292 # doesn't, we have a PASS vs SKIP mismatch.
293 'Check mbedtls_calloc overallocation',
294 ],
295 # This test wants a legacy function that takes f_rng, p_rng
296 # arguments, and uses legacy ECDSA for that. The test is
297 # really about the wrapper around the PSA RNG, not ECDSA.
298 'test_suite_random': [
299 'PSA classic wrapper: ECDSA signature (SECP256R1)',
300 ],
301 # In the accelerated test ECP_C is not set (only ECP_LIGHT is)
302 # so we must ignore disparities in the tests for which ECP_C
303 # is required.
304 'test_suite_ecp': [
305 re.compile(r'ECP check public-private .*'),
306 re.compile(r'ECP calculate public: .*'),
307 re.compile(r'ECP gen keypair .*'),
308 re.compile(r'ECP point muladd .*'),
309 re.compile(r'ECP point multiplication .*'),
310 re.compile(r'ECP test vectors .*'),
311 ],
312 'test_suite_ssl': [
313 # This deprecated function is only present when ECP_C is On.
314 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
315 ],
316 }
317
Gilles Peskine082eade2024-10-03 18:42:37 +0200318class DriverVSReference_no_ecp_at_all(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200319 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_ecp_at_all'
320 DRIVER = 'test_psa_crypto_config_accel_ecc_no_ecp_at_all'
321 IGNORED_SUITES = [
322 # Modules replaced by drivers
323 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
324 ]
325 IGNORED_TESTS = {
326 'test_suite_config': [
327 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
328 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
329 ],
330 'test_suite_platform': [
331 # Incompatible with sanitizers (e.g. ASan). If the driver
332 # component uses a sanitizer but the reference component
333 # doesn't, we have a PASS vs SKIP mismatch.
334 'Check mbedtls_calloc overallocation',
335 ],
336 # See ecp_light_only
337 'test_suite_random': [
338 'PSA classic wrapper: ECDSA signature (SECP256R1)',
339 ],
340 'test_suite_pkparse': [
341 # When PK_PARSE_C and ECP_C are defined then PK_PARSE_EC_COMPRESSED
342 # is automatically enabled in build_info.h (backward compatibility)
343 # even if it is disabled in config_psa_crypto_no_ecp_at_all(). As a
344 # consequence compressed points are supported in the reference
345 # component but not in the accelerated one, so they should be skipped
346 # while checking driver's coverage.
347 re.compile(r'Parse EC Key .*compressed\)'),
348 re.compile(r'Parse Public EC Key .*compressed\)'),
349 ],
350 # See ecp_light_only
351 'test_suite_ssl': [
352 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
353 ],
354 }
355
Gilles Peskine082eade2024-10-03 18:42:37 +0200356class DriverVSReference_ecc_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200357 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_bignum'
358 DRIVER = 'test_psa_crypto_config_accel_ecc_no_bignum'
359 IGNORED_SUITES = [
360 # Modules replaced by drivers
361 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
362 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
363 'bignum.generated', 'bignum.misc',
364 ]
365 IGNORED_TESTS = {
366 'test_suite_config': [
367 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
368 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
369 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
370 ],
371 'test_suite_platform': [
372 # Incompatible with sanitizers (e.g. ASan). If the driver
373 # component uses a sanitizer but the reference component
374 # doesn't, we have a PASS vs SKIP mismatch.
375 'Check mbedtls_calloc overallocation',
376 ],
377 # See ecp_light_only
378 'test_suite_random': [
379 'PSA classic wrapper: ECDSA signature (SECP256R1)',
380 ],
381 # See no_ecp_at_all
382 'test_suite_pkparse': [
383 re.compile(r'Parse EC Key .*compressed\)'),
384 re.compile(r'Parse Public EC Key .*compressed\)'),
385 ],
386 'test_suite_asn1parse': [
387 'INTEGER too large for mpi',
388 ],
389 'test_suite_asn1write': [
390 re.compile(r'ASN.1 Write mpi.*'),
391 ],
392 'test_suite_debug': [
393 re.compile(r'Debug print mbedtls_mpi.*'),
394 ],
395 # See ecp_light_only
396 'test_suite_ssl': [
397 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
398 ],
399 }
400
Gilles Peskine082eade2024-10-03 18:42:37 +0200401class DriverVSReference_ecc_ffdh_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200402 REFERENCE = 'test_psa_crypto_config_reference_ecc_ffdh_no_bignum'
403 DRIVER = 'test_psa_crypto_config_accel_ecc_ffdh_no_bignum'
404 IGNORED_SUITES = [
405 # Modules replaced by drivers
406 'ecp', 'ecdsa', 'ecdh', 'ecjpake', 'dhm',
407 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
408 'bignum.generated', 'bignum.misc',
409 ]
410 IGNORED_TESTS = {
411 'ssl-opt': [
412 # DHE support in TLS 1.2 requires built-in MBEDTLS_DHM_C
413 # (because it needs custom groups, which PSA does not
414 # provide), even with MBEDTLS_USE_PSA_CRYPTO.
415 re.compile(r'PSK callback:.*\bdhe-psk\b.*'),
416 ],
417 'test_suite_config': [
418 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
419 re.compile(r'.*\bMBEDTLS_DHM_C\b.*'),
420 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
421 re.compile(r'.*\bMBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED\b.*'),
422 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
423 ],
424 'test_suite_platform': [
425 # Incompatible with sanitizers (e.g. ASan). If the driver
426 # component uses a sanitizer but the reference component
427 # doesn't, we have a PASS vs SKIP mismatch.
428 'Check mbedtls_calloc overallocation',
429 ],
430 # See ecp_light_only
431 'test_suite_random': [
432 'PSA classic wrapper: ECDSA signature (SECP256R1)',
433 ],
434 # See no_ecp_at_all
435 'test_suite_pkparse': [
436 re.compile(r'Parse EC Key .*compressed\)'),
437 re.compile(r'Parse Public EC Key .*compressed\)'),
438 ],
439 'test_suite_asn1parse': [
440 'INTEGER too large for mpi',
441 ],
442 'test_suite_asn1write': [
443 re.compile(r'ASN.1 Write mpi.*'),
444 ],
445 'test_suite_debug': [
446 re.compile(r'Debug print mbedtls_mpi.*'),
447 ],
448 # See ecp_light_only
449 'test_suite_ssl': [
450 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
451 ],
452 }
453
Gilles Peskine082eade2024-10-03 18:42:37 +0200454class DriverVSReference_ffdh_alg(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200455 REFERENCE = 'test_psa_crypto_config_reference_ffdh'
456 DRIVER = 'test_psa_crypto_config_accel_ffdh'
457 IGNORED_SUITES = ['dhm']
458 IGNORED_TESTS = {
459 'test_suite_config': [
460 re.compile(r'.*\bMBEDTLS_DHM_C\b.*'),
461 ],
462 'test_suite_platform': [
463 # Incompatible with sanitizers (e.g. ASan). If the driver
464 # component uses a sanitizer but the reference component
465 # doesn't, we have a PASS vs SKIP mismatch.
466 'Check mbedtls_calloc overallocation',
467 ],
468 }
469
Gilles Peskine082eade2024-10-03 18:42:37 +0200470class DriverVSReference_tfm_config(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200471 REFERENCE = 'test_tfm_config_no_p256m'
472 DRIVER = 'test_tfm_config_p256m_driver_accel_ec'
473 IGNORED_SUITES = [
474 # Modules replaced by drivers
475 'asn1parse', 'asn1write',
476 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
477 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
478 'bignum.generated', 'bignum.misc',
479 ]
480 IGNORED_TESTS = {
481 'test_suite_config': [
482 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
483 re.compile(r'.*\bMBEDTLS_(ASN1\w+)_C\b.*'),
484 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECP)_.*'),
485 re.compile(r'.*\bMBEDTLS_PSA_P256M_DRIVER_ENABLED\b.*')
486 ],
487 'test_suite_config.crypto_combinations': [
488 'Config: ECC: Weierstrass curves only',
489 ],
490 'test_suite_platform': [
491 # Incompatible with sanitizers (e.g. ASan). If the driver
492 # component uses a sanitizer but the reference component
493 # doesn't, we have a PASS vs SKIP mismatch.
494 'Check mbedtls_calloc overallocation',
495 ],
496 # See ecp_light_only
497 'test_suite_random': [
498 'PSA classic wrapper: ECDSA signature (SECP256R1)',
499 ],
500 }
501
Gilles Peskine082eade2024-10-03 18:42:37 +0200502class DriverVSReference_rsa(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200503 REFERENCE = 'test_psa_crypto_config_reference_rsa_crypto'
504 DRIVER = 'test_psa_crypto_config_accel_rsa_crypto'
505 IGNORED_SUITES = [
506 # Modules replaced by drivers.
507 'rsa', 'pkcs1_v15', 'pkcs1_v21',
508 # We temporarily don't care about PK stuff.
509 'pk', 'pkwrite', 'pkparse'
510 ]
511 IGNORED_TESTS = {
512 'test_suite_config': [
513 re.compile(r'.*\bMBEDTLS_(PKCS1|RSA)_.*'),
514 re.compile(r'.*\bMBEDTLS_GENPRIME\b.*')
515 ],
516 'test_suite_platform': [
517 # Incompatible with sanitizers (e.g. ASan). If the driver
518 # component uses a sanitizer but the reference component
519 # doesn't, we have a PASS vs SKIP mismatch.
520 'Check mbedtls_calloc overallocation',
521 ],
522 # Following tests depend on RSA_C but are not about
523 # them really, just need to know some error code is there.
524 'test_suite_error': [
525 'Low and high error',
526 'Single high error'
527 ],
528 # Constant time operations only used for PKCS1_V15
529 'test_suite_constant_time': [
530 re.compile(r'mbedtls_ct_zeroize_if .*'),
531 re.compile(r'mbedtls_ct_memmove_left .*')
532 ],
533 'test_suite_psa_crypto': [
534 # We don't support generate_key_custom entry points
535 # in drivers yet.
536 re.compile(r'PSA generate key custom: RSA, e=.*'),
537 re.compile(r'PSA generate key ext: RSA, e=.*'),
538 ],
539 }
540
Gilles Peskine082eade2024-10-03 18:42:37 +0200541class DriverVSReference_block_cipher_dispatch(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200542 REFERENCE = 'test_full_block_cipher_legacy_dispatch'
543 DRIVER = 'test_full_block_cipher_psa_dispatch'
544 IGNORED_SUITES = [
545 # Skipped in the accelerated component
546 'aes', 'aria', 'camellia',
547 # These require AES_C, ARIA_C or CAMELLIA_C to be enabled in
548 # order for the cipher module (actually cipher_wrapper) to work
549 # properly. However these symbols are disabled in the accelerated
550 # component so we ignore them.
551 'cipher.ccm', 'cipher.gcm', 'cipher.aes', 'cipher.aria',
552 'cipher.camellia',
553 ]
554 IGNORED_TESTS = {
555 'test_suite_config': [
556 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA)_.*'),
557 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
558 ],
559 'test_suite_cmac': [
560 # Following tests require AES_C/ARIA_C/CAMELLIA_C to be enabled,
561 # but these are not available in the accelerated component.
562 'CMAC null arguments',
563 re.compile('CMAC.* (AES|ARIA|Camellia).*'),
564 ],
565 'test_suite_cipher.padding': [
566 # Following tests require AES_C/CAMELLIA_C to be enabled,
567 # but these are not available in the accelerated component.
568 re.compile('Set( non-existent)? padding with (AES|CAMELLIA).*'),
569 ],
570 'test_suite_pkcs5': [
571 # The AES part of PKCS#5 PBES2 is not yet supported.
572 # The rest of PKCS#5 (PBKDF2) works, though.
573 re.compile(r'PBES2 .* AES-.*')
574 ],
575 'test_suite_pkparse': [
576 # PEM (called by pkparse) requires AES_C in order to decrypt
577 # the key, but this is not available in the accelerated
578 # component.
579 re.compile('Parse RSA Key.*(password|AES-).*'),
580 ],
581 'test_suite_pem': [
582 # Following tests require AES_C, but this is diabled in the
583 # accelerated component.
584 re.compile('PEM read .*AES.*'),
585 'PEM read (unknown encryption algorithm)',
586 ],
587 'test_suite_error': [
588 # Following tests depend on AES_C but are not about them
589 # really, just need to know some error code is there.
590 'Single low error',
591 'Low and high error',
592 ],
593 'test_suite_version': [
594 # Similar to test_suite_error above.
595 'Check for MBEDTLS_AES_C when already present',
596 ],
597 'test_suite_platform': [
598 # Incompatible with sanitizers (e.g. ASan). If the driver
599 # component uses a sanitizer but the reference component
600 # doesn't, we have a PASS vs SKIP mismatch.
601 'Check mbedtls_calloc overallocation',
602 ],
603 }
604
605#pylint: enable=invalid-name,missing-class-docstring
606
607
Przemek Stekiel6856f4c2022-11-09 10:50:29 +0100608# List of tasks with a function that can handle this task and additional arguments if required
Valerio Settidfd7ca62023-10-09 16:30:11 +0200609KNOWN_TASKS = {
Gilles Peskinef646dbf2024-09-16 19:15:29 +0200610 'analyze_coverage': CoverageTask,
Gilles Peskine9df375b2024-09-16 20:14:26 +0200611 'analyze_driver_vs_reference_hash': DriverVSReference_hash,
612 'analyze_driver_vs_reference_hmac': DriverVSReference_hmac,
613 'analyze_driver_vs_reference_cipher_aead_cmac': DriverVSReference_cipher_aead_cmac,
614 'analyze_driver_vs_reference_ecp_light_only': DriverVSReference_ecp_light_only,
615 'analyze_driver_vs_reference_no_ecp_at_all': DriverVSReference_no_ecp_at_all,
616 'analyze_driver_vs_reference_ecc_no_bignum': DriverVSReference_ecc_no_bignum,
617 'analyze_driver_vs_reference_ecc_ffdh_no_bignum': DriverVSReference_ecc_ffdh_no_bignum,
618 'analyze_driver_vs_reference_ffdh_alg': DriverVSReference_ffdh_alg,
619 'analyze_driver_vs_reference_tfm_config': DriverVSReference_tfm_config,
620 'analyze_driver_vs_reference_rsa': DriverVSReference_rsa,
621 'analyze_block_cipher_dispatch': DriverVSReference_block_cipher_dispatch,
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200622}
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200623
Gilles Peskine15c2cbf2020-06-25 18:36:28 +0200624if __name__ == '__main__':
Gilles Peskine082eade2024-10-03 18:42:37 +0200625 outcome_analysis.main(KNOWN_TASKS)