Move check of the key type to mbedtls_psa_key_agreement_ffdh

Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
This commit is contained in:
Przemek Stekiel 2022-12-05 15:02:32 +01:00
parent 0dd746d998
commit a9ca13136c
2 changed files with 4 additions and 4 deletions

View File

@ -6594,10 +6594,6 @@ psa_status_t psa_key_agreement_raw_builtin(const psa_key_attributes_t *attribute
#if defined(MBEDTLS_PSA_BUILTIN_ALG_FFDH)
case PSA_ALG_FFDH:
if (!PSA_KEY_TYPE_IS_DH_KEY_PAIR(psa_get_key_type(attributes))) {
return PSA_ERROR_INVALID_ARGUMENT;
}
return mbedtls_psa_key_agreement_ffdh(attributes,
peer_key,
peer_key_length,

View File

@ -131,6 +131,10 @@ psa_status_t mbedtls_psa_key_agreement_ffdh(
return PSA_ERROR_INVALID_ARGUMENT;
}
if (!PSA_KEY_TYPE_IS_DH_KEY_PAIR(psa_get_key_type(attributes))) {
return PSA_ERROR_INVALID_ARGUMENT;
}
mbedtls_mpi_init(&P); mbedtls_mpi_init(&G);
mbedtls_mpi_init(&X); mbedtls_mpi_init(&GY);
mbedtls_mpi_init(&K);