Skip to content

Commit 3386e40

Browse files
authored
Merge pull request #9890 from philljj/fix_f_hmac
hmac: add missing ForceZero for tmp, prk.
2 parents 3736352 + dd2c5a7 commit 3386e40

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

wolfcrypt/src/hmac.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,6 +1679,7 @@ int wolfSSL_GetHmacMaxSize(void)
16791679
n++;
16801680
}
16811681

1682+
ForceZero(tmp, WC_MAX_DIGEST_SIZE);
16821683
wc_HmacFree(myHmac);
16831684
WC_FREE_VAR_EX(myHmac, NULL, DYNAMIC_TYPE_HMAC);
16841685

@@ -1734,11 +1735,12 @@ int wolfSSL_GetHmacMaxSize(void)
17341735

17351736
ret = wc_HKDF_Extract_ex(type, salt, saltSz, inKey, inKeySz, prk, heap,
17361737
devId);
1737-
if (ret != 0)
1738-
return ret;
1739-
1740-
return wc_HKDF_Expand_ex(type, prk, hashSz, info, infoSz, out, outSz,
1741-
heap, devId);
1738+
if (ret == 0) {
1739+
ret = wc_HKDF_Expand_ex(type, prk, hashSz, info, infoSz,
1740+
out, outSz, heap, devId);
1741+
}
1742+
ForceZero(prk, WC_MAX_DIGEST_SIZE);
1743+
return ret;
17421744
}
17431745

17441746
int wc_HKDF(int type, const byte* inKey, word32 inKeySz, const byte* salt,

0 commit comments

Comments
 (0)