@@ -796,6 +796,8 @@ static int wc_HpkeEncap(Hpke* hpke, void* ephemeralKey, void* receiverKey,
796796 hpke -> Npk * 2 , sharedSecret );
797797 }
798798
799+ ForceZero (dh , hpke -> Ndh );
800+ ForceZero (kemContext , hpke -> Npk * 2 );
799801 WC_FREE_VAR_EX (dh , hpke -> heap , DYNAMIC_TYPE_TMP_BUFFER );
800802 WC_FREE_VAR_EX (kemContext , hpke -> heap , DYNAMIC_TYPE_TMP_BUFFER );
801803
@@ -827,6 +829,7 @@ static int wc_HpkeSetupBaseSender(Hpke* hpke, HpkeBaseContext* context,
827829 infoSz );
828830 }
829831
832+ ForceZero (sharedSecret , hpke -> Nsecret );
830833 WC_FREE_VAR_EX (sharedSecret , hpke -> heap , DYNAMIC_TYPE_TMP_BUFFER );
831834
832835 return ret ;
@@ -914,6 +917,7 @@ int wc_HpkeSealBase(Hpke* hpke, void* ephemeralKey, void* receiverKey,
914917
915918 PRIVATE_KEY_LOCK ();
916919
920+ ForceZero (context , sizeof (HpkeBaseContext ));
917921 WC_FREE_VAR_EX (context , hpke -> heap , DYNAMIC_TYPE_TMP_BUFFER );
918922
919923 return ret ;
@@ -1032,6 +1036,7 @@ static int wc_HpkeDecap(Hpke* hpke, void* receiverKey, const byte* pubKey,
10321036 hpke -> Npk * 2 , sharedSecret );
10331037 }
10341038
1039+ ForceZero (dh , hpke -> Ndh );
10351040 WC_FREE_VAR_EX (dh , hpke -> heap , DYNAMIC_TYPE_TMP_BUFFER );
10361041 WC_FREE_VAR_EX (kemContext , hpke -> heap , DYNAMIC_TYPE_TMP_BUFFER );
10371042
@@ -1058,6 +1063,7 @@ static int wc_HpkeSetupBaseReceiver(Hpke* hpke, HpkeBaseContext* context,
10581063 infoSz );
10591064 }
10601065
1066+ ForceZero (sharedSecret , hpke -> Nsecret );
10611067 WC_FREE_VAR_EX (sharedSecret , hpke -> heap , DYNAMIC_TYPE_TMP_BUFFER );
10621068
10631069 return ret ;
@@ -1144,6 +1150,7 @@ int wc_HpkeOpenBase(Hpke* hpke, void* receiverKey, const byte* pubKey,
11441150
11451151 PRIVATE_KEY_LOCK ();
11461152
1153+ ForceZero (context , sizeof (HpkeBaseContext ));
11471154 WC_FREE_VAR_EX (context , hpke -> heap , DYNAMIC_TYPE_TMP_BUFFER );
11481155
11491156 return ret ;
0 commit comments