blob: f6f7d87297ac8c3208ab999fbd8d7ad76f3674ab [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',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100412 # Unit tests for the built-in implementation
413 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200414 ]
415 IGNORED_TESTS = {
416 'test_suite_config': [
417 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
418 ],
419 'test_suite_platform': [
420 # Incompatible with sanitizers (e.g. ASan). If the driver
421 # component uses a sanitizer but the reference component
422 # doesn't, we have a PASS vs SKIP mismatch.
423 'Check mbedtls_calloc overallocation',
424 ],
425 # This test wants a legacy function that takes f_rng, p_rng
426 # arguments, and uses legacy ECDSA for that. The test is
427 # really about the wrapper around the PSA RNG, not ECDSA.
428 'test_suite_random': [
429 'PSA classic wrapper: ECDSA signature (SECP256R1)',
430 ],
431 # In the accelerated test ECP_C is not set (only ECP_LIGHT is)
432 # so we must ignore disparities in the tests for which ECP_C
433 # is required.
434 'test_suite_ecp': [
435 re.compile(r'ECP check public-private .*'),
436 re.compile(r'ECP calculate public: .*'),
437 re.compile(r'ECP gen keypair .*'),
438 re.compile(r'ECP point muladd .*'),
439 re.compile(r'ECP point multiplication .*'),
440 re.compile(r'ECP test vectors .*'),
441 ],
442 'test_suite_ssl': [
443 # This deprecated function is only present when ECP_C is On.
444 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
445 ],
446 }
447
Gilles Peskine082eade2024-10-03 18:42:37 +0200448class DriverVSReference_no_ecp_at_all(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200449 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_ecp_at_all'
450 DRIVER = 'test_psa_crypto_config_accel_ecc_no_ecp_at_all'
451 IGNORED_SUITES = [
452 # Modules replaced by drivers
453 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100454 # Unit tests for the built-in implementation
455 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200456 ]
457 IGNORED_TESTS = {
458 'test_suite_config': [
459 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
460 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\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 # See ecp_light_only
469 'test_suite_random': [
470 'PSA classic wrapper: ECDSA signature (SECP256R1)',
471 ],
472 'test_suite_pkparse': [
473 # When PK_PARSE_C and ECP_C are defined then PK_PARSE_EC_COMPRESSED
474 # is automatically enabled in build_info.h (backward compatibility)
475 # even if it is disabled in config_psa_crypto_no_ecp_at_all(). As a
476 # consequence compressed points are supported in the reference
477 # component but not in the accelerated one, so they should be skipped
478 # while checking driver's coverage.
479 re.compile(r'Parse EC Key .*compressed\)'),
480 re.compile(r'Parse Public EC Key .*compressed\)'),
481 ],
482 # See ecp_light_only
483 'test_suite_ssl': [
484 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
485 ],
486 }
487
Gilles Peskine082eade2024-10-03 18:42:37 +0200488class DriverVSReference_ecc_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200489 REFERENCE = 'test_psa_crypto_config_reference_ecc_no_bignum'
490 DRIVER = 'test_psa_crypto_config_accel_ecc_no_bignum'
491 IGNORED_SUITES = [
492 # Modules replaced by drivers
493 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
494 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
495 'bignum.generated', 'bignum.misc',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100496 # Unit tests for the built-in implementation
497 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200498 ]
499 IGNORED_TESTS = {
500 'test_suite_config': [
501 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
502 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
503 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
504 ],
505 'test_suite_platform': [
506 # Incompatible with sanitizers (e.g. ASan). If the driver
507 # component uses a sanitizer but the reference component
508 # doesn't, we have a PASS vs SKIP mismatch.
509 'Check mbedtls_calloc overallocation',
510 ],
511 # See ecp_light_only
512 'test_suite_random': [
513 'PSA classic wrapper: ECDSA signature (SECP256R1)',
514 ],
515 # See no_ecp_at_all
516 'test_suite_pkparse': [
517 re.compile(r'Parse EC Key .*compressed\)'),
518 re.compile(r'Parse Public EC Key .*compressed\)'),
519 ],
520 'test_suite_asn1parse': [
521 'INTEGER too large for mpi',
522 ],
523 'test_suite_asn1write': [
524 re.compile(r'ASN.1 Write mpi.*'),
525 ],
526 'test_suite_debug': [
527 re.compile(r'Debug print mbedtls_mpi.*'),
528 ],
529 # See ecp_light_only
530 'test_suite_ssl': [
531 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
532 ],
533 }
534
Gilles Peskine082eade2024-10-03 18:42:37 +0200535class DriverVSReference_ecc_ffdh_no_bignum(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200536 REFERENCE = 'test_psa_crypto_config_reference_ecc_ffdh_no_bignum'
537 DRIVER = 'test_psa_crypto_config_accel_ecc_ffdh_no_bignum'
538 IGNORED_SUITES = [
539 # Modules replaced by drivers
540 'ecp', 'ecdsa', 'ecdh', 'ecjpake', 'dhm',
541 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
542 'bignum.generated', 'bignum.misc',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100543 # Unit tests for the built-in implementation
544 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200545 ]
546 IGNORED_TESTS = {
547 'ssl-opt': [
548 # DHE support in TLS 1.2 requires built-in MBEDTLS_DHM_C
549 # (because it needs custom groups, which PSA does not
550 # provide), even with MBEDTLS_USE_PSA_CRYPTO.
551 re.compile(r'PSK callback:.*\bdhe-psk\b.*'),
552 ],
553 'test_suite_config': [
554 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
555 re.compile(r'.*\bMBEDTLS_DHM_C\b.*'),
556 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'),
557 re.compile(r'.*\bMBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED\b.*'),
558 re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'),
559 ],
560 'test_suite_platform': [
561 # Incompatible with sanitizers (e.g. ASan). If the driver
562 # component uses a sanitizer but the reference component
563 # doesn't, we have a PASS vs SKIP mismatch.
564 'Check mbedtls_calloc overallocation',
565 ],
566 # See ecp_light_only
567 'test_suite_random': [
568 'PSA classic wrapper: ECDSA signature (SECP256R1)',
569 ],
570 # See no_ecp_at_all
571 'test_suite_pkparse': [
572 re.compile(r'Parse EC Key .*compressed\)'),
573 re.compile(r'Parse Public EC Key .*compressed\)'),
574 ],
575 'test_suite_asn1parse': [
576 'INTEGER too large for mpi',
577 ],
578 'test_suite_asn1write': [
579 re.compile(r'ASN.1 Write mpi.*'),
580 ],
581 'test_suite_debug': [
582 re.compile(r'Debug print mbedtls_mpi.*'),
583 ],
584 # See ecp_light_only
585 'test_suite_ssl': [
586 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
587 ],
588 }
589
Gilles Peskine082eade2024-10-03 18:42:37 +0200590class DriverVSReference_ffdh_alg(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200591 REFERENCE = 'test_psa_crypto_config_reference_ffdh'
592 DRIVER = 'test_psa_crypto_config_accel_ffdh'
593 IGNORED_SUITES = ['dhm']
594 IGNORED_TESTS = {
595 'test_suite_config': [
596 re.compile(r'.*\bMBEDTLS_DHM_C\b.*'),
597 ],
598 'test_suite_platform': [
599 # Incompatible with sanitizers (e.g. ASan). If the driver
600 # component uses a sanitizer but the reference component
601 # doesn't, we have a PASS vs SKIP mismatch.
602 'Check mbedtls_calloc overallocation',
603 ],
604 }
605
Gilles Peskine082eade2024-10-03 18:42:37 +0200606class DriverVSReference_tfm_config(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200607 REFERENCE = 'test_tfm_config_no_p256m'
608 DRIVER = 'test_tfm_config_p256m_driver_accel_ec'
609 IGNORED_SUITES = [
610 # Modules replaced by drivers
611 'asn1parse', 'asn1write',
612 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
613 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
614 'bignum.generated', 'bignum.misc',
Gilles Peskine77587ce2024-10-29 20:55:11 +0100615 # Unit tests for the built-in implementation
616 'psa_crypto_ecp',
Gilles Peskine9df375b2024-09-16 20:14:26 +0200617 ]
618 IGNORED_TESTS = {
619 'test_suite_config': [
620 re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'),
621 re.compile(r'.*\bMBEDTLS_(ASN1\w+)_C\b.*'),
622 re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECP)_.*'),
623 re.compile(r'.*\bMBEDTLS_PSA_P256M_DRIVER_ENABLED\b.*')
624 ],
625 'test_suite_config.crypto_combinations': [
626 'Config: ECC: Weierstrass curves only',
627 ],
628 'test_suite_platform': [
629 # Incompatible with sanitizers (e.g. ASan). If the driver
630 # component uses a sanitizer but the reference component
631 # doesn't, we have a PASS vs SKIP mismatch.
632 'Check mbedtls_calloc overallocation',
633 ],
634 # See ecp_light_only
635 'test_suite_random': [
636 'PSA classic wrapper: ECDSA signature (SECP256R1)',
637 ],
638 }
639
Gilles Peskine082eade2024-10-03 18:42:37 +0200640class DriverVSReference_rsa(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200641 REFERENCE = 'test_psa_crypto_config_reference_rsa_crypto'
642 DRIVER = 'test_psa_crypto_config_accel_rsa_crypto'
643 IGNORED_SUITES = [
644 # Modules replaced by drivers.
645 'rsa', 'pkcs1_v15', 'pkcs1_v21',
646 # We temporarily don't care about PK stuff.
647 'pk', 'pkwrite', 'pkparse'
648 ]
649 IGNORED_TESTS = {
650 'test_suite_config': [
651 re.compile(r'.*\bMBEDTLS_(PKCS1|RSA)_.*'),
652 re.compile(r'.*\bMBEDTLS_GENPRIME\b.*')
653 ],
654 'test_suite_platform': [
655 # Incompatible with sanitizers (e.g. ASan). If the driver
656 # component uses a sanitizer but the reference component
657 # doesn't, we have a PASS vs SKIP mismatch.
658 'Check mbedtls_calloc overallocation',
659 ],
660 # Following tests depend on RSA_C but are not about
661 # them really, just need to know some error code is there.
662 'test_suite_error': [
663 'Low and high error',
664 'Single high error'
665 ],
666 # Constant time operations only used for PKCS1_V15
667 'test_suite_constant_time': [
668 re.compile(r'mbedtls_ct_zeroize_if .*'),
669 re.compile(r'mbedtls_ct_memmove_left .*')
670 ],
671 'test_suite_psa_crypto': [
672 # We don't support generate_key_custom entry points
673 # in drivers yet.
674 re.compile(r'PSA generate key custom: RSA, e=.*'),
675 re.compile(r'PSA generate key ext: RSA, e=.*'),
676 ],
677 }
678
Gilles Peskine082eade2024-10-03 18:42:37 +0200679class DriverVSReference_block_cipher_dispatch(outcome_analysis.DriverVSReference):
Gilles Peskine9df375b2024-09-16 20:14:26 +0200680 REFERENCE = 'test_full_block_cipher_legacy_dispatch'
681 DRIVER = 'test_full_block_cipher_psa_dispatch'
682 IGNORED_SUITES = [
683 # Skipped in the accelerated component
684 'aes', 'aria', 'camellia',
685 # These require AES_C, ARIA_C or CAMELLIA_C to be enabled in
686 # order for the cipher module (actually cipher_wrapper) to work
687 # properly. However these symbols are disabled in the accelerated
688 # component so we ignore them.
689 'cipher.ccm', 'cipher.gcm', 'cipher.aes', 'cipher.aria',
690 'cipher.camellia',
691 ]
692 IGNORED_TESTS = {
693 'test_suite_config': [
694 re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA)_.*'),
695 re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'),
696 ],
697 'test_suite_cmac': [
698 # Following tests require AES_C/ARIA_C/CAMELLIA_C to be enabled,
699 # but these are not available in the accelerated component.
700 'CMAC null arguments',
701 re.compile('CMAC.* (AES|ARIA|Camellia).*'),
702 ],
703 'test_suite_cipher.padding': [
704 # Following tests require AES_C/CAMELLIA_C to be enabled,
705 # but these are not available in the accelerated component.
706 re.compile('Set( non-existent)? padding with (AES|CAMELLIA).*'),
707 ],
708 'test_suite_pkcs5': [
709 # The AES part of PKCS#5 PBES2 is not yet supported.
710 # The rest of PKCS#5 (PBKDF2) works, though.
711 re.compile(r'PBES2 .* AES-.*')
712 ],
713 'test_suite_pkparse': [
714 # PEM (called by pkparse) requires AES_C in order to decrypt
715 # the key, but this is not available in the accelerated
716 # component.
717 re.compile('Parse RSA Key.*(password|AES-).*'),
718 ],
719 'test_suite_pem': [
720 # Following tests require AES_C, but this is diabled in the
721 # accelerated component.
722 re.compile('PEM read .*AES.*'),
723 'PEM read (unknown encryption algorithm)',
724 ],
725 'test_suite_error': [
726 # Following tests depend on AES_C but are not about them
727 # really, just need to know some error code is there.
728 'Single low error',
729 'Low and high error',
730 ],
731 'test_suite_version': [
732 # Similar to test_suite_error above.
733 'Check for MBEDTLS_AES_C when already present',
734 ],
735 'test_suite_platform': [
736 # Incompatible with sanitizers (e.g. ASan). If the driver
737 # component uses a sanitizer but the reference component
738 # doesn't, we have a PASS vs SKIP mismatch.
739 'Check mbedtls_calloc overallocation',
740 ],
741 }
742
743#pylint: enable=invalid-name,missing-class-docstring
744
745
Przemek Stekiel6856f4c2022-11-09 10:50:29 +0100746# List of tasks with a function that can handle this task and additional arguments if required
Valerio Settidfd7ca62023-10-09 16:30:11 +0200747KNOWN_TASKS = {
Gilles Peskinef646dbf2024-09-16 19:15:29 +0200748 'analyze_coverage': CoverageTask,
Gilles Peskine9df375b2024-09-16 20:14:26 +0200749 'analyze_driver_vs_reference_hash': DriverVSReference_hash,
750 'analyze_driver_vs_reference_hmac': DriverVSReference_hmac,
751 'analyze_driver_vs_reference_cipher_aead_cmac': DriverVSReference_cipher_aead_cmac,
752 'analyze_driver_vs_reference_ecp_light_only': DriverVSReference_ecp_light_only,
753 'analyze_driver_vs_reference_no_ecp_at_all': DriverVSReference_no_ecp_at_all,
754 'analyze_driver_vs_reference_ecc_no_bignum': DriverVSReference_ecc_no_bignum,
755 'analyze_driver_vs_reference_ecc_ffdh_no_bignum': DriverVSReference_ecc_ffdh_no_bignum,
756 'analyze_driver_vs_reference_ffdh_alg': DriverVSReference_ffdh_alg,
757 'analyze_driver_vs_reference_tfm_config': DriverVSReference_tfm_config,
758 'analyze_driver_vs_reference_rsa': DriverVSReference_rsa,
759 'analyze_block_cipher_dispatch': DriverVSReference_block_cipher_dispatch,
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200760}
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200761
Gilles Peskine15c2cbf2020-06-25 18:36:28 +0200762if __name__ == '__main__':
Gilles Peskine082eade2024-10-03 18:42:37 +0200763 outcome_analysis.main(KNOWN_TASKS)