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