Repository navigation
sha2, sha3: refuse mixed variants, rates and SHAKE call order in FIPS v7 #12213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -330,6 +330,9 @@ static int InitSha256(wc_Sha256* sha256) | |
| sha256->len = 0; | ||
| sha256->used = 0; | ||
| #endif | ||
| #ifdef WC_HASH_CHECK_VARIANT | ||
| sha256->digestSz = WC_SHA256_DIGEST_SIZE; | ||
| #endif | ||
|
|
||
| #if (defined(WOLFSSL_X86_64_BUILD) && defined(USE_INTEL_SPEEDUP) && \ | ||
| (defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2))) || \ | ||
|
|
@@ -2524,6 +2527,11 @@ static WC_INLINE int Transform_Sha256_Len(wc_Sha256* sha256, const byte* data, | |
| if (sha256 == NULL || hash == NULL) { | ||
| return BAD_FUNC_ARG; | ||
| } | ||
| #ifdef WC_HASH_CHECK_VARIANT | ||
| if (sha256->digestSz != WC_SHA256_DIGEST_SIZE) { | ||
| return BAD_STATE_E; | ||
| } | ||
| #endif | ||
| #if defined(WOLFSSL_CHECK_MEM_ZERO) && defined(LITTLE_ENDIAN_ORDER) && \ | ||
| !defined(WOLFSSL_WIDE_BYTE) | ||
| wc_MemZero_Add("wc_Sha256FinalRaw digest", digest, sizeof(digest)); | ||
|
|
@@ -2557,6 +2565,11 @@ static WC_INLINE int Transform_Sha256_Len(wc_Sha256* sha256, const byte* data, | |
| if (sha256 == NULL || hash == NULL) { | ||
| return BAD_FUNC_ARG; | ||
| } | ||
| #ifdef WC_HASH_CHECK_VARIANT | ||
| if (sha256->digestSz != WC_SHA256_DIGEST_SIZE) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SHA-256 Final always fails on ESP32-HW and Freescale MMCAU builds: their init paths never set digestSz · Logic errors Only the generic Suggested fix: Set Related known findings (similar but distinct; listed for context, not part of this finding)
|
||
| return BAD_STATE_E; | ||
| } | ||
| #endif | ||
|
|
||
| #ifdef WOLF_CRYPTO_CB | ||
| #ifndef WOLF_CRYPTO_CB_FIND | ||
|
|
@@ -2995,6 +3008,9 @@ static WC_INLINE int Transform_Sha256_Len(wc_Sha256* sha256, const byte* data, | |
| XMEMSET(sha224->buffer, 0, sizeof(sha224->buffer)); | ||
| sha224->loLen = 0; | ||
| sha224->hiLen = 0; | ||
| #ifdef WC_HASH_CHECK_VARIANT | ||
| sha224->digestSz = WC_SHA224_DIGEST_SIZE; | ||
| #endif | ||
|
|
||
| #if defined(WOLFSSL_X86_64_BUILD) && defined(USE_INTEL_SPEEDUP) && \ | ||
| (defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2)) | ||
|
|
@@ -3180,6 +3196,11 @@ int wc_Sha224Reset(wc_Sha224* sha224) { | |
| if (sha224 == NULL || hash == NULL) { | ||
| return BAD_FUNC_ARG; | ||
| } | ||
| #ifdef WC_HASH_CHECK_VARIANT | ||
| if (sha224->digestSz != WC_SHA224_DIGEST_SIZE) { | ||
| return BAD_STATE_E; | ||
| } | ||
| #endif | ||
| #ifdef WOLF_CRYPTO_CB | ||
| #ifndef WOLF_CRYPTO_CB_FIND | ||
| if (sha224->devId != INVALID_DEVID) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.