diff --git a/IDE/ROWLEY-CROSSWORKS-ARM/user_settings.h b/IDE/ROWLEY-CROSSWORKS-ARM/user_settings.h index 7947ef34e..f8d751ff0 100644 --- a/IDE/ROWLEY-CROSSWORKS-ARM/user_settings.h +++ b/IDE/ROWLEY-CROSSWORKS-ARM/user_settings.h @@ -79,12 +79,13 @@ extern "C" { #define ECC_TIMING_RESISTANT #ifdef USE_FAST_MATH - /* Max ECC bits (curve size * 8). ECC256 is (32*8) = 256 */ - /* Note: ECC521 requires (curve size * 16): (66*16) = 1056 */ + /* use reduced size math buffers for ecc points */ #undef ALT_ECC_SIZE #define ALT_ECC_SIZE + + /* optionally override the default max ecc bits */ #undef FP_MAX_BITS_ECC - #define FP_MAX_BITS_ECC 1056 + //#define FP_MAX_BITS_ECC 512 /* Enable TFM optimizations for ECC */ #define TFM_ECC192 diff --git a/wolfssl/wolfcrypt/ecc.h b/wolfssl/wolfcrypt/ecc.h index f9ca3b41a..a1bc1f61a 100644 --- a/wolfssl/wolfcrypt/ecc.h +++ b/wolfssl/wolfcrypt/ecc.h @@ -114,12 +114,12 @@ typedef struct { /* determine max bits required for ECC math */ #ifndef FP_MAX_BITS_ECC /* check alignment */ - #if ((MAX_ECC_BITS & CHAR_BIT) == 0) + #if (MAX_ECC_BITS % CHAR_BIT) == 0 /* max bits is double */ #define FP_MAX_BITS_ECC (MAX_ECC_BITS * 2) #else - /* max bits is rounded up to 8-bit alignment, doubled, plus one digit of fudge */ - #define FP_MAX_BITS_ECC ((((MAX_ECC_BITS + CHAR_BIT) & ~CHAR_BIT) * 2) + DIGIT_BIT) + /* max bits is doubled, plus one digit of fudge then 8-bit aligned */ + #define FP_MAX_BITS_ECC (((MAX_ECC_BITS * 2) + DIGIT_BIT) & ~(CHAR_BIT-1)) #endif #endif