Merge pull request #3537 from SparkiDev/sp_int_configs

SP math all: fixes for configurations that don't specify size
This commit is contained in:
toddouska
2020-12-09 09:16:46 -08:00
committed by GitHub
2 changed files with 13 additions and 16 deletions

View File

@ -4805,7 +4805,7 @@ int sp_mod(sp_int* a, sp_int* m, sp_int* r)
#endif #endif
#ifndef WOLFSSL_SP_SMALL #ifndef WOLFSSL_SP_SMALL
#ifndef WOLFSSL_HAVE_SP_ECC #if !defined(WOLFSSL_HAVE_SP_ECC) && defined(HAVE_ECC)
#if SP_WORD_SIZE == 64 #if SP_WORD_SIZE == 64
#ifndef SQR_MUL_ASM #ifndef SQR_MUL_ASM
/* Multiply a by b and store in r: r = a * b /* Multiply a by b and store in r: r = a * b
@ -5585,7 +5585,7 @@ int sp_mod(sp_int* a, sp_int* m, sp_int* r)
} }
#endif /* SQR_MUL_ASM */ #endif /* SQR_MUL_ASM */
#endif /* SP_WORD_SIZE == 32 */ #endif /* SP_WORD_SIZE == 32 */
#endif /* WOLFSSL_HAVE_SP_ECC */ #endif /* !WOLFSSL_HAVE_SP_ECC && HAVE_ECC */
#if defined(SQR_MUL_ASM) && defined(WOLFSSL_SP_INT_LARGE_COMBA) #if defined(SQR_MUL_ASM) && defined(WOLFSSL_SP_INT_LARGE_COMBA)
#if SP_INT_DIGITS >= 32 #if SP_INT_DIGITS >= 32
@ -7579,7 +7579,7 @@ int sp_mul(sp_int* a, sp_int* b, sp_int* r)
} }
else else
#ifndef WOLFSSL_SP_SMALL #ifndef WOLFSSL_SP_SMALL
#ifndef WOLFSSL_HAVE_SP_ECC #if !defined(WOLFSSL_HAVE_SP_ECC) && defined(HAVE_ECC)
#if SP_WORD_SIZE == 64 #if SP_WORD_SIZE == 64
if ((a->used == 4) && (b->used == 4)) { if ((a->used == 4) && (b->used == 4)) {
err = _sp_mul_4(a, b, r); err = _sp_mul_4(a, b, r);
@ -7610,7 +7610,7 @@ int sp_mul(sp_int* a, sp_int* b, sp_int* r)
else else
#endif /* SQR_MUL_ASM */ #endif /* SQR_MUL_ASM */
#endif /* SP_WORD_SIZE == 32 */ #endif /* SP_WORD_SIZE == 32 */
#endif /* WOLFSSL_HAVE_SP_ECC */ #endif /* !WOLFSSL_HAVE_SP_ECC && HAVE_ECC */
#if defined(SQR_MUL_ASM) && defined(WOLFSSL_SP_INT_LARGE_COMBA) #if defined(SQR_MUL_ASM) && defined(WOLFSSL_SP_INT_LARGE_COMBA)
#if SP_INT_DIGITS >= 32 #if SP_INT_DIGITS >= 32
if ((a->used == 16) && (b->used == 16)) { if ((a->used == 16) && (b->used == 16)) {
@ -9515,10 +9515,10 @@ int sp_mul_2d(sp_int* a, int e, sp_int* r)
return err; return err;
} }
#endif /* SQR_MUL_ASM */ #endif /* SQR_MUL_ASM */
#endif #endif /* !WOLFSSL_SP_MATH || !WOLFSSL_SP_SMALL */
#ifndef WOLFSSL_SP_SMALL #ifndef WOLFSSL_SP_SMALL
#ifndef WOLFSSL_HAVE_SP_ECC #if !defined(WOLFSSL_HAVE_SP_ECC) && defined(HAVE_ECC)
#if SP_WORD_SIZE == 64 #if SP_WORD_SIZE == 64
#ifndef SQR_MUL_ASM #ifndef SQR_MUL_ASM
/* Square a and store in r. r = a * a /* Square a and store in r. r = a * a
@ -9646,10 +9646,6 @@ int sp_mul_2d(sp_int* a, int e, sp_int* r)
#else #else
sp_int t[1]; sp_int t[1];
#endif #endif
#ifdef WOLFSSL_SP_PPC
tl = 0;
th = 0;
#endif
#ifdef WOLFSSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
if (err == MP_OKAY) { if (err == MP_OKAY) {
@ -10210,7 +10206,7 @@ int sp_mul_2d(sp_int* a, int e, sp_int* r)
} }
#endif /* SQR_MUL_ASM */ #endif /* SQR_MUL_ASM */
#endif /* SP_WORD_SIZE == 32 */ #endif /* SP_WORD_SIZE == 32 */
#endif /* WOLFSSL_HAVE_SP_ECC */ #endif /* !WOLFSSL_HAVE_SP_ECC && HAVE_ECC */
#if defined(SQR_MUL_ASM) && defined(WOLFSSL_SP_INT_LARGE_COMBA) #if defined(SQR_MUL_ASM) && defined(WOLFSSL_SP_INT_LARGE_COMBA)
#if SP_INT_DIGITS >= 32 #if SP_INT_DIGITS >= 32
@ -11763,7 +11759,7 @@ int sp_sqr(sp_int* a, sp_int* r)
} }
else else
#ifndef WOLFSSL_SP_SMALL #ifndef WOLFSSL_SP_SMALL
#ifndef WOLFSSL_HAVE_SP_ECC #if !defined(WOLFSSL_HAVE_SP_ECC) && defined(HAVE_ECC)
#if SP_WORD_SIZE == 64 #if SP_WORD_SIZE == 64
if (a->used == 4) { if (a->used == 4) {
err = _sp_sqr_4(a, r); err = _sp_sqr_4(a, r);
@ -11794,7 +11790,7 @@ int sp_sqr(sp_int* a, sp_int* r)
else else
#endif /* SQR_MUL_ASM */ #endif /* SQR_MUL_ASM */
#endif /* SP_WORD_SIZE == 32 */ #endif /* SP_WORD_SIZE == 32 */
#endif /* WOLFSSL_HAVE_SP_ECC */ #endif /* !WOLFSSL_HAVE_SP_ECC && HAVE_ECC */
#if defined(SQR_MUL_ASM) && defined(WOLFSSL_SP_INT_LARGE_COMBA) #if defined(SQR_MUL_ASM) && defined(WOLFSSL_SP_INT_LARGE_COMBA)
#if SP_INT_DIGITS >= 32 #if SP_INT_DIGITS >= 32
if (a->used == 16) { if (a->used == 16) {
@ -11850,7 +11846,7 @@ int sp_sqr(sp_int* a, sp_int* r)
} }
return err; return err;
#endif #endif /* WOLFSSL_SP_MATH && WOLFSSL_SP_SMALL */
} }
/* END SP_SQR implementations */ /* END SP_SQR implementations */
#endif /* WOLFSSL_SP_MATH_ALL || WOLFSSL_HAVE_SP_DH || HAVE_ECC || #endif /* WOLFSSL_SP_MATH_ALL || WOLFSSL_HAVE_SP_DH || HAVE_ECC ||

