Skip to content

Commit e88dd14

Browse files
committed
Minor audit fixup items
Fixup macro guards Nother RSA fix
1 parent 76197b6 commit e88dd14

File tree

5 files changed

+23
-1
lines changed

5 files changed

+23
-1
lines changed

configure.ac

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7336,6 +7336,10 @@ then
73367336
fi
73377337
73387338
if test "$ENABLED_ORIGINAL" = "yes"; then
7339+
# FIPS 203 (ML-KEM) and Kyber use different implicit rejection.
7340+
# Kyber mode must not be used in FIPS v7+ builds.
7341+
AS_IF([test "$HAVE_FIPS_VERSION" -ge 7],
7342+
[AC_MSG_ERROR([Kyber (--enable-mlkem=original) is not compatible with FIPS v7+. Use ML-KEM (FIPS 203) instead.])])
73397343
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_MLKEM_KYBER"
73407344
if test "$ENABLED_MLKEM512" = ""; then
73417345
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_NO_KYBER512"

wolfcrypt/src/rsa.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,12 @@ static int RsaMGF_SHAKE(enum wc_HashType shakeType, byte* seed, word32 seedSz,
10721072
ret = wc_InitShake128(&shake, heap, INVALID_DEVID);
10731073
else
10741074
#endif
1075+
#ifdef WOLFSSL_SHAKE256
1076+
if (shakeType == WC_HASH_TYPE_SHAKE256)
10751077
ret = wc_InitShake256(&shake, heap, INVALID_DEVID);
1078+
else
1079+
#endif
1080+
ret = BAD_FUNC_ARG;
10761081

10771082
if (ret == 0) {
10781083
#ifdef WOLFSSL_SHAKE128
@@ -1084,12 +1089,18 @@ static int RsaMGF_SHAKE(enum wc_HashType shakeType, byte* seed, word32 seedSz,
10841089
}
10851090
else
10861091
#endif
1087-
{
1092+
#ifdef WOLFSSL_SHAKE256
1093+
if (shakeType == WC_HASH_TYPE_SHAKE256) {
10881094
ret = wc_Shake256_Update(&shake, seed, seedSz);
10891095
if (ret == 0)
10901096
ret = wc_Shake256_Final(&shake, out, outSz);
10911097
wc_Shake256_Free(&shake);
10921098
}
1099+
else
1100+
#endif
1101+
{
1102+
ret = BAD_FUNC_ARG;
1103+
}
10931104
}
10941105
return ret;
10951106
}

wolfcrypt/src/sha256.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ static int InitSha256(wc_Sha256* sha256)
252252
sha256->digest[7] = 0x5BE0CD19L;
253253

254254
sha256->buffLen = 0;
255+
XMEMSET(sha256->buffer, 0, sizeof(sha256->buffer));
255256
sha256->loLen = 0;
256257
sha256->hiLen = 0;
257258
#ifdef WOLFSSL_HASH_FLAGS
@@ -2085,6 +2086,7 @@ static WC_INLINE int Transform_Sha256_Len(wc_Sha256* sha256, const byte* data,
20852086
sha224->digest[7] = 0xbefa4fa4;
20862087

20872088
sha224->buffLen = 0;
2089+
XMEMSET(sha224->buffer, 0, sizeof(sha224->buffer));
20882090
sha224->loLen = 0;
20892091
sha224->hiLen = 0;
20902092

wolfcrypt/src/sha3.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,7 @@ static int InitSha3(wc_Sha3* sha3)
653653

654654
for (i = 0; i < 25; i++)
655655
sha3->s[i] = 0;
656+
XMEMSET(sha3->t, 0, sizeof(sha3->t));
656657
sha3->i = 0;
657658
#ifdef WOLFSSL_HASH_FLAGS
658659
sha3->flags = 0;

wolfcrypt/src/sha512.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ static int InitSha512(wc_Sha512* sha512)
331331
sha512->digest[7] = W64LIT(0x5be0cd19137e2179);
332332

333333
sha512->buffLen = 0;
334+
XMEMSET(sha512->buffer, 0, sizeof(sha512->buffer));
334335
sha512->loLen = 0;
335336
sha512->hiLen = 0;
336337

@@ -386,6 +387,7 @@ static int InitSha512_224(wc_Sha512* sha512)
386387
sha512->digest[7] = W64LIT(0x1112e6ad91d692a1);
387388

388389
sha512->buffLen = 0;
390+
XMEMSET(sha512->buffer, 0, sizeof(sha512->buffer));
389391
sha512->loLen = 0;
390392
sha512->hiLen = 0;
391393

@@ -443,6 +445,7 @@ static int InitSha512_256(wc_Sha512* sha512)
443445
sha512->digest[7] = W64LIT(0x0eb72ddc81c52ca2);
444446

445447
sha512->buffLen = 0;
448+
XMEMSET(sha512->buffer, 0, sizeof(sha512->buffer));
446449
sha512->loLen = 0;
447450
sha512->hiLen = 0;
448451

@@ -1938,6 +1941,7 @@ static int InitSha384(wc_Sha384* sha384)
19381941
sha384->digest[7] = W64LIT(0x47b5481dbefa4fa4);
19391942

19401943
sha384->buffLen = 0;
1944+
XMEMSET(sha384->buffer, 0, sizeof(sha384->buffer));
19411945
sha384->loLen = 0;
19421946
sha384->hiLen = 0;
19431947

0 commit comments

Comments
 (0)