@@ -659,7 +659,7 @@ static void HandshakeInfoFree(HandshakeInfo* hs, void* heap)
659659 if (hs->kexHashId != WC_HASH_TYPE_NONE) {
660660 wc_HashFree(&hs->kexHash, (enum wc_HashType)hs->kexHashId);
661661 }
662- ForceZero (hs, sizeof(HandshakeInfo));
662+ WS_FORCEZERO (hs, sizeof(HandshakeInfo));
663663 WFREE(hs, heap, DYNTYPE_HS);
664664 }
665665}
@@ -1160,7 +1160,7 @@ void CtxResourceFree(WOLFSSH_CTX* ctx)
11601160
11611161 for (i = 0; i < ctx->privateKeyCount; i++) {
11621162 if (ctx->privateKey[i].key != NULL) {
1163- ForceZero (ctx->privateKey[i].key, ctx->privateKey[i].keySz);
1163+ WS_FORCEZERO (ctx->privateKey[i].key, ctx->privateKey[i].keySz);
11641164 WFREE(ctx->privateKey[i].key, ctx->heap, DYNTYPE_PRIVKEY);
11651165 ctx->privateKey[i].key = NULL;
11661166 ctx->privateKey[i].keySz = 0;
@@ -1554,10 +1554,10 @@ void SshResourceFree(WOLFSSH* ssh, void* heap)
15541554 ShrinkBuffer(&ssh->inputBuffer, 1);
15551555 ShrinkBuffer(&ssh->outputBuffer, 1);
15561556 ShrinkBuffer(&ssh->extDataBuffer, 1);
1557- ForceZero (ssh->k, ssh->kSz);
1557+ WS_FORCEZERO (ssh->k, ssh->kSz);
15581558 HandshakeInfoFree(ssh->handshake, heap);
1559- ForceZero (&ssh->keys, sizeof(Keys));
1560- ForceZero (&ssh->peerKeys, sizeof(Keys));
1559+ WS_FORCEZERO (&ssh->keys, sizeof(Keys));
1560+ WS_FORCEZERO (&ssh->peerKeys, sizeof(Keys));
15611561 if (ssh->rng) {
15621562 wc_FreeRng(ssh->rng);
15631563 WFREE(ssh->rng, heap, DYNTYPE_RNG);
@@ -1590,7 +1590,7 @@ void SshResourceFree(WOLFSSH* ssh, void* heap)
15901590 ssh->scpConfirmMsgSz = 0;
15911591 }
15921592 if (ssh->scpFileBuffer) {
1593- ForceZero (ssh->scpFileBuffer, ssh->scpFileBufferSz);
1593+ WS_FORCEZERO (ssh->scpFileBuffer, ssh->scpFileBufferSz);
15941594 WFREE(ssh->scpFileBuffer, heap, DYNTYPE_BUFFER);
15951595 ssh->scpFileBuffer = NULL;
15961596 ssh->scpFileBufferSz = 0;
@@ -2674,7 +2674,7 @@ static int UpdateHostCertificates(WOLFSSH_CTX* ctx,
26742674 * software key on the certificate slot and mark it TPM-backed. */
26752675 if (keyIsTpm) {
26762676 if (ctx->privateKey[certHint].key != NULL) {
2677- ForceZero (ctx->privateKey[certHint].key,
2677+ WS_FORCEZERO (ctx->privateKey[certHint].key,
26782678 ctx->privateKey[certHint].keySz);
26792679 WFREE(ctx->privateKey[certHint].key,
26802680 ctx->heap, DYNTYPE_PRIVKEY);
@@ -2698,7 +2698,7 @@ static int UpdateHostCertificates(WOLFSSH_CTX* ctx,
26982698 WMEMCPY(key, ctx->privateKey[keyHint].key, keySz);
26992699
27002700 if (ctx->privateKey[certHint].key != NULL) {
2701- ForceZero (ctx->privateKey[certHint].key,
2701+ WS_FORCEZERO (ctx->privateKey[certHint].key,
27022702 ctx->privateKey[certHint].keySz);
27032703 WFREE(ctx->privateKey[certHint].key,
27042704 ctx->heap, DYNTYPE_PRIVKEY);
@@ -2801,7 +2801,7 @@ static int SetHostPrivateKey(WOLFSSH_CTX* ctx,
28012801
28022802 if (pvtKey->publicKeyFmt == keyId) {
28032803 if (pvtKey->key != NULL) {
2804- ForceZero (pvtKey->key, pvtKey->keySz);
2804+ WS_FORCEZERO (pvtKey->key, pvtKey->keySz);
28052805 WFREE(pvtKey->key, ctx->heap, dynamicType);
28062806 }
28072807 }
@@ -2859,7 +2859,7 @@ int wolfSSH_SetHostTpmKey(WOLFSSH_CTX* ctx, byte keyId)
28592859 pvtKey->publicKeyFmt = keyId;
28602860 }
28612861 else if (pvtKey->key != NULL) {
2862- ForceZero (pvtKey->key, pvtKey->keySz);
2862+ WS_FORCEZERO (pvtKey->key, pvtKey->keySz);
28632863 WFREE(pvtKey->key, ctx->heap, DYNTYPE_PRIVKEY);
28642864 }
28652865
@@ -2874,7 +2874,7 @@ int wolfSSH_SetHostTpmKey(WOLFSSH_CTX* ctx, byte keyId)
28742874 for (certIdx = 0; certIdx < ctx->privateKeyCount; certIdx++) {
28752875 if (ctx->privateKey[certIdx].publicKeyFmt == certId) {
28762876 if (ctx->privateKey[certIdx].key != NULL) {
2877- ForceZero (ctx->privateKey[certIdx].key,
2877+ WS_FORCEZERO (ctx->privateKey[certIdx].key,
28782878 ctx->privateKey[certIdx].keySz);
28792879 WFREE(ctx->privateKey[certIdx].key, ctx->heap,
28802880 DYNTYPE_PRIVKEY);
@@ -2961,7 +2961,7 @@ int wolfSSH_ProcessBuffer(WOLFSSH_CTX* ctx,
29612961 if (type == BUFTYPE_PRIVKEY) {
29622962 /* wc_KeyPemToDer may have written partial key material;
29632963 * zeroize before free on the private-key path. */
2964- ForceZero (der, inSz);
2964+ WS_FORCEZERO (der, inSz);
29652965 }
29662966 WFREE(der, heap, dynamicType);
29672967 return WS_BAD_FILE_E;
@@ -2979,7 +2979,7 @@ int wolfSSH_ProcessBuffer(WOLFSSH_CTX* ctx,
29792979 ret = IdentifyAsn1Key(der, derSz, 1, ctx->heap, NULL);
29802980 if (ret < 0) {
29812981 if (der != NULL) {
2982- ForceZero (der, derSz);
2982+ WS_FORCEZERO (der, derSz);
29832983 WFREE(der, heap, dynamicType);
29842984 }
29852985 return ret;
@@ -3108,7 +3108,7 @@ int GenerateKey(byte hashId, byte keyId,
31083108 ret = wc_HashFinal(&hash, enmhashId, lastBlock);
31093109 if (ret == WS_SUCCESS)
31103110 WMEMCPY(key, lastBlock, remainder);
3111- ForceZero (lastBlock, sizeof(lastBlock));
3111+ WS_FORCEZERO (lastBlock, sizeof(lastBlock));
31123112 }
31133113 }
31143114 else {
@@ -3154,7 +3154,7 @@ int GenerateKey(byte hashId, byte keyId,
31543154 ret = wc_HashFinal(&hash, enmhashId, lastBlock);
31553155 if (ret == WS_SUCCESS)
31563156 WMEMCPY(key + runningKeySz, lastBlock, remainder);
3157- ForceZero (lastBlock, sizeof(lastBlock));
3157+ WS_FORCEZERO (lastBlock, sizeof(lastBlock));
31583158 }
31593159 }
31603160 }
@@ -6303,7 +6303,7 @@ static int KeyAgreeDh_client(WOLFSSH* ssh, byte hashId,
63036303 ret = WS_CRYPTO_FAILED;
63046304 }
63056305 }
6306- ForceZero (ssh->handshake->x, ssh->handshake->xSz);
6306+ WS_FORCEZERO (ssh->handshake->x, ssh->handshake->xSz);
63076307 wc_FreeDhKey(&ssh->handshake->privKey.dh);
63086308
63096309 WLOG(WS_LOG_DEBUG, "Leaving KeyAgreeDh_client(), ret = %d", ret);
@@ -6697,7 +6697,7 @@ static int KeyAgreeEcdhMlKem_client(WOLFSSH* ssh, byte hashId,
66976697 }
66986698
66996699 if (sharedSecretHash) {
6700- ForceZero (sharedSecretHash, sharedSecretHashSz);
6700+ WS_FORCEZERO (sharedSecretHash, sharedSecretHashSz);
67016701 WFREE(sharedSecretHash, ssh->ctx->heap, DYNTYPE_PRIVKEY);
67026702 }
67036703
@@ -8962,7 +8962,7 @@ static int DoUserAuthRequestMlDsa(WOLFSSH* ssh,
89628962 }
89638963
89648964 if (checkData != NULL) {
8965- ForceZero (checkData, checkDataSz);
8965+ WS_FORCEZERO (checkData, checkDataSz);
89668966 WFREE(checkData, ssh->ctx->heap, DYNTYPE_TEMP);
89678967 }
89688968
@@ -11523,7 +11523,7 @@ static int DoPacket(WOLFSSH* ssh, byte* bufferConsumed)
1152311523 in += AES_BLOCK_SIZE;
1152411524 sz -= AES_BLOCK_SIZE;
1152511525 }
11526- ForceZero (scratch, sizeof(scratch));
11526+ WS_FORCEZERO (scratch, sizeof(scratch));
1152711527
1152811528 return ret;
1152911529 }
@@ -13497,7 +13497,7 @@ static int KeyAgreeDh_server(WOLFSSH* ssh, byte hashId, byte* f, word32* fSz)
1349713497 ssh->handshake->e, ssh->handshake->eSz);
1349813498 PRIVATE_KEY_LOCK();
1349913499 }
13500- ForceZero (y_ptr, ySz);
13500+ WS_FORCEZERO (y_ptr, ySz);
1350113501 wc_FreeDhKey(privKey);
1350213502 }
1350313503 #ifdef WOLFSSH_SMALL_STACK
@@ -13965,7 +13965,7 @@ static int KeyAgreeEcdhMlKem_server(WOLFSSH* ssh, byte hashId,
1396513965 }
1396613966
1396713967 if (sharedSecretHash) {
13968- ForceZero (sharedSecretHash, sharedSecretHashSz);
13968+ WS_FORCEZERO (sharedSecretHash, sharedSecretHashSz);
1396913969 WFREE(sharedSecretHash, ssh->ctx->heap, DYNTYPE_PRIVKEY);
1397013970 }
1397113971
@@ -14852,7 +14852,7 @@ int SendKexDhReply(WOLFSSH* ssh)
1485214852
1485314853 WLOG(WS_LOG_DEBUG, "Leaving SendKexDhReply(), ret = %d", ret);
1485414854 if (sigKeyBlock_ptr) {
14855- ForceZero (sigKeyBlock_ptr, sizeof(struct wolfSSH_sigKeyBlockFull));
14855+ WS_FORCEZERO (sigKeyBlock_ptr, sizeof(struct wolfSSH_sigKeyBlockFull));
1485614856 WFREE(sigKeyBlock_ptr, heap, DYNTYPE_PRIVKEY);
1485714857 }
1485814858#ifdef WOLFSSH_SMALL_STACK
@@ -16247,7 +16247,7 @@ static int BuildUserAuthRequestRsa(WOLFSSH* ssh,
1624716247 *idx = begin;
1624816248
1624916249 if (checkData != NULL) {
16250- ForceZero (checkData, checkDataSz);
16250+ WS_FORCEZERO (checkData, checkDataSz);
1625116251 WFREE(checkData, ssh->ctx->heap, DYNTYPE_TEMP);
1625216252 }
1625316253
@@ -16427,7 +16427,7 @@ static int BuildUserAuthRequestRsaCert(WOLFSSH* ssh,
1642716427 *idx = begin;
1642816428
1642916429 if (checkData != NULL) {
16430- ForceZero (checkData, checkDataSz);
16430+ WS_FORCEZERO (checkData, checkDataSz);
1643116431 WFREE(checkData, ssh->ctx->heap, DYNTYPE_TEMP);
1643216432 }
1643316433
@@ -16694,7 +16694,7 @@ static int BuildUserAuthRequestEcc(WOLFSSH* ssh,
1669416694 *idx = begin;
1669516695
1669616696 if (checkData != NULL) {
16697- ForceZero (checkData, checkDataSz);
16697+ WS_FORCEZERO (checkData, checkDataSz);
1669816698 WFREE(checkData, ssh->ctx->heap, DYNTYPE_TEMP);
1669916699 }
1670016700
@@ -16954,7 +16954,7 @@ static int BuildUserAuthRequestEccCert(WOLFSSH* ssh,
1695416954 *idx = begin;
1695516955
1695616956 if (checkData != NULL) {
16957- ForceZero (checkData, checkDataSz);
16957+ WS_FORCEZERO (checkData, checkDataSz);
1695816958 WFREE(checkData, ssh->ctx->heap, DYNTYPE_TEMP);
1695916959 }
1696016960
@@ -17109,7 +17109,7 @@ static int BuildUserAuthRequestEd25519(WOLFSSH* ssh,
1710917109 *idx = begin;
1711017110
1711117111 if (checkData != NULL) {
17112- ForceZero (checkData, checkDataSz);
17112+ WS_FORCEZERO (checkData, checkDataSz);
1711317113 WFREE(checkData, keySig->heap, DYNTYPE_TEMP);
1711417114 }
1711517115
@@ -17356,7 +17356,7 @@ static int BuildUserAuthRequestMlDsa(WOLFSSH* ssh,
1735617356 *idx = begin;
1735717357
1735817358 if (checkData != NULL) {
17359- ForceZero (checkData, checkDataSz);
17359+ WS_FORCEZERO (checkData, checkDataSz);
1736017360 WFREE(checkData, keySig->heap, DYNTYPE_TEMP);
1736117361 }
1736217362
@@ -17769,7 +17769,7 @@ int SendUserAuthKeyboardResponse(WOLFSSH* ssh)
1776917769 if (ret != WS_WANT_WRITE && ret != WS_SUCCESS)
1777017770 PurgePacket(ssh);
1777117771
17772- ForceZero (&authData, sizeof(WS_UserAuthData));
17772+ WS_FORCEZERO (&authData, sizeof(WS_UserAuthData));
1777317773
1777417774 WLOG(WS_LOG_DEBUG, "Leaving SendUserAuthKeyboardResponse(), ret = %d", ret);
1777517775
@@ -17978,7 +17978,7 @@ int SendUserAuthRequest(WOLFSSH* ssh, byte authType, int addSig)
1797817978 if (ret != WS_WANT_WRITE && ret != WS_SUCCESS)
1797917979 PurgePacket(ssh);
1798017980
17981- ForceZero (&authData, sizeof(WS_UserAuthData));
17981+ WS_FORCEZERO (&authData, sizeof(WS_UserAuthData));
1798217982 WLOG(WS_LOG_DEBUG, "Leaving SendUserAuthRequest(), ret = %d", ret);
1798317983
1798417984 if (keySig_ptr)
0 commit comments