mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-29 18:27:29 +02:00
Merge pull request #4171 from SparkiDev/sp_small_fast_modexp
SP: allow fast mod_exp to be compiled for small C code
This commit is contained in:
@ -54,7 +54,7 @@
|
||||
#if SP_WORD_SIZE == 32
|
||||
#if ((!defined(WC_NO_CACHE_RESISTANT) && \
|
||||
(defined(WOLFSSL_HAVE_SP_RSA) || defined(WOLFSSL_HAVE_SP_DH))) || \
|
||||
defined(WOLFSSL_SP_SMALL)) && \
|
||||
(defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_FAST_MODEXP))) && \
|
||||
(defined(WOLFSSL_HAVE_SP_ECC) || !defined(WOLFSSL_RSA_PUBLIC_ONLY))
|
||||
/* Mask for address to obfuscate which of the two address will be used. */
|
||||
static const size_t addr_mask[2] = { 0, (size_t)-1 };
|
||||
@ -1904,7 +1904,7 @@ static int sp_2048_mod_45(sp_digit* r, const sp_digit* a, const sp_digit* m)
|
||||
static int sp_2048_mod_exp_45(sp_digit* r, const sp_digit* a, const sp_digit* e,
|
||||
int bits, const sp_digit* m, int reduceA)
|
||||
{
|
||||
#ifdef WOLFSSL_SP_SMALL
|
||||
#if defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_FAST_MODEXP)
|
||||
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_SP_NO_MALLOC)
|
||||
sp_digit* td = NULL;
|
||||
#else
|
||||
@ -2796,7 +2796,7 @@ static int sp_2048_mod_90(sp_digit* r, const sp_digit* a, const sp_digit* m)
|
||||
static int sp_2048_mod_exp_90(sp_digit* r, const sp_digit* a, const sp_digit* e,
|
||||
int bits, const sp_digit* m, int reduceA)
|
||||
{
|
||||
#ifdef WOLFSSL_SP_SMALL
|
||||
#if defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_FAST_MODEXP)
|
||||
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_SP_NO_MALLOC)
|
||||
sp_digit* td = NULL;
|
||||
#else
|
||||
@ -5776,7 +5776,7 @@ static int sp_3072_mod_67(sp_digit* r, const sp_digit* a, const sp_digit* m)
|
||||
static int sp_3072_mod_exp_67(sp_digit* r, const sp_digit* a, const sp_digit* e,
|
||||
int bits, const sp_digit* m, int reduceA)
|
||||
{
|
||||
#ifdef WOLFSSL_SP_SMALL
|
||||
#if defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_FAST_MODEXP)
|
||||
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_SP_NO_MALLOC)
|
||||
sp_digit* td = NULL;
|
||||
#else
|
||||
@ -6704,7 +6704,7 @@ static int sp_3072_mod_134(sp_digit* r, const sp_digit* a, const sp_digit* m)
|
||||
static int sp_3072_mod_exp_134(sp_digit* r, const sp_digit* a, const sp_digit* e,
|
||||
int bits, const sp_digit* m, int reduceA)
|
||||
{
|
||||
#ifdef WOLFSSL_SP_SMALL
|
||||
#if defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_FAST_MODEXP)
|
||||
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_SP_NO_MALLOC)
|
||||
sp_digit* td = NULL;
|
||||
#else
|
||||
@ -9846,7 +9846,7 @@ static int sp_4096_mod_98(sp_digit* r, const sp_digit* a, const sp_digit* m)
|
||||
static int sp_4096_mod_exp_98(sp_digit* r, const sp_digit* a, const sp_digit* e,
|
||||
int bits, const sp_digit* m, int reduceA)
|
||||
{
|
||||
#ifdef WOLFSSL_SP_SMALL
|
||||
#if defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_FAST_MODEXP)
|
||||
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_SP_NO_MALLOC)
|
||||
sp_digit* td = NULL;
|
||||
#else
|
||||
@ -10757,7 +10757,7 @@ static int sp_4096_mod_196(sp_digit* r, const sp_digit* a, const sp_digit* m)
|
||||
static int sp_4096_mod_exp_196(sp_digit* r, const sp_digit* a, const sp_digit* e,
|
||||
int bits, const sp_digit* m, int reduceA)
|
||||
{
|
||||
#ifdef WOLFSSL_SP_SMALL
|
||||
#if defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_FAST_MODEXP)
|
||||
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_SP_NO_MALLOC)
|
||||
sp_digit* td = NULL;
|
||||
#else
|
||||
|
@ -54,7 +54,7 @@
|
||||
#if SP_WORD_SIZE == 64
|
||||
#if ((!defined(WC_NO_CACHE_RESISTANT) && \
|
||||
(defined(WOLFSSL_HAVE_SP_RSA) || defined(WOLFSSL_HAVE_SP_DH))) || \
|
||||
defined(WOLFSSL_SP_SMALL)) && \
|
||||
(defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_FAST_MODEXP))) && \
|
||||
(defined(WOLFSSL_HAVE_SP_ECC) || !defined(WOLFSSL_RSA_PUBLIC_ONLY))
|
||||
/* Mask for address to obfuscate which of the two address will be used. */
|
||||
static const size_t addr_mask[2] = { 0, (size_t)-1 };
|
||||
@ -1531,7 +1531,7 @@ static int sp_2048_mod_18(sp_digit* r, const sp_digit* a, const sp_digit* m)
|
||||
static int sp_2048_mod_exp_18(sp_digit* r, const sp_digit* a, const sp_digit* e,
|
||||
int bits, const sp_digit* m, int reduceA)
|
||||
{
|
||||
#ifdef WOLFSSL_SP_SMALL
|
||||
#if defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_FAST_MODEXP)
|
||||
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_SP_NO_MALLOC)
|
||||
sp_digit* td = NULL;
|
||||
#else
|
||||
@ -2418,7 +2418,7 @@ static int sp_2048_mod_36(sp_digit* r, const sp_digit* a, const sp_digit* m)
|
||||
static int sp_2048_mod_exp_36(sp_digit* r, const sp_digit* a, const sp_digit* e,
|
||||
int bits, const sp_digit* m, int reduceA)
|
||||
{
|
||||
#ifdef WOLFSSL_SP_SMALL
|
||||
#if defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_FAST_MODEXP)
|
||||
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_SP_NO_MALLOC)
|
||||
sp_digit* td = NULL;
|
||||
#else
|
||||
@ -5765,7 +5765,7 @@ static int sp_3072_mod_27(sp_digit* r, const sp_digit* a, const sp_digit* m)
|
||||
static int sp_3072_mod_exp_27(sp_digit* r, const sp_digit* a, const sp_digit* e,
|
||||
int bits, const sp_digit* m, int reduceA)
|
||||
{
|
||||
#ifdef WOLFSSL_SP_SMALL
|
||||
#if defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_FAST_MODEXP)
|
||||
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_SP_NO_MALLOC)
|
||||
sp_digit* td = NULL;
|
||||
#else
|
||||
@ -6659,7 +6659,7 @@ static int sp_3072_mod_54(sp_digit* r, const sp_digit* a, const sp_digit* m)
|
||||
static int sp_3072_mod_exp_54(sp_digit* r, const sp_digit* a, const sp_digit* e,
|
||||
int bits, const sp_digit* m, int reduceA)
|
||||
{
|
||||
#ifdef WOLFSSL_SP_SMALL
|
||||
#if defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_FAST_MODEXP)
|
||||
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_SP_NO_MALLOC)
|
||||
sp_digit* td = NULL;
|
||||
#else
|
||||
@ -10121,7 +10121,7 @@ static int sp_4096_mod_39(sp_digit* r, const sp_digit* a, const sp_digit* m)
|
||||
static int sp_4096_mod_exp_39(sp_digit* r, const sp_digit* a, const sp_digit* e,
|
||||
int bits, const sp_digit* m, int reduceA)
|
||||
{
|
||||
#ifdef WOLFSSL_SP_SMALL
|
||||
#if defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_FAST_MODEXP)
|
||||
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_SP_NO_MALLOC)
|
||||
sp_digit* td = NULL;
|
||||
#else
|
||||
@ -11074,7 +11074,7 @@ static int sp_4096_mod_78(sp_digit* r, const sp_digit* a, const sp_digit* m)
|
||||
static int sp_4096_mod_exp_78(sp_digit* r, const sp_digit* a, const sp_digit* e,
|
||||
int bits, const sp_digit* m, int reduceA)
|
||||
{
|
||||
#ifdef WOLFSSL_SP_SMALL
|
||||
#if defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_FAST_MODEXP)
|
||||
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_SP_NO_MALLOC)
|
||||
sp_digit* td = NULL;
|
||||
#else
|
||||
|
@ -82,6 +82,7 @@ This library provides single precision (SP) integer math functions.
|
||||
* pointer is not allowed.
|
||||
* WOLFSSL_SP_NO_DYN_STACK Disable use of dynamic stack items.
|
||||
* Used with small code size and not small stack.
|
||||
* WOLFSSL_SP_FAST_MODEXP Allow fast mod_exp with small C code
|
||||
*/
|
||||
|
||||
#if defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_SP_MATH_ALL)
|
||||
|
Reference in New Issue
Block a user