@@ -3248,10 +3248,16 @@ static int DoKexDhReply(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
32483248 ssh -> kSz = MAX_KEX_KEY_SZ ;
32493249 if (!ssh -> handshake -> useEcc ) {
32503250#ifndef WOLFSSH_NO_DH
3251+ #ifdef PRIVATE_KEY_UNLOCK
3252+ PRIVATE_KEY_UNLOCK ();
3253+ #endif
32513254 ret = wc_DhAgree (& ssh -> handshake -> privKey .dh ,
32523255 ssh -> k , & ssh -> kSz ,
32533256 ssh -> handshake -> x , ssh -> handshake -> xSz ,
32543257 f , fSz );
3258+ #ifdef PRIVATE_KEY_LOCK
3259+ PRIVATE_KEY_LOCK ();
3260+ #endif
32553261 ForceZero (ssh -> handshake -> x , ssh -> handshake -> xSz );
32563262 wc_FreeDhKey (& ssh -> handshake -> privKey .dh );
32573263 if (ret != 0 ) {
@@ -7262,9 +7268,16 @@ int SendKexDhReply(WOLFSSH* ssh)
72627268 if (ret == 0 )
72637269 ret = wc_DhGenerateKeyPair (privKey , ssh -> rng ,
72647270 y_ptr , & ySz , f_ptr , & fSz );
7265- if (ret == 0 )
7271+ if (ret == 0 ) {
7272+ #ifdef PRIVATE_KEY_UNLOCK
7273+ PRIVATE_KEY_UNLOCK ();
7274+ #endif
72667275 ret = wc_DhAgree (privKey , ssh -> k , & ssh -> kSz , y_ptr , ySz ,
72677276 ssh -> handshake -> e , ssh -> handshake -> eSz );
7277+ #ifdef PRIVATE_KEY_LOCK
7278+ PRIVATE_KEY_LOCK ();
7279+ #endif
7280+ }
72687281 ForceZero (y_ptr , ySz );
72697282 wc_FreeDhKey (privKey );
72707283 }
@@ -7952,8 +7965,15 @@ int SendKexDhInit(WOLFSSH* ssh)
79527965 ret = wc_ecc_make_key_ex (ssh -> rng ,
79537966 wc_ecc_get_curve_size_from_id (primeId ),
79547967 privKey , primeId );
7955- if (ret == 0 )
7968+ if (ret == 0 ) {
7969+ #ifdef PRIVATE_KEY_UNLOCK
7970+ PRIVATE_KEY_UNLOCK ();
7971+ #endif
79567972 ret = wc_ecc_export_x963 (privKey , e , & eSz );
7973+ #ifdef PRIVATE_KEY_LOCK
7974+ PRIVATE_KEY_LOCK ();
7975+ #endif
7976+ }
79577977#else
79587978 ret = WS_INVALID_ALGO_ID ;
79597979#endif /* !defined(WOLFSSH_NO_ECDH) */
0 commit comments