Skip to content

Commit 766c3b5

Browse files
committed
Comments and further relaxing of some other hmac restrictions
1 parent 49e9c06 commit 766c3b5

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

wolfcrypt/src/hmac.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,12 @@ int wolfSSL_GetHmacMaxSize(void)
12751275

12761276
ret = wc_HmacInit(myHmac, heap, devId);
12771277
if (ret == 0) {
1278+
#if FIPS_VERSION3_GE(6,0,0)
1279+
ret = wc_HmacSetKey_ex(myHmac, type, localSalt, saltSz,
1280+
FIPS_ALLOW_SHORT);
1281+
#else
12781282
ret = wc_HmacSetKey(myHmac, type, localSalt, saltSz);
1283+
#endif
12791284
if (ret == 0)
12801285
ret = wc_HmacUpdate(myHmac, inKey, inKeySz);
12811286
if (ret == 0)
@@ -1356,7 +1361,12 @@ int wolfSSL_GetHmacMaxSize(void)
13561361
word32 tmpSz = (n == 1) ? 0 : hashSz;
13571362
word32 left = outSz - outIdx;
13581363

1364+
#if FIPS_VERSION3_GE(6,0,0)
1365+
ret = wc_HmacSetKey_ex(myHmac, type, inKey, inKeySz,
1366+
FIPS_ALLOW_SHORT);
1367+
#else
13591368
ret = wc_HmacSetKey(myHmac, type, inKey, inKeySz);
1369+
#endif
13601370
if (ret != 0)
13611371
break;
13621372
ret = wc_HmacUpdate(myHmac, tmp, tmpSz);

wolfcrypt/src/rsa.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4510,22 +4510,24 @@ static int _CheckProbablePrime(mp_int* p, mp_int* q, mp_int* e, int nlen,
45104510

45114511
if (q != NULL) {
45124512
int valid = 0;
4513-
/* 5.4 - check that |p-q| <= (2^(1/2))(2^((nlen/2)-1)) */
4513+
/* 5.4 (186-4) 5.5 (186-5) -
4514+
* check that |p-q| <= (2^(1/2))(2^((nlen/2)-1)) */
45144515
ret = wc_CompareDiffPQ(p, q, nlen, &valid);
45154516
if ((ret != MP_OKAY) || (!valid)) goto notOkay;
45164517
prime = q;
45174518
}
45184519
else
45194520
prime = p;
45204521

4521-
/* 4.4,5.5 - Check that prime >= (2^(1/2))(2^((nlen/2)-1))
4522+
/* 4.4,5.5 (186-4) 4.4,5.4 (186-5) -
4523+
* Check that prime >= (2^(1/2))(2^((nlen/2)-1))
45224524
* This is a comparison against lowerBound */
45234525
ret = mp_read_unsigned_bin(tmp1, lower_bound, (word32)nlen/16);
45244526
if (ret != MP_OKAY) goto notOkay;
45254527
ret = mp_cmp(prime, tmp1);
45264528
if (ret == MP_LT) goto exit;
45274529

4528-
/* 4.5,5.6 - Check that GCD(p-1, e) == 1 */
4530+
/* 4.5,5.6 (186-4 & 186-5) - Check that GCD(p-1, e) == 1 */
45294531
ret = mp_sub_d(prime, 1, tmp1); /* tmp1 = prime-1 */
45304532
if (ret != MP_OKAY) goto notOkay;
45314533
#ifdef WOLFSSL_CHECK_MEM_ZERO

wolfssl/wolfcrypt/hmac.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@
4343
WOLFSSL_LOCAL int wolfCrypt_FIPS_HMAC_sanity(void);
4444
#endif
4545

46+
#if FIPS_VERSION3_GE(6,0,0)
47+
#define FIPS_ALLOW_SHORT 1
48+
#endif
49+
4650
/* avoid redefinition of structs */
4751
#if !defined(HAVE_FIPS) || FIPS_VERSION3_GE(2,0,0)
4852

0 commit comments

Comments
 (0)