blob: f19d4b6f34f77075138840bae11bf3dcefaa1672 [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
36 # generate_psa_tests.py generates test cases involving cryptographic
37 # mechanisms (key types, families, algorithms) that are declared but
38 # not implemented. Until we improve the Python scripts, ignore those
39 # test cases in the analysis.
40 # https://github.com/Mbed-TLS/mbedtls/issues/9572
41 _PSA_MECHANISMS_NOT_IMPLEMENTED = [
42 r'CBC_MAC',
43 r'DETERMINISTIC_DSA',
44 r'DET_DSA',
45 r'DSA',
46 r'ECC_KEY_PAIR\(BRAINPOOL_P_R1\) (?:160|192|224|320)-bit',
47 r'ECC_KEY_PAIR\(SECP_K1\) 225-bit',
48 r'ECC_PAIR\(BP_R1\) (?:160|192|224|320)-bit',
49 r'ECC_PAIR\(SECP_K1\) 225-bit',
50 r'ECC_PUBLIC_KEY\(BRAINPOOL_P_R1\) (?:160|192|224|320)-bit',
51 r'ECC_PUBLIC_KEY\(SECP_K1\) 225-bit',
52 r'ECC_PUB\(BP_R1\) (?:160|192|224|320)-bit',
53 r'ECC_PUB\(SECP_K1\) 225-bit',
54 r'ED25519PH',
55 r'ED448PH',
56 r'PEPPER',
57 r'PURE_EDDSA',
58 r'SECP_R2',
59 r'SECT_K1',
60 r'SECT_R1',
61 r'SECT_R2',
62 r'SHAKE256_512',
63 r'SHA_512_224',
64 r'SHA_512_256',
65 r'TWISTED_EDWARDS',
66 r'XTS',
67 ]
68 PSA_MECHANISM_NOT_IMPLEMENTED_SEARCH_RE = \
69 _has_word_re(_PSA_MECHANISMS_NOT_IMPLEMENTED)
70
71 IGNORED_TESTS = {
Gilles Peskinede2316b2024-09-17 18:32:05 +020072 'ssl-opt': [
73 # We don't run ssl-opt.sh with Valgrind on the CI because
74 # it's extremely slow. We don't intend to change this.
75 'DTLS client reconnect from same port: reconnect, nbio, valgrind',
Gilles Peskinede2316b2024-09-17 18:32:05 +020076 # We don't have IPv6 in our CI environment.
77 # https://github.com/Mbed-TLS/mbedtls-test/issues/176
78 'DTLS cookie: enabled, IPv6',
79 # Disabled due to OpenSSL bug.
80 # https://github.com/openssl/openssl/issues/18887
81 'DTLS fragmenting: 3d, openssl client, DTLS 1.2',
82 # We don't run ssl-opt.sh with Valgrind on the CI because
83 # it's extremely slow. We don't intend to change this.
84 'DTLS fragmenting: proxy MTU: auto-reduction (with valgrind)',
Gilles Peskine24b03d82024-10-04 16:22:24 +020085 # TLS doesn't use restartable ECDH yet.
86 # https://github.com/Mbed-TLS/mbedtls/issues/7294
87 re.compile(r'EC restart:.*no USE_PSA.*'),
Gilles Peskinede2316b2024-09-17 18:32:05 +020088 ],
Gilles Peskine2fd25bb2024-09-17 19:46:18 +020089 'test_suite_config.mbedtls_boolean': [
Gilles Peskine2fd25bb2024-09-17 19:46:18 +020090 # https://github.com/Mbed-TLS/mbedtls/issues/9583
91 'Config: !MBEDTLS_ECP_NIST_OPTIM',
Gilles Peskined9c40f52024-10-04 16:24:02 +020092 # We never test without the PSA client code. Should we?
93 # https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/112
94 'Config: !MBEDTLS_PSA_CRYPTO_CLIENT',
Gilles Peskine2fd25bb2024-09-17 19:46:18 +020095 # Missing coverage of test configurations.
96 # https://github.com/Mbed-TLS/mbedtls/issues/9585
97 'Config: !MBEDTLS_SSL_DTLS_ANTI_REPLAY',
98 # Missing coverage of test configurations.
99 # https://github.com/Mbed-TLS/mbedtls/issues/9585
100 'Config: !MBEDTLS_SSL_DTLS_HELLO_VERIFY',
101 # We don't run test_suite_config when we test this.
102 # https://github.com/Mbed-TLS/mbedtls/issues/9586
103 'Config: !MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED',
104 # We only test multithreading with pthreads.
105 # https://github.com/Mbed-TLS/mbedtls/issues/9584
106 'Config: !MBEDTLS_THREADING_PTHREAD',
107 # Built but not tested.
108 # https://github.com/Mbed-TLS/mbedtls/issues/9587
109 'Config: MBEDTLS_AES_USE_HARDWARE_ONLY',
110 # Untested platform-specific optimizations.
111 # https://github.com/Mbed-TLS/mbedtls/issues/9588
112 'Config: MBEDTLS_HAVE_SSE2',
113 # Obsolete configuration option, to be replaced by
114 # PSA entropy drivers.
115 # https://github.com/Mbed-TLS/mbedtls/issues/8150
116 'Config: MBEDTLS_NO_PLATFORM_ENTROPY',
117 # Untested aspect of the platform interface.
118 # https://github.com/Mbed-TLS/mbedtls/issues/9589
119 'Config: MBEDTLS_PLATFORM_NO_STD_FUNCTIONS',
120 # In a client-server build, test_suite_config runs in the
121 # client configuration, so it will never report
122 # MBEDTLS_PSA_CRYPTO_SPM as enabled. That's ok.
123 'Config: MBEDTLS_PSA_CRYPTO_SPM',
124 # We don't test on armv8 yet.
125 'Config: MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT',
126 'Config: MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY',
127 'Config: MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY',
128 'Config: MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY',
129 # We don't run test_suite_config when we test this.
130 # https://github.com/Mbed-TLS/mbedtls/issues/9586
131 'Config: MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND',
132 ],
133 'test_suite_config.psa_boolean': [
134 # We don't test with HMAC disabled.
135 # https://github.com/Mbed-TLS/mbedtls/issues/9591
136 'Config: !PSA_WANT_ALG_HMAC',
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200137 # The DERIVE key type is always enabled.
138 'Config: !PSA_WANT_KEY_TYPE_DERIVE',
139 # More granularity of key pair type enablement macros
140 # than we care to test.
141 # https://github.com/Mbed-TLS/mbedtls/issues/9590
142 'Config: !PSA_WANT_KEY_TYPE_DH_KEY_PAIR_EXPORT',
143 'Config: !PSA_WANT_KEY_TYPE_DH_KEY_PAIR_GENERATE',
144 'Config: !PSA_WANT_KEY_TYPE_DH_KEY_PAIR_IMPORT',
145 # More granularity of key pair type enablement macros
146 # than we care to test.
147 # https://github.com/Mbed-TLS/mbedtls/issues/9590
148 'Config: !PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT',
149 'Config: !PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT',
150 # We don't test with HMAC disabled.
151 # https://github.com/Mbed-TLS/mbedtls/issues/9591
152 'Config: !PSA_WANT_KEY_TYPE_HMAC',
153 # The PASSWORD key type is always enabled.
154 'Config: !PSA_WANT_KEY_TYPE_PASSWORD',
155 # The PASSWORD_HASH key type is always enabled.
156 'Config: !PSA_WANT_KEY_TYPE_PASSWORD_HASH',
157 # The RAW_DATA key type is always enabled.
158 'Config: !PSA_WANT_KEY_TYPE_RAW_DATA',
159 # More granularity of key pair type enablement macros
160 # than we care to test.
161 # https://github.com/Mbed-TLS/mbedtls/issues/9590
162 'Config: !PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_EXPORT',
163 'Config: !PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT',
164 # Algorithm declared but not supported.
165 'Config: PSA_WANT_ALG_CBC_MAC',
166 # Algorithm declared but not supported.
167 'Config: PSA_WANT_ALG_XTS',
168 # Family declared but not supported.
169 'Config: PSA_WANT_ECC_SECP_K1_224',
170 # More granularity of key pair type enablement macros
171 # than we care to test.
172 # https://github.com/Mbed-TLS/mbedtls/issues/9590
173 'Config: PSA_WANT_KEY_TYPE_DH_KEY_PAIR_DERIVE',
174 'Config: PSA_WANT_KEY_TYPE_ECC_KEY_PAIR',
175 'Config: PSA_WANT_KEY_TYPE_RSA_KEY_PAIR',
176 'Config: PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_DERIVE',
177 ],
178 'test_suite_config.psa_combinations': [
179 # We don't test this unusual, but sensible configuration.
180 # https://github.com/Mbed-TLS/mbedtls/issues/9592
181 'Config: PSA_WANT_ALG_DETERMINSTIC_ECDSA without PSA_WANT_ALG_ECDSA',
182 ],
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200183 'test_suite_pkcs12': [
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200184 # We never test with CBC/PKCS5/PKCS12 enabled but
185 # PKCS7 padding disabled.
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200186 # https://github.com/Mbed-TLS/mbedtls/issues/9580
187 'PBE Decrypt, (Invalid padding & PKCS7 padding disabled)',
188 'PBE Encrypt, pad = 8 (PKCS7 padding disabled)',
189 ],
190 'test_suite_pkcs5': [
Gilles Peskine2fd25bb2024-09-17 19:46:18 +0200191 # We never test with CBC/PKCS5/PKCS12 enabled but
192 # PKCS7 padding disabled.
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200193 # https://github.com/Mbed-TLS/mbedtls/issues/9580
194 'PBES2 Decrypt (Invalid padding & PKCS7 padding disabled)',
195 'PBES2 Encrypt, pad=6 (PKCS7 padding disabled)',
196 'PBES2 Encrypt, pad=8 (PKCS7 padding disabled)',
197 ],
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200198 'test_suite_psa_crypto_generate_key.generated': [
Gilles Peskine5872c0d2024-09-17 17:15:29 +0200199 # Ignore mechanisms that are not implemented, except
200 # for public keys for which we always test that
201 # psa_generate_key() returns PSA_ERROR_INVALID_ARGUMENT
202 # regardless of whether the specific key type is supported.
203 _has_word_re((mech
204 for mech in _PSA_MECHANISMS_NOT_IMPLEMENTED
205 if not mech.startswith('ECC_PUB')),
206 exclude=r'ECC_PUB'),
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200207 ],
Gilles Peskineb0ec85d2024-09-17 18:33:29 +0200208 'test_suite_psa_crypto_metadata': [
209 # Algorithms declared but not supported.
210 # https://github.com/Mbed-TLS/mbedtls/issues/9579
211 'Asymmetric signature: Ed25519ph',
212 'Asymmetric signature: Ed448ph',
213 'Asymmetric signature: pure EdDSA',
214 'Cipher: XTS',
215 'MAC: CBC_MAC-3DES',
216 'MAC: CBC_MAC-AES-128',
217 'MAC: CBC_MAC-AES-192',
218 'MAC: CBC_MAC-AES-256',
219 ],
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200220 'test_suite_psa_crypto_not_supported.generated': [
Gilles Peskineab5cc9b2024-09-17 17:57:11 +0200221 # It is a bug that not-supported test cases aren't getting
222 # run for never-implemented key types.
223 # https://github.com/Mbed-TLS/mbedtls/issues/7915
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200224 PSA_MECHANISM_NOT_IMPLEMENTED_SEARCH_RE,
Gilles Peskine5e3ed3f2024-10-11 12:00:44 +0200225 # We never test with DH key support disabled but support
Gilles Peskineab5cc9b2024-09-17 17:57:11 +0200226 # for a DH group enabled. The dependencies of these test
227 # cases don't really make sense.
228 # https://github.com/Mbed-TLS/mbedtls/issues/9574
229 re.compile(r'PSA \w+ DH_.*type not supported'),
230 # We only test partial support for DH with the 2048-bit group
231 # enabled and the other groups disabled.
232 # https://github.com/Mbed-TLS/mbedtls/issues/9575
233 'PSA generate DH_KEY_PAIR(RFC7919) 2048-bit group not supported',
234 'PSA import DH_KEY_PAIR(RFC7919) 2048-bit group not supported',
235 'PSA import DH_PUBLIC_KEY(RFC7919) 2048-bit group not supported',
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200236 ],
237 'test_suite_psa_crypto_op_fail.generated': [
Gilles Peskine5872c0d2024-09-17 17:15:29 +0200238 # Ignore mechanisms that are not implemented, except
239 # for test cases that assume the mechanism is not supported.
240 _has_word_re(_PSA_MECHANISMS_NOT_IMPLEMENTED,
241 exclude=(r'.*: !(?:' +
242 r'|'.join(_PSA_MECHANISMS_NOT_IMPLEMENTED) +
243 r')\b')),
Gilles Peskineab5cc9b2024-09-17 17:57:11 +0200244 # Incorrect dependency generation. To be fixed as part of the
245 # resolution of https://github.com/Mbed-TLS/mbedtls/issues/9167
246 # by forward-porting the commit
247 # "PSA test case generation: dependency inference class: operation fail"
248 # from https://github.com/Mbed-TLS/mbedtls/pull/9025 .
249 re.compile(r'.* with (?:DH|ECC)_(?:KEY_PAIR|PUBLIC_KEY)\(.*'),
Gilles Peskineab5cc9b2024-09-17 17:57:11 +0200250
251 # We never test with the HMAC algorithm enabled but the HMAC
252 # key type disabled. Those dependencies don't really make sense.
253 # https://github.com/Mbed-TLS/mbedtls/issues/9573
254 re.compile(r'.* !HMAC with HMAC'),
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200255 ],
256 'test_suite_psa_crypto_storage_format.current': [
257 PSA_MECHANISM_NOT_IMPLEMENTED_SEARCH_RE,
258 ],
259 'test_suite_psa_crypto_storage_format.v0': [
260 PSA_MECHANISM_NOT_IMPLEMENTED_SEARCH_RE,
261 ],
Gilles Peskinede2316b2024-09-17 18:32:05 +0200262 'tls13-misc': [
263 # Disabled due to OpenSSL bug.
264 # https://github.com/openssl/openssl/issues/10714
265 'TLS 1.3 O->m: resumption',
266 # Disabled due to OpenSSL command line limitation.
267 # https://github.com/Mbed-TLS/mbedtls/issues/9582
268 'TLS 1.3 m->O: resumption with early data',
269 ],
Gilles Peskine2a71fac2024-09-17 15:07:22 +0200270 }
271
Gilles Peskine82b16722024-09-16 19:57:10 +0200272
Gilles Peskine9df375b2024-09-16 20:14:26 +0200273# The names that we give to classes derived from DriverVSReference do not
274# follow the usual naming convention, because it's more readable to use
275# underscores and parts of the configuration names. Also, these classes
276# are just there to specify some data, so they don't need repetitive
277# documentation.
278#pylint: disable=invalid-name,missing-class-docstring
279
Gilles Peskine082eade2024-10-03 18:42:37 +0200280class DriverVSReference_hash(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200281 REFERENCE = 'test_psa_crypto_config_reference_hash_use_psa'
282 DRIVER = 'test_psa_crypto_config_accel_hash_use_psa'
283 IGNORED_SUITES = [
284 'shax', 'mdx', # the software implementations that are being excluded
285 'md.psa', # purposefully depends on whether drivers are present
286 'psa_crypto_low_hash.generated', # testing the builtins
287 ]
288 IGNORED_TESTS = {
289 'test_suite_config': [
290 re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'),
291 ],
292 'test_suite_platform': [
293 # Incompatible with sanitizers (e.g. ASan). If the driver
294 # component uses a sanitizer but the reference component
295 # doesn't, we have a PASS vs SKIP mismatch.
296 'Check mbedtls_calloc overallocation',
297 ],
298 }
299
Gilles Peskine082eade2024-10-03 18:42:37 +0200300class DriverVSReference_hmac(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200301 REFERENCE = 'test_psa_crypto_config_reference_hmac'
302 DRIVER = 'test_psa_crypto_config_accel_hmac'
303 IGNORED_SUITES = [
304 # These suites require legacy hash support, which is disabled
305 # in the accelerated component.
306 'shax', 'mdx',
307 # This suite tests builtins directly, but these are missing
308 # in the accelerated case.
309 'psa_crypto_low_hash.generated',
310 ]
311 IGNORED_TESTS = {
312 'test_suite_config': [
313 re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'),
314 re.compile(r'.*\bMBEDTLS_MD_C\b')
315 ],
316 'test_suite_md': [
317 # Builtin HMAC is not supported in the accelerate component.
318 re.compile('.*HMAC.*'),
319 # Following tests make use of functions which are not available
320 # when MD_C is disabled, as it happens in the accelerated
321 # test component.
322 re.compile('generic .* Hash file .*'),
323 'MD list',
324 ],
325 'test_suite_md.psa': [
326 # "legacy only" tests require hash algorithms to be NOT
327 # accelerated, but this of course false for the accelerated
328 # test component.
329 re.compile('PSA dispatch .* legacy only'),
330 ],
331 'test_suite_platform': [
332 # Incompatible with sanitizers (e.g. ASan). If the driver
333 # component uses a sanitizer but the reference component
334 # doesn't, we have a PASS vs SKIP mismatch.
335 'Check mbedtls_calloc overallocation',
336 ],
337 }
338
Gilles Peskine082eade2024-10-03 18:42:37 +0200339class DriverVSReference_cipher_aead_cmac(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200340 REFERENCE = 'test_psa_crypto_config_reference_cipher_aead_cmac'
341 DRIVER = 'test_psa_crypto_config_accel_cipher_aead_cmac'
342 # Modules replaced by drivers.
343 IGNORED_SUITES = [
344 # low-level (block/stream) cipher modules
345 'aes', 'aria', 'camellia', 'des', 'chacha20',
346 # AEAD modes and CMAC
347 'ccm', 'chachapoly', 'cmac', 'gcm',
348 # The Cipher abstraction layer
349 'cipher',
350 ]
351 IGNORED_TESTS = {
352 'test_suite_config': [
353 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA|CHACHA20|DES)_.*'),
354 re.compile(r'.*\bMBEDTLS_(CCM|CHACHAPOLY|CMAC|GCM)_.*'),
355 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
356 re.compile(r'.*\bMBEDTLS_CIPHER_.*'),
357 ],
358 # PEM decryption is not supported so far.
359 # The rest of PEM (write, unencrypted read) works though.
360 'test_suite_pem': [
361 re.compile(r'PEM read .*(AES|DES|\bencrypt).*'),
362 ],
363 'test_suite_platform': [
364 # Incompatible with sanitizers (e.g. ASan). If the driver
365 # component uses a sanitizer but the reference component
366 # doesn't, we have a PASS vs SKIP mismatch.
367 'Check mbedtls_calloc overallocation',
368 ],
369 # Following tests depend on AES_C/DES_C but are not about
370 # them really, just need to know some error code is there.
371 'test_suite_error': [
372 'Low and high error',
373 'Single low error'
374 ],
375 # Similar to test_suite_error above.
376 'test_suite_version': [
377 'Check for MBEDTLS_AES_C when already present',
378 ],
379 # The en/decryption part of PKCS#12 is not supported so far.
380 # The rest of PKCS#12 (key derivation) works though.
381 'test_suite_pkcs12': [
382 re.compile(r'PBE Encrypt, .*'),
383 re.compile(r'PBE Decrypt, .*'),
384 ],
385 # The en/decryption part of PKCS#5 is not supported so far.
386 # The rest of PKCS#5 (PBKDF2) works though.
387 'test_suite_pkcs5': [
388 re.compile(r'PBES2 Encrypt, .*'),
389 re.compile(r'PBES2 Decrypt .*'),
390 ],
391 # Encrypted keys are not supported so far.
392 # pylint: disable=line-too-long
393 'test_suite_pkparse': [
394 'Key ASN1 (Encrypted key PKCS12, trailing garbage data)',
395 'Key ASN1 (Encrypted key PKCS5, trailing garbage data)',
396 re.compile(r'Parse (RSA|EC) Key .*\(.* ([Ee]ncrypted|password).*\)'),
397 ],
398 # Encrypted keys are not supported so far.
399 'ssl-opt': [
400 'TLS: password protected server key',
401 'TLS: password protected client key',
402 'TLS: password protected server key, two certificates',
403 ],
404 }
405
Gilles Peskine082eade2024-10-03 18:42:37 +0200406class DriverVSReference_ecp_light_only(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200407 REFERENCE = 'test_psa_crypto_config_reference_ecc_ecp_light_only'
408 DRIVER = 'test_psa_crypto_config_accel_ecc_ecp_light_only'
409 IGNORED_SUITES = [
410 # Modules replaced by drivers
411 'ecdsa', 'ecdh', 'ecjpake',
412 ]
413 IGNORED_TESTS = {
414 'test_suite_config': [
415 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
416 ],
417 'test_suite_platform': [
418 # Incompatible with sanitizers (e.g. ASan). If the driver
419 # component uses a sanitizer but the reference component
420 # doesn't, we have a PASS vs SKIP mismatch.
421 'Check mbedtls_calloc overallocation',
422 ],
423 # This test wants a legacy function that takes f_rng, p_rng
424 # arguments, and uses legacy ECDSA for that. The test is
425 # really about the wrapper around the PSA RNG, not ECDSA.
426 'test_suite_random': [
427 'PSA classic wrapper: ECDSA signature (SECP256R1)',
428 ],
429 # In the accelerated test ECP_C is not set (only ECP_LIGHT is)
430 # so we must ignore disparities in the tests for which ECP_C
431 # is required.
432 'test_suite_ecp': [
433 re.compile(r'ECP check public-private .*'),
434 re.compile(r'ECP calculate public: .*'),
435 re.compile(r'ECP gen keypair .*'),
436 re.compile(r'ECP point muladd .*'),
437 re.compile(r'ECP point multiplication .*'),
438 re.compile(r'ECP test vectors .*'),
439 ],
440 'test_suite_ssl': [
441 # This deprecated function is only present when ECP_C is On.
442 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
443 ],
444 }
445
Gilles Peskine082eade2024-10-03 18:42:37 +0200446class DriverVSReference_no_ecp_at_all(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200447 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_ecp_at_all'
448 DRIVER = 'test_psa_crypto_config_accel_ecc_no_ecp_at_all'
449 IGNORED_SUITES = [
450 # Modules replaced by drivers
451 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
452 ]
453 IGNORED_TESTS = {
454 'test_suite_config': [
455 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
456 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
457 ],
458 'test_suite_platform': [
459 # Incompatible with sanitizers (e.g. ASan). If the driver
460 # component uses a sanitizer but the reference component
461 # doesn't, we have a PASS vs SKIP mismatch.
462 'Check mbedtls_calloc overallocation',
463 ],
464 # See ecp_light_only
465 'test_suite_random': [
466 'PSA classic wrapper: ECDSA signature (SECP256R1)',
467 ],
468 'test_suite_pkparse': [
469 # When PK_PARSE_C and ECP_C are defined then PK_PARSE_EC_COMPRESSED
470 # is automatically enabled in build_info.h (backward compatibility)
471 # even if it is disabled in config_psa_crypto_no_ecp_at_all(). As a
472 # consequence compressed points are supported in the reference
473 # component but not in the accelerated one, so they should be skipped
474 # while checking driver's coverage.
475 re.compile(r'Parse EC Key .*compressed\)'),
476 re.compile(r'Parse Public EC Key .*compressed\)'),
477 ],
478 # See ecp_light_only
479 'test_suite_ssl': [
480 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
481 ],
482 }
483
Gilles Peskine082eade2024-10-03 18:42:37 +0200484class DriverVSReference_ecc_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200485 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_bignum'
486 DRIVER = 'test_psa_crypto_config_accel_ecc_no_bignum'
487 IGNORED_SUITES = [
488 # Modules replaced by drivers
489 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
490 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
491 'bignum.generated', 'bignum.misc',
492 ]
493 IGNORED_TESTS = {
494 'test_suite_config': [
495 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
496 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
497 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
498 ],
499 'test_suite_platform': [
500 # Incompatible with sanitizers (e.g. ASan). If the driver
501 # component uses a sanitizer but the reference component
502 # doesn't, we have a PASS vs SKIP mismatch.
503 'Check mbedtls_calloc overallocation',
504 ],
505 # See ecp_light_only
506 'test_suite_random': [
507 'PSA classic wrapper: ECDSA signature (SECP256R1)',
508 ],
509 # See no_ecp_at_all
510 'test_suite_pkparse': [
511 re.compile(r'Parse EC Key .*compressed\)'),
512 re.compile(r'Parse Public EC Key .*compressed\)'),
513 ],
514 'test_suite_asn1parse': [
515 'INTEGER too large for mpi',
516 ],
517 'test_suite_asn1write': [
518 re.compile(r'ASN.1 Write mpi.*'),
519 ],
520 'test_suite_debug': [
521 re.compile(r'Debug print mbedtls_mpi.*'),
522 ],
523 # See ecp_light_only
524 'test_suite_ssl': [
525 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
526 ],
527 }
528
Gilles Peskine082eade2024-10-03 18:42:37 +0200529class DriverVSReference_ecc_ffdh_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200530 REFERENCE = 'test_psa_crypto_config_reference_ecc_ffdh_no_bignum'
531 DRIVER = 'test_psa_crypto_config_accel_ecc_ffdh_no_bignum'
532 IGNORED_SUITES = [
533 # Modules replaced by drivers
534 'ecp', 'ecdsa', 'ecdh', 'ecjpake', 'dhm',
535 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
536 'bignum.generated', 'bignum.misc',
537 ]
538 IGNORED_TESTS = {
539 'ssl-opt': [
540 # DHE support in TLS 1.2 requires built-in MBEDTLS_DHM_C
541 # (because it needs custom groups, which PSA does not
542 # provide), even with MBEDTLS_USE_PSA_CRYPTO.
543 re.compile(r'PSK callback:.*\bdhe-psk\b.*'),
544 ],
545 'test_suite_config': [
546 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
547 re.compile(r'.*\bMBEDTLS_DHM_C\b.*'),
548 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
549 re.compile(r'.*\bMBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED\b.*'),
550 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
551 ],
552 'test_suite_platform': [
553 # Incompatible with sanitizers (e.g. ASan). If the driver
554 # component uses a sanitizer but the reference component
555 # doesn't, we have a PASS vs SKIP mismatch.
556 'Check mbedtls_calloc overallocation',
557 ],
558 # See ecp_light_only
559 'test_suite_random': [
560 'PSA classic wrapper: ECDSA signature (SECP256R1)',
561 ],
562 # See no_ecp_at_all
563 'test_suite_pkparse': [
564 re.compile(r'Parse EC Key .*compressed\)'),
565 re.compile(r'Parse Public EC Key .*compressed\)'),
566 ],
567 'test_suite_asn1parse': [
568 'INTEGER too large for mpi',
569 ],
570 'test_suite_asn1write': [
571 re.compile(r'ASN.1 Write mpi.*'),
572 ],
573 'test_suite_debug': [
574 re.compile(r'Debug print mbedtls_mpi.*'),
575 ],
576 # See ecp_light_only
577 'test_suite_ssl': [
578 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
579 ],
580 }
581
Gilles Peskine082eade2024-10-03 18:42:37 +0200582class DriverVSReference_ffdh_alg(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200583 REFERENCE = 'test_psa_crypto_config_reference_ffdh'
584 DRIVER = 'test_psa_crypto_config_accel_ffdh'
585 IGNORED_SUITES = ['dhm']
586 IGNORED_TESTS = {
587 'test_suite_config': [
588 re.compile(r'.*\bMBEDTLS_DHM_C\b.*'),
589 ],
590 'test_suite_platform': [
591 # Incompatible with sanitizers (e.g. ASan). If the driver
592 # component uses a sanitizer but the reference component
593 # doesn't, we have a PASS vs SKIP mismatch.
594 'Check mbedtls_calloc overallocation',
595 ],
596 }
597
Gilles Peskine082eade2024-10-03 18:42:37 +0200598class DriverVSReference_tfm_config(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200599 REFERENCE = 'test_tfm_config_no_p256m'
600 DRIVER = 'test_tfm_config_p256m_driver_accel_ec'
601 IGNORED_SUITES = [
602 # Modules replaced by drivers
603 'asn1parse', 'asn1write',
604 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
605 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
606 'bignum.generated', 'bignum.misc',
607 ]
608 IGNORED_TESTS = {
609 'test_suite_config': [
610 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
611 re.compile(r'.*\bMBEDTLS_(ASN1\w+)_C\b.*'),
612 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECP)_.*'),
613 re.compile(r'.*\bMBEDTLS_PSA_P256M_DRIVER_ENABLED\b.*')
614 ],
615 'test_suite_config.crypto_combinations': [
616 'Config: ECC: Weierstrass curves only',
617 ],
618 'test_suite_platform': [
619 # Incompatible with sanitizers (e.g. ASan). If the driver
620 # component uses a sanitizer but the reference component
621 # doesn't, we have a PASS vs SKIP mismatch.
622 'Check mbedtls_calloc overallocation',
623 ],
624 # See ecp_light_only
625 'test_suite_random': [
626 'PSA classic wrapper: ECDSA signature (SECP256R1)',
627 ],
628 }
629
Gilles Peskine082eade2024-10-03 18:42:37 +0200630class DriverVSReference_rsa(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200631 REFERENCE = 'test_psa_crypto_config_reference_rsa_crypto'
632 DRIVER = 'test_psa_crypto_config_accel_rsa_crypto'
633 IGNORED_SUITES = [
634 # Modules replaced by drivers.
635 'rsa', 'pkcs1_v15', 'pkcs1_v21',
636 # We temporarily don't care about PK stuff.
637 'pk', 'pkwrite', 'pkparse'
638 ]
639 IGNORED_TESTS = {
640 'test_suite_config': [
641 re.compile(r'.*\bMBEDTLS_(PKCS1|RSA)_.*'),
642 re.compile(r'.*\bMBEDTLS_GENPRIME\b.*')
643 ],
644 'test_suite_platform': [
645 # Incompatible with sanitizers (e.g. ASan). If the driver
646 # component uses a sanitizer but the reference component
647 # doesn't, we have a PASS vs SKIP mismatch.
648 'Check mbedtls_calloc overallocation',
649 ],
650 # Following tests depend on RSA_C but are not about
651 # them really, just need to know some error code is there.
652 'test_suite_error': [
653 'Low and high error',
654 'Single high error'
655 ],
656 # Constant time operations only used for PKCS1_V15
657 'test_suite_constant_time': [
658 re.compile(r'mbedtls_ct_zeroize_if .*'),
659 re.compile(r'mbedtls_ct_memmove_left .*')
660 ],
661 'test_suite_psa_crypto': [
662 # We don't support generate_key_custom entry points
663 # in drivers yet.
664 re.compile(r'PSA generate key custom: RSA, e=.*'),
665 re.compile(r'PSA generate key ext: RSA, e=.*'),
666 ],
667 }
668
Gilles Peskine082eade2024-10-03 18:42:37 +0200669class DriverVSReference_block_cipher_dispatch(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200670 REFERENCE = 'test_full_block_cipher_legacy_dispatch'
671 DRIVER = 'test_full_block_cipher_psa_dispatch'
672 IGNORED_SUITES = [
673 # Skipped in the accelerated component
674 'aes', 'aria', 'camellia',
675 # These require AES_C, ARIA_C or CAMELLIA_C to be enabled in
676 # order for the cipher module (actually cipher_wrapper) to work
677 # properly. However these symbols are disabled in the accelerated
678 # component so we ignore them.
679 'cipher.ccm', 'cipher.gcm', 'cipher.aes', 'cipher.aria',
680 'cipher.camellia',
681 ]
682 IGNORED_TESTS = {
683 'test_suite_config': [
684 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA)_.*'),
685 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
686 ],
687 'test_suite_cmac': [
688 # Following tests require AES_C/ARIA_C/CAMELLIA_C to be enabled,
689 # but these are not available in the accelerated component.
690 'CMAC null arguments',
691 re.compile('CMAC.* (AES|ARIA|Camellia).*'),
692 ],
693 'test_suite_cipher.padding': [
694 # Following tests require AES_C/CAMELLIA_C to be enabled,
695 # but these are not available in the accelerated component.
696 re.compile('Set( non-existent)? padding with (AES|CAMELLIA).*'),
697 ],
698 'test_suite_pkcs5': [
699 # The AES part of PKCS#5 PBES2 is not yet supported.
700 # The rest of PKCS#5 (PBKDF2) works, though.
701 re.compile(r'PBES2 .* AES-.*')
702 ],
703 'test_suite_pkparse': [
704 # PEM (called by pkparse) requires AES_C in order to decrypt
705 # the key, but this is not available in the accelerated
706 # component.
707 re.compile('Parse RSA Key.*(password|AES-).*'),
708 ],
709 'test_suite_pem': [
710 # Following tests require AES_C, but this is diabled in the
711 # accelerated component.
712 re.compile('PEM read .*AES.*'),
713 'PEM read (unknown encryption algorithm)',
714 ],
715 'test_suite_error': [
716 # Following tests depend on AES_C but are not about them
717 # really, just need to know some error code is there.
718 'Single low error',
719 'Low and high error',
720 ],
721 'test_suite_version': [
722 # Similar to test_suite_error above.
723 'Check for MBEDTLS_AES_C when already present',
724 ],
725 'test_suite_platform': [
726 # Incompatible with sanitizers (e.g. ASan). If the driver
727 # component uses a sanitizer but the reference component
728 # doesn't, we have a PASS vs SKIP mismatch.
729 'Check mbedtls_calloc overallocation',
730 ],
731 }
732
733#pylint: enable=invalid-name,missing-class-docstring
734
735
Przemek Stekiel6856f4c2022-11-09 10:50:29 +0100736# List of tasks with a function that can handle this task and additional arguments if required
Valerio Settidfd7ca62023-10-09 16:30:11 +0200737KNOWN_TASKS = {
Gilles Peskinef646dbf2024-09-16 19:15:29 +0200738 'analyze_coverage': CoverageTask,
Gilles Peskine9df375b2024-09-16 20:14:26 +0200739 'analyze_driver_vs_reference_hash': DriverVSReference_hash,
740 'analyze_driver_vs_reference_hmac': DriverVSReference_hmac,
741 'analyze_driver_vs_reference_cipher_aead_cmac': DriverVSReference_cipher_aead_cmac,
742 'analyze_driver_vs_reference_ecp_light_only': DriverVSReference_ecp_light_only,
743 'analyze_driver_vs_reference_no_ecp_at_all': DriverVSReference_no_ecp_at_all,
744 'analyze_driver_vs_reference_ecc_no_bignum': DriverVSReference_ecc_no_bignum,
745 'analyze_driver_vs_reference_ecc_ffdh_no_bignum': DriverVSReference_ecc_ffdh_no_bignum,
746 'analyze_driver_vs_reference_ffdh_alg': DriverVSReference_ffdh_alg,
747 'analyze_driver_vs_reference_tfm_config': DriverVSReference_tfm_config,
748 'analyze_driver_vs_reference_rsa': DriverVSReference_rsa,
749 'analyze_block_cipher_dispatch': DriverVSReference_block_cipher_dispatch,
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200750}
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200751
Gilles Peskine15c2cbf2020-06-25 18:36:28 +0200752if __name__ == '__main__':
Gilles Peskine082eade2024-10-03 18:42:37 +0200753 outcome_analysis.main(KNOWN_TASKS)