mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-04-03 11:06:14 +02:00
Add missing FFDH public key buffer length check
When exporting an FFDH public key we were not properly checking the length of the output buffer and would write the full length of the key in all cases. Fix this by checking the size of the output buffer before we write to it. Signed-off-by: David Horstmann <david.horstmann@arm.com>
This commit is contained in:
@@ -168,6 +168,10 @@ psa_status_t mbedtls_psa_ffdh_export_public_key(
|
||||
mbedtls_mpi_init(&X); mbedtls_mpi_init(&P);
|
||||
|
||||
size_t key_len = PSA_BITS_TO_BYTES(attributes->bits);
|
||||
if (key_len > data_size) {
|
||||
status = PSA_ERROR_BUFFER_TOO_SMALL;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
status = mbedtls_psa_ffdh_set_prime_generator(key_len, &P, &G);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user