From 0d16cb158b654287a8c0e204b6a44cfefe415c3a Mon Sep 17 00:00:00 2001 From: FLOC'H Tanguy Date: Wed, 7 May 2025 15:55:29 +0200 Subject: [PATCH] adjust_legacy_from_psa: Add XTS algorithm support Signed-off-by: FLOC'H Tanguy --- include/mbedtls/config_adjust_legacy_from_psa.h | 6 ++++++ include/psa/crypto_config.h | 1 + library/psa_crypto_cipher.c | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/include/mbedtls/config_adjust_legacy_from_psa.h b/include/mbedtls/config_adjust_legacy_from_psa.h index 48f1bab1ed..3b44736216 100644 --- a/include/mbedtls/config_adjust_legacy_from_psa.h +++ b/include/mbedtls/config_adjust_legacy_from_psa.h @@ -859,6 +859,12 @@ #endif #endif /* PSA_WANT_ALG_GCM */ +#if defined(PSA_WANT_ALG_XTS) +#if !defined(MBEDTLS_PSA_ACCEL_ALG_XTS) +#define MBEDTLS_PSA_BUILTIN_ALG_XTS 1 +#endif +#endif /* PSA_WANT_ALG_XTS */ + #if defined(PSA_WANT_ALG_CHACHA20_POLY1305) #if !defined(MBEDTLS_PSA_ACCEL_ALG_CHACHA20_POLY1305) #if defined(PSA_WANT_KEY_TYPE_CHACHA20) diff --git a/include/psa/crypto_config.h b/include/psa/crypto_config.h index e0a8d60606..208bbc6f83 100644 --- a/include/psa/crypto_config.h +++ b/include/psa/crypto_config.h @@ -79,6 +79,7 @@ #define PSA_WANT_ALG_TLS12_PRF 1 #define PSA_WANT_ALG_TLS12_PSK_TO_MS 1 #define PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS 1 +#define PSA_WANT_ALG_XTS 1 #define PSA_WANT_ECC_BRAINPOOL_P_R1_256 1 #define PSA_WANT_ECC_BRAINPOOL_P_R1_384 1 diff --git a/library/psa_crypto_cipher.c b/library/psa_crypto_cipher.c index efc5813ff0..6c78602647 100644 --- a/library/psa_crypto_cipher.c +++ b/library/psa_crypto_cipher.c @@ -174,6 +174,11 @@ psa_status_t mbedtls_cipher_values_from_psa( *mode = MBEDTLS_MODE_CBC; break; #endif +#if defined(MBEDTLS_PSA_BUILTIN_ALG_XTS) + case PSA_ALG_XTS: + *mode = MBEDTLS_MODE_XTS; + break; +#endif #if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM_STAR_NO_TAG) case PSA_ALG_CCM_STAR_NO_TAG: *mode = MBEDTLS_MODE_CCM_STAR_NO_TAG;