Skip to content

Commit c684aa4

Browse files
committed
memset 0 the temp contexts
1 parent 99217df commit c684aa4

3 files changed

Lines changed: 9 additions & 0 deletions

File tree

src/internal.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12372,6 +12372,7 @@ static int BuildMD5(WOLFSSL* ssl, Hashes* hashes, const byte* sender)
1237212372
#else
1237312373
wc_Md5 md5[1];
1237412374
#endif
12375+
XMEMSET(md5, 0, sizeof(wc_Md5));
1237512376

1237612377
/* make md5 inner */
1237712378
ret = wc_Md5Copy(&ssl->hsHashes->hashMd5, md5);
@@ -12417,6 +12418,7 @@ static int BuildSHA(WOLFSSL* ssl, Hashes* hashes, const byte* sender)
1241712418
#else
1241812419
wc_Sha sha[1];
1241912420
#endif
12421+
XMEMSET(sha, 0, sizeof(wc_Sha));
1242012422
/* make sha inner */
1242112423
ret = wc_ShaCopy(&ssl->hsHashes->hashSha, sha); /* Save current position */
1242212424
if (ret == 0)
@@ -23926,6 +23928,7 @@ static int BuildMD5_CertVerify(const WOLFSSL* ssl, byte* digest)
2392623928
#else
2392723929
wc_Md5 md5[1];
2392823930
#endif
23931+
XMEMSET(md5, 0, sizeof(wc_Md5));
2392923932

2393023933
/* make md5 inner */
2393123934
ret = wc_Md5Copy(&ssl->hsHashes->hashMd5, md5); /* Save current position */
@@ -23969,6 +23972,7 @@ static int BuildSHA_CertVerify(const WOLFSSL* ssl, byte* digest)
2396923972
#else
2397023973
wc_Sha sha[1];
2397123974
#endif
23975+
XMEMSET(sha, 0, sizeof(wc_Sha));
2397223976

2397323977
/* make sha inner */
2397423978
ret = wc_ShaCopy(&ssl->hsHashes->hashSha, sha); /* Save current position */

src/tls13.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11982,6 +11982,8 @@ static int ExpectedResumptionSecret(WOLFSSL* ssl)
1198211982
Digest digest;
1198311983
static byte header[] = { 0x14, 0x00, 0x00, 0x00 };
1198411984

11985+
XMEMSET(&digest, 0, sizeof(Digest));
11986+
1198511987
/* Copy the running hash so we can restore it after. */
1198611988
switch (ssl->specs.mac_algorithm) {
1198711989
#ifndef NO_SHA256

wolfcrypt/src/evp.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5846,6 +5846,9 @@ void wolfSSL_EVP_init(void)
58465846
if (out->pctx == NULL)
58475847
return WOLFSSL_FAILURE;
58485848
}
5849+
/* Zero hash context after shallow copy to prevent shared sub-pointers
5850+
* with src. The hash Copy function will perform the proper deep copy. */
5851+
XMEMSET(&out->hash, 0, sizeof(out->hash));
58495852
return wolfSSL_EVP_MD_Copy_Hasher(out, (WOLFSSL_EVP_MD_CTX*)in);
58505853
}
58515854
#ifndef NO_AES

0 commit comments

Comments
 (0)