check return value of hash digest size

This commit is contained in:
Jacob Barthelmeh
2021-03-25 22:31:53 +07:00
parent 75abeebaf7
commit 4ead19e21f

View File

@ -6120,7 +6120,7 @@ static int sakke_hash_to_range(SakkeKey* key, enum wc_HashType hashType,
int err = 0;
byte h[WC_MAX_DIGEST_SIZE];
byte v[WC_MAX_DIGEST_SIZE];
word32 hashSz = wc_HashGetDigestSize(hashType);
word32 hashSz;
word32 i;
/* Step 1: A = hashfn( s ), where s = data | extra
@ -6128,7 +6128,12 @@ static int sakke_hash_to_range(SakkeKey* key, enum wc_HashType hashType,
*/
/* Step 2: h_0 = 00...00, a string of null bits of length hashlen bits */
XMEMSET(h, 0, hashSz);
err = wc_HashGetDigestSize(hashType);
if (err > 0) {
hashSz = (word32)err;
XMEMSET(h, 0, hashSz);
err = 0; /* reset err value after getting digest size */
}
/* Step 3: l = Ceiling(lg(n)/hashlen) */
/* Step 4: For each i in 1 to l, do */