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:
David Garske 2016-05-09 10:34:37 -07:00
parent 8c9b8a596a
commit 8f6352725a
2 changed files with 7 additions and 6 deletions

View File

@ -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

View File

@ -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