Skip to content

Commit

Permalink
Merge pull request #8118 from bigbrett/wc-test-ecc-zero-digest-disable
Browse files Browse the repository at this point in the history
wolfcrypt tests: disable ecc sign/verify of all zero digest
  • Loading branch information
SparkiDev authored Oct 31, 2024
2 parents 652f705 + aafd07d commit 76e421b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
9 changes: 3 additions & 6 deletions wolfcrypt/test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -30874,11 +30874,8 @@ static wc_test_ret_t ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerif
#if !defined(ECC_TIMING_RESISTANT) || (defined(ECC_TIMING_RESISTANT) && \
!defined(WC_NO_RNG) && !defined(WOLFSSL_KCAPI_ECC))
#ifdef HAVE_ECC_SIGN
/* ECC w/out Shamir has issue with all 0 digest */
/* WC_BIGINT doesn't have 0 len well on hardware */
/* Cryptocell has issues with all 0 digest */
#if defined(ECC_SHAMIR) && !defined(WOLFSSL_ASYNC_CRYPT) && \
!defined(WOLFSSL_CRYPTOCELL)
/* some hardware doesn't support sign/verify of all zero digest */
#if !defined(WC_TEST_NO_ECC_SIGN_VERIFY_ZERO_DIGEST)
/* test DSA sign hash with zeros */
for (i = 0; i < (int)ECC_DIGEST_SIZE; i++) {
digest[i] = 0;
Expand Down Expand Up @@ -30915,7 +30912,7 @@ static wc_test_ret_t ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerif
TEST_SLEEP();
}
#endif /* HAVE_ECC_VERIFY */
#endif /* ECC_SHAMIR && !WOLFSSL_ASYNC_CRYPT && !WOLFSSL_CRYPTOCELL */
#endif /* !WC_TEST_NO_ECC_SIGN_VERIFY_ZERO_DIGEST */

/* test DSA sign hash with sequence (0,1,2,3,4,...) */
for (i = 0; i < (int)ECC_DIGEST_SIZE; i++) {
Expand Down
14 changes: 14 additions & 0 deletions wolfssl/wolfcrypt/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -3168,6 +3168,14 @@ extern void uITRON4_free(void *p) ;
#undef NO_DH
#endif

/* CryptoCell defines */
#ifdef WOLFSSL_CRYPTOCELL
#if defined(HAVE_ECC) && defined(HAVE_ECC_SIGN)
/* Don't attempt to sign/verify an all-zero digest in wolfCrypt tests */
#define WC_TEST_NO_ECC_SIGN_VERIFY_ZERO_DIGEST
#endif /* HAVE_ECC && HAVE_ECC_SIGN */
#endif

/* Asynchronous Crypto */
#ifdef WOLFSSL_ASYNC_CRYPT
#if !defined(HAVE_CAVIUM) && !defined(HAVE_INTEL_QA) && \
Expand All @@ -3192,6 +3200,12 @@ extern void uITRON4_free(void *p) ;
* but not required */
#define ECC_CACHE_CURVE
#endif

#if defined(HAVE_ECC) && defined(HAVE_ECC_SIGN)
/* Don't attempt to sign/verify an all-zero digest in wolfCrypt tests */
#define WC_TEST_NO_ECC_SIGN_VERIFY_ZERO_DIGEST
#endif /* HAVE_ECC && HAVE_ECC_SIGN */

#endif /* WOLFSSL_ASYNC_CRYPT */
#ifndef WC_ASYNC_DEV_SIZE
#define WC_ASYNC_DEV_SIZE 0
Expand Down

0 comments on commit 76e421b

Please sign in to comment.