diff --git a/wolfcrypt/src/sp_arm32.c b/wolfcrypt/src/sp_arm32.c index 95ae9d550..6a9cb09fe 100644 --- a/wolfcrypt/src/sp_arm32.c +++ b/wolfcrypt/src/sp_arm32.c @@ -37574,6 +37574,19 @@ static WC_INLINE int sp_256_mod_8(sp_digit* r, const sp_digit* a, const sp_digit #endif #if defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY) +/* Multiply two number mod the order of P256 curve. (r = a * b mod order) + * + * r Result of the multiplication. + * a First operand of the multiplication. + * b Second operand of the multiplication. + */ +static void sp_256_mont_mul_order_8(sp_digit* r, const sp_digit* a, const sp_digit* b) +{ + sp_256_mul_8(r, a, b); + sp_256_mont_reduce_order_8(r, p256_order, p256_mp_order); +} + +#if defined(HAVE_ECC_SIGN) || (defined(HAVE_ECC_VERIFY) && defined(WOLFSSL_SP_SMALL)) #ifdef WOLFSSL_SP_SMALL /* Order-2 for the P256 curve. */ static const uint32_t p256_order_minus_2[8] = { @@ -37587,18 +37600,6 @@ static const sp_int_digit p256_order_low[4] = { }; #endif /* WOLFSSL_SP_SMALL */ -/* Multiply two number mod the order of P256 curve. (r = a * b mod order) - * - * r Result of the multiplication. - * a First operand of the multiplication. - * b Second operand of the multiplication. - */ -static void sp_256_mont_mul_order_8(sp_digit* r, const sp_digit* a, const sp_digit* b) -{ - sp_256_mul_8(r, a, b); - sp_256_mont_reduce_order_8(r, p256_order, p256_mp_order); -} - /* Square number mod the order of P256 curve. (r = a * a mod order) * * r Result of the squaring. @@ -37769,6 +37770,7 @@ static void sp_256_mont_inv_order_8(sp_digit* r, const sp_digit* a, #endif /* WOLFSSL_SP_SMALL */ } +#endif /* HAVE_ECC_SIGN || (HAVE_ECC_VERIFY && WOLFSSL_SP_SMALL) */ #endif /* HAVE_ECC_SIGN | HAVE_ECC_VERIFY */ #ifdef HAVE_ECC_SIGN #ifndef SP_ECC_MAX_SIG_GEN @@ -46840,6 +46842,19 @@ static WC_INLINE int sp_384_mod_12(sp_digit* r, const sp_digit* a, const sp_digi #endif #if defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY) +/* Multiply two number mod the order of P384 curve. (r = a * b mod order) + * + * r Result of the multiplication. + * a First operand of the multiplication. + * b Second operand of the multiplication. + */ +static void sp_384_mont_mul_order_12(sp_digit* r, const sp_digit* a, const sp_digit* b) +{ + sp_384_mul_12(r, a, b); + sp_384_mont_reduce_order_12(r, p384_order, p384_mp_order); +} + +#if defined(HAVE_ECC_SIGN) || (defined(HAVE_ECC_VERIFY) && defined(WOLFSSL_SP_SMALL)) #ifdef WOLFSSL_SP_SMALL /* Order-2 for the P384 curve. */ static const uint32_t p384_order_minus_2[12] = { @@ -46853,18 +46868,6 @@ static const uint32_t p384_order_low[6] = { }; #endif /* WOLFSSL_SP_SMALL */ -/* Multiply two number mod the order of P384 curve. (r = a * b mod order) - * - * r Result of the multiplication. - * a First operand of the multiplication. - * b Second operand of the multiplication. - */ -static void sp_384_mont_mul_order_12(sp_digit* r, const sp_digit* a, const sp_digit* b) -{ - sp_384_mul_12(r, a, b); - sp_384_mont_reduce_order_12(r, p384_order, p384_mp_order); -} - /* Square number mod the order of P384 curve. (r = a * a mod order) * * r Result of the squaring. @@ -47006,6 +47009,7 @@ static void sp_384_mont_inv_order_12(sp_digit* r, const sp_digit* a, #endif /* WOLFSSL_SP_SMALL */ } +#endif /* HAVE_ECC_SIGN || (HAVE_ECC_VERIFY && WOLFSSL_SP_SMALL) */ #endif /* HAVE_ECC_SIGN | HAVE_ECC_VERIFY */ #ifdef HAVE_ECC_SIGN #ifndef SP_ECC_MAX_SIG_GEN diff --git a/wolfcrypt/src/sp_arm64.c b/wolfcrypt/src/sp_arm64.c index 9ae209f04..8280e5696 100644 --- a/wolfcrypt/src/sp_arm64.c +++ b/wolfcrypt/src/sp_arm64.c @@ -37759,6 +37759,19 @@ static WC_INLINE int sp_256_mod_4(sp_digit* r, const sp_digit* a, const sp_digit #endif #if defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY) +/* Multiply two number mod the order of P256 curve. (r = a * b mod order) + * + * r Result of the multiplication. + * a First operand of the multiplication. + * b Second operand of the multiplication. + */ +static void sp_256_mont_mul_order_4(sp_digit* r, const sp_digit* a, const sp_digit* b) +{ + sp_256_mul_4(r, a, b); + sp_256_mont_reduce_order_4(r, p256_order, p256_mp_order); +} + +#if defined(HAVE_ECC_SIGN) || (defined(HAVE_ECC_VERIFY) && defined(WOLFSSL_SP_SMALL)) #ifdef WOLFSSL_SP_SMALL /* Order-2 for the P256 curve. */ static const uint64_t p256_order_minus_2[4] = { @@ -37772,18 +37785,6 @@ static const sp_int_digit p256_order_low[2] = { }; #endif /* WOLFSSL_SP_SMALL */ -/* Multiply two number mod the order of P256 curve. (r = a * b mod order) - * - * r Result of the multiplication. - * a First operand of the multiplication. - * b Second operand of the multiplication. - */ -static void sp_256_mont_mul_order_4(sp_digit* r, const sp_digit* a, const sp_digit* b) -{ - sp_256_mul_4(r, a, b); - sp_256_mont_reduce_order_4(r, p256_order, p256_mp_order); -} - /* Square number mod the order of P256 curve. (r = a * a mod order) * * r Result of the squaring. @@ -37954,6 +37955,7 @@ static void sp_256_mont_inv_order_4(sp_digit* r, const sp_digit* a, #endif /* WOLFSSL_SP_SMALL */ } +#endif /* HAVE_ECC_SIGN || (HAVE_ECC_VERIFY && WOLFSSL_SP_SMALL) */ #endif /* HAVE_ECC_SIGN | HAVE_ECC_VERIFY */ #ifdef HAVE_ECC_SIGN #ifndef SP_ECC_MAX_SIG_GEN @@ -63546,6 +63548,19 @@ static WC_INLINE int sp_384_mod_6(sp_digit* r, const sp_digit* a, const sp_digit #endif #if defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY) +/* Multiply two number mod the order of P384 curve. (r = a * b mod order) + * + * r Result of the multiplication. + * a First operand of the multiplication. + * b Second operand of the multiplication. + */ +static void sp_384_mont_mul_order_6(sp_digit* r, const sp_digit* a, const sp_digit* b) +{ + sp_384_mul_6(r, a, b); + sp_384_mont_reduce_order_6(r, p384_order, p384_mp_order); +} + +#if defined(HAVE_ECC_SIGN) || (defined(HAVE_ECC_VERIFY) && defined(WOLFSSL_SP_SMALL)) #ifdef WOLFSSL_SP_SMALL /* Order-2 for the P384 curve. */ static const uint64_t p384_order_minus_2[6] = { @@ -63559,18 +63574,6 @@ static const uint64_t p384_order_low[3] = { }; #endif /* WOLFSSL_SP_SMALL */ -/* Multiply two number mod the order of P384 curve. (r = a * b mod order) - * - * r Result of the multiplication. - * a First operand of the multiplication. - * b Second operand of the multiplication. - */ -static void sp_384_mont_mul_order_6(sp_digit* r, const sp_digit* a, const sp_digit* b) -{ - sp_384_mul_6(r, a, b); - sp_384_mont_reduce_order_6(r, p384_order, p384_mp_order); -} - /* Square number mod the order of P384 curve. (r = a * a mod order) * * r Result of the squaring. @@ -63712,6 +63715,7 @@ static void sp_384_mont_inv_order_6(sp_digit* r, const sp_digit* a, #endif /* WOLFSSL_SP_SMALL */ } +#endif /* HAVE_ECC_SIGN || (HAVE_ECC_VERIFY && WOLFSSL_SP_SMALL) */ #endif /* HAVE_ECC_SIGN | HAVE_ECC_VERIFY */ #ifdef HAVE_ECC_SIGN #ifndef SP_ECC_MAX_SIG_GEN diff --git a/wolfcrypt/src/sp_armthumb.c b/wolfcrypt/src/sp_armthumb.c index 5e68ab8c9..8a45d68d4 100644 --- a/wolfcrypt/src/sp_armthumb.c +++ b/wolfcrypt/src/sp_armthumb.c @@ -104222,6 +104222,19 @@ static WC_INLINE int sp_256_mod_8(sp_digit* r, const sp_digit* a, const sp_digit #endif #if defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY) +/* Multiply two number mod the order of P256 curve. (r = a * b mod order) + * + * r Result of the multiplication. + * a First operand of the multiplication. + * b Second operand of the multiplication. + */ +static void sp_256_mont_mul_order_8(sp_digit* r, const sp_digit* a, const sp_digit* b) +{ + sp_256_mul_8(r, a, b); + sp_256_mont_reduce_order_8(r, p256_order, p256_mp_order); +} + +#if defined(HAVE_ECC_SIGN) || (defined(HAVE_ECC_VERIFY) && defined(WOLFSSL_SP_SMALL)) #ifdef WOLFSSL_SP_SMALL /* Order-2 for the P256 curve. */ static const uint32_t p256_order_minus_2[8] = { @@ -104235,18 +104248,6 @@ static const sp_int_digit p256_order_low[4] = { }; #endif /* WOLFSSL_SP_SMALL */ -/* Multiply two number mod the order of P256 curve. (r = a * b mod order) - * - * r Result of the multiplication. - * a First operand of the multiplication. - * b Second operand of the multiplication. - */ -static void sp_256_mont_mul_order_8(sp_digit* r, const sp_digit* a, const sp_digit* b) -{ - sp_256_mul_8(r, a, b); - sp_256_mont_reduce_order_8(r, p256_order, p256_mp_order); -} - /* Square number mod the order of P256 curve. (r = a * a mod order) * * r Result of the squaring. @@ -104417,6 +104418,7 @@ static void sp_256_mont_inv_order_8(sp_digit* r, const sp_digit* a, #endif /* WOLFSSL_SP_SMALL */ } +#endif /* HAVE_ECC_SIGN || (HAVE_ECC_VERIFY && WOLFSSL_SP_SMALL) */ #endif /* HAVE_ECC_SIGN | HAVE_ECC_VERIFY */ #ifdef HAVE_ECC_SIGN #ifndef SP_ECC_MAX_SIG_GEN @@ -114742,6 +114744,19 @@ static WC_INLINE int sp_384_mod_12(sp_digit* r, const sp_digit* a, const sp_digi #endif #if defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY) +/* Multiply two number mod the order of P384 curve. (r = a * b mod order) + * + * r Result of the multiplication. + * a First operand of the multiplication. + * b Second operand of the multiplication. + */ +static void sp_384_mont_mul_order_12(sp_digit* r, const sp_digit* a, const sp_digit* b) +{ + sp_384_mul_12(r, a, b); + sp_384_mont_reduce_order_12(r, p384_order, p384_mp_order); +} + +#if defined(HAVE_ECC_SIGN) || (defined(HAVE_ECC_VERIFY) && defined(WOLFSSL_SP_SMALL)) #ifdef WOLFSSL_SP_SMALL /* Order-2 for the P384 curve. */ static const uint32_t p384_order_minus_2[12] = { @@ -114755,18 +114770,6 @@ static const uint32_t p384_order_low[6] = { }; #endif /* WOLFSSL_SP_SMALL */ -/* Multiply two number mod the order of P384 curve. (r = a * b mod order) - * - * r Result of the multiplication. - * a First operand of the multiplication. - * b Second operand of the multiplication. - */ -static void sp_384_mont_mul_order_12(sp_digit* r, const sp_digit* a, const sp_digit* b) -{ - sp_384_mul_12(r, a, b); - sp_384_mont_reduce_order_12(r, p384_order, p384_mp_order); -} - /* Square number mod the order of P384 curve. (r = a * a mod order) * * r Result of the squaring. @@ -114908,6 +114911,7 @@ static void sp_384_mont_inv_order_12(sp_digit* r, const sp_digit* a, #endif /* WOLFSSL_SP_SMALL */ } +#endif /* HAVE_ECC_SIGN || (HAVE_ECC_VERIFY && WOLFSSL_SP_SMALL) */ #endif /* HAVE_ECC_SIGN | HAVE_ECC_VERIFY */ #ifdef HAVE_ECC_SIGN #ifndef SP_ECC_MAX_SIG_GEN diff --git a/wolfcrypt/src/sp_c32.c b/wolfcrypt/src/sp_c32.c index 6b909ea04..cb14d9028 100644 --- a/wolfcrypt/src/sp_c32.c +++ b/wolfcrypt/src/sp_c32.c @@ -25606,6 +25606,19 @@ static int sp_256_mod_9(sp_digit* r, const sp_digit* a, const sp_digit* m) #endif #if defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY) +/* Multiply two number mod the order of P256 curve. (r = a * b mod order) + * + * r Result of the multiplication. + * a First operand of the multiplication. + * b Second operand of the multiplication. + */ +static void sp_256_mont_mul_order_9(sp_digit* r, const sp_digit* a, const sp_digit* b) +{ + sp_256_mul_9(r, a, b); + sp_256_mont_reduce_order_9(r, p256_order, p256_mp_order); +} + +#if defined(HAVE_ECC_SIGN) || (defined(HAVE_ECC_VERIFY) && defined(WOLFSSL_SP_SMALL)) #ifdef WOLFSSL_SP_SMALL /* Order-2 for the P256 curve. */ static const uint32_t p256_order_minus_2[8] = { @@ -25619,18 +25632,6 @@ static const sp_int_digit p256_order_low[4] = { }; #endif /* WOLFSSL_SP_SMALL */ -/* Multiply two number mod the order of P256 curve. (r = a * b mod order) - * - * r Result of the multiplication. - * a First operand of the multiplication. - * b Second operand of the multiplication. - */ -static void sp_256_mont_mul_order_9(sp_digit* r, const sp_digit* a, const sp_digit* b) -{ - sp_256_mul_9(r, a, b); - sp_256_mont_reduce_order_9(r, p256_order, p256_mp_order); -} - /* Square number mod the order of P256 curve. (r = a * a mod order) * * r Result of the squaring. @@ -25801,6 +25802,7 @@ static void sp_256_mont_inv_order_9(sp_digit* r, const sp_digit* a, #endif /* WOLFSSL_SP_SMALL */ } +#endif /* HAVE_ECC_SIGN || (HAVE_ECC_VERIFY && WOLFSSL_SP_SMALL) */ #endif /* HAVE_ECC_SIGN | HAVE_ECC_VERIFY */ #ifdef HAVE_ECC_SIGN #ifndef SP_ECC_MAX_SIG_GEN @@ -33494,6 +33496,19 @@ static int sp_384_mod_15(sp_digit* r, const sp_digit* a, const sp_digit* m) #endif #if defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY) +/* Multiply two number mod the order of P384 curve. (r = a * b mod order) + * + * r Result of the multiplication. + * a First operand of the multiplication. + * b Second operand of the multiplication. + */ +static void sp_384_mont_mul_order_15(sp_digit* r, const sp_digit* a, const sp_digit* b) +{ + sp_384_mul_15(r, a, b); + sp_384_mont_reduce_order_15(r, p384_order, p384_mp_order); +} + +#if defined(HAVE_ECC_SIGN) || (defined(HAVE_ECC_VERIFY) && defined(WOLFSSL_SP_SMALL)) #ifdef WOLFSSL_SP_SMALL /* Order-2 for the P384 curve. */ static const uint32_t p384_order_minus_2[12] = { @@ -33507,18 +33522,6 @@ static const uint32_t p384_order_low[6] = { }; #endif /* WOLFSSL_SP_SMALL */ -/* Multiply two number mod the order of P384 curve. (r = a * b mod order) - * - * r Result of the multiplication. - * a First operand of the multiplication. - * b Second operand of the multiplication. - */ -static void sp_384_mont_mul_order_15(sp_digit* r, const sp_digit* a, const sp_digit* b) -{ - sp_384_mul_15(r, a, b); - sp_384_mont_reduce_order_15(r, p384_order, p384_mp_order); -} - /* Square number mod the order of P384 curve. (r = a * a mod order) * * r Result of the squaring. @@ -33660,6 +33663,7 @@ static void sp_384_mont_inv_order_15(sp_digit* r, const sp_digit* a, #endif /* WOLFSSL_SP_SMALL */ } +#endif /* HAVE_ECC_SIGN || (HAVE_ECC_VERIFY && WOLFSSL_SP_SMALL) */ #endif /* HAVE_ECC_SIGN | HAVE_ECC_VERIFY */ #ifdef HAVE_ECC_SIGN #ifndef SP_ECC_MAX_SIG_GEN diff --git a/wolfcrypt/src/sp_c64.c b/wolfcrypt/src/sp_c64.c index 4517f4536..f9998a813 100644 --- a/wolfcrypt/src/sp_c64.c +++ b/wolfcrypt/src/sp_c64.c @@ -26866,6 +26866,19 @@ static int sp_256_mod_5(sp_digit* r, const sp_digit* a, const sp_digit* m) #endif #if defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY) +/* Multiply two number mod the order of P256 curve. (r = a * b mod order) + * + * r Result of the multiplication. + * a First operand of the multiplication. + * b Second operand of the multiplication. + */ +static void sp_256_mont_mul_order_5(sp_digit* r, const sp_digit* a, const sp_digit* b) +{ + sp_256_mul_5(r, a, b); + sp_256_mont_reduce_order_5(r, p256_order, p256_mp_order); +} + +#if defined(HAVE_ECC_SIGN) || (defined(HAVE_ECC_VERIFY) && defined(WOLFSSL_SP_SMALL)) #ifdef WOLFSSL_SP_SMALL /* Order-2 for the P256 curve. */ static const uint64_t p256_order_minus_2[4] = { @@ -26879,18 +26892,6 @@ static const sp_int_digit p256_order_low[2] = { }; #endif /* WOLFSSL_SP_SMALL */ -/* Multiply two number mod the order of P256 curve. (r = a * b mod order) - * - * r Result of the multiplication. - * a First operand of the multiplication. - * b Second operand of the multiplication. - */ -static void sp_256_mont_mul_order_5(sp_digit* r, const sp_digit* a, const sp_digit* b) -{ - sp_256_mul_5(r, a, b); - sp_256_mont_reduce_order_5(r, p256_order, p256_mp_order); -} - /* Square number mod the order of P256 curve. (r = a * a mod order) * * r Result of the squaring. @@ -27061,6 +27062,7 @@ static void sp_256_mont_inv_order_5(sp_digit* r, const sp_digit* a, #endif /* WOLFSSL_SP_SMALL */ } +#endif /* HAVE_ECC_SIGN || (HAVE_ECC_VERIFY && WOLFSSL_SP_SMALL) */ #endif /* HAVE_ECC_SIGN | HAVE_ECC_VERIFY */ #ifdef HAVE_ECC_SIGN #ifndef SP_ECC_MAX_SIG_GEN @@ -34169,6 +34171,19 @@ static int sp_384_mod_7(sp_digit* r, const sp_digit* a, const sp_digit* m) #endif #if defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY) +/* Multiply two number mod the order of P384 curve. (r = a * b mod order) + * + * r Result of the multiplication. + * a First operand of the multiplication. + * b Second operand of the multiplication. + */ +static void sp_384_mont_mul_order_7(sp_digit* r, const sp_digit* a, const sp_digit* b) +{ + sp_384_mul_7(r, a, b); + sp_384_mont_reduce_order_7(r, p384_order, p384_mp_order); +} + +#if defined(HAVE_ECC_SIGN) || (defined(HAVE_ECC_VERIFY) && defined(WOLFSSL_SP_SMALL)) #ifdef WOLFSSL_SP_SMALL /* Order-2 for the P384 curve. */ static const uint64_t p384_order_minus_2[6] = { @@ -34182,18 +34197,6 @@ static const uint64_t p384_order_low[3] = { }; #endif /* WOLFSSL_SP_SMALL */ -/* Multiply two number mod the order of P384 curve. (r = a * b mod order) - * - * r Result of the multiplication. - * a First operand of the multiplication. - * b Second operand of the multiplication. - */ -static void sp_384_mont_mul_order_7(sp_digit* r, const sp_digit* a, const sp_digit* b) -{ - sp_384_mul_7(r, a, b); - sp_384_mont_reduce_order_7(r, p384_order, p384_mp_order); -} - /* Square number mod the order of P384 curve. (r = a * a mod order) * * r Result of the squaring. @@ -34335,6 +34338,7 @@ static void sp_384_mont_inv_order_7(sp_digit* r, const sp_digit* a, #endif /* WOLFSSL_SP_SMALL */ } +#endif /* HAVE_ECC_SIGN || (HAVE_ECC_VERIFY && WOLFSSL_SP_SMALL) */ #endif /* HAVE_ECC_SIGN | HAVE_ECC_VERIFY */ #ifdef HAVE_ECC_SIGN #ifndef SP_ECC_MAX_SIG_GEN diff --git a/wolfcrypt/src/sp_cortexm.c b/wolfcrypt/src/sp_cortexm.c index 00cd8ea99..6b1493148 100644 --- a/wolfcrypt/src/sp_cortexm.c +++ b/wolfcrypt/src/sp_cortexm.c @@ -22954,6 +22954,19 @@ static WC_INLINE int sp_256_mod_8(sp_digit* r, const sp_digit* a, const sp_digit #endif #if defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY) +/* Multiply two number mod the order of P256 curve. (r = a * b mod order) + * + * r Result of the multiplication. + * a First operand of the multiplication. + * b Second operand of the multiplication. + */ +static void sp_256_mont_mul_order_8(sp_digit* r, const sp_digit* a, const sp_digit* b) +{ + sp_256_mul_8(r, a, b); + sp_256_mont_reduce_order_8(r, p256_order, p256_mp_order); +} + +#if defined(HAVE_ECC_SIGN) || (defined(HAVE_ECC_VERIFY) && defined(WOLFSSL_SP_SMALL)) #ifdef WOLFSSL_SP_SMALL /* Order-2 for the P256 curve. */ static const uint32_t p256_order_minus_2[8] = { @@ -22967,18 +22980,6 @@ static const sp_int_digit p256_order_low[4] = { }; #endif /* WOLFSSL_SP_SMALL */ -/* Multiply two number mod the order of P256 curve. (r = a * b mod order) - * - * r Result of the multiplication. - * a First operand of the multiplication. - * b Second operand of the multiplication. - */ -static void sp_256_mont_mul_order_8(sp_digit* r, const sp_digit* a, const sp_digit* b) -{ - sp_256_mul_8(r, a, b); - sp_256_mont_reduce_order_8(r, p256_order, p256_mp_order); -} - /* Square number mod the order of P256 curve. (r = a * a mod order) * * r Result of the squaring. @@ -23149,6 +23150,7 @@ static void sp_256_mont_inv_order_8(sp_digit* r, const sp_digit* a, #endif /* WOLFSSL_SP_SMALL */ } +#endif /* HAVE_ECC_SIGN || (HAVE_ECC_VERIFY && WOLFSSL_SP_SMALL) */ #endif /* HAVE_ECC_SIGN | HAVE_ECC_VERIFY */ #ifdef HAVE_ECC_SIGN #ifndef SP_ECC_MAX_SIG_GEN @@ -30165,6 +30167,19 @@ static WC_INLINE int sp_384_mod_12(sp_digit* r, const sp_digit* a, const sp_digi #endif #if defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY) +/* Multiply two number mod the order of P384 curve. (r = a * b mod order) + * + * r Result of the multiplication. + * a First operand of the multiplication. + * b Second operand of the multiplication. + */ +static void sp_384_mont_mul_order_12(sp_digit* r, const sp_digit* a, const sp_digit* b) +{ + sp_384_mul_12(r, a, b); + sp_384_mont_reduce_order_12(r, p384_order, p384_mp_order); +} + +#if defined(HAVE_ECC_SIGN) || (defined(HAVE_ECC_VERIFY) && defined(WOLFSSL_SP_SMALL)) #ifdef WOLFSSL_SP_SMALL /* Order-2 for the P384 curve. */ static const uint32_t p384_order_minus_2[12] = { @@ -30178,18 +30193,6 @@ static const uint32_t p384_order_low[6] = { }; #endif /* WOLFSSL_SP_SMALL */ -/* Multiply two number mod the order of P384 curve. (r = a * b mod order) - * - * r Result of the multiplication. - * a First operand of the multiplication. - * b Second operand of the multiplication. - */ -static void sp_384_mont_mul_order_12(sp_digit* r, const sp_digit* a, const sp_digit* b) -{ - sp_384_mul_12(r, a, b); - sp_384_mont_reduce_order_12(r, p384_order, p384_mp_order); -} - /* Square number mod the order of P384 curve. (r = a * a mod order) * * r Result of the squaring. @@ -30331,6 +30334,7 @@ static void sp_384_mont_inv_order_12(sp_digit* r, const sp_digit* a, #endif /* WOLFSSL_SP_SMALL */ } +#endif /* HAVE_ECC_SIGN || (HAVE_ECC_VERIFY && WOLFSSL_SP_SMALL) */ #endif /* HAVE_ECC_SIGN | HAVE_ECC_VERIFY */ #ifdef HAVE_ECC_SIGN #ifndef SP_ECC_MAX_SIG_GEN diff --git a/wolfcrypt/src/sp_x86_64.c b/wolfcrypt/src/sp_x86_64.c index bbe1873c1..387d3d6da 100644 --- a/wolfcrypt/src/sp_x86_64.c +++ b/wolfcrypt/src/sp_x86_64.c @@ -23641,19 +23641,6 @@ static WC_INLINE int sp_256_mod_4(sp_digit* r, const sp_digit* a, #endif #if defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY) -#ifdef WOLFSSL_SP_SMALL -/* Order-2 for the P256 curve. */ -static const uint64_t p256_order_minus_2[4] = { - 0xf3b9cac2fc63254fU,0xbce6faada7179e84U,0xffffffffffffffffU, - 0xffffffff00000000U -}; -#else -/* The low half of the order-2 of the P256 curve. */ -static const uint64_t p256_order_low[2] = { - 0xf3b9cac2fc63254fU,0xbce6faada7179e84U -}; -#endif /* WOLFSSL_SP_SMALL */ - /* Multiply two number mod the order of P256 curve. (r = a * b mod order) * * r Result of the multiplication. @@ -23667,6 +23654,20 @@ static void sp_256_mont_mul_order_4(sp_digit* r, const sp_digit* a, const sp_dig sp_256_mont_reduce_order_4(r, p256_order, p256_mp_order); } +#if defined(HAVE_ECC_SIGN) || (defined(HAVE_ECC_VERIFY) && defined(WOLFSSL_SP_SMALL)) +#ifdef WOLFSSL_SP_SMALL +/* Order-2 for the P256 curve. */ +static const uint64_t p256_order_minus_2[4] = { + 0xf3b9cac2fc63254fU,0xbce6faada7179e84U,0xffffffffffffffffU, + 0xffffffff00000000U +}; +#else +/* The low half of the order-2 of the P256 curve. */ +static const uint64_t p256_order_low[2] = { + 0xf3b9cac2fc63254fU,0xbce6faada7179e84U +}; +#endif /* WOLFSSL_SP_SMALL */ + /* Square number mod the order of P256 curve. (r = a * a mod order) * * r Result of the squaring. @@ -23853,8 +23854,10 @@ static void sp_256_mont_inv_order_4(sp_digit* r, const sp_digit* a, #endif /* WOLFSSL_SP_SMALL */ } +#endif /* HAVE_ECC_SIGN || (HAVE_ECC_VERIFY && WOLFSSL_SP_SMALL) */ #ifdef HAVE_INTEL_AVX2 extern void sp_256_mont_mul_order_avx2_4(sp_digit* r, const sp_digit* a, const sp_digit* b); +#if defined(HAVE_ECC_SIGN) || (defined(HAVE_ECC_VERIFY) && defined(WOLFSSL_SP_SMALL)) extern void sp_256_mont_sqr_order_avx2_4(sp_digit* r, const sp_digit* a); #ifndef WOLFSSL_SP_SMALL @@ -24031,6 +24034,7 @@ static void sp_256_mont_inv_order_avx2_4(sp_digit* r, const sp_digit* a, #endif /* WOLFSSL_SP_SMALL */ } +#endif /* HAVE_ECC_SIGN || (HAVE_ECC_VERIFY && WOLFSSL_SP_SMALL) */ #endif /* HAVE_INTEL_AVX2 */ #endif /* HAVE_ECC_SIGN | HAVE_ECC_VERIFY */ #ifdef HAVE_ECC_SIGN @@ -48232,6 +48236,19 @@ static WC_INLINE int sp_384_mod_6(sp_digit* r, const sp_digit* a, #endif #if defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY) +/* Multiply two number mod the order of P384 curve. (r = a * b mod order) + * + * r Result of the multiplication. + * a First operand of the multiplication. + * b Second operand of the multiplication. + */ +static void sp_384_mont_mul_order_6(sp_digit* r, const sp_digit* a, const sp_digit* b) +{ + sp_384_mul_6(r, a, b); + sp_384_mont_reduce_order_6(r, p384_order, p384_mp_order); +} + +#if defined(HAVE_ECC_SIGN) || (defined(HAVE_ECC_VERIFY) && defined(WOLFSSL_SP_SMALL)) #ifdef WOLFSSL_SP_SMALL /* Order-2 for the P384 curve. */ static const uint64_t p384_order_minus_2[6] = { @@ -48245,18 +48262,6 @@ static const uint64_t p384_order_low[3] = { }; #endif /* WOLFSSL_SP_SMALL */ -/* Multiply two number mod the order of P384 curve. (r = a * b mod order) - * - * r Result of the multiplication. - * a First operand of the multiplication. - * b Second operand of the multiplication. - */ -static void sp_384_mont_mul_order_6(sp_digit* r, const sp_digit* a, const sp_digit* b) -{ - sp_384_mul_6(r, a, b); - sp_384_mont_reduce_order_6(r, p384_order, p384_mp_order); -} - /* Square number mod the order of P384 curve. (r = a * a mod order) * * r Result of the squaring. @@ -48398,6 +48403,7 @@ static void sp_384_mont_inv_order_6(sp_digit* r, const sp_digit* a, #endif /* WOLFSSL_SP_SMALL */ } +#endif /* HAVE_ECC_SIGN || (HAVE_ECC_VERIFY && WOLFSSL_SP_SMALL) */ #ifdef HAVE_INTEL_AVX2 /* Multiply two number mod the order of P384 curve. (r = a * b mod order) * @@ -48411,6 +48417,7 @@ static void sp_384_mont_mul_order_avx2_6(sp_digit* r, const sp_digit* a, const s sp_384_mont_reduce_order_avx2_6(r, p384_order, p384_mp_order); } +#if defined(HAVE_ECC_SIGN) || (defined(HAVE_ECC_VERIFY) && defined(WOLFSSL_SP_SMALL)) /* Square number mod the order of P384 curve. (r = a * a mod order) * * r Result of the squaring. @@ -48552,6 +48559,7 @@ static void sp_384_mont_inv_order_avx2_6(sp_digit* r, const sp_digit* a, #endif /* WOLFSSL_SP_SMALL */ } +#endif /* HAVE_ECC_SIGN || (HAVE_ECC_VERIFY && WOLFSSL_SP_SMALL) */ #endif /* HAVE_INTEL_AVX2 */ #endif /* HAVE_ECC_SIGN | HAVE_ECC_VERIFY */ #ifdef HAVE_ECC_SIGN diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 4b6c80bb5..74aa48ce7 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -22976,7 +22976,8 @@ static int ecc_def_curve_test(WC_RNG *rng) #else ecc_key key[1]; #endif -#if defined(HAVE_ECC_KEY_IMPORT) && defined(HAVE_ECC_KEY_EXPORT) +#if (defined(HAVE_ECC_KEY_IMPORT) && defined(HAVE_ECC_KEY_EXPORT)) || \ + (defined(HAVE_ECC_KEY_IMPORT) && !defined(WOLFSSL_VALIDATE_ECC_IMPORT)) word32 idx = 0; #endif