From 57ecd4b246ef1cc0a9c6c2de642a16de6e470588 Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Thu, 20 Mar 2025 22:18:22 -0500 Subject: [PATCH] configure.ac: fix -DNO_BIG_INT setup to recognize $ENABLED_SP_MATH. wolfcrypt/test/test.c: fix gating around modLen in rsa_test(). wolfssl/openssl/bn.h: remove superfluous WOLFSSL_SP_MATH gate around mp_int mpi in struct WOLFSSL_BIGNUM definition. wolfssl/wolfcrypt/wolfmath.h: add check for "Conflicting MPI settings.", add initial check for WOLFSSL_SP_MATH_ALL || WOLFSSL_SP_MATH to include sp_int.h, and remove superfluous WOLFSSL_SP_MATH gate on "common math functions". --- configure.ac | 4 ++-- wolfcrypt/test/test.c | 8 +++++--- wolfssl/openssl/bn.h | 2 +- wolfssl/wolfcrypt/wolfmath.h | 9 ++++++++- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 8e89c2f8b..af90dd2b8 100644 --- a/configure.ac +++ b/configure.ac @@ -9809,8 +9809,8 @@ AS_IF([test "x$ENABLED_16BIT" = "xyes" && \ ################################################################################ # Update CFLAGS based on options # ################################################################################ -AS_IF([test "x$ENABLED_SP_MATH_ALL" = "xno" && test "x$ENABLED_FASTMATH" = "xno" && - test "x$ENABLED_HEAPMATH" = "xno"], +AS_IF([test "$ENABLED_SP_MATH" = "no" && test "$ENABLED_SP_MATH_ALL" = "no" && + test "$ENABLED_FASTMATH" = "no" && test "$ENABLED_HEAPMATH" = "no"], [AM_CFLAGS="$AM_CFLAGS -DNO_BIG_INT"]) AS_IF([test "x$ENABLED_CERTS" = "xno"], diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 98bb272a4..45f293ac5 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -22109,13 +22109,15 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t rsa_test(void) ERROR_OUT(WC_TEST_RET_ENC_EC(ret), exit_rsa); #endif -#if !defined(NO_SIG_WRAPPER) && !defined(NO_SHA256) +#ifndef NO_SIG_WRAPPER +#ifndef NO_SHA256 ret = rsa_sig_test(key, sizeof *key, modLen, &rng); if (ret != 0) goto exit_rsa; -#else +#else /* NO_SHA256 */ (void)modLen; -#endif +#endif /* NO_SHA256 */ +#endif /* !NO_SIG_WRAPPER */ #ifdef WC_RSA_NONBLOCK ret = rsa_nb_test(key, in, inLen, out, outSz, plain, plainSz, &rng); diff --git a/wolfssl/openssl/bn.h b/wolfssl/openssl/bn.h index c0d7f9b6b..c4768b286 100644 --- a/wolfssl/openssl/bn.h +++ b/wolfssl/openssl/bn.h @@ -40,7 +40,7 @@ typedef struct WOLFSSL_BIGNUM { int neg; /* openssh deference */ void *internal; /* our big num */ -#if !defined(NO_BIG_INT) || defined(WOLFSSL_SP_MATH) +#if !defined(NO_BIG_INT) mp_int mpi; #endif } WOLFSSL_BIGNUM; diff --git a/wolfssl/wolfcrypt/wolfmath.h b/wolfssl/wolfcrypt/wolfmath.h index d32d60a4a..e2e854525 100644 --- a/wolfssl/wolfcrypt/wolfmath.h +++ b/wolfssl/wolfcrypt/wolfmath.h @@ -42,6 +42,13 @@ This library provides big integer math functions. #if defined(NO_BIG_INT) /* MPI globally disabled -- no PK algorithms supported. */ + #if defined(USE_FAST_MATH) || defined(USE_INTEGER_HEAP_MATH) || \ + defined(WOLFSSL_SP_MATH_ALL) || defined(WOLFSSL_SP_MATH) || \ + defined(HAVE_WOLF_BIGINT) || defined(WOLFSSL_EXPORT_INT) + #error Conflicting MPI settings. + #endif +#elif defined(WOLFSSL_SP_MATH_ALL) || defined(WOLFSSL_SP_MATH) + #include #elif defined(USE_FAST_MATH) #include #elif defined(USE_INTEGER_HEAP_MATH) @@ -74,7 +81,7 @@ This library provides big integer math functions. extern const wc_ptr_t wc_off_on_addr[2]; #endif -#if !defined(NO_BIG_INT) || defined(WOLFSSL_SP_MATH) +#if !defined(NO_BIG_INT) /* common math functions */ MP_API int get_digit_count(const mp_int* a); MP_API mp_digit get_digit(const mp_int* a, int n);