blob: 39460176253a1cfc01816a41c93bd05fcf340798 [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 Peskine095561c2024-10-04 16:24:26 +020017 """Justify test cases that are never executed."""
Gilles Peskine3f5022e2024-09-16 20:23:40 +020018
Gilles Peskine2a71fac2024-09-17 15:07:22 +020019 @staticmethod
Gilles Peskine5872c0d2024-09-17 17:15:29 +020020 def _has_word_re(words: typing.Iterable[str],
21 exclude: typing.Optional[str] = None) -> typing.Pattern:
Gilles Peskine2a71fac2024-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 Peskine5872c0d2024-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 Peskine2a71fac2024-09-17 15:07:22 +020028 """
Gilles Peskine5872c0d2024-09-17 17:15:29 +020029 exclude_clause = r''
30 if exclude:
31 exclude_clause = r'(?!.*' + exclude + ')'
32 return re.compile(exclude_clause +
33 r'.*\b(?:' + r'|'.join(words) + r')\b.*',
Gilles Peskine5e3ed3f2024-10-11 12:00:44 +020034 re.DOTALL)
Gilles Peskine2a71fac2024-09-17 15:07:22 +020035
Gilles Peskine2a71fac2024-09-17 15:07:22 +020036 IGNORED_TESTS = {
Gilles Peskinee0bd20b2025-03-03 14:10:08 +010037 'handshake-generated': [
38 # Temporary disable Handshake defragmentation tests until mbedtls
39 # pr #10011 has been merged.
40 'Handshake defragmentation on client: len=4, TLS 1.2',
41 'Handshake defragmentation on client: len=5, TLS 1.2',
42 'Handshake defragmentation on client: len=13, TLS 1.2'
43 ],
Gilles Peskinede2316b2024-09-17 18:32:05 +020044 'ssl-opt': [
45 # We don't run ssl-opt.sh with Valgrind on the CI because
46 # it's extremely slow. We don't intend to change this.
47 'DTLS client reconnect from same port: reconnect, nbio, valgrind',
Gilles Peskinede2316b2024-09-17 18:32:05 +020048 # We don't have IPv6 in our CI environment.
49 # https://github.com/Mbed-TLS/mbedtls-test/issues/176
50 'DTLS cookie: enabled, IPv6',
51 # Disabled due to OpenSSL bug.
52 # https://github.com/openssl/openssl/issues/18887
53 'DTLS fragmenting: 3d, openssl client, DTLS 1.2',
54 # We don't run ssl-opt.sh with Valgrind on the CI because
55 # it's extremely slow. We don't intend to change this.
56 'DTLS fragmenting: proxy MTU: auto-reduction (with valgrind)',
Gilles Peskine24b03d82024-10-04 16:22:24 +020057 # TLS doesn't use restartable ECDH yet.
58 # https://github.com/Mbed-TLS/mbedtls/issues/7294
59 re.compile(r'EC restart:.*no USE_PSA.*'),
Gilles Peskinede2316b2024-09-17 18:32:05 +020060 ],
Gilles Peskine2fd25bb2024-09-17 19:46:18 +020061 'test_suite_config.mbedtls_boolean': [
Gilles Peskine2fd25bb2024-09-17 19:46:18 +020062 # Missing coverage of test configurations.
63 # https://github.com/Mbed-TLS/mbedtls/issues/9585
64 'Config: !MBEDTLS_SSL_DTLS_ANTI_REPLAY',
65 # Missing coverage of test configurations.
66 # https://github.com/Mbed-TLS/mbedtls/issues/9585
67 'Config: !MBEDTLS_SSL_DTLS_HELLO_VERIFY',
68 # We don't run test_suite_config when we test this.
69 # https://github.com/Mbed-TLS/mbedtls/issues/9586
70 'Config: !MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED',
Gilles Peskine2fd25bb2024-09-17 19:46:18 +020071 ],
72 'test_suite_config.psa_boolean': [
73 # We don't test with HMAC disabled.
74 # https://github.com/Mbed-TLS/mbedtls/issues/9591
75 'Config: !PSA_WANT_ALG_HMAC',
Gilles Peskine2fd25bb2024-09-17 19:46:18 +020076 # The DERIVE key type is always enabled.
77 'Config: !PSA_WANT_KEY_TYPE_DERIVE',
78 # More granularity of key pair type enablement macros
79 # than we care to test.
80 # https://github.com/Mbed-TLS/mbedtls/issues/9590
81 'Config: !PSA_WANT_KEY_TYPE_DH_KEY_PAIR_EXPORT',
82 'Config: !PSA_WANT_KEY_TYPE_DH_KEY_PAIR_GENERATE',
83 'Config: !PSA_WANT_KEY_TYPE_DH_KEY_PAIR_IMPORT',
84 # More granularity of key pair type enablement macros
85 # than we care to test.
86 # https://github.com/Mbed-TLS/mbedtls/issues/9590
87 'Config: !PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT',
88 'Config: !PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT',
89 # We don't test with HMAC disabled.
90 # https://github.com/Mbed-TLS/mbedtls/issues/9591
91 'Config: !PSA_WANT_KEY_TYPE_HMAC',
92 # The PASSWORD key type is always enabled.
93 'Config: !PSA_WANT_KEY_TYPE_PASSWORD',
94 # The PASSWORD_HASH key type is always enabled.
95 'Config: !PSA_WANT_KEY_TYPE_PASSWORD_HASH',
96 # The RAW_DATA key type is always enabled.
97 'Config: !PSA_WANT_KEY_TYPE_RAW_DATA',
98 # More granularity of key pair type enablement macros
99 # than we care to test.
100 # https://github.com/Mbed-TLS/mbedtls/issues/9590
101 'Config: !PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_EXPORT',
102 'Config: !PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT',
103 # Algorithm declared but not supported.
104 'Config: PSA_WANT_ALG_CBC_MAC',
105 # Algorithm declared but not supported.
106 'Config: PSA_WANT_ALG_XTS',
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200107 # More granularity of key pair type enablement macros
108 # than we care to test.
109 # https://github.com/Mbed-TLS/mbedtls/issues/9590
110 'Config: PSA_WANT_KEY_TYPE_DH_KEY_PAIR_DERIVE',
111 'Config: PSA_WANT_KEY_TYPE_ECC_KEY_PAIR',
112 'Config: PSA_WANT_KEY_TYPE_RSA_KEY_PAIR',
113 'Config: PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_DERIVE',
Minos Galanakis848333d2024-12-02 15:58:32 +0000114 # https://github.com/Mbed-TLS/mbedtls/issues/9583
115 'Config: !MBEDTLS_ECP_NIST_OPTIM',
116 # We never test without the PSA client code. Should we?
117 # https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/112
118 'Config: !MBEDTLS_PSA_CRYPTO_CLIENT',
119 # We only test multithreading with pthreads.
120 # https://github.com/Mbed-TLS/mbedtls/issues/9584
121 'Config: !MBEDTLS_THREADING_PTHREAD',
122 # Built but not tested.
123 # https://github.com/Mbed-TLS/mbedtls/issues/9587
124 'Config: MBEDTLS_AES_USE_HARDWARE_ONLY',
125 # Untested platform-specific optimizations.
126 # https://github.com/Mbed-TLS/mbedtls/issues/9588
127 'Config: MBEDTLS_HAVE_SSE2',
128 # Obsolete configuration option, to be replaced by
129 # PSA entropy drivers.
130 # https://github.com/Mbed-TLS/mbedtls/issues/8150
131 'Config: MBEDTLS_NO_PLATFORM_ENTROPY',
132 # Untested aspect of the platform interface.
133 # https://github.com/Mbed-TLS/mbedtls/issues/9589
134 'Config: MBEDTLS_PLATFORM_NO_STD_FUNCTIONS',
135 # In a client-server build, test_suite_config runs in the
136 # client configuration, so it will never report
137 # MBEDTLS_PSA_CRYPTO_SPM as enabled. That's ok.
138 'Config: MBEDTLS_PSA_CRYPTO_SPM',
139 # We don't test on armv8 yet.
140 'Config: MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT',
141 'Config: MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY',
142 'Config: MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY',
143 'Config: MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY',
144 # We don't run test_suite_config when we test this.
145 # https://github.com/Mbed-TLS/mbedtls/issues/9586
146 'Config: MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND',
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200147 ],
148 'test_suite_config.psa_combinations': [
149 # We don't test this unusual, but sensible configuration.
150 # https://github.com/Mbed-TLS/mbedtls/issues/9592
151 'Config: PSA_WANT_ALG_DETERMINSTIC_ECDSA without PSA_WANT_ALG_ECDSA',
152 ],
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200153 'test_suite_pkcs12': [
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200154 # We never test with CBC/PKCS5/PKCS12 enabled but
155 # PKCS7 padding disabled.
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200156 # https://github.com/Mbed-TLS/mbedtls/issues/9580
157 'PBE Decrypt, (Invalid padding & PKCS7 padding disabled)',
158 'PBE Encrypt, pad = 8 (PKCS7 padding disabled)',
159 ],
160 'test_suite_pkcs5': [
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200161 # We never test with CBC/PKCS5/PKCS12 enabled but
162 # PKCS7 padding disabled.
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200163 # https://github.com/Mbed-TLS/mbedtls/issues/9580
164 'PBES2 Decrypt (Invalid padding & PKCS7 padding disabled)',
165 'PBES2 Encrypt, pad=6 (PKCS7 padding disabled)',
166 'PBES2 Encrypt, pad=8 (PKCS7 padding disabled)',
167 ],
Gilles Peskineeafc2752024-04-19 19:08:34 +0200168 'test_suite_psa_crypto': [
169 # We don't test this unusual, but sensible configuration.
170 # https://github.com/Mbed-TLS/mbedtls/issues/9592
171 re.compile(r'.*ECDSA.*only deterministic supported'),
172 ],
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200173 'test_suite_psa_crypto_metadata': [
174 # Algorithms declared but not supported.
175 # https://github.com/Mbed-TLS/mbedtls/issues/9579
176 'Asymmetric signature: Ed25519ph',
177 'Asymmetric signature: Ed448ph',
178 'Asymmetric signature: pure EdDSA',
179 'Cipher: XTS',
180 'MAC: CBC_MAC-3DES',
181 'MAC: CBC_MAC-AES-128',
182 'MAC: CBC_MAC-AES-192',
183 'MAC: CBC_MAC-AES-256',
184 ],
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200185 'test_suite_psa_crypto_not_supported.generated': [
Gilles Peskine5e3ed3f2024-10-11 12:00:44 +0200186 # We never test with DH key support disabled but support
Gilles Peskineab5cc9b2024-09-17 17:57:11 +0200187 # for a DH group enabled. The dependencies of these test
188 # cases don't really make sense.
189 # https://github.com/Mbed-TLS/mbedtls/issues/9574
190 re.compile(r'PSA \w+ DH_.*type not supported'),
191 # We only test partial support for DH with the 2048-bit group
192 # enabled and the other groups disabled.
193 # https://github.com/Mbed-TLS/mbedtls/issues/9575
194 'PSA generate DH_KEY_PAIR(RFC7919) 2048-bit group not supported',
195 'PSA import DH_KEY_PAIR(RFC7919) 2048-bit group not supported',
196 'PSA import DH_PUBLIC_KEY(RFC7919) 2048-bit group not supported',
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200197 ],
198 'test_suite_psa_crypto_op_fail.generated': [
Gilles Peskineeafc2752024-04-19 19:08:34 +0200199 # We don't test this unusual, but sensible configuration.
200 # https://github.com/Mbed-TLS/mbedtls/issues/9592
201 re.compile(r'.*: !ECDSA but DETERMINISTIC_ECDSA with ECC_.*'),
Gilles Peskineab5cc9b2024-09-17 17:57:11 +0200202 # We never test with the HMAC algorithm enabled but the HMAC
203 # key type disabled. Those dependencies don't really make sense.
204 # https://github.com/Mbed-TLS/mbedtls/issues/9573
205 re.compile(r'.* !HMAC with HMAC'),
Gilles Peskine13c418d2025-01-16 19:49:12 +0100206 # We don't test with ECDH disabled but the key type enabled.
207 # https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/161
208 re.compile(r'PSA key_agreement.* !ECDH with ECC_KEY_PAIR\(.*'),
209 # We don't test with FFDH disabled but the key type enabled.
210 # https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/160
211 re.compile(r'PSA key_agreement.* !FFDH with DH_KEY_PAIR\(.*'),
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200212 ],
Gilles Peskineeafc2752024-04-19 19:08:34 +0200213 'test_suite_psa_crypto_op_fail.misc': [
214 # We don't test this unusual, but sensible configuration.
215 # https://github.com/Mbed-TLS/mbedtls/issues/9592
216 'PSA sign DETERMINISTIC_ECDSA(SHA_256): !ECDSA but DETERMINISTIC_ECDSA with ECC_KEY_PAIR(SECP_R1)', #pylint: disable=line-too-long
217 ],
Gilles Peskinede2316b2024-09-17 18:32:05 +0200218 'tls13-misc': [
219 # Disabled due to OpenSSL bug.
220 # https://github.com/openssl/openssl/issues/10714
221 'TLS 1.3 O->m: resumption',
222 # Disabled due to OpenSSL command line limitation.
223 # https://github.com/Mbed-TLS/mbedtls/issues/9582
224 'TLS 1.3 m->O: resumption with early data',
225 ],
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200226 }
227
Gilles Peskine82b16722024-09-16 19:57:10 +0200228
Gilles Peskine9df375b2024-09-16 20:14:26 +0200229# The names that we give to classes derived from DriverVSReference do not
230# follow the usual naming convention, because it's more readable to use
231# underscores and parts of the configuration names. Also, these classes
232# are just there to specify some data, so they don't need repetitive
233# documentation.
234#pylint: disable=invalid-name,missing-class-docstring
235
Gilles Peskine082eade2024-10-03 18:42:37 +0200236class DriverVSReference_hash(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200237 REFERENCE = 'test_psa_crypto_config_reference_hash_use_psa'
238 DRIVER = 'test_psa_crypto_config_accel_hash_use_psa'
239 IGNORED_SUITES = [
240 'shax', 'mdx', # the software implementations that are being excluded
241 'md.psa', # purposefully depends on whether drivers are present
242 'psa_crypto_low_hash.generated', # testing the builtins
243 ]
244 IGNORED_TESTS = {
245 'test_suite_config': [
246 re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'),
247 ],
248 'test_suite_platform': [
249 # Incompatible with sanitizers (e.g. ASan). If the driver
250 # component uses a sanitizer but the reference component
251 # doesn't, we have a PASS vs SKIP mismatch.
252 'Check mbedtls_calloc overallocation',
253 ],
254 }
255
Gilles Peskine082eade2024-10-03 18:42:37 +0200256class DriverVSReference_hmac(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200257 REFERENCE = 'test_psa_crypto_config_reference_hmac'
258 DRIVER = 'test_psa_crypto_config_accel_hmac'
259 IGNORED_SUITES = [
260 # These suites require legacy hash support, which is disabled
261 # in the accelerated component.
262 'shax', 'mdx',
263 # This suite tests builtins directly, but these are missing
264 # in the accelerated case.
265 'psa_crypto_low_hash.generated',
266 ]
267 IGNORED_TESTS = {
268 'test_suite_config': [
269 re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'),
270 re.compile(r'.*\bMBEDTLS_MD_C\b')
271 ],
272 'test_suite_md': [
273 # Builtin HMAC is not supported in the accelerate component.
274 re.compile('.*HMAC.*'),
275 # Following tests make use of functions which are not available
276 # when MD_C is disabled, as it happens in the accelerated
277 # test component.
278 re.compile('generic .* Hash file .*'),
279 'MD list',
280 ],
281 'test_suite_md.psa': [
282 # "legacy only" tests require hash algorithms to be NOT
283 # accelerated, but this of course false for the accelerated
284 # test component.
285 re.compile('PSA dispatch .* legacy only'),
286 ],
287 'test_suite_platform': [
288 # Incompatible with sanitizers (e.g. ASan). If the driver
289 # component uses a sanitizer but the reference component
290 # doesn't, we have a PASS vs SKIP mismatch.
291 'Check mbedtls_calloc overallocation',
292 ],
293 }
294
Gilles Peskine082eade2024-10-03 18:42:37 +0200295class DriverVSReference_cipher_aead_cmac(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200296 REFERENCE = 'test_psa_crypto_config_reference_cipher_aead_cmac'
297 DRIVER = 'test_psa_crypto_config_accel_cipher_aead_cmac'
298 # Modules replaced by drivers.
299 IGNORED_SUITES = [
300 # low-level (block/stream) cipher modules
301 'aes', 'aria', 'camellia', 'des', 'chacha20',
302 # AEAD modes and CMAC
303 'ccm', 'chachapoly', 'cmac', 'gcm',
304 # The Cipher abstraction layer
305 'cipher',
306 ]
307 IGNORED_TESTS = {
308 'test_suite_config': [
309 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA|CHACHA20|DES)_.*'),
310 re.compile(r'.*\bMBEDTLS_(CCM|CHACHAPOLY|CMAC|GCM)_.*'),
311 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
312 re.compile(r'.*\bMBEDTLS_CIPHER_.*'),
313 ],
314 # PEM decryption is not supported so far.
315 # The rest of PEM (write, unencrypted read) works though.
316 'test_suite_pem': [
317 re.compile(r'PEM read .*(AES|DES|\bencrypt).*'),
318 ],
319 'test_suite_platform': [
320 # Incompatible with sanitizers (e.g. ASan). If the driver
321 # component uses a sanitizer but the reference component
322 # doesn't, we have a PASS vs SKIP mismatch.
323 'Check mbedtls_calloc overallocation',
324 ],
325 # Following tests depend on AES_C/DES_C but are not about
326 # them really, just need to know some error code is there.
327 'test_suite_error': [
328 'Low and high error',
329 'Single low error'
330 ],
331 # Similar to test_suite_error above.
332 'test_suite_version': [
333 'Check for MBEDTLS_AES_C when already present',
334 ],
335 # The en/decryption part of PKCS#12 is not supported so far.
336 # The rest of PKCS#12 (key derivation) works though.
337 'test_suite_pkcs12': [
338 re.compile(r'PBE Encrypt, .*'),
339 re.compile(r'PBE Decrypt, .*'),
340 ],
341 # The en/decryption part of PKCS#5 is not supported so far.
342 # The rest of PKCS#5 (PBKDF2) works though.
343 'test_suite_pkcs5': [
344 re.compile(r'PBES2 Encrypt, .*'),
345 re.compile(r'PBES2 Decrypt .*'),
346 ],
347 # Encrypted keys are not supported so far.
348 # pylint: disable=line-too-long
349 'test_suite_pkparse': [
350 'Key ASN1 (Encrypted key PKCS12, trailing garbage data)',
351 'Key ASN1 (Encrypted key PKCS5, trailing garbage data)',
352 re.compile(r'Parse (RSA|EC) Key .*\(.* ([Ee]ncrypted|password).*\)'),
353 ],
354 # Encrypted keys are not supported so far.
355 'ssl-opt': [
356 'TLS: password protected server key',
357 'TLS: password protected client key',
358 'TLS: password protected server key, two certificates',
359 ],
360 }
361
Gilles Peskine082eade2024-10-03 18:42:37 +0200362class DriverVSReference_ecp_light_only(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200363 REFERENCE = 'test_psa_crypto_config_reference_ecc_ecp_light_only'
364 DRIVER = 'test_psa_crypto_config_accel_ecc_ecp_light_only'
365 IGNORED_SUITES = [
366 # Modules replaced by drivers
367 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100368 # Unit tests for the built-in implementation
369 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200370 ]
371 IGNORED_TESTS = {
372 'test_suite_config': [
373 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
374 ],
375 'test_suite_platform': [
376 # Incompatible with sanitizers (e.g. ASan). If the driver
377 # component uses a sanitizer but the reference component
378 # doesn't, we have a PASS vs SKIP mismatch.
379 'Check mbedtls_calloc overallocation',
380 ],
381 # This test wants a legacy function that takes f_rng, p_rng
382 # arguments, and uses legacy ECDSA for that. The test is
383 # really about the wrapper around the PSA RNG, not ECDSA.
384 'test_suite_random': [
385 'PSA classic wrapper: ECDSA signature (SECP256R1)',
386 ],
387 # In the accelerated test ECP_C is not set (only ECP_LIGHT is)
388 # so we must ignore disparities in the tests for which ECP_C
389 # is required.
390 'test_suite_ecp': [
391 re.compile(r'ECP check public-private .*'),
392 re.compile(r'ECP calculate public: .*'),
393 re.compile(r'ECP gen keypair .*'),
394 re.compile(r'ECP point muladd .*'),
395 re.compile(r'ECP point multiplication .*'),
396 re.compile(r'ECP test vectors .*'),
397 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200398 }
399
Gilles Peskine082eade2024-10-03 18:42:37 +0200400class DriverVSReference_no_ecp_at_all(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200401 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_ecp_at_all'
402 DRIVER = 'test_psa_crypto_config_accel_ecc_no_ecp_at_all'
403 IGNORED_SUITES = [
404 # Modules replaced by drivers
405 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100406 # Unit tests for the built-in implementation
407 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200408 ]
409 IGNORED_TESTS = {
410 'test_suite_config': [
411 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
412 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
413 ],
414 'test_suite_platform': [
415 # Incompatible with sanitizers (e.g. ASan). If the driver
416 # component uses a sanitizer but the reference component
417 # doesn't, we have a PASS vs SKIP mismatch.
418 'Check mbedtls_calloc overallocation',
419 ],
420 # See ecp_light_only
421 'test_suite_random': [
422 'PSA classic wrapper: ECDSA signature (SECP256R1)',
423 ],
424 'test_suite_pkparse': [
425 # When PK_PARSE_C and ECP_C are defined then PK_PARSE_EC_COMPRESSED
426 # is automatically enabled in build_info.h (backward compatibility)
427 # even if it is disabled in config_psa_crypto_no_ecp_at_all(). As a
428 # consequence compressed points are supported in the reference
429 # component but not in the accelerated one, so they should be skipped
430 # while checking driver's coverage.
431 re.compile(r'Parse EC Key .*compressed\)'),
432 re.compile(r'Parse Public EC Key .*compressed\)'),
433 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200434 }
435
Gilles Peskine082eade2024-10-03 18:42:37 +0200436class DriverVSReference_ecc_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200437 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_bignum'
438 DRIVER = 'test_psa_crypto_config_accel_ecc_no_bignum'
439 IGNORED_SUITES = [
440 # Modules replaced by drivers
441 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
442 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
443 'bignum.generated', 'bignum.misc',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100444 # Unit tests for the built-in implementation
445 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200446 ]
447 IGNORED_TESTS = {
448 'test_suite_config': [
449 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
450 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
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 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200477 }
478
Gilles Peskine082eade2024-10-03 18:42:37 +0200479class DriverVSReference_ecc_ffdh_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200480 REFERENCE = 'test_psa_crypto_config_reference_ecc_ffdh_no_bignum'
481 DRIVER = 'test_psa_crypto_config_accel_ecc_ffdh_no_bignum'
482 IGNORED_SUITES = [
483 # Modules replaced by drivers
484 'ecp', 'ecdsa', 'ecdh', 'ecjpake', 'dhm',
485 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
486 'bignum.generated', 'bignum.misc',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100487 # Unit tests for the built-in implementation
488 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200489 ]
490 IGNORED_TESTS = {
Gilles Peskine9df375b2024-09-16 20:14:26 +0200491 'test_suite_config': [
492 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
493 re.compile(r'.*\bMBEDTLS_DHM_C\b.*'),
494 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
Gilles Peskine9df375b2024-09-16 20:14:26 +0200495 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
496 ],
497 'test_suite_platform': [
498 # Incompatible with sanitizers (e.g. ASan). If the driver
499 # component uses a sanitizer but the reference component
500 # doesn't, we have a PASS vs SKIP mismatch.
501 'Check mbedtls_calloc overallocation',
502 ],
503 # See ecp_light_only
504 'test_suite_random': [
505 'PSA classic wrapper: ECDSA signature (SECP256R1)',
506 ],
507 # See no_ecp_at_all
508 'test_suite_pkparse': [
509 re.compile(r'Parse EC Key .*compressed\)'),
510 re.compile(r'Parse Public EC Key .*compressed\)'),
511 ],
512 'test_suite_asn1parse': [
513 'INTEGER too large for mpi',
514 ],
515 'test_suite_asn1write': [
516 re.compile(r'ASN.1 Write mpi.*'),
517 ],
518 'test_suite_debug': [
519 re.compile(r'Debug print mbedtls_mpi.*'),
520 ],
Gilles Peskine9df375b2024-09-16 20:14:26 +0200521 }
522
Gilles Peskine082eade2024-10-03 18:42:37 +0200523class DriverVSReference_ffdh_alg(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200524 REFERENCE = 'test_psa_crypto_config_reference_ffdh'
525 DRIVER = 'test_psa_crypto_config_accel_ffdh'
526 IGNORED_SUITES = ['dhm']
527 IGNORED_TESTS = {
528 'test_suite_config': [
529 re.compile(r'.*\bMBEDTLS_DHM_C\b.*'),
530 ],
531 'test_suite_platform': [
532 # Incompatible with sanitizers (e.g. ASan). If the driver
533 # component uses a sanitizer but the reference component
534 # doesn't, we have a PASS vs SKIP mismatch.
535 'Check mbedtls_calloc overallocation',
536 ],
537 }
538
Gilles Peskine082eade2024-10-03 18:42:37 +0200539class DriverVSReference_tfm_config(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200540 REFERENCE = 'test_tfm_config_no_p256m'
541 DRIVER = 'test_tfm_config_p256m_driver_accel_ec'
542 IGNORED_SUITES = [
543 # Modules replaced by drivers
544 'asn1parse', 'asn1write',
545 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
546 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
547 'bignum.generated', 'bignum.misc',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100548 # Unit tests for the built-in implementation
549 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200550 ]
551 IGNORED_TESTS = {
552 'test_suite_config': [
553 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
554 re.compile(r'.*\bMBEDTLS_(ASN1\w+)_C\b.*'),
555 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECP)_.*'),
556 re.compile(r'.*\bMBEDTLS_PSA_P256M_DRIVER_ENABLED\b.*')
557 ],
558 'test_suite_config.crypto_combinations': [
559 'Config: ECC: Weierstrass curves only',
560 ],
561 'test_suite_platform': [
562 # Incompatible with sanitizers (e.g. ASan). If the driver
563 # component uses a sanitizer but the reference component
564 # doesn't, we have a PASS vs SKIP mismatch.
565 'Check mbedtls_calloc overallocation',
566 ],
567 # See ecp_light_only
568 'test_suite_random': [
569 'PSA classic wrapper: ECDSA signature (SECP256R1)',
570 ],
571 }
572
Gilles Peskine082eade2024-10-03 18:42:37 +0200573class DriverVSReference_rsa(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200574 REFERENCE = 'test_psa_crypto_config_reference_rsa_crypto'
575 DRIVER = 'test_psa_crypto_config_accel_rsa_crypto'
576 IGNORED_SUITES = [
577 # Modules replaced by drivers.
578 'rsa', 'pkcs1_v15', 'pkcs1_v21',
579 # We temporarily don't care about PK stuff.
580 'pk', 'pkwrite', 'pkparse'
581 ]
582 IGNORED_TESTS = {
583 'test_suite_config': [
584 re.compile(r'.*\bMBEDTLS_(PKCS1|RSA)_.*'),
585 re.compile(r'.*\bMBEDTLS_GENPRIME\b.*')
586 ],
587 'test_suite_platform': [
588 # Incompatible with sanitizers (e.g. ASan). If the driver
589 # component uses a sanitizer but the reference component
590 # doesn't, we have a PASS vs SKIP mismatch.
591 'Check mbedtls_calloc overallocation',
592 ],
593 # Following tests depend on RSA_C but are not about
594 # them really, just need to know some error code is there.
595 'test_suite_error': [
596 'Low and high error',
597 'Single high error'
598 ],
599 # Constant time operations only used for PKCS1_V15
600 'test_suite_constant_time': [
601 re.compile(r'mbedtls_ct_zeroize_if .*'),
602 re.compile(r'mbedtls_ct_memmove_left .*')
603 ],
604 'test_suite_psa_crypto': [
605 # We don't support generate_key_custom entry points
606 # in drivers yet.
607 re.compile(r'PSA generate key custom: RSA, e=.*'),
608 re.compile(r'PSA generate key ext: RSA, e=.*'),
609 ],
610 }
611
Gilles Peskine082eade2024-10-03 18:42:37 +0200612class DriverVSReference_block_cipher_dispatch(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200613 REFERENCE = 'test_full_block_cipher_legacy_dispatch'
614 DRIVER = 'test_full_block_cipher_psa_dispatch'
615 IGNORED_SUITES = [
616 # Skipped in the accelerated component
617 'aes', 'aria', 'camellia',
618 # These require AES_C, ARIA_C or CAMELLIA_C to be enabled in
619 # order for the cipher module (actually cipher_wrapper) to work
620 # properly. However these symbols are disabled in the accelerated
621 # component so we ignore them.
622 'cipher.ccm', 'cipher.gcm', 'cipher.aes', 'cipher.aria',
623 'cipher.camellia',
624 ]
625 IGNORED_TESTS = {
626 'test_suite_config': [
627 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA)_.*'),
628 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
629 ],
630 'test_suite_cmac': [
631 # Following tests require AES_C/ARIA_C/CAMELLIA_C to be enabled,
632 # but these are not available in the accelerated component.
633 'CMAC null arguments',
634 re.compile('CMAC.* (AES|ARIA|Camellia).*'),
635 ],
636 'test_suite_cipher.padding': [
637 # Following tests require AES_C/CAMELLIA_C to be enabled,
638 # but these are not available in the accelerated component.
639 re.compile('Set( non-existent)? padding with (AES|CAMELLIA).*'),
640 ],
641 'test_suite_pkcs5': [
642 # The AES part of PKCS#5 PBES2 is not yet supported.
643 # The rest of PKCS#5 (PBKDF2) works, though.
644 re.compile(r'PBES2 .* AES-.*')
645 ],
646 'test_suite_pkparse': [
647 # PEM (called by pkparse) requires AES_C in order to decrypt
648 # the key, but this is not available in the accelerated
649 # component.
650 re.compile('Parse RSA Key.*(password|AES-).*'),
651 ],
652 'test_suite_pem': [
653 # Following tests require AES_C, but this is diabled in the
654 # accelerated component.
655 re.compile('PEM read .*AES.*'),
656 'PEM read (unknown encryption algorithm)',
657 ],
658 'test_suite_error': [
659 # Following tests depend on AES_C but are not about them
660 # really, just need to know some error code is there.
661 'Single low error',
662 'Low and high error',
663 ],
664 'test_suite_version': [
665 # Similar to test_suite_error above.
666 'Check for MBEDTLS_AES_C when already present',
667 ],
668 'test_suite_platform': [
669 # Incompatible with sanitizers (e.g. ASan). If the driver
670 # component uses a sanitizer but the reference component
671 # doesn't, we have a PASS vs SKIP mismatch.
672 'Check mbedtls_calloc overallocation',
673 ],
674 }
675
676#pylint: enable=invalid-name,missing-class-docstring
677
678
Przemek Stekiel6856f4c2022-11-09 10:50:29 +0100679# List of tasks with a function that can handle this task and additional arguments if required
Valerio Settidfd7ca62023-10-09 16:30:11 +0200680KNOWN_TASKS = {
Gilles Peskinef646dbf2024-09-16 19:15:29 +0200681 'analyze_coverage': CoverageTask,
Gilles Peskine9df375b2024-09-16 20:14:26 +0200682 'analyze_driver_vs_reference_hash': DriverVSReference_hash,
683 'analyze_driver_vs_reference_hmac': DriverVSReference_hmac,
684 'analyze_driver_vs_reference_cipher_aead_cmac': DriverVSReference_cipher_aead_cmac,
685 'analyze_driver_vs_reference_ecp_light_only': DriverVSReference_ecp_light_only,
686 'analyze_driver_vs_reference_no_ecp_at_all': DriverVSReference_no_ecp_at_all,
687 'analyze_driver_vs_reference_ecc_no_bignum': DriverVSReference_ecc_no_bignum,
688 'analyze_driver_vs_reference_ecc_ffdh_no_bignum': DriverVSReference_ecc_ffdh_no_bignum,
689 'analyze_driver_vs_reference_ffdh_alg': DriverVSReference_ffdh_alg,
690 'analyze_driver_vs_reference_tfm_config': DriverVSReference_tfm_config,
691 'analyze_driver_vs_reference_rsa': DriverVSReference_rsa,
692 'analyze_block_cipher_dispatch': DriverVSReference_block_cipher_dispatch,
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200693}
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200694
Gilles Peskine15c2cbf2020-06-25 18:36:28 +0200695if __name__ == '__main__':
Gilles Peskine082eade2024-10-03 18:42:37 +0200696 outcome_analysis.main(KNOWN_TASKS)