Replace MBEDTLS_PSA_BUILTIN_PBKDF2_XXX with PSA_HAVE_SOFT_PBKDF2

Signed-off-by: Kusumit Ghoderao <Kusumit.Ghoderao@silabs.com>
This commit is contained in:
Kusumit Ghoderao 2023-07-27 21:09:26 +05:30
parent 105f772fe8
commit 2addf35855
2 changed files with 15 additions and 38 deletions

View file

@ -105,8 +105,7 @@ typedef struct psa_tls12_prf_key_derivation_s {
} psa_tls12_prf_key_derivation_t; } psa_tls12_prf_key_derivation_t;
#endif /* MBEDTLS_PSA_BUILTIN_ALG_TLS12_PRF) || #endif /* MBEDTLS_PSA_BUILTIN_ALG_TLS12_PRF) ||
* MBEDTLS_PSA_BUILTIN_ALG_TLS12_PSK_TO_MS */ * MBEDTLS_PSA_BUILTIN_ALG_TLS12_PSK_TO_MS */
#if defined(MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_HMAC) || \ #if defined(PSA_HAVE_SOFT_PBKDF2)
defined(MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_AES_CMAC_PRF_128)
typedef enum { typedef enum {
PSA_PBKDF2_STATE_INIT, /* no input provided */ PSA_PBKDF2_STATE_INIT, /* no input provided */
PSA_PBKDF2_STATE_INPUT_COST_SET, /* input cost has been set */ PSA_PBKDF2_STATE_INPUT_COST_SET, /* input cost has been set */
@ -126,7 +125,6 @@ typedef struct {
uint8_t MBEDTLS_PRIVATE(bytes_used); uint8_t MBEDTLS_PRIVATE(bytes_used);
uint32_t MBEDTLS_PRIVATE(block_number); uint32_t MBEDTLS_PRIVATE(block_number);
} psa_pbkdf2_key_derivation_t; } psa_pbkdf2_key_derivation_t;
#endif /* MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_HMAC || #endif /* PSA_HAVE_SOFT_PBKDF2 */
* MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_AES_CMAC_PRF_128 */
#endif /* PSA_CRYPTO_BUILTIN_KEY_DERIVATION_H */ #endif /* PSA_CRYPTO_BUILTIN_KEY_DERIVATION_H */

View file

@ -5080,8 +5080,7 @@ psa_status_t psa_aead_abort(psa_aead_operation_t *operation)
defined(MBEDTLS_PSA_BUILTIN_ALG_TLS12_PRF) || \ defined(MBEDTLS_PSA_BUILTIN_ALG_TLS12_PRF) || \
defined(MBEDTLS_PSA_BUILTIN_ALG_TLS12_PSK_TO_MS) || \ defined(MBEDTLS_PSA_BUILTIN_ALG_TLS12_PSK_TO_MS) || \
defined(MBEDTLS_PSA_BUILTIN_ALG_TLS12_ECJPAKE_TO_PMS) || \ defined(MBEDTLS_PSA_BUILTIN_ALG_TLS12_ECJPAKE_TO_PMS) || \
defined(MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_HMAC) || \ defined(PSA_HAVE_SOFT_PBKDF2)
defined(MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_AES_CMAC_PRF_128)
#define AT_LEAST_ONE_BUILTIN_KDF #define AT_LEAST_ONE_BUILTIN_KDF
#endif /* At least one builtin KDF */ #endif /* At least one builtin KDF */
@ -5185,10 +5184,7 @@ psa_status_t psa_key_derivation_abort(psa_key_derivation_operation_t *operation)
sizeof(operation->ctx.tls12_ecjpake_to_pms.data)); sizeof(operation->ctx.tls12_ecjpake_to_pms.data));
} else } else
#endif /* defined(MBEDTLS_PSA_BUILTIN_ALG_TLS12_ECJPAKE_TO_PMS) */ #endif /* defined(MBEDTLS_PSA_BUILTIN_ALG_TLS12_ECJPAKE_TO_PMS) */
#if defined(MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_HMAC) || \ #if defined(PSA_HAVE_SOFT_PBKDF2)
defined(MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_AES_CMAC_PRF_128)
if (PSA_ALG_IS_PBKDF2_HMAC(kdf_alg) ||
kdf_alg == PSA_ALG_PBKDF2_AES_CMAC_PRF_128) {
if (operation->ctx.pbkdf2.salt != NULL) { if (operation->ctx.pbkdf2.salt != NULL) {
mbedtls_platform_zeroize(operation->ctx.pbkdf2.salt, mbedtls_platform_zeroize(operation->ctx.pbkdf2.salt,
operation->ctx.pbkdf2.salt_length); operation->ctx.pbkdf2.salt_length);
@ -5197,8 +5193,7 @@ psa_status_t psa_key_derivation_abort(psa_key_derivation_operation_t *operation)
status = PSA_SUCCESS; status = PSA_SUCCESS;
} else } else
#endif /* defined(MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_HMAC) || #endif /* defined(PSA_HAVE_SOFT_PBKDF2) */
* defined(MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_AES_CMAC_PRF_128) */
{ {
status = PSA_ERROR_BAD_STATE; status = PSA_ERROR_BAD_STATE;
} }
@ -5525,8 +5520,7 @@ static psa_status_t psa_key_derivation_tls12_ecjpake_to_pms_read(
} }
#endif #endif
#if defined(MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_HMAC) || \ #if defined(PSA_HAVE_SOFT_PBKDF2)
defined(MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_AES_CMAC_PRF_128)
static psa_status_t psa_key_derivation_pbkdf2_generate_block( static psa_status_t psa_key_derivation_pbkdf2_generate_block(
psa_pbkdf2_key_derivation_t *pbkdf2, psa_pbkdf2_key_derivation_t *pbkdf2,
psa_algorithm_t prf_alg, psa_algorithm_t prf_alg,
@ -5662,8 +5656,7 @@ static psa_status_t psa_key_derivation_pbkdf2_read(
return PSA_SUCCESS; return PSA_SUCCESS;
} }
#endif /* MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_HMAC || #endif /* PSA_HAVE_SOFT_PBKDF2 */
* MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_AES_CMAC_PRF_128 */
psa_status_t psa_key_derivation_output_bytes( psa_status_t psa_key_derivation_output_bytes(
psa_key_derivation_operation_t *operation, psa_key_derivation_operation_t *operation,
@ -5718,15 +5711,11 @@ psa_status_t psa_key_derivation_output_bytes(
&operation->ctx.tls12_ecjpake_to_pms, output, output_length); &operation->ctx.tls12_ecjpake_to_pms, output, output_length);
} else } else
#endif /* MBEDTLS_PSA_BUILTIN_ALG_TLS12_ECJPAKE_TO_PMS */ #endif /* MBEDTLS_PSA_BUILTIN_ALG_TLS12_ECJPAKE_TO_PMS */
#if defined(MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_HMAC) || \ #if defined(PSA_HAVE_SOFT_PBKDF2)
defined(MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_AES_CMAC_PRF_128)
if (PSA_ALG_IS_PBKDF2_HMAC(kdf_alg) ||
kdf_alg == PSA_ALG_PBKDF2_AES_CMAC_PRF_128) {
status = psa_key_derivation_pbkdf2_read(&operation->ctx.pbkdf2, kdf_alg, status = psa_key_derivation_pbkdf2_read(&operation->ctx.pbkdf2, kdf_alg,
output, output_length); output, output_length);
} else } else
#endif /* MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_HMAC || #endif /* PSA_HAVE_SOFT_PBKDF2 */
* MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_AES_CMAC_PRF_128 */
{ {
(void) kdf_alg; (void) kdf_alg;
@ -6651,8 +6640,7 @@ static psa_status_t psa_tls12_ecjpake_to_pms_input(
} }
#endif /* MBEDTLS_PSA_BUILTIN_ALG_TLS12_ECJPAKE_TO_PMS */ #endif /* MBEDTLS_PSA_BUILTIN_ALG_TLS12_ECJPAKE_TO_PMS */
#if defined(MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_HMAC) || \ #if defined(PSA_HAVE_SOFT_PBKDF2)
defined(MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_AES_CMAC_PRF_128)
static psa_status_t psa_pbkdf2_set_input_cost( static psa_status_t psa_pbkdf2_set_input_cost(
psa_pbkdf2_key_derivation_t *pbkdf2, psa_pbkdf2_key_derivation_t *pbkdf2,
psa_key_derivation_step_t step, psa_key_derivation_step_t step,
@ -6802,8 +6790,7 @@ static psa_status_t psa_pbkdf2_input(psa_pbkdf2_key_derivation_t *pbkdf2,
return PSA_ERROR_INVALID_ARGUMENT; return PSA_ERROR_INVALID_ARGUMENT;
} }
} }
#endif /* MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_HMAC || #endif /* PSA_HAVE_SOFT_PBKDF2 */
* MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_AES_CMAC_PRF_128 */
/** Check whether the given key type is acceptable for the given /** Check whether the given key type is acceptable for the given
* input step of a key derivation. * input step of a key derivation.
@ -6900,15 +6887,11 @@ static psa_status_t psa_key_derivation_input_internal(
&operation->ctx.tls12_ecjpake_to_pms, step, data, data_length); &operation->ctx.tls12_ecjpake_to_pms, step, data, data_length);
} else } else
#endif /* MBEDTLS_PSA_BUILTIN_ALG_TLS12_ECJPAKE_TO_PMS */ #endif /* MBEDTLS_PSA_BUILTIN_ALG_TLS12_ECJPAKE_TO_PMS */
#if defined(MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_HMAC) || \ #if defined(PSA_HAVE_SOFT_PBKDF2)
defined(MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_AES_CMAC_PRF_128)
if (PSA_ALG_IS_PBKDF2_HMAC(kdf_alg) ||
kdf_alg == PSA_ALG_PBKDF2_AES_CMAC_PRF_128) {
status = psa_pbkdf2_input(&operation->ctx.pbkdf2, kdf_alg, status = psa_pbkdf2_input(&operation->ctx.pbkdf2, kdf_alg,
step, data, data_length); step, data, data_length);
} else } else
#endif /* MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_HMAC || #endif /* PSA_HAVE_SOFT_PBKDF2 */
* MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_AES_CMAC_PRF_128 */
{ {
/* This can't happen unless the operation object was not initialized */ /* This can't happen unless the operation object was not initialized */
(void) data; (void) data;
@ -6932,15 +6915,11 @@ static psa_status_t psa_key_derivation_input_integer_internal(
psa_status_t status; psa_status_t status;
psa_algorithm_t kdf_alg = psa_key_derivation_get_kdf_alg(operation); psa_algorithm_t kdf_alg = psa_key_derivation_get_kdf_alg(operation);
#if defined(MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_HMAC) || \ #if defined(PSA_HAVE_SOFT_PBKDF2)
defined(MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_AES_CMAC_PRF_128)
if (PSA_ALG_IS_PBKDF2_HMAC(kdf_alg) ||
kdf_alg == PSA_ALG_PBKDF2_AES_CMAC_PRF_128) {
status = psa_pbkdf2_set_input_cost( status = psa_pbkdf2_set_input_cost(
&operation->ctx.pbkdf2, step, value); &operation->ctx.pbkdf2, step, value);
} else } else
#endif /* MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_HMAC || #endif /* PSA_HAVE_SOFT_PBKDF2 */
* MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_AES_CMAC_PRF_128 */
{ {
(void) step; (void) step;
(void) value; (void) value;