Fix intermittent test failure

Ecp key data length should not be measured by mbedtls_mpi_size(), as
this does not count leading zeros, which are still part of the key. This
resulted intermittently in the code attempting to import a wrongly sized
key as the first byte was all zero.

Signed-off-by: Paul Elliott <[email protected]>
This commit is contained in:
Paul Elliott
2024-11-06 16:57:50 +00:00
committed by Waleed Elmelegy
parent 30437e6408
commit 7164dc52ce
@@ -634,7 +634,7 @@ psa_status_t mbedtls_psa_generate_key_complete(
operation->num_ops = 1;
*key_len = mbedtls_mpi_size(&operation->ecp.d);
*key_len = operation->ecp.d.n * sizeof(mbedtls_mpi_uint);
if (*key_len > key_output_size) {
return PSA_ERROR_BUFFER_TOO_SMALL;
}