forked from wolfSSL/wolfssl
Fixed math for FP_MAX_BITS_ECC calculations. Error in alignment check. Altered non-aligned formula to be (max bits * 2) + digit, then 8-bit aligned. Cleanup of the example user_settings.h.
This commit is contained in:
@@ -79,12 +79,13 @@ extern "C" {
|
|||||||
#define ECC_TIMING_RESISTANT
|
#define ECC_TIMING_RESISTANT
|
||||||
|
|
||||||
#ifdef USE_FAST_MATH
|
#ifdef USE_FAST_MATH
|
||||||
/* Max ECC bits (curve size * 8). ECC256 is (32*8) = 256 */
|
/* use reduced size math buffers for ecc points */
|
||||||
/* Note: ECC521 requires (curve size * 16): (66*16) = 1056 */
|
|
||||||
#undef ALT_ECC_SIZE
|
#undef ALT_ECC_SIZE
|
||||||
#define ALT_ECC_SIZE
|
#define ALT_ECC_SIZE
|
||||||
|
|
||||||
|
/* optionally override the default max ecc bits */
|
||||||
#undef FP_MAX_BITS_ECC
|
#undef FP_MAX_BITS_ECC
|
||||||
#define FP_MAX_BITS_ECC 1056
|
//#define FP_MAX_BITS_ECC 512
|
||||||
|
|
||||||
/* Enable TFM optimizations for ECC */
|
/* Enable TFM optimizations for ECC */
|
||||||
#define TFM_ECC192
|
#define TFM_ECC192
|
||||||
|
@@ -114,12 +114,12 @@ typedef struct {
|
|||||||
/* determine max bits required for ECC math */
|
/* determine max bits required for ECC math */
|
||||||
#ifndef FP_MAX_BITS_ECC
|
#ifndef FP_MAX_BITS_ECC
|
||||||
/* check alignment */
|
/* check alignment */
|
||||||
#if ((MAX_ECC_BITS & CHAR_BIT) == 0)
|
#if (MAX_ECC_BITS % CHAR_BIT) == 0
|
||||||
/* max bits is double */
|
/* max bits is double */
|
||||||
#define FP_MAX_BITS_ECC (MAX_ECC_BITS * 2)
|
#define FP_MAX_BITS_ECC (MAX_ECC_BITS * 2)
|
||||||
#else
|
#else
|
||||||
/* max bits is rounded up to 8-bit alignment, doubled, plus one digit of fudge */
|
/* max bits is doubled, plus one digit of fudge then 8-bit aligned */
|
||||||
#define FP_MAX_BITS_ECC ((((MAX_ECC_BITS + CHAR_BIT) & ~CHAR_BIT) * 2) + DIGIT_BIT)
|
#define FP_MAX_BITS_ECC (((MAX_ECC_BITS * 2) + DIGIT_BIT) & ~(CHAR_BIT-1))
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user