use MIN macro

This commit is contained in:
Karel Miko 2017-02-21 02:03:39 +01:00 committed by karel-m
parent ecbac7324e
commit bcf7753a26
2 changed files with 3 additions and 3 deletions

View File

@ -84,8 +84,8 @@ retry:
if (mp_iszero(r) == LTC_MP_YES) { goto retry; }
/* FIPS 186-4 4.6: use leftmost min(bitlen(q), bitlen(hash)) */
if (inlen > (unsigned long)(key->qord)) inlen = (unsigned long)(key->qord);
/* FIPS 186-4 4.6: use leftmost min(bitlen(q), bitlen(hash)) bits of 'hash'*/
inlen = MIN(inlen, (unsigned long)(key->qord));
/* now find s = (in + xr)/k mod q */
if ((err = mp_read_unsigned_bin(tmp, (unsigned char *)in, inlen)) != CRYPT_OK) { goto error; }

View File

@ -55,7 +55,7 @@ int dsa_verify_hash_raw( void *r, void *s,
}
/* FIPS 186-4 4.7: use leftmost min(bitlen(q), bitlen(hash)) bits of 'hash' */
if (hashlen > (unsigned long)(key->qord)) hashlen = (unsigned long)(key->qord);
hashlen = MIN(hashlen, (unsigned long)(key->qord));
/* w = 1/s mod q */
if ((err = mp_invmod(s, key->q, w)) != CRYPT_OK) { goto error; }