From 6f77baff685669bf6f21ffd90517e6e1fdd889d2 Mon Sep 17 00:00:00 2001 From: Gabor Mezei Date: Fri, 20 Sep 2024 14:18:42 +0200 Subject: [PATCH] Use PSA macros for the `chipher_chaining` domain Exclude the XTS mode because it is not implemented via the PSA API. Signed-off-by: Gabor Mezei --- tests/scripts/depends.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/tests/scripts/depends.py b/tests/scripts/depends.py index cc7aca9699..ceaac22774 100755 --- a/tests/scripts/depends.py +++ b/tests/scripts/depends.py @@ -260,11 +260,7 @@ REVERSE_DEPENDENCIES = { 'MBEDTLS_CMAC_C'], 'PSA_WANT_ALG_GCM': ['MBEDTLS_GCM_C'], - 'MBEDTLS_CIPHER_MODE_CBC': ['PSA_WANT_ALG_CBC_PKCS7', - 'PSA_WANT_ALG_CBC_NO_PADDING'], - 'MBEDTLS_CIPHER_MODE_CFB': ['PSA_WANT_ALG_CFB'], - 'MBEDTLS_CIPHER_MODE_CTR': ['PSA_WANT_ALG_CTR'], - 'MBEDTLS_CIPHER_MODE_OFB': ['PSA_WANT_ALG_OFB'], + 'PSA_WANT_ALG_CBC_NO_PADDING': ['PSA_WANT_ALG_CBC_PKCS7'], 'MBEDTLS_CIPHER_PADDING_PKCS7': ['MBEDTLS_PKCS5_C', 'MBEDTLS_PKCS12_C', @@ -504,14 +500,26 @@ class DomainData: for key_type, symbol in key_types.items() for alg in cipher_algs if key_type.can_do(alg)} - # Find block cipher chaining and padding mode enabling macros by name. - cipher_chaining_symbols = self.config_symbols_matching(r'MBEDTLS_CIPHER_MODE_\w+\Z') + + # Get block cipher chaining modes. Do not select ECB, it is always enabled. + cipher_modes_filter = re.compile(r'PSA_WANT_ALG_(?!ECB|STREAM|CCM)\w+\Z') + cipher_chaining_symbols = {symbol + for alg, symbol in algs.items() + if alg.can_do(crypto_knowledge.AlgorithmCategory.CIPHER) + if re.match(cipher_modes_filter, symbol)} + + # Find block padding mode enabling macros by name. cipher_padding_symbols = self.config_symbols_matching(r'MBEDTLS_CIPHER_PADDING_\w+\Z') + self.domains = { # Cipher key types 'cipher_id': ExclusiveDomain(cipher_key_types, build_and_test), + + # XTS is not supported via the PSA API. 'cipher_chaining': ExclusiveDomain(cipher_chaining_symbols, - build_and_test), + build_and_test, + exclude=r'PSA_WANT_ALG_XTS'), + 'cipher_padding': ExclusiveDomain(cipher_padding_symbols, build_and_test), # Elliptic curves. Run the test suites.