Skip to content

Commit da440d1

Browse files
account for FIPS ready build and SE050 test
1 parent b3e9e51 commit da440d1

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

wolfcrypt/src/port/nxp/se050_port.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,6 +2113,10 @@ int se050_ecc_sign_hash_ex(const byte* in, word32 inLen, MATH_INT_T* r, MATH_INT
21132113
size_t sigSz = sizeof(sigBuf);
21142114
word32 rLen = 0;
21152115
word32 sLen = 0;
2116+
#ifndef WC_ALLOW_ECC_ZERO_HASH
2117+
byte hashIsZero = 0;
2118+
word32 zIdx;
2119+
#endif
21162120

21172121
#ifdef SE050_DEBUG
21182122
printf("se050_ecc_sign_hash_ex: key %p, in %p (%d), out %p (%d), "
@@ -2124,6 +2128,15 @@ int se050_ecc_sign_hash_ex(const byte* in, word32 inLen, MATH_INT_T* r, MATH_INT
21242128
return BAD_FUNC_ARG;
21252129
}
21262130

2131+
#ifndef WC_ALLOW_ECC_ZERO_HASH
2132+
/* SE050 hardware does not reject all-zero digests; mirror the
2133+
* software path's check so behavior is consistent. */
2134+
for (zIdx = 0; zIdx < inLen; zIdx++)
2135+
hashIsZero |= in[zIdx];
2136+
if (hashIsZero == 0)
2137+
return ECC_BAD_ARG_E;
2138+
#endif
2139+
21272140
if (cfg_se050_i2c_pi == NULL) {
21282141
return WC_HW_E;
21292142
}

wolfssl/wolfcrypt/settings.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3514,10 +3514,12 @@ extern void uITRON4_free(void *p) ;
35143514
#endif
35153515

35163516
#ifdef HAVE_ECC
3517-
/* defined for all ECC non FIPS builds and for FIPS v7+, unless the user
3518-
* explicitly opts in to allowing an all-zero digest with
3517+
/* defined for all ECC non FIPS builds and for FIPS v7+ (including
3518+
* fips-ready/fips-dev which track the latest in-development source),
3519+
* unless the user explicitly opts in to allowing an all-zero digest with
35193520
* WC_ALLOW_ECC_ZERO_HASH or is building with HAVE_SELFTEST */
3520-
#if (!defined(HAVE_FIPS) || FIPS_VERSION_GT(7,0)) && \
3521+
#if (!defined(HAVE_FIPS) || FIPS_VERSION_GT(7,0) || \
3522+
defined(WOLFSSL_FIPS_READY) || defined(WOLFSSL_FIPS_DEV)) && \
35213523
!defined(HAVE_SELFTEST) && !defined(WC_ALLOW_ECC_ZERO_HASH)
35223524
/* sign/verify of an all-zero digest in wolfCrypt rejected */
35233525
#define WC_TEST_NO_ECC_SIGN_VERIFY_ZERO_DIGEST

0 commit comments

Comments
 (0)