Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | |
| 3 | """Analyze the test outcomes from a full CI run. |
| 4 | |
| 5 | This script can also run on outcomes from a partial run, but the results are |
| 6 | less likely to be useful. |
| 7 | """ |
| 8 | |
Przemek Stekiel | 85c54ea | 2022-11-17 11:50:23 +0100 | [diff] [blame] | 9 | import re |
Gilles Peskine | 2a71fac | 2024-09-17 15:07:22 +0200 | [diff] [blame] | 10 | import typing |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 11 | |
Gilles Peskine | 3146772 | 2024-10-03 18:52:58 +0200 | [diff] [blame] | 12 | import scripts_path # pylint: disable=unused-import |
| 13 | from mbedtls_framework import outcome_analysis |
Gilles Peskine | 8d3c70a | 2020-06-25 18:37:43 +0200 | [diff] [blame] | 14 | |
Pengyu Lv | c2e8f3a | 2023-11-28 17:22:04 +0800 | [diff] [blame] | 15 | |
Gilles Peskine | 082eade | 2024-10-03 18:42:37 +0200 | [diff] [blame] | 16 | class CoverageTask(outcome_analysis.CoverageTask): |
Gilles Peskine | 96db2cc | 2024-10-04 15:52:01 +0200 | [diff] [blame] | 17 | # We'll populate IGNORED_TESTS soon. In the meantime, lack of coverage |
| 18 | # is just a warning. |
| 19 | outcome_analysis.FULL_COVERAGE_BY_DEFAULT = False |
Gilles Peskine | 3f5022e | 2024-09-16 20:23:40 +0200 | [diff] [blame] | 20 | |
Gilles Peskine | 2a71fac | 2024-09-17 15:07:22 +0200 | [diff] [blame] | 21 | @staticmethod |
Gilles Peskine | 5872c0d | 2024-09-17 17:15:29 +0200 | [diff] [blame^] | 22 | def _has_word_re(words: typing.Iterable[str], |
| 23 | exclude: typing.Optional[str] = None) -> typing.Pattern: |
Gilles Peskine | 2a71fac | 2024-09-17 15:07:22 +0200 | [diff] [blame] | 24 | """Construct a regex that matches if any of the words appears. |
| 25 | |
| 26 | The occurrence must start and end at a word boundary. |
Gilles Peskine | 5872c0d | 2024-09-17 17:15:29 +0200 | [diff] [blame^] | 27 | |
| 28 | If exclude is specified, strings containing a match for that |
| 29 | regular expression will not match the returned pattern. |
Gilles Peskine | 2a71fac | 2024-09-17 15:07:22 +0200 | [diff] [blame] | 30 | """ |
Gilles Peskine | 5872c0d | 2024-09-17 17:15:29 +0200 | [diff] [blame^] | 31 | exclude_clause = r'' |
| 32 | if exclude: |
| 33 | exclude_clause = r'(?!.*' + exclude + ')' |
| 34 | return re.compile(exclude_clause + |
| 35 | r'.*\b(?:' + r'|'.join(words) + r')\b.*', |
| 36 | re.S) |
Gilles Peskine | 2a71fac | 2024-09-17 15:07:22 +0200 | [diff] [blame] | 37 | |
| 38 | # generate_psa_tests.py generates test cases involving cryptographic |
| 39 | # mechanisms (key types, families, algorithms) that are declared but |
| 40 | # not implemented. Until we improve the Python scripts, ignore those |
| 41 | # test cases in the analysis. |
| 42 | # https://github.com/Mbed-TLS/mbedtls/issues/9572 |
| 43 | _PSA_MECHANISMS_NOT_IMPLEMENTED = [ |
| 44 | r'CBC_MAC', |
| 45 | r'DETERMINISTIC_DSA', |
| 46 | r'DET_DSA', |
| 47 | r'DSA', |
| 48 | r'ECC_KEY_PAIR\(BRAINPOOL_P_R1\) (?:160|192|224|320)-bit', |
| 49 | r'ECC_KEY_PAIR\(SECP_K1\) 225-bit', |
| 50 | r'ECC_PAIR\(BP_R1\) (?:160|192|224|320)-bit', |
| 51 | r'ECC_PAIR\(SECP_K1\) 225-bit', |
| 52 | r'ECC_PUBLIC_KEY\(BRAINPOOL_P_R1\) (?:160|192|224|320)-bit', |
| 53 | r'ECC_PUBLIC_KEY\(SECP_K1\) 225-bit', |
| 54 | r'ECC_PUB\(BP_R1\) (?:160|192|224|320)-bit', |
| 55 | r'ECC_PUB\(SECP_K1\) 225-bit', |
| 56 | r'ED25519PH', |
| 57 | r'ED448PH', |
| 58 | r'PEPPER', |
| 59 | r'PURE_EDDSA', |
| 60 | r'SECP_R2', |
| 61 | r'SECT_K1', |
| 62 | r'SECT_R1', |
| 63 | r'SECT_R2', |
| 64 | r'SHAKE256_512', |
| 65 | r'SHA_512_224', |
| 66 | r'SHA_512_256', |
| 67 | r'TWISTED_EDWARDS', |
| 68 | r'XTS', |
| 69 | ] |
| 70 | PSA_MECHANISM_NOT_IMPLEMENTED_SEARCH_RE = \ |
| 71 | _has_word_re(_PSA_MECHANISMS_NOT_IMPLEMENTED) |
| 72 | |
| 73 | IGNORED_TESTS = { |
| 74 | 'test_suite_psa_crypto_generate_key.generated': [ |
Gilles Peskine | 5872c0d | 2024-09-17 17:15:29 +0200 | [diff] [blame^] | 75 | # Ignore mechanisms that are not implemented, except |
| 76 | # for public keys for which we always test that |
| 77 | # psa_generate_key() returns PSA_ERROR_INVALID_ARGUMENT |
| 78 | # regardless of whether the specific key type is supported. |
| 79 | _has_word_re((mech |
| 80 | for mech in _PSA_MECHANISMS_NOT_IMPLEMENTED |
| 81 | if not mech.startswith('ECC_PUB')), |
| 82 | exclude=r'ECC_PUB'), |
Gilles Peskine | 2a71fac | 2024-09-17 15:07:22 +0200 | [diff] [blame] | 83 | ], |
| 84 | 'test_suite_psa_crypto_not_supported.generated': [ |
| 85 | PSA_MECHANISM_NOT_IMPLEMENTED_SEARCH_RE, |
| 86 | ], |
| 87 | 'test_suite_psa_crypto_op_fail.generated': [ |
Gilles Peskine | 5872c0d | 2024-09-17 17:15:29 +0200 | [diff] [blame^] | 88 | # Ignore mechanisms that are not implemented, except |
| 89 | # for test cases that assume the mechanism is not supported. |
| 90 | _has_word_re(_PSA_MECHANISMS_NOT_IMPLEMENTED, |
| 91 | exclude=(r'.*: !(?:' + |
| 92 | r'|'.join(_PSA_MECHANISMS_NOT_IMPLEMENTED) + |
| 93 | r')\b')), |
Gilles Peskine | 2a71fac | 2024-09-17 15:07:22 +0200 | [diff] [blame] | 94 | ], |
| 95 | 'test_suite_psa_crypto_storage_format.current': [ |
| 96 | PSA_MECHANISM_NOT_IMPLEMENTED_SEARCH_RE, |
| 97 | ], |
| 98 | 'test_suite_psa_crypto_storage_format.v0': [ |
| 99 | PSA_MECHANISM_NOT_IMPLEMENTED_SEARCH_RE, |
| 100 | ], |
| 101 | } |
| 102 | |
Gilles Peskine | 82b1672 | 2024-09-16 19:57:10 +0200 | [diff] [blame] | 103 | |
Gilles Peskine | 9df375b | 2024-09-16 20:14:26 +0200 | [diff] [blame] | 104 | # The names that we give to classes derived from DriverVSReference do not |
| 105 | # follow the usual naming convention, because it's more readable to use |
| 106 | # underscores and parts of the configuration names. Also, these classes |
| 107 | # are just there to specify some data, so they don't need repetitive |
| 108 | # documentation. |
| 109 | #pylint: disable=invalid-name,missing-class-docstring |
| 110 | |
Gilles Peskine | 082eade | 2024-10-03 18:42:37 +0200 | [diff] [blame] | 111 | class DriverVSReference_hash(outcome_analysis.DriverVSReference): |
Gilles Peskine | 9df375b | 2024-09-16 20:14:26 +0200 | [diff] [blame] | 112 | REFERENCE = 'test_psa_crypto_config_reference_hash_use_psa' |
| 113 | DRIVER = 'test_psa_crypto_config_accel_hash_use_psa' |
| 114 | IGNORED_SUITES = [ |
| 115 | 'shax', 'mdx', # the software implementations that are being excluded |
| 116 | 'md.psa', # purposefully depends on whether drivers are present |
| 117 | 'psa_crypto_low_hash.generated', # testing the builtins |
| 118 | ] |
| 119 | IGNORED_TESTS = { |
| 120 | 'test_suite_config': [ |
| 121 | re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'), |
| 122 | ], |
| 123 | 'test_suite_platform': [ |
| 124 | # Incompatible with sanitizers (e.g. ASan). If the driver |
| 125 | # component uses a sanitizer but the reference component |
| 126 | # doesn't, we have a PASS vs SKIP mismatch. |
| 127 | 'Check mbedtls_calloc overallocation', |
| 128 | ], |
| 129 | } |
| 130 | |
Gilles Peskine | 082eade | 2024-10-03 18:42:37 +0200 | [diff] [blame] | 131 | class DriverVSReference_hmac(outcome_analysis.DriverVSReference): |
Gilles Peskine | 9df375b | 2024-09-16 20:14:26 +0200 | [diff] [blame] | 132 | REFERENCE = 'test_psa_crypto_config_reference_hmac' |
| 133 | DRIVER = 'test_psa_crypto_config_accel_hmac' |
| 134 | IGNORED_SUITES = [ |
| 135 | # These suites require legacy hash support, which is disabled |
| 136 | # in the accelerated component. |
| 137 | 'shax', 'mdx', |
| 138 | # This suite tests builtins directly, but these are missing |
| 139 | # in the accelerated case. |
| 140 | 'psa_crypto_low_hash.generated', |
| 141 | ] |
| 142 | IGNORED_TESTS = { |
| 143 | 'test_suite_config': [ |
| 144 | re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'), |
| 145 | re.compile(r'.*\bMBEDTLS_MD_C\b') |
| 146 | ], |
| 147 | 'test_suite_md': [ |
| 148 | # Builtin HMAC is not supported in the accelerate component. |
| 149 | re.compile('.*HMAC.*'), |
| 150 | # Following tests make use of functions which are not available |
| 151 | # when MD_C is disabled, as it happens in the accelerated |
| 152 | # test component. |
| 153 | re.compile('generic .* Hash file .*'), |
| 154 | 'MD list', |
| 155 | ], |
| 156 | 'test_suite_md.psa': [ |
| 157 | # "legacy only" tests require hash algorithms to be NOT |
| 158 | # accelerated, but this of course false for the accelerated |
| 159 | # test component. |
| 160 | re.compile('PSA dispatch .* legacy only'), |
| 161 | ], |
| 162 | 'test_suite_platform': [ |
| 163 | # Incompatible with sanitizers (e.g. ASan). If the driver |
| 164 | # component uses a sanitizer but the reference component |
| 165 | # doesn't, we have a PASS vs SKIP mismatch. |
| 166 | 'Check mbedtls_calloc overallocation', |
| 167 | ], |
| 168 | } |
| 169 | |
Gilles Peskine | 082eade | 2024-10-03 18:42:37 +0200 | [diff] [blame] | 170 | class DriverVSReference_cipher_aead_cmac(outcome_analysis.DriverVSReference): |
Gilles Peskine | 9df375b | 2024-09-16 20:14:26 +0200 | [diff] [blame] | 171 | REFERENCE = 'test_psa_crypto_config_reference_cipher_aead_cmac' |
| 172 | DRIVER = 'test_psa_crypto_config_accel_cipher_aead_cmac' |
| 173 | # Modules replaced by drivers. |
| 174 | IGNORED_SUITES = [ |
| 175 | # low-level (block/stream) cipher modules |
| 176 | 'aes', 'aria', 'camellia', 'des', 'chacha20', |
| 177 | # AEAD modes and CMAC |
| 178 | 'ccm', 'chachapoly', 'cmac', 'gcm', |
| 179 | # The Cipher abstraction layer |
| 180 | 'cipher', |
| 181 | ] |
| 182 | IGNORED_TESTS = { |
| 183 | 'test_suite_config': [ |
| 184 | re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA|CHACHA20|DES)_.*'), |
| 185 | re.compile(r'.*\bMBEDTLS_(CCM|CHACHAPOLY|CMAC|GCM)_.*'), |
| 186 | re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'), |
| 187 | re.compile(r'.*\bMBEDTLS_CIPHER_.*'), |
| 188 | ], |
| 189 | # PEM decryption is not supported so far. |
| 190 | # The rest of PEM (write, unencrypted read) works though. |
| 191 | 'test_suite_pem': [ |
| 192 | re.compile(r'PEM read .*(AES|DES|\bencrypt).*'), |
| 193 | ], |
| 194 | 'test_suite_platform': [ |
| 195 | # Incompatible with sanitizers (e.g. ASan). If the driver |
| 196 | # component uses a sanitizer but the reference component |
| 197 | # doesn't, we have a PASS vs SKIP mismatch. |
| 198 | 'Check mbedtls_calloc overallocation', |
| 199 | ], |
| 200 | # Following tests depend on AES_C/DES_C but are not about |
| 201 | # them really, just need to know some error code is there. |
| 202 | 'test_suite_error': [ |
| 203 | 'Low and high error', |
| 204 | 'Single low error' |
| 205 | ], |
| 206 | # Similar to test_suite_error above. |
| 207 | 'test_suite_version': [ |
| 208 | 'Check for MBEDTLS_AES_C when already present', |
| 209 | ], |
| 210 | # The en/decryption part of PKCS#12 is not supported so far. |
| 211 | # The rest of PKCS#12 (key derivation) works though. |
| 212 | 'test_suite_pkcs12': [ |
| 213 | re.compile(r'PBE Encrypt, .*'), |
| 214 | re.compile(r'PBE Decrypt, .*'), |
| 215 | ], |
| 216 | # The en/decryption part of PKCS#5 is not supported so far. |
| 217 | # The rest of PKCS#5 (PBKDF2) works though. |
| 218 | 'test_suite_pkcs5': [ |
| 219 | re.compile(r'PBES2 Encrypt, .*'), |
| 220 | re.compile(r'PBES2 Decrypt .*'), |
| 221 | ], |
| 222 | # Encrypted keys are not supported so far. |
| 223 | # pylint: disable=line-too-long |
| 224 | 'test_suite_pkparse': [ |
| 225 | 'Key ASN1 (Encrypted key PKCS12, trailing garbage data)', |
| 226 | 'Key ASN1 (Encrypted key PKCS5, trailing garbage data)', |
| 227 | re.compile(r'Parse (RSA|EC) Key .*\(.* ([Ee]ncrypted|password).*\)'), |
| 228 | ], |
| 229 | # Encrypted keys are not supported so far. |
| 230 | 'ssl-opt': [ |
| 231 | 'TLS: password protected server key', |
| 232 | 'TLS: password protected client key', |
| 233 | 'TLS: password protected server key, two certificates', |
| 234 | ], |
| 235 | } |
| 236 | |
Gilles Peskine | 082eade | 2024-10-03 18:42:37 +0200 | [diff] [blame] | 237 | class DriverVSReference_ecp_light_only(outcome_analysis.DriverVSReference): |
Gilles Peskine | 9df375b | 2024-09-16 20:14:26 +0200 | [diff] [blame] | 238 | REFERENCE = 'test_psa_crypto_config_reference_ecc_ecp_light_only' |
| 239 | DRIVER = 'test_psa_crypto_config_accel_ecc_ecp_light_only' |
| 240 | IGNORED_SUITES = [ |
| 241 | # Modules replaced by drivers |
| 242 | 'ecdsa', 'ecdh', 'ecjpake', |
| 243 | ] |
| 244 | IGNORED_TESTS = { |
| 245 | 'test_suite_config': [ |
| 246 | re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'), |
| 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 | # This test wants a legacy function that takes f_rng, p_rng |
| 255 | # arguments, and uses legacy ECDSA for that. The test is |
| 256 | # really about the wrapper around the PSA RNG, not ECDSA. |
| 257 | 'test_suite_random': [ |
| 258 | 'PSA classic wrapper: ECDSA signature (SECP256R1)', |
| 259 | ], |
| 260 | # In the accelerated test ECP_C is not set (only ECP_LIGHT is) |
| 261 | # so we must ignore disparities in the tests for which ECP_C |
| 262 | # is required. |
| 263 | 'test_suite_ecp': [ |
| 264 | re.compile(r'ECP check public-private .*'), |
| 265 | re.compile(r'ECP calculate public: .*'), |
| 266 | re.compile(r'ECP gen keypair .*'), |
| 267 | re.compile(r'ECP point muladd .*'), |
| 268 | re.compile(r'ECP point multiplication .*'), |
| 269 | re.compile(r'ECP test vectors .*'), |
| 270 | ], |
| 271 | 'test_suite_ssl': [ |
| 272 | # This deprecated function is only present when ECP_C is On. |
| 273 | 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()', |
| 274 | ], |
| 275 | } |
| 276 | |
Gilles Peskine | 082eade | 2024-10-03 18:42:37 +0200 | [diff] [blame] | 277 | class DriverVSReference_no_ecp_at_all(outcome_analysis.DriverVSReference): |
Gilles Peskine | 9df375b | 2024-09-16 20:14:26 +0200 | [diff] [blame] | 278 | REFERENCE = 'test_psa_crypto_config_reference_ecc_no_ecp_at_all' |
| 279 | DRIVER = 'test_psa_crypto_config_accel_ecc_no_ecp_at_all' |
| 280 | IGNORED_SUITES = [ |
| 281 | # Modules replaced by drivers |
| 282 | 'ecp', 'ecdsa', 'ecdh', 'ecjpake', |
| 283 | ] |
| 284 | IGNORED_TESTS = { |
| 285 | 'test_suite_config': [ |
| 286 | re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'), |
| 287 | re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'), |
| 288 | ], |
| 289 | 'test_suite_platform': [ |
| 290 | # Incompatible with sanitizers (e.g. ASan). If the driver |
| 291 | # component uses a sanitizer but the reference component |
| 292 | # doesn't, we have a PASS vs SKIP mismatch. |
| 293 | 'Check mbedtls_calloc overallocation', |
| 294 | ], |
| 295 | # See ecp_light_only |
| 296 | 'test_suite_random': [ |
| 297 | 'PSA classic wrapper: ECDSA signature (SECP256R1)', |
| 298 | ], |
| 299 | 'test_suite_pkparse': [ |
| 300 | # When PK_PARSE_C and ECP_C are defined then PK_PARSE_EC_COMPRESSED |
| 301 | # is automatically enabled in build_info.h (backward compatibility) |
| 302 | # even if it is disabled in config_psa_crypto_no_ecp_at_all(). As a |
| 303 | # consequence compressed points are supported in the reference |
| 304 | # component but not in the accelerated one, so they should be skipped |
| 305 | # while checking driver's coverage. |
| 306 | re.compile(r'Parse EC Key .*compressed\)'), |
| 307 | re.compile(r'Parse Public EC Key .*compressed\)'), |
| 308 | ], |
| 309 | # See ecp_light_only |
| 310 | 'test_suite_ssl': [ |
| 311 | 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()', |
| 312 | ], |
| 313 | } |
| 314 | |
Gilles Peskine | 082eade | 2024-10-03 18:42:37 +0200 | [diff] [blame] | 315 | class DriverVSReference_ecc_no_bignum(outcome_analysis.DriverVSReference): |
Gilles Peskine | 9df375b | 2024-09-16 20:14:26 +0200 | [diff] [blame] | 316 | REFERENCE = 'test_psa_crypto_config_reference_ecc_no_bignum' |
| 317 | DRIVER = 'test_psa_crypto_config_accel_ecc_no_bignum' |
| 318 | IGNORED_SUITES = [ |
| 319 | # Modules replaced by drivers |
| 320 | 'ecp', 'ecdsa', 'ecdh', 'ecjpake', |
| 321 | 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw', |
| 322 | 'bignum.generated', 'bignum.misc', |
| 323 | ] |
| 324 | IGNORED_TESTS = { |
| 325 | 'test_suite_config': [ |
| 326 | re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'), |
| 327 | re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'), |
| 328 | re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'), |
| 329 | ], |
| 330 | 'test_suite_platform': [ |
| 331 | # Incompatible with sanitizers (e.g. ASan). If the driver |
| 332 | # component uses a sanitizer but the reference component |
| 333 | # doesn't, we have a PASS vs SKIP mismatch. |
| 334 | 'Check mbedtls_calloc overallocation', |
| 335 | ], |
| 336 | # See ecp_light_only |
| 337 | 'test_suite_random': [ |
| 338 | 'PSA classic wrapper: ECDSA signature (SECP256R1)', |
| 339 | ], |
| 340 | # See no_ecp_at_all |
| 341 | 'test_suite_pkparse': [ |
| 342 | re.compile(r'Parse EC Key .*compressed\)'), |
| 343 | re.compile(r'Parse Public EC Key .*compressed\)'), |
| 344 | ], |
| 345 | 'test_suite_asn1parse': [ |
| 346 | 'INTEGER too large for mpi', |
| 347 | ], |
| 348 | 'test_suite_asn1write': [ |
| 349 | re.compile(r'ASN.1 Write mpi.*'), |
| 350 | ], |
| 351 | 'test_suite_debug': [ |
| 352 | re.compile(r'Debug print mbedtls_mpi.*'), |
| 353 | ], |
| 354 | # See ecp_light_only |
| 355 | 'test_suite_ssl': [ |
| 356 | 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()', |
| 357 | ], |
| 358 | } |
| 359 | |
Gilles Peskine | 082eade | 2024-10-03 18:42:37 +0200 | [diff] [blame] | 360 | class DriverVSReference_ecc_ffdh_no_bignum(outcome_analysis.DriverVSReference): |
Gilles Peskine | 9df375b | 2024-09-16 20:14:26 +0200 | [diff] [blame] | 361 | REFERENCE = 'test_psa_crypto_config_reference_ecc_ffdh_no_bignum' |
| 362 | DRIVER = 'test_psa_crypto_config_accel_ecc_ffdh_no_bignum' |
| 363 | IGNORED_SUITES = [ |
| 364 | # Modules replaced by drivers |
| 365 | 'ecp', 'ecdsa', 'ecdh', 'ecjpake', 'dhm', |
| 366 | 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw', |
| 367 | 'bignum.generated', 'bignum.misc', |
| 368 | ] |
| 369 | IGNORED_TESTS = { |
| 370 | 'ssl-opt': [ |
| 371 | # DHE support in TLS 1.2 requires built-in MBEDTLS_DHM_C |
| 372 | # (because it needs custom groups, which PSA does not |
| 373 | # provide), even with MBEDTLS_USE_PSA_CRYPTO. |
| 374 | re.compile(r'PSK callback:.*\bdhe-psk\b.*'), |
| 375 | ], |
| 376 | 'test_suite_config': [ |
| 377 | re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'), |
| 378 | re.compile(r'.*\bMBEDTLS_DHM_C\b.*'), |
| 379 | re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'), |
| 380 | re.compile(r'.*\bMBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED\b.*'), |
| 381 | re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'), |
| 382 | ], |
| 383 | 'test_suite_platform': [ |
| 384 | # Incompatible with sanitizers (e.g. ASan). If the driver |
| 385 | # component uses a sanitizer but the reference component |
| 386 | # doesn't, we have a PASS vs SKIP mismatch. |
| 387 | 'Check mbedtls_calloc overallocation', |
| 388 | ], |
| 389 | # See ecp_light_only |
| 390 | 'test_suite_random': [ |
| 391 | 'PSA classic wrapper: ECDSA signature (SECP256R1)', |
| 392 | ], |
| 393 | # See no_ecp_at_all |
| 394 | 'test_suite_pkparse': [ |
| 395 | re.compile(r'Parse EC Key .*compressed\)'), |
| 396 | re.compile(r'Parse Public EC Key .*compressed\)'), |
| 397 | ], |
| 398 | 'test_suite_asn1parse': [ |
| 399 | 'INTEGER too large for mpi', |
| 400 | ], |
| 401 | 'test_suite_asn1write': [ |
| 402 | re.compile(r'ASN.1 Write mpi.*'), |
| 403 | ], |
| 404 | 'test_suite_debug': [ |
| 405 | re.compile(r'Debug print mbedtls_mpi.*'), |
| 406 | ], |
| 407 | # See ecp_light_only |
| 408 | 'test_suite_ssl': [ |
| 409 | 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()', |
| 410 | ], |
| 411 | } |
| 412 | |
Gilles Peskine | 082eade | 2024-10-03 18:42:37 +0200 | [diff] [blame] | 413 | class DriverVSReference_ffdh_alg(outcome_analysis.DriverVSReference): |
Gilles Peskine | 9df375b | 2024-09-16 20:14:26 +0200 | [diff] [blame] | 414 | REFERENCE = 'test_psa_crypto_config_reference_ffdh' |
| 415 | DRIVER = 'test_psa_crypto_config_accel_ffdh' |
| 416 | IGNORED_SUITES = ['dhm'] |
| 417 | IGNORED_TESTS = { |
| 418 | 'test_suite_config': [ |
| 419 | re.compile(r'.*\bMBEDTLS_DHM_C\b.*'), |
| 420 | ], |
| 421 | 'test_suite_platform': [ |
| 422 | # Incompatible with sanitizers (e.g. ASan). If the driver |
| 423 | # component uses a sanitizer but the reference component |
| 424 | # doesn't, we have a PASS vs SKIP mismatch. |
| 425 | 'Check mbedtls_calloc overallocation', |
| 426 | ], |
| 427 | } |
| 428 | |
Gilles Peskine | 082eade | 2024-10-03 18:42:37 +0200 | [diff] [blame] | 429 | class DriverVSReference_tfm_config(outcome_analysis.DriverVSReference): |
Gilles Peskine | 9df375b | 2024-09-16 20:14:26 +0200 | [diff] [blame] | 430 | REFERENCE = 'test_tfm_config_no_p256m' |
| 431 | DRIVER = 'test_tfm_config_p256m_driver_accel_ec' |
| 432 | IGNORED_SUITES = [ |
| 433 | # Modules replaced by drivers |
| 434 | 'asn1parse', 'asn1write', |
| 435 | 'ecp', 'ecdsa', 'ecdh', 'ecjpake', |
| 436 | 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw', |
| 437 | 'bignum.generated', 'bignum.misc', |
| 438 | ] |
| 439 | IGNORED_TESTS = { |
| 440 | 'test_suite_config': [ |
| 441 | re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'), |
| 442 | re.compile(r'.*\bMBEDTLS_(ASN1\w+)_C\b.*'), |
| 443 | re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECP)_.*'), |
| 444 | re.compile(r'.*\bMBEDTLS_PSA_P256M_DRIVER_ENABLED\b.*') |
| 445 | ], |
| 446 | 'test_suite_config.crypto_combinations': [ |
| 447 | 'Config: ECC: Weierstrass curves only', |
| 448 | ], |
| 449 | 'test_suite_platform': [ |
| 450 | # Incompatible with sanitizers (e.g. ASan). If the driver |
| 451 | # component uses a sanitizer but the reference component |
| 452 | # doesn't, we have a PASS vs SKIP mismatch. |
| 453 | 'Check mbedtls_calloc overallocation', |
| 454 | ], |
| 455 | # See ecp_light_only |
| 456 | 'test_suite_random': [ |
| 457 | 'PSA classic wrapper: ECDSA signature (SECP256R1)', |
| 458 | ], |
| 459 | } |
| 460 | |
Gilles Peskine | 082eade | 2024-10-03 18:42:37 +0200 | [diff] [blame] | 461 | class DriverVSReference_rsa(outcome_analysis.DriverVSReference): |
Gilles Peskine | 9df375b | 2024-09-16 20:14:26 +0200 | [diff] [blame] | 462 | REFERENCE = 'test_psa_crypto_config_reference_rsa_crypto' |
| 463 | DRIVER = 'test_psa_crypto_config_accel_rsa_crypto' |
| 464 | IGNORED_SUITES = [ |
| 465 | # Modules replaced by drivers. |
| 466 | 'rsa', 'pkcs1_v15', 'pkcs1_v21', |
| 467 | # We temporarily don't care about PK stuff. |
| 468 | 'pk', 'pkwrite', 'pkparse' |
| 469 | ] |
| 470 | IGNORED_TESTS = { |
| 471 | 'test_suite_config': [ |
| 472 | re.compile(r'.*\bMBEDTLS_(PKCS1|RSA)_.*'), |
| 473 | re.compile(r'.*\bMBEDTLS_GENPRIME\b.*') |
| 474 | ], |
| 475 | 'test_suite_platform': [ |
| 476 | # Incompatible with sanitizers (e.g. ASan). If the driver |
| 477 | # component uses a sanitizer but the reference component |
| 478 | # doesn't, we have a PASS vs SKIP mismatch. |
| 479 | 'Check mbedtls_calloc overallocation', |
| 480 | ], |
| 481 | # Following tests depend on RSA_C but are not about |
| 482 | # them really, just need to know some error code is there. |
| 483 | 'test_suite_error': [ |
| 484 | 'Low and high error', |
| 485 | 'Single high error' |
| 486 | ], |
| 487 | # Constant time operations only used for PKCS1_V15 |
| 488 | 'test_suite_constant_time': [ |
| 489 | re.compile(r'mbedtls_ct_zeroize_if .*'), |
| 490 | re.compile(r'mbedtls_ct_memmove_left .*') |
| 491 | ], |
| 492 | 'test_suite_psa_crypto': [ |
| 493 | # We don't support generate_key_custom entry points |
| 494 | # in drivers yet. |
| 495 | re.compile(r'PSA generate key custom: RSA, e=.*'), |
| 496 | re.compile(r'PSA generate key ext: RSA, e=.*'), |
| 497 | ], |
| 498 | } |
| 499 | |
Gilles Peskine | 082eade | 2024-10-03 18:42:37 +0200 | [diff] [blame] | 500 | class DriverVSReference_block_cipher_dispatch(outcome_analysis.DriverVSReference): |
Gilles Peskine | 9df375b | 2024-09-16 20:14:26 +0200 | [diff] [blame] | 501 | REFERENCE = 'test_full_block_cipher_legacy_dispatch' |
| 502 | DRIVER = 'test_full_block_cipher_psa_dispatch' |
| 503 | IGNORED_SUITES = [ |
| 504 | # Skipped in the accelerated component |
| 505 | 'aes', 'aria', 'camellia', |
| 506 | # These require AES_C, ARIA_C or CAMELLIA_C to be enabled in |
| 507 | # order for the cipher module (actually cipher_wrapper) to work |
| 508 | # properly. However these symbols are disabled in the accelerated |
| 509 | # component so we ignore them. |
| 510 | 'cipher.ccm', 'cipher.gcm', 'cipher.aes', 'cipher.aria', |
| 511 | 'cipher.camellia', |
| 512 | ] |
| 513 | IGNORED_TESTS = { |
| 514 | 'test_suite_config': [ |
| 515 | re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA)_.*'), |
| 516 | re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'), |
| 517 | ], |
| 518 | 'test_suite_cmac': [ |
| 519 | # Following tests require AES_C/ARIA_C/CAMELLIA_C to be enabled, |
| 520 | # but these are not available in the accelerated component. |
| 521 | 'CMAC null arguments', |
| 522 | re.compile('CMAC.* (AES|ARIA|Camellia).*'), |
| 523 | ], |
| 524 | 'test_suite_cipher.padding': [ |
| 525 | # Following tests require AES_C/CAMELLIA_C to be enabled, |
| 526 | # but these are not available in the accelerated component. |
| 527 | re.compile('Set( non-existent)? padding with (AES|CAMELLIA).*'), |
| 528 | ], |
| 529 | 'test_suite_pkcs5': [ |
| 530 | # The AES part of PKCS#5 PBES2 is not yet supported. |
| 531 | # The rest of PKCS#5 (PBKDF2) works, though. |
| 532 | re.compile(r'PBES2 .* AES-.*') |
| 533 | ], |
| 534 | 'test_suite_pkparse': [ |
| 535 | # PEM (called by pkparse) requires AES_C in order to decrypt |
| 536 | # the key, but this is not available in the accelerated |
| 537 | # component. |
| 538 | re.compile('Parse RSA Key.*(password|AES-).*'), |
| 539 | ], |
| 540 | 'test_suite_pem': [ |
| 541 | # Following tests require AES_C, but this is diabled in the |
| 542 | # accelerated component. |
| 543 | re.compile('PEM read .*AES.*'), |
| 544 | 'PEM read (unknown encryption algorithm)', |
| 545 | ], |
| 546 | 'test_suite_error': [ |
| 547 | # Following tests depend on AES_C but are not about them |
| 548 | # really, just need to know some error code is there. |
| 549 | 'Single low error', |
| 550 | 'Low and high error', |
| 551 | ], |
| 552 | 'test_suite_version': [ |
| 553 | # Similar to test_suite_error above. |
| 554 | 'Check for MBEDTLS_AES_C when already present', |
| 555 | ], |
| 556 | 'test_suite_platform': [ |
| 557 | # Incompatible with sanitizers (e.g. ASan). If the driver |
| 558 | # component uses a sanitizer but the reference component |
| 559 | # doesn't, we have a PASS vs SKIP mismatch. |
| 560 | 'Check mbedtls_calloc overallocation', |
| 561 | ], |
| 562 | } |
| 563 | |
| 564 | #pylint: enable=invalid-name,missing-class-docstring |
| 565 | |
| 566 | |
Przemek Stekiel | 6856f4c | 2022-11-09 10:50:29 +0100 | [diff] [blame] | 567 | # List of tasks with a function that can handle this task and additional arguments if required |
Valerio Setti | dfd7ca6 | 2023-10-09 16:30:11 +0200 | [diff] [blame] | 568 | KNOWN_TASKS = { |
Gilles Peskine | f646dbf | 2024-09-16 19:15:29 +0200 | [diff] [blame] | 569 | 'analyze_coverage': CoverageTask, |
Gilles Peskine | 9df375b | 2024-09-16 20:14:26 +0200 | [diff] [blame] | 570 | 'analyze_driver_vs_reference_hash': DriverVSReference_hash, |
| 571 | 'analyze_driver_vs_reference_hmac': DriverVSReference_hmac, |
| 572 | 'analyze_driver_vs_reference_cipher_aead_cmac': DriverVSReference_cipher_aead_cmac, |
| 573 | 'analyze_driver_vs_reference_ecp_light_only': DriverVSReference_ecp_light_only, |
| 574 | 'analyze_driver_vs_reference_no_ecp_at_all': DriverVSReference_no_ecp_at_all, |
| 575 | 'analyze_driver_vs_reference_ecc_no_bignum': DriverVSReference_ecc_no_bignum, |
| 576 | 'analyze_driver_vs_reference_ecc_ffdh_no_bignum': DriverVSReference_ecc_ffdh_no_bignum, |
| 577 | 'analyze_driver_vs_reference_ffdh_alg': DriverVSReference_ffdh_alg, |
| 578 | 'analyze_driver_vs_reference_tfm_config': DriverVSReference_tfm_config, |
| 579 | 'analyze_driver_vs_reference_rsa': DriverVSReference_rsa, |
| 580 | 'analyze_block_cipher_dispatch': DriverVSReference_block_cipher_dispatch, |
Przemek Stekiel | 4d13c83 | 2022-10-26 16:11:26 +0200 | [diff] [blame] | 581 | } |
Przemek Stekiel | 4d13c83 | 2022-10-26 16:11:26 +0200 | [diff] [blame] | 582 | |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 583 | if __name__ == '__main__': |
Gilles Peskine | 082eade | 2024-10-03 18:42:37 +0200 | [diff] [blame] | 584 | outcome_analysis.main(KNOWN_TASKS) |