mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
fix(mbedtls): correct inverted NULL check in esp_hmac_abort_opaque
esp_hmac_abort_opaque() had an inverted guard that called mbedtls_platform_zeroize() on the context only when the context pointer was NULL, dereferencing NULL and skipping cleanup of valid contexts. Effect: * Calling the abort path with a NULL pointer crashes (NULL write) instead of being a safe no-op. * The valid (non-NULL) HMAC opaque operation context is never zeroized on abort, leaving sensitive intermediate HMAC state and key handle references in operation memory until the buffer is overwritten or freed. Fix: invert the check so zeroization runs only when the context pointer is non-NULL.
This commit is contained in:
@@ -219,7 +219,7 @@ psa_status_t esp_hmac_import_key_opaque(
|
|||||||
|
|
||||||
psa_status_t esp_hmac_abort_opaque(esp_hmac_opaque_operation_t *esp_hmac_ctx)
|
psa_status_t esp_hmac_abort_opaque(esp_hmac_opaque_operation_t *esp_hmac_ctx)
|
||||||
{
|
{
|
||||||
if (!esp_hmac_ctx) {
|
if (esp_hmac_ctx != NULL) {
|
||||||
mbedtls_platform_zeroize(esp_hmac_ctx, sizeof(esp_hmac_opaque_operation_t));
|
mbedtls_platform_zeroize(esp_hmac_ctx, sizeof(esp_hmac_opaque_operation_t));
|
||||||
}
|
}
|
||||||
return PSA_SUCCESS;
|
return PSA_SUCCESS;
|
||||||
|
|||||||
Reference in New Issue
Block a user