mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 12:14:38 +02:00
check on hmac free and add else if case for check if key is 0's
This commit is contained in:
@@ -5829,9 +5829,9 @@ static int _HMAC_K(byte* K, word32 KSz, byte* V, word32 VSz,
|
|||||||
const byte* h1, word32 h1Sz, byte* x, word32 xSz, byte* oct,
|
const byte* h1, word32 h1Sz, byte* x, word32 xSz, byte* oct,
|
||||||
byte* out, enum wc_HashType hashType, void* heap) {
|
byte* out, enum wc_HashType hashType, void* heap) {
|
||||||
Hmac hmac;
|
Hmac hmac;
|
||||||
int ret;
|
int ret, init;
|
||||||
|
|
||||||
ret = wc_HmacInit(&hmac, heap, 0);
|
ret = init = wc_HmacInit(&hmac, heap, 0);
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
ret = wc_HmacSetKey(&hmac, hashType, K, KSz);
|
ret = wc_HmacSetKey(&hmac, hashType, K, KSz);
|
||||||
|
|
||||||
@@ -5850,7 +5850,9 @@ static int _HMAC_K(byte* K, word32 KSz, byte* V, word32 VSz,
|
|||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
ret = wc_HmacFinal(&hmac, out);
|
ret = wc_HmacFinal(&hmac, out);
|
||||||
|
|
||||||
|
if (init == 0)
|
||||||
wc_HmacFree(&hmac);
|
wc_HmacFree(&hmac);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6031,12 +6033,11 @@ int wc_ecc_gen_deterministic_k(const byte* hash, word32 hashSz,
|
|||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
if (mp_cmp(k, order) != MP_LT) {
|
if (mp_cmp(k, order) != MP_LT) {
|
||||||
err = MP_VAL;
|
err = MP_VAL;
|
||||||
}
|
} else if (mp_iszero(k) == MP_YES) {
|
||||||
|
|
||||||
/* no 0 key's */
|
/* no 0 key's */
|
||||||
if (mp_iszero(k) == MP_YES)
|
|
||||||
err = MP_ZERO_E;
|
err = MP_ZERO_E;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* 3.2 step h.3 if there was a problem with 'k' generated then try
|
/* 3.2 step h.3 if there was a problem with 'k' generated then try
|
||||||
* again K = HMAC_K(V || 0x00) and V = HMAC_K(V) */
|
* again K = HMAC_K(V || 0x00) and V = HMAC_K(V) */
|
||||||
|
Reference in New Issue
Block a user