Skip to content

Commit 897ce55

Browse files
committed
zero HMAC-DRBG K and V in deterministic k
1 parent bdebcfc commit 897ce55

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

wolfcrypt/src/ecc.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7666,6 +7666,11 @@ int wc_ecc_gen_deterministic_k(const byte* hash, word32 hashSz,
76667666
/* 3.2 c. Set K = 0x00 0x00 ... */
76677667
XMEMSET(K, 0x00, KSz);
76687668

7669+
#ifdef WOLFSSL_CHECK_MEM_ZERO
7670+
wc_MemZero_Add("wc_ecc_gen_deterministic_k K", K, KSz);
7671+
wc_MemZero_Add("wc_ecc_gen_deterministic_k V", V, VSz);
7672+
#endif
7673+
76697674
if (ret == 0) {
76707675
ret = mp_init(z1); /* always init z1 and free z1 */
76717676
}
@@ -7808,6 +7813,8 @@ int wc_ecc_gen_deterministic_k(const byte* hash, word32 hashSz,
78087813
}
78097814

78107815
ForceZero(x, MAX_ECC_BYTES);
7816+
ForceZero(K, WC_MAX_DIGEST_SIZE);
7817+
ForceZero(V, WC_MAX_DIGEST_SIZE);
78117818
#ifdef WOLFSSL_SMALL_STACK
78127819
XFREE(z1, heap, DYNAMIC_TYPE_ECC_BUFFER);
78137820
XFREE(x, heap, DYNAMIC_TYPE_PRIVATE_KEY);
@@ -7816,6 +7823,8 @@ int wc_ecc_gen_deterministic_k(const byte* hash, word32 hashSz,
78167823
XFREE(h1, heap, DYNAMIC_TYPE_DIGEST);
78177824
#elif defined(WOLFSSL_CHECK_MEM_ZERO)
78187825
wc_MemZero_Check(x, MAX_ECC_BYTES);
7826+
wc_MemZero_Check(K, WC_MAX_DIGEST_SIZE);
7827+
wc_MemZero_Check(V, WC_MAX_DIGEST_SIZE);
78197828
#endif
78207829

78217830
return ret;

0 commit comments

Comments
 (0)