FFDH: reorder checks to satisfy picky test

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
This commit is contained in:
Manuel Pégourié-Gonnard
2026-02-10 12:08:23 +01:00
parent fb70b7f849
commit 7a4e2c67b4

View File

@@ -269,16 +269,16 @@ psa_status_t mbedtls_psa_ffdh_key_agreement(
mbedtls_mpi P, X, GY, K;
const size_t calculated_shared_secret_size = key_buffer_size;
/* This has been checked by the library, but keep a local check too. */
if (calculated_shared_secret_size > shared_secret_size) {
return PSA_ERROR_BUFFER_TOO_SMALL;
}
if (peer_key_length != key_buffer_size ||
!PSA_KEY_TYPE_IS_DH_KEY_PAIR(psa_get_key_type(attributes))) {
return PSA_ERROR_INVALID_ARGUMENT;
}
/* This has been checked by the library, but keep a local check too. */
if (calculated_shared_secret_size > shared_secret_size) {
return PSA_ERROR_BUFFER_TOO_SMALL;
}
mbedtls_mpi_init(&P);
mbedtls_mpi_init(&X); mbedtls_mpi_init(&GY);
mbedtls_mpi_init(&K);