FFDH: improve sanity checks

- avoid grouping checks, for a better debugging experience (breakpoints)
- use a more logical order, checking the key type first

Signed-off-by: Manuel Pégourié-Gonnard <[email protected]>
This commit is contained in:
Manuel Pégourié-Gonnard
2026-03-05 12:56:45 +01:00
parent 5cce3c8a75
commit c173dfb035
+5 -2
View File
@@ -269,8 +269,11 @@ psa_status_t mbedtls_psa_ffdh_key_agreement(
mbedtls_mpi P, X, GY, K;
const size_t calculated_shared_secret_size = key_buffer_size;
if (peer_key_length != key_buffer_size ||
!PSA_KEY_TYPE_IS_DH_KEY_PAIR(psa_get_key_type(attributes))) {
if (!PSA_KEY_TYPE_IS_DH_KEY_PAIR(psa_get_key_type(attributes))) {
return PSA_ERROR_INVALID_ARGUMENT;
}
if (peer_key_length != key_buffer_size) {
return PSA_ERROR_INVALID_ARGUMENT;
}