mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-04 08:02:28 +03:00
Merge pull request #1273 from gowthamsk-arm/mem-alloc-cleanup-2.28
Backport 2.28: Fix: Memory allocation cleanup in internal crypto api functions
This commit is contained in:
@ -215,16 +215,14 @@ psa_status_t mbedtls_psa_rsa_export_public_key(
|
|||||||
|
|
||||||
status = mbedtls_psa_rsa_load_representation(
|
status = mbedtls_psa_rsa_load_representation(
|
||||||
attributes->core.type, key_buffer, key_buffer_size, &rsa);
|
attributes->core.type, key_buffer, key_buffer_size, &rsa);
|
||||||
if (status != PSA_SUCCESS) {
|
if (status == PSA_SUCCESS) {
|
||||||
return status;
|
status = mbedtls_psa_rsa_export_key(PSA_KEY_TYPE_RSA_PUBLIC_KEY,
|
||||||
|
rsa,
|
||||||
|
data,
|
||||||
|
data_size,
|
||||||
|
data_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
status = mbedtls_psa_rsa_export_key(PSA_KEY_TYPE_RSA_PUBLIC_KEY,
|
|
||||||
rsa,
|
|
||||||
data,
|
|
||||||
data_size,
|
|
||||||
data_length);
|
|
||||||
|
|
||||||
mbedtls_rsa_free(rsa);
|
mbedtls_rsa_free(rsa);
|
||||||
mbedtls_free(rsa);
|
mbedtls_free(rsa);
|
||||||
|
|
||||||
@ -286,6 +284,7 @@ psa_status_t mbedtls_psa_rsa_generate_key(
|
|||||||
(unsigned int) attributes->core.bits,
|
(unsigned int) attributes->core.bits,
|
||||||
exponent);
|
exponent);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
|
mbedtls_rsa_free(&rsa);
|
||||||
return mbedtls_to_psa_error(ret);
|
return mbedtls_to_psa_error(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -354,7 +353,7 @@ psa_status_t mbedtls_psa_rsa_sign_hash(
|
|||||||
key_buffer_size,
|
key_buffer_size,
|
||||||
&rsa);
|
&rsa);
|
||||||
if (status != PSA_SUCCESS) {
|
if (status != PSA_SUCCESS) {
|
||||||
return status;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = psa_rsa_decode_md_type(alg, hash_length, &md_alg);
|
status = psa_rsa_decode_md_type(alg, hash_length, &md_alg);
|
||||||
|
Reference in New Issue
Block a user