Skip to content

Commit 3e819b7

Browse files
psa_key_agreement_ecdh: zeroize output on failure
If psa_key_agreement_ecdh fails, there may be output that leaks sensitive information in the output buffer. Zeroize it. If this is due to an underlying failure in the ECDH implementation, it is currently not an issue since both the traditional Mbed TLS/Crypto implementation and Everest only write to the output buffer once every intermediate step has succeeded, but zeroizing is more robust. If this is because the recently added key size check fails, a leak could be a serious issue.
1 parent 7cfcb3f commit 3e819b7

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

library/psa_crypto.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5343,6 +5343,8 @@ static psa_status_t psa_key_agreement_ecdh( const uint8_t *peer_key,
53435343
status = PSA_ERROR_CORRUPTION_DETECTED;
53445344

53455345
exit:
5346+
if( status != PSA_SUCCESS )
5347+
mbedtls_platform_zeroize( shared_secret, shared_secret_size );
53465348
mbedtls_ecdh_free( &ecdh );
53475349
mbedtls_ecp_keypair_free( their_key );
53485350
mbedtls_free( their_key );

0 commit comments

Comments
 (0)