@@ -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,8 @@ static int wc_HpkeDecap(Hpke* hpke, void* receiverKey, const byte* pubKey,
10321036 hpke -> Npk * 2 , sharedSecret );
10331037 }
10341038
1039+ ForceZero (dh , hpke -> Ndh );
1040+ ForceZero (kemContext , hpke -> Npk * 2 );
10351041 WC_FREE_VAR_EX (dh , hpke -> heap , DYNAMIC_TYPE_TMP_BUFFER );
10361042 WC_FREE_VAR_EX (kemContext , hpke -> heap , DYNAMIC_TYPE_TMP_BUFFER );
10371043
@@ -1058,6 +1064,7 @@ static int wc_HpkeSetupBaseReceiver(Hpke* hpke, HpkeBaseContext* context,
10581064 infoSz );
10591065 }
10601066
1067+ ForceZero (sharedSecret , hpke -> Nsecret );
10611068 WC_FREE_VAR_EX (sharedSecret , hpke -> heap , DYNAMIC_TYPE_TMP_BUFFER );
10621069
10631070 return ret ;
@@ -1144,6 +1151,7 @@ int wc_HpkeOpenBase(Hpke* hpke, void* receiverKey, const byte* pubKey,
11441151
11451152 PRIVATE_KEY_LOCK ();
11461153
1154+ ForceZero (context , sizeof (HpkeBaseContext ));
11471155 WC_FREE_VAR_EX (context , hpke -> heap , DYNAMIC_TYPE_TMP_BUFFER );
11481156
11491157 return ret ;
0 commit comments