View File

@ -331,8 +331,9 @@ typedef struct sp_ecc_ctx {
#define SP_INT_DIGITS (( 256 + SP_WORD_SIZE) / SP_WORD_SIZE) #define SP_INT_DIGITS (( 256 + SP_WORD_SIZE) / SP_WORD_SIZE)
#endif #endif
#elif !defined(WOLFSSL_HAVE_SP_RSA) && !defined(WOLFSSL_HAVE_SP_DH) #elif !defined(WOLFSSL_HAVE_SP_RSA) && !defined(WOLFSSL_HAVE_SP_DH)
#if !defined(NO_PWDBASED) && defined(WOLFSSL_SHA512) #ifdef WOLFSSL_SP_MATH_ALL
#define SP_INT_DIGITS (( 512 + SP_WORD_SIZE) / SP_WORD_SIZE) #define SP_INT_DIGITS \
((2 * ( 521 + SP_WORD_SIZE) + SP_WORD_SIZE) / SP_WORD_SIZE)
#elif defined(WOLFSSL_SP_384) #elif defined(WOLFSSL_SP_384)
#define SP_INT_DIGITS (( 768 + SP_WORD_SIZE) / SP_WORD_SIZE) #define SP_INT_DIGITS (( 768 + SP_WORD_SIZE) / SP_WORD_SIZE)
#else #else