Fill the the output buffer with zero data in case of failure

This commit is contained in:
mohammad1603 2018-04-30 17:23:47 +03:00 committed by itayzafrir
parent 6bbd8c75dc
commit 4f5eb7cb54

View file

@ -1528,6 +1528,7 @@ psa_status_t psa_aead_encrypt( psa_key_slot_t key,
if( ret != 0 )
{
mbedtls_gcm_free( &gcm );
mbedtls_zeroize( ciphertext, plaintext_length );
return( mbedtls_to_psa_error( ret ) );
}
@ -1554,6 +1555,7 @@ psa_status_t psa_aead_encrypt( psa_key_slot_t key,
if( ret != 0 )
{
mbedtls_ccm_free( &ccm );
mbedtls_zeroize( ciphertext, plaintext_length );
return( mbedtls_to_psa_error( ret ) );
}
@ -1622,6 +1624,7 @@ psa_status_t psa_aead_decrypt( psa_key_slot_t key,
if( ret != 0 )
{
mbedtls_gcm_free( &gcm );
mbedtls_zeroize( plaintext, ciphertext_length );
return( mbedtls_to_psa_error( ret ) );
}
@ -1649,14 +1652,14 @@ psa_status_t psa_aead_decrypt( psa_key_slot_t key,
if( ret != 0 )
{
mbedtls_ccm_free( &ccm );
mbedtls_zeroize( plaintext, ciphertext_length );
return( mbedtls_to_psa_error( ret ) );
}
mbedtls_ccm_free( &ccm );
}
memcpy( plaintext + ciphertext_length, tag, sizeof( tag ) );
*plaintext_length = ciphertext_length + sizeof( tag );
*plaintext_length = ciphertext_length;
return( PSA_SUCCESS );
}