Skip to content

Commit 1d3a0ca

Browse files
committed
hpke: add missing ForceZero for eae_prk, key_schedule_context, secret.
1 parent 36328e3 commit 1d3a0ca

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

wolfcrypt/src/hpke.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,12 +599,14 @@ static int wc_HpkeExtractAndExpand( Hpke* hpke, byte* dh, word32 dh_len,
599599
EAE_PRK_LABEL_STR_LEN, dh, dh_len, eae_prk);
600600

601601
/* expand */
602-
if ( ret == 0 )
602+
if ( ret == 0 ) {
603603
ret = wc_HpkeLabeledExpand(hpke, hpke->kem_suite_id,
604604
sizeof( hpke->kem_suite_id ), eae_prk, hpke->Nh,
605605
(byte*)SHARED_SECRET_LABEL_STR, SHARED_SECRET_LABEL_STR_LEN,
606606
kemContext, kem_context_length, hpke->Nsecret, sharedSecret);
607+
}
607608

609+
ForceZero(eae_prk, WC_MAX_DIGEST_SIZE);
608610
WC_FREE_VAR_EX(eae_prk, hpke->heap, DYNAMIC_TYPE_DIGEST);
609611

610612
return ret;
@@ -693,6 +695,8 @@ static int wc_HpkeKeyScheduleBase(Hpke* hpke, HpkeBaseContext* context,
693695
1 + 2 * hpke->Nh, hpke->Nh, context->exporter_secret);
694696
}
695697

698+
ForceZero(key_schedule_context, 1 + 2 * WC_MAX_DIGEST_SIZE);
699+
ForceZero(secret, WC_MAX_DIGEST_SIZE);
696700
WC_FREE_VAR_EX(key_schedule_context, hpke->heap,
697701
DYNAMIC_TYPE_TMP_BUFFER);
698702
WC_FREE_VAR_EX(secret, hpke->heap, DYNAMIC_TYPE_DIGEST);

0 commit comments

Comments
 (0)