Skip to content

Commit 60573a3

Browse files
committed
memset 0 the temp contexts
1 parent 4c9b980 commit 60573a3

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
@@ -12368,6 +12368,7 @@ static int BuildMD5(WOLFSSL* ssl, Hashes* hashes, const byte* sender)
1236812368
#else
1236912369
wc_Md5 md5[1];
1237012370
#endif
12371+
XMEMSET(md5, 0, sizeof(wc_Md5));
1237112372

1237212373
/* make md5 inner */
1237312374
ret = wc_Md5Copy(&ssl->hsHashes->hashMd5, md5);
@@ -12413,6 +12414,7 @@ static int BuildSHA(WOLFSSL* ssl, Hashes* hashes, const byte* sender)
1241312414
#else
1241412415
wc_Sha sha[1];
1241512416
#endif
12417+
XMEMSET(sha, 0, sizeof(wc_Sha));
1241612418
/* make sha inner */
1241712419
ret = wc_ShaCopy(&ssl->hsHashes->hashSha, sha); /* Save current position */
1241812420
if (ret == 0)
@@ -23919,6 +23921,7 @@ static int BuildMD5_CertVerify(const WOLFSSL* ssl, byte* digest)
2391923921
#else
2392023922
wc_Md5 md5[1];
2392123923
#endif
23924+
XMEMSET(md5, 0, sizeof(wc_Md5));
2392223925

2392323926
/* make md5 inner */
2392423927
ret = wc_Md5Copy(&ssl->hsHashes->hashMd5, md5); /* Save current position */
@@ -23962,6 +23965,7 @@ static int BuildSHA_CertVerify(const WOLFSSL* ssl, byte* digest)
2396223965
#else
2396323966
wc_Sha sha[1];
2396423967
#endif
23968+
XMEMSET(sha, 0, sizeof(wc_Sha));
2396523969

2396623970
/* make sha inner */
2396723971
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
@@ -11983,6 +11983,8 @@ static int ExpectedResumptionSecret(WOLFSSL* ssl)
1198311983
Digest digest;
1198411984
static byte header[] = { 0x14, 0x00, 0x00, 0x00 };
1198511985

11986+
XMEMSET(&digest, 0, sizeof(Digest));
11987+
1198611988
/* Copy the running hash so we can restore it after. */
1198711989
switch (ssl->specs.mac_algorithm) {
1198811990
#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)