mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-30 22:43:08 +03:00
pk_wrap: fix: always clear buffer holding private key in eckey_check_pair_psa
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
This commit is contained in:
@ -1240,17 +1240,18 @@ static int eckey_check_pair_psa(mbedtls_pk_context *pub, mbedtls_pk_context *prv
|
|||||||
ret = mbedtls_mpi_write_binary(&mbedtls_pk_ec_ro(*prv)->d,
|
ret = mbedtls_mpi_write_binary(&mbedtls_pk_ec_ro(*prv)->d,
|
||||||
prv_key_buf, curve_bytes);
|
prv_key_buf, curve_bytes);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
|
mbedtls_platform_zeroize(prv_key_buf, sizeof(prv_key_buf));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = psa_import_key(&key_attr, prv_key_buf, curve_bytes, &key_id);
|
status = psa_import_key(&key_attr, prv_key_buf, curve_bytes, &key_id);
|
||||||
|
mbedtls_platform_zeroize(prv_key_buf, sizeof(prv_key_buf));
|
||||||
ret = PSA_PK_TO_MBEDTLS_ERR(status);
|
ret = PSA_PK_TO_MBEDTLS_ERR(status);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
mbedtls_platform_zeroize(prv_key_buf, sizeof(prv_key_buf));
|
// From now on prv_key_buf is used to store the public key of prv.
|
||||||
|
|
||||||
status = psa_export_public_key(key_id, prv_key_buf, sizeof(prv_key_buf),
|
status = psa_export_public_key(key_id, prv_key_buf, sizeof(prv_key_buf),
|
||||||
&prv_key_len);
|
&prv_key_len);
|
||||||
ret = PSA_PK_TO_MBEDTLS_ERR(status);
|
ret = PSA_PK_TO_MBEDTLS_ERR(status);
|
||||||
|
Reference in New Issue
Block a user