From 0a05258d5f6d3eada03fd28c1a4e7ed1ae24bee4 Mon Sep 17 00:00:00 2001 From: Justin King-Lacroix Date: Wed, 10 Jun 2015 17:56:01 +0100 Subject: [PATCH] adjusted declaration locations at kmackay's request; also removed uECC_FPTR_FIXUP mechanism (not needed in new version of SDCC?) --- uECC.c | 6 +++--- uECC.h | 8 +------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/uECC.c b/uECC.c index 08aa6af..281922f 100644 --- a/uECC.c +++ b/uECC.c @@ -2215,10 +2215,10 @@ int uECC_sign(const uint8_t p_privateKey[uECC_BYTES], const uint8_t p_hash[uECC_ uECC_word_t *k2[2] = {l_tmp, s}; EccPoint p; uECC_word_t l_tries = 0; - uECC_word_t l_carry; do { + uECC_word_t l_carry; repeat: if(!g_rng((uint8_t *)k, sizeof(k)) || (l_tries++ >= MAX_TRIES)) { @@ -2251,7 +2251,7 @@ int uECC_sign(const uint8_t p_privateKey[uECC_BYTES], const uint8_t p_hash[uECC_ } /* make sure that we don't leak timing information about k. See http://eprint.iacr.org/2011/232.pdf */ - uECC_word_t l_carry = vli_add(l_tmp, k, curve_n); + l_carry = vli_add(l_tmp, k, curve_n); vli_add(s, l_tmp, curve_n); /* p = k * G */ @@ -2317,7 +2317,6 @@ int uECC_verify(const uint8_t p_publicKey[uECC_BYTES*2], const uint8_t p_hash[uE uECC_word_t tx[uECC_WORDS]; uECC_word_t ty[uECC_WORDS]; uECC_word_t tz[uECC_WORDS]; - uECC_word_t l_index; const EccPoint *l_points[4]; const EccPoint *l_point; @@ -2377,6 +2376,7 @@ int uECC_verify(const uint8_t p_publicKey[uECC_BYTES*2], const uint8_t p_hash[uE for(i = l_numBits - 2; i >= 0; --i) { + uECC_word_t l_index; EccPoint_double_jacobian(rx, ry, z); l_index = (!!vli_testBit(u1, i)) | ((!!vli_testBit(u2, i)) << 1); diff --git a/uECC.h b/uECC.h index e965d11..0a89add 100644 --- a/uECC.h +++ b/uECC.h @@ -55,12 +55,6 @@ uECC_asm_fast - Use GCC inline assembly optimized for maximum speed. */ #define uECC_BYTES uECC_CONCAT(uECC_size_, uECC_CURVE) -#if(__SDCC_mcs51) -#define uECC_FPTR_FIXUP __reentrant -#else //SDCC_mcs51 -#define uECC_FPTR_FIXUP -#endif //SDCC_mcs51 - #ifdef __cplusplus extern "C" { @@ -79,7 +73,7 @@ If you are building on another POSIX-compliant system that supports /dev/random you can define uECC_POSIX to use the predefined RNG. For embedded platforms there is no predefined RNG function; you must provide your own. */ -typedef int (*uECC_RNG_Function)(uint8_t *p_dest, unsigned p_size) uECC_FPTR_FIXUP; +typedef int (*uECC_RNG_Function)(uint8_t *p_dest, unsigned p_size); /* uECC_set_rng() function. Set the function that will be used to generate random bytes. The RNG function should