Make key derivation initialisation consistent

The macro initialiser might leave bytes in the union unspecified.
Zeroising it in setup makes sure that the behaviour is the same
independently of the initialisation method used.
This commit is contained in:
Janos Follath 2019-06-20 15:09:30 +01:00
parent ea29bfb148
commit 5fe19734d5

View file

@ -4740,6 +4740,10 @@ static psa_status_t psa_key_derivation_setup_kdf(
psa_key_derivation_operation_t *operation, psa_key_derivation_operation_t *operation,
psa_algorithm_t kdf_alg ) psa_algorithm_t kdf_alg )
{ {
/* Make sure that operation->ctx is properly zero-initialised. (Macro
* initialisers for this union leave some bytes unspecified.) */
memset( &operation->ctx, 0, sizeof( operation->ctx ) );
/* Make sure that kdf_alg is a supported key derivation algorithm. */ /* Make sure that kdf_alg is a supported key derivation algorithm. */
#if defined(MBEDTLS_MD_C) #if defined(MBEDTLS_MD_C)
if( PSA_ALG_IS_HKDF( kdf_alg ) || if( PSA_ALG_IS_HKDF( kdf_alg ) ||