diff --git a/ed25519-donna/curve25519-donna-32bit.h b/ed25519-donna/curve25519-donna-32bit.h index 16606fcfe..6a4e9c3ab 100644 --- a/ed25519-donna/curve25519-donna-32bit.h +++ b/ed25519-donna/curve25519-donna-32bit.h @@ -541,39 +541,6 @@ curve25519_contract(unsigned char out[32], const bignum25519 in) { #undef F } -/* out = (flag) ? in : out */ -DONNA_INLINE static void -curve25519_move_conditional_bytes(uint8_t out[96], const uint8_t in[96], uint32_t flag) { - const uint32_t nb = flag - 1, b = ~nb; - const uint32_t *inl = (const uint32_t *)in; - uint32_t *outl = (uint32_t *)out; - outl[0] = (outl[0] & nb) | (inl[0] & b); - outl[1] = (outl[1] & nb) | (inl[1] & b); - outl[2] = (outl[2] & nb) | (inl[2] & b); - outl[3] = (outl[3] & nb) | (inl[3] & b); - outl[4] = (outl[4] & nb) | (inl[4] & b); - outl[5] = (outl[5] & nb) | (inl[5] & b); - outl[6] = (outl[6] & nb) | (inl[6] & b); - outl[7] = (outl[7] & nb) | (inl[7] & b); - outl[8] = (outl[8] & nb) | (inl[8] & b); - outl[9] = (outl[9] & nb) | (inl[9] & b); - outl[10] = (outl[10] & nb) | (inl[10] & b); - outl[11] = (outl[11] & nb) | (inl[11] & b); - outl[12] = (outl[12] & nb) | (inl[12] & b); - outl[13] = (outl[13] & nb) | (inl[13] & b); - outl[14] = (outl[14] & nb) | (inl[14] & b); - outl[15] = (outl[15] & nb) | (inl[15] & b); - outl[16] = (outl[16] & nb) | (inl[16] & b); - outl[17] = (outl[17] & nb) | (inl[17] & b); - outl[18] = (outl[18] & nb) | (inl[18] & b); - outl[19] = (outl[19] & nb) | (inl[19] & b); - outl[20] = (outl[20] & nb) | (inl[20] & b); - outl[21] = (outl[21] & nb) | (inl[21] & b); - outl[22] = (outl[22] & nb) | (inl[22] & b); - outl[23] = (outl[23] & nb) | (inl[23] & b); - -} - /* if (iswap) swap(a, b) */ DONNA_INLINE static void curve25519_swap_conditional(bignum25519 a, bignum25519 b, uint32_t iswap) { diff --git a/ed25519-donna/ed25519-donna-impl-base.h b/ed25519-donna/ed25519-donna-impl-base.h index e2e2db895..d5472795c 100644 --- a/ed25519-donna/ed25519-donna-impl-base.h +++ b/ed25519-donna/ed25519-donna-impl-base.h @@ -29,28 +29,6 @@ ge25519_full_to_pniels(ge25519_pniels *p, const ge25519 *r) { adding & doubling */ -#if 0 // UNUSED -static void -ge25519_add_p1p1(ge25519_p1p1 *r, const ge25519 *p, const ge25519 *q) { - bignum25519 a,b,c,d,t,u; - - curve25519_sub(a, p->y, p->x); - curve25519_add(b, p->y, p->x); - curve25519_sub(t, q->y, q->x); - curve25519_add(u, q->y, q->x); - curve25519_mul(a, a, t); - curve25519_mul(b, b, u); - curve25519_mul(c, p->t, q->t); - curve25519_mul(c, c, ge25519_ec2d); - curve25519_mul(d, p->z, q->z); - curve25519_add(d, d, d); - curve25519_sub(r->x, b, a); - curve25519_add(r->y, b, a); - curve25519_add_after_basic(r->z, d, c); - curve25519_sub_after_basic(r->t, d, c); -} -#endif - static void ge25519_double_p1p1(ge25519_p1p1 *r, const ge25519 *p) { bignum25519 a,b,c; @@ -120,15 +98,6 @@ ge25519_double(ge25519 *r, const ge25519 *p) { ge25519_p1p1_to_full(r, &t); } -#if 0 // UNUSED -static void -ge25519_add(ge25519 *r, const ge25519 *p, const ge25519 *q) { - ge25519_p1p1 t; - ge25519_add_p1p1(&t, p, q); - ge25519_p1p1_to_full(r, &t); -} -#endif - static void ge25519_nielsadd2(ge25519 *r, const ge25519_niels *q) { bignum25519 a,b,c,e,f,g,h; @@ -296,42 +265,6 @@ static void ge25519_double_scalarmult_vartime(ge25519 *r, const ge25519 *p1, con } } -/* computes [s1]p1 */ -#if 0 // UNUSED -static void ge25519_scalarmult_vartime(ge25519 *r, const ge25519 *p1, const bignum256modm s1) { - signed char slide1[256]; - ge25519_pniels pre1[S1_TABLE_SIZE]; - ge25519 d1; - ge25519_p1p1 t; - int32_t i; - - contract256_slidingwindow_modm(slide1, s1, S1_SWINDOWSIZE); - - ge25519_double(&d1, p1); - ge25519_full_to_pniels(pre1, p1); - for (i = 0; i < S1_TABLE_SIZE - 1; i++) - ge25519_pnielsadd(&pre1[i+1], &d1, &pre1[i]); - - /* set neutral */ - ge25519_set_neutral(r); - - i = 255; - while ((i >= 0) && !slide1[i]) - i--; - - for (; i >= 0; i--) { - ge25519_double_p1p1(&t, r); - - if (slide1[i]) { - ge25519_p1p1_to_full(r, &t); - ge25519_pnielsadd_p1p1(&t, r, &pre1[abs(slide1[i]) / 2], (unsigned char)slide1[i] >> 7); - } - - ge25519_p1p1_to_partial(r, &t); - } -} -#endif - /* * The following conditional move stuff uses conditional moves. * I will check on which compilers this works, and provide suitable @@ -361,46 +294,6 @@ DONNA_INLINE static void ge25519_cmove_stride4(long * r, long * p, long * pos, l } #define HAS_CMOVE_STRIDE4 -DONNA_INLINE static void ge25519_cmove_stride4b(long * r, long * p, long * pos, long * n, int stride) { - long x0=p[0], x1=p[1], x2=p[2], x3=p[3], y0, y1, y2, y3; - for(p+=stride; p= 0; i--) { - int k=abs(slide1[i]); - ge25519_double_partial(r, r); - ge25519_double_partial(r, r); - ge25519_double_partial(r, r); - ge25519_double_p1p1(&t, r); - ge25519_move_conditional_pniels_array(&pre, pre1, k, 9); - ge25519_p1p1_to_full(r, &t); - ge25519_pnielsadd_p1p1(&t, r, &pre, (unsigned char)slide1[i] >> 7); - ge25519_p1p1_to_partial(r, &t); - } -} -#endif - -#if !defined(HAVE_GE25519_SCALARMULT_BASE_CHOOSE_NIELS) - -DONNA_INLINE static uint32_t -ge25519_windowb_equal(uint32_t b, uint32_t c) { - return ((b ^ c) - 1) >> 31; -} - static void ge25519_scalarmult_base_choose_niels(ge25519_niels *t, const uint8_t table[256][96], uint32_t pos, signed char b) { bignum25519 neg; @@ -481,9 +330,6 @@ ge25519_scalarmult_base_choose_niels(ge25519_niels *t, const uint8_t table[256][ curve25519_swap_conditional(t->t2d, neg, sign); } -#endif /* HAVE_GE25519_SCALARMULT_BASE_CHOOSE_NIELS */ - - /* computes [s]basepoint */ static void ge25519_scalarmult_base_niels(ge25519 *r, const uint8_t basepoint_table[256][96], const bignum256modm s) { diff --git a/ed25519-donna/ed25519-donna-portable.h b/ed25519-donna/ed25519-donna-portable.h index bb8602869..2fa0ac56e 100644 --- a/ed25519-donna/ed25519-donna-portable.h +++ b/ed25519-donna/ed25519-donna-portable.h @@ -4,8 +4,7 @@ #include #include -#define DONNA_INLINE inline __attribute__((always_inline)) -#define DONNA_NOINLINE __attribute__((noinline)) +#define DONNA_INLINE #undef ALIGN #define ALIGN(x) __attribute__((aligned(x))) #define ROTL32(a,b) (((a) << (b)) | ((a) >> (32 - b)))