Skip to content

Commit f41a9dc

Browse files
committed
Fix FIPS v6 or older build with crypto callbacks and SHA512
1 parent 7467ce2 commit f41a9dc

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

wolfcrypt/src/cryptocb.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2033,10 +2033,20 @@ int wc_CryptoCb_Sha384Hash(wc_Sha384* sha384, const byte* in,
20332033

20342034
#ifdef WOLFSSL_SHA512
20352035
int wc_CryptoCb_Sha512Hash(wc_Sha512* sha512, const byte* in,
2036-
word32 inSz, byte* digest, size_t digestSz)
2036+
word32 inSz, byte* digest
2037+
#if !(defined(HAVE_FIPS) && FIPS_VERSION_LT(7,0))
2038+
, size_t digestSz
2039+
#endif
2040+
)
20372041
{
20382042
int ret = WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE);
20392043
CryptoCb* dev;
2044+
#if defined(HAVE_FIPS) && FIPS_VERSION_LT(7,0)
2045+
/* Older FIPS sha512.c snapshots call the 4-arg API (no digestSz). Treat as
2046+
* full-size SHA-512 with no variant dispatch, matching pre-digestSz
2047+
* behavior. */
2048+
size_t digestSz = WC_SHA512_DIGEST_SIZE;
2049+
#endif
20402050

20412051
/* locate registered callback */
20422052
#ifndef NO_SHA2_CRYPTO_CB

wolfssl/wolfcrypt/cryptocb.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,11 @@ WOLFSSL_LOCAL int wc_CryptoCb_Sha384Hash(wc_Sha384* sha384, const byte* in,
871871
#endif
872872
#ifdef WOLFSSL_SHA512
873873
WOLFSSL_LOCAL int wc_CryptoCb_Sha512Hash(wc_Sha512* sha512, const byte* in,
874-
word32 inSz, byte* digest, size_t digestSz);
874+
word32 inSz, byte* digest
875+
#if !(defined(HAVE_FIPS) && FIPS_VERSION_LT(7,0))
876+
, size_t digestSz
877+
#endif
878+
);
875879
#endif
876880

877881
#ifdef WOLFSSL_SHA3

0 commit comments

Comments
 (0)