@@ -4706,7 +4706,8 @@ void sp_free(sp_int* a)
47064706 }
47074707}
47084708
4709- #if !defined(WOLFSSL_RSA_VERIFY_ONLY) || !defined(NO_DH) || defined(HAVE_ECC)
4709+ #if (!defined(NO_RSA) && !defined(WOLFSSL_RSA_VERIFY_ONLY)) || \
4710+ !defined(NO_DH) || defined(HAVE_ECC)
47104711/* Grow multi-precision number to be able to hold l digits.
47114712 * This function does nothing as the number of digits is fixed.
47124713 *
@@ -4739,9 +4740,10 @@ int sp_grow(sp_int* a, int l)
47394740
47404741 return err;
47414742}
4742- #endif /* ! WOLFSSL_RSA_VERIFY_ONLY || !NO_DH || HAVE_ECC */
4743+ #endif /* (!NO_RSA && ! WOLFSSL_RSA_VERIFY_ONLY) || !NO_DH || HAVE_ECC */
47434744
4744- #if !defined(WOLFSSL_RSA_VERIFY_ONLY) || defined(HAVE_ECC)
4745+ #if (!defined(NO_RSA) && !defined(WOLFSSL_RSA_VERIFY_ONLY)) || \
4746+ defined(HAVE_ECC)
47454747/* Set the multi-precision number to zero.
47464748 *
47474749 * @param [out] a SP integer to set to zero.
@@ -4753,7 +4755,7 @@ void sp_zero(sp_int* a)
47534755 _sp_zero(a);
47544756 }
47554757}
4756- #endif /* ! WOLFSSL_RSA_VERIFY_ONLY */
4758+ #endif /* (!NO_RSA && ! WOLFSSL_RSA_VERIFY_ONLY) || HAVE_ECC */
47574759
47584760/* Clear the data from the multi-precision number, set to zero and free.
47594761 *
@@ -5166,8 +5168,8 @@ int sp_cmp(const sp_int* a, const sp_int* b)
51665168 * Bit check/set functions
51675169 *************************/
51685170
5169- #if !defined(WOLFSSL_RSA_VERIFY_ONLY) || ( defined(WOLFSSL_SP_MATH_ALL) && \
5170- defined(HAVE_ECC))
5171+ #if ( !defined(NO_RSA) && ! defined(WOLFSSL_RSA_VERIFY_ONLY)) || \
5172+ (defined(WOLFSSL_SP_MATH_ALL) && defined(HAVE_ECC))
51715173/* Check if a bit is set
51725174 *
51735175 * When a is NULL, result is 0.
@@ -5195,7 +5197,8 @@ int sp_is_bit_set(const sp_int* a, unsigned int b)
51955197
51965198 return ret;
51975199}
5198- #endif /* WOLFSSL_RSA_VERIFY_ONLY */
5200+ #endif /* (!NO_RSA && !WOLFSSL_RSA_VERIFY_ONLY) ||
5201+ * (WOLFSSL_SP_MATH_ALL && HAVE_ECC) */
51995202
52005203/* Count the number of bits in the multi-precision number.
52015204 *
@@ -5424,6 +5427,8 @@ int sp_2expt(sp_int* a, int e)
54245427 * Digit/Long functions
54255428 **********************/
54265429
5430+ #if defined(WOLFSSL_SP_MATH_ALL) || !defined(NO_RSA) || !defined(NO_DH) || \
5431+ defined(HAVE_ECC)
54275432/* Set the multi-precision number to be the value of the digit.
54285433 *
54295434 * @param [out] a SP integer to become number.
@@ -5454,6 +5459,7 @@ int sp_set(sp_int* a, sp_int_digit d)
54545459
54555460 return err;
54565461}
5462+ #endif
54575463
54585464#if defined(WOLFSSL_SP_MATH_ALL) || !defined(NO_RSA) || defined(OPENSSL_EXTRA)
54595465/* Set a number into the multi-precision number.
@@ -5507,8 +5513,9 @@ int sp_set_int(sp_int* a, unsigned long n)
55075513}
55085514#endif /* WOLFSSL_SP_MATH_ALL || !NO_RSA */
55095515
5510- #if !defined(WOLFSSL_RSA_VERIFY_ONLY) || \
5511- (defined(WOLFSSL_SP_MATH_ALL) && !defined(NO_DH))
5516+ #if defined(WOLFSSL_SP_MATH_ALL) || \
5517+ (!defined(NO_RSA) && !defined(WOLFSSL_RSA_VERIFY_ONLY)) || \
5518+ !defined(NO_DH) || defined(HAVE_ECC)
55125519/* Compare a one digit number with a multi-precision number.
55135520 *
55145521 * When a is NULL, MP_LT is returned.
@@ -7559,8 +7566,8 @@ int sp_submod_ct(const sp_int* a, const sp_int* b, const sp_int* m, sp_int* r)
75597566 * Shifting functoins
75607567 ********************/
75617568
7562- #if !defined(NO_DH) || defined(HAVE_ECC) || (defined(WC_RSA_BLINDING ) && \
7563- !defined(WOLFSSL_RSA_VERIFY_ONLY))
7569+ #if !defined(NO_DH) || defined(HAVE_ECC) || (! defined(NO_RSA ) && \
7570+ defined(WC_RSA_BLINDING) && !defined(WOLFSSL_RSA_VERIFY_ONLY))
75647571/* Left shift the multi-precision number by a number of digits.
75657572 *
75667573 * @param [in,out] a SP integer to shift.
@@ -8265,6 +8272,9 @@ int sp_mod(const sp_int* a, const sp_int* m, sp_int* r)
82658272#endif /* WOLFSSL_SP_MATH_ALL || !NO_DH || HAVE_ECC || \
82668273 * (!NO_RSA && !WOLFSSL_RSA_VERIFY_ONLY) */
82678274
8275+ #if defined(WOLFSSL_SP_MATH_ALL) || defined(WOLFSSL_HAVE_SP_DH) || \
8276+ defined(HAVE_ECC) || !defined(NO_RSA)
8277+
82688278/* START SP_MUL implementations. */
82698279/* This code is generated.
82708280 * To generate:
@@ -11266,6 +11276,8 @@ int sp_mul(const sp_int* a, const sp_int* b, sp_int* r)
1126611276}
1126711277/* END SP_MUL implementations. */
1126811278
11279+ #endif
11280+
1126911281#if defined(WOLFSSL_SP_MATH_ALL) || defined(WOLFSSL_HAVE_SP_DH) || \
1127011282 defined(WOLFCRYPT_HAVE_ECCSI) || \
1127111283 (!defined(NO_RSA) && defined(WOLFSSL_KEY_GEN)) || defined(OPENSSL_ALL)
@@ -16014,8 +16026,9 @@ int sp_sqr(const sp_int* a, sp_int* r)
1601416026#endif /* WOLFSSL_SP_MATH_ALL || WOLFSSL_HAVE_SP_DH || HAVE_ECC ||
1601516027 * (!NO_RSA && !WOLFSSL_RSA_VERIFY_ONLY) */
1601616028
16017- #if (!defined(WOLFSSL_RSA_VERIFY_ONLY) && \
16018- !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || !defined(NO_DH)
16029+ #if defined(WOLFSSL_SP_MATH_ALL) || \
16030+ (!defined(NO_RSA) && !defined(WOLFSSL_RSA_VERIFY_ONLY) && \
16031+ !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || !defined(NO_DH) || defined(HAVE_ECC)
1601916032/* Square a mod m and store in r: r = (a * a) mod m
1602016033 *
1602116034 * @param [in] a SP integer to square.
@@ -16739,20 +16752,21 @@ int sp_read_unsigned_bin(sp_int* a, const byte* in, word32 inSz)
1673916752 #else
1674016753 /* Construct digit from required number of bytes. */
1674116754 for (i = inSz-1; i >= SP_WORD_SIZEOF - 1; i -= SP_WORD_SIZEOF) {
16742- a->dp[j] = ((sp_int_digit)in[i - 0] << 0);
16755+ a->dp[j] = ((sp_int_digit)in[i - 0] << 0)
1674316756 #if SP_WORD_SIZE >= 16
16744- a->dp[j] |= ((sp_int_digit)in[i - 1] << 8);
16757+ | ((sp_int_digit)in[i - 1] << 8)
1674516758 #endif
1674616759 #if SP_WORD_SIZE >= 32
16747- a->dp[j] |= ((sp_int_digit)in[i - 2] << 16) |
16748- ((sp_int_digit)in[i - 3] << 24);
16760+ | ((sp_int_digit)in[i - 2] << 16) |
16761+ ((sp_int_digit)in[i - 3] << 24)
1674916762 #endif
1675016763 #if SP_WORD_SIZE >= 64
16751- a->dp[j] |= ((sp_int_digit)in[i - 4] << 32) |
16764+ | ((sp_int_digit)in[i - 4] << 32) |
1675216765 ((sp_int_digit)in[i - 5] << 40) |
1675316766 ((sp_int_digit)in[i - 6] << 48) |
16754- ((sp_int_digit)in[i - 7] << 56);
16767+ ((sp_int_digit)in[i - 7] << 56)
1675516768 #endif
16769+ ;
1675616770 j++;
1675716771 }
1675816772 #endif
@@ -17536,11 +17550,6 @@ int sp_rand_prime(sp_int* r, int len, WC_RNG* rng, void* heap)
1753617550#else
1753717551 ((byte*)(r->dp + r->used - 1))[0] |= 0x80 | 0x40;
1753817552#endif /* LITTLE_ENDIAN_ORDER */
17539- /* Set mandatory low bits
17540- * - bottom bit to make odd.
17541- * - For BBS, second lowest too to make Blum integer (3 mod 4).
17542- */
17543- r->dp[0] |= low_bits;
1754417553
1754517554#ifdef BIG_ENDIAN_ORDER
1754617555 /* Bytes were put into wrong place when less than full digit. */
@@ -17554,6 +17563,11 @@ int sp_rand_prime(sp_int* r, int len, WC_RNG* rng, void* heap)
1755417563 r->dp[r->used - 1] &= ((sp_int_digit)1 << bits) - 1;
1755517564 }
1755617565#endif /* WOLFSSL_SP_MATH_ALL */
17566+ /* Set mandatory low bits
17567+ * - bottom bit to make odd.
17568+ * - For BBS, second lowest too to make Blum integer (3 mod 4).
17569+ */
17570+ r->dp[0] |= low_bits;
1755717571
1755817572 /* Running Miller-Rabin up to 3 times gives us a 2^{-80} chance
1755917573 * of a 1024-bit candidate being a false positive, when it is our
0 commit comments