1
0
mirror of https://github.com/ARMmbed/mbedtls.git synced 2025-06-24 14:20:59 +08:00

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 <gabor.mezei@arm.com>
This commit is contained in:
Gabor Mezei 2024-09-20 14:18:42 +02:00
parent 241b9012a0
commit 6f77baff68
No known key found for this signature in database
GPG Key ID: 6310BD29B0BFF98C

View File

@ -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.