From 1d232a6f86c97e603205dd539c933ee94aa8e857 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Tue, 28 Mar 2017 22:52:02 +0200 Subject: [PATCH] whitespace cleanup --- ed25519-donna/curve25519-donna-32bit.h | 2 +- ed25519-donna/curve25519-donna-scalarmult-base.h | 3 +-- ed25519-donna/ed25519-donna-32bit-tables.h | 10 +++++----- ed25519-donna/ed25519-donna-impl-base.h | 7 +++---- ed25519-donna/ed25519-donna.h | 2 -- ed25519-donna/ed25519.c | 4 ---- ed25519-donna/modm-donna-32bit.h | 4 +--- 7 files changed, 11 insertions(+), 21 deletions(-) diff --git a/ed25519-donna/curve25519-donna-32bit.h b/ed25519-donna/curve25519-donna-32bit.h index 6a4e9c3ab..d49e80ff0 100644 --- a/ed25519-donna/curve25519-donna-32bit.h +++ b/ed25519-donna/curve25519-donna-32bit.h @@ -40,7 +40,7 @@ curve25519_add(bignum25519 out, const bignum25519 a, const bignum25519 b) { out[9] = a[9] + b[9]; } -DONNA_INLINE static void +DONNA_INLINE static void curve25519_add_after_basic(bignum25519 out, const bignum25519 a, const bignum25519 b) { uint32_t c; out[0] = a[0] + b[0] ; c = (out[0] >> 26); out[0] &= reduce_mask_26; diff --git a/ed25519-donna/curve25519-donna-scalarmult-base.h b/ed25519-donna/curve25519-donna-scalarmult-base.h index 061759fa6..ff1010122 100644 --- a/ed25519-donna/curve25519-donna-scalarmult-base.h +++ b/ed25519-donna/curve25519-donna-scalarmult-base.h @@ -15,7 +15,7 @@ curve25519_scalarmult_donna(curve25519_key mypublic, const curve25519_key n, con curve25519_expand(q, basepoint); curve25519_copy(nqx, q); - /* bit 255 is always 0, and bit 254 is always 1, so skip bit 255 and + /* bit 255 is always 0, and bit 254 is always 1, so skip bit 255 and start pre-swapped on bit 254 */ lastbit = 1; @@ -63,4 +63,3 @@ curve25519_scalarmult_donna(curve25519_key mypublic, const curve25519_key n, con curve25519_mul(nqz, nqx, zmone); curve25519_contract(mypublic, nqz); } - diff --git a/ed25519-donna/ed25519-donna-32bit-tables.h b/ed25519-donna/ed25519-donna-32bit-tables.h index 49022aee2..c977c26eb 100644 --- a/ed25519-donna/ed25519-donna-32bit-tables.h +++ b/ed25519-donna/ed25519-donna-32bit-tables.h @@ -1,4 +1,4 @@ -const ge25519 ALIGN(16) ge25519_basepoint = { +static const ge25519 ALIGN(16) ge25519_basepoint = { {0x0325d51a,0x018b5823,0x00f6592a,0x0104a92d,0x01a4b31d,0x01d6dc5c,0x027118fe,0x007fd814,0x013cd6e5,0x0085a4db}, {0x02666658,0x01999999,0x00cccccc,0x01333333,0x01999999,0x00666666,0x03333333,0x00cccccc,0x02666666,0x01999999}, {0x00000001,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000}, @@ -9,11 +9,11 @@ const ge25519 ALIGN(16) ge25519_basepoint = { d */ -const bignum25519 ALIGN(16) ge25519_ecd = { +static const bignum25519 ALIGN(16) ge25519_ecd = { 0x035978a3,0x00d37284,0x03156ebd,0x006a0a0e,0x0001c029,0x0179e898,0x03a03cbb,0x01ce7198,0x02e2b6ff,0x01480db3 }; -const bignum25519 ALIGN(16) ge25519_ec2d = { +static const bignum25519 ALIGN(16) ge25519_ec2d = { 0x02b2f159,0x01a6e509,0x022add7a,0x00d4141d,0x00038052,0x00f3d130,0x03407977,0x019ce331,0x01c56dff,0x00901b67 }; @@ -21,11 +21,11 @@ const bignum25519 ALIGN(16) ge25519_ec2d = { sqrt(-1) */ -const bignum25519 ALIGN(16) ge25519_sqrtneg1 = { +static const bignum25519 ALIGN(16) ge25519_sqrtneg1 = { 0x020ea0b0,0x0186c9d2,0x008f189d,0x0035697f,0x00bd0c60,0x01fbd7a7,0x02804c9e,0x01e16569,0x0004fc1d,0x00ae0c92 }; -const ge25519_niels ALIGN(16) ge25519_niels_sliding_multiples[32] = { +static const ge25519_niels ALIGN(16) ge25519_niels_sliding_multiples[32] = { {{0x0340913e,0x000e4175,0x03d673a2,0x002e8a05,0x03f4e67c,0x008f8a09,0x00c21a34,0x004cf4b8,0x01298f81,0x0113f4be},{0x018c3b85,0x0124f1bd,0x01c325f7,0x0037dc60,0x033e4cb7,0x003d42c2,0x01a44c32,0x014ca4e1,0x03a33d4b,0x001f3e74},{0x037aaa68,0x00448161,0x0093d579,0x011e6556,0x009b67a0,0x0143598c,0x01bee5ee,0x00b50b43,0x0289f0c6,0x01bc45ed}}, {{0x00fcd265,0x0047fa29,0x034faacc,0x01ef2e0d,0x00ef4d4f,0x014bd6bd,0x00f98d10,0x014c5026,0x007555bd,0x00aae456},{0x00ee9730,0x016c2a13,0x017155e4,0x01874432,0x00096a10,0x01016732,0x01a8014f,0x011e9823,0x01b9a80f,0x01e85938},{0x01d0d889,0x01a4cfc3,0x034c4295,0x0110e1ae,0x0162508c,0x00f2db4c,0x0072a2c6,0x0098da2e,0x02f12b9b,0x0168a09a}}, {{0x0047d6ba,0x0060b0e9,0x0136eff2,0x008a5939,0x03540053,0x0064a087,0x02788e5c,0x00be7c67,0x033eb1b5,0x005529f9},{0x00a5bb33,0x00af1102,0x01a05442,0x001e3af7,0x02354123,0x00bfec44,0x01f5862d,0x00dd7ba3,0x03146e20,0x00a51733},{0x012a8285,0x00f6fc60,0x023f9797,0x003e85ee,0x009c3820,0x01bda72d,0x01b3858d,0x00d35683,0x0296b3bb,0x010eaaf9}}, diff --git a/ed25519-donna/ed25519-donna-impl-base.h b/ed25519-donna/ed25519-donna-impl-base.h index d5472795c..93257e224 100644 --- a/ed25519-donna/ed25519-donna-impl-base.h +++ b/ed25519-donna/ed25519-donna-impl-base.h @@ -6,15 +6,15 @@ DONNA_INLINE static void ge25519_p1p1_to_partial(ge25519 *r, const ge25519_p1p1 *p) { curve25519_mul(r->x, p->x, p->t); curve25519_mul(r->y, p->y, p->z); - curve25519_mul(r->z, p->z, p->t); + curve25519_mul(r->z, p->z, p->t); } DONNA_INLINE static void ge25519_p1p1_to_full(ge25519 *r, const ge25519_p1p1 *p) { curve25519_mul(r->x, p->x, p->t); curve25519_mul(r->y, p->y, p->z); - curve25519_mul(r->z, p->z, p->t); - curve25519_mul(r->t, p->x, p->y); + curve25519_mul(r->z, p->z, p->t); + curve25519_mul(r->t, p->x, p->y); } static void @@ -209,7 +209,6 @@ static int ge25519_unpack_negative_vartime(ge25519 *r, const unsigned char p[32] return 1; } - /* scalarmults */ diff --git a/ed25519-donna/ed25519-donna.h b/ed25519-donna/ed25519-donna.h index de176abad..f72cb7e66 100644 --- a/ed25519-donna/ed25519-donna.h +++ b/ed25519-donna/ed25519-donna.h @@ -8,7 +8,6 @@ Bo-Yin Yang */ - #include "ed25519-donna-portable.h" #include "curve25519-donna-32bit.h" @@ -30,7 +29,6 @@ ed25519_verify(const unsigned char *x, const unsigned char *y, size_t len) { return (int) (1 & ((differentbits - 1) >> 8)); } - /* * Arithmetic on the twisted Edwards curve -x^2 + y^2 = 1 + dx^2y^2 * with d = -(121665/121666) = 37095705934669439343138083508754565189542113879843219016388785533085940283555 diff --git a/ed25519-donna/ed25519.c b/ed25519-donna/ed25519.c index 6b13f6087..52a7f21fe 100644 --- a/ed25519-donna/ed25519.c +++ b/ed25519-donna/ed25519.c @@ -4,7 +4,6 @@ Ed25519 reference implementation using Ed25519-donna */ - #include "ed25519-donna.h" #include "ed25519.h" #include "ed25519-hash-custom.h" @@ -14,7 +13,6 @@ /* Generates a (extsk[0..31]) and aExt (extsk[32..63]) */ - DONNA_INLINE static void ed25519_extsk(hash_512bits extsk, const ed25519_secret_key sk) { ed25519_hash(extsk, sk, 32); @@ -46,7 +44,6 @@ ed25519_publickey(const ed25519_secret_key sk, ed25519_public_key pk) { ge25519_pack(pk, &A); } - void ed25519_sign(const unsigned char *m, size_t mlen, const ed25519_secret_key sk, const ed25519_public_key pk, ed25519_signature RS) { ed25519_hash_context ctx; @@ -110,7 +107,6 @@ ed25519_sign_open(const unsigned char *m, size_t mlen, const ed25519_public_key /* Fast Curve25519 basepoint scalar multiplication */ - void curved25519_scalarmult_basepoint(curved25519_key pk, const curved25519_key e) { curved25519_key ec; diff --git a/ed25519-donna/modm-donna-32bit.h b/ed25519-donna/modm-donna-32bit.h index 16fba16d4..ca691dec2 100644 --- a/ed25519-donna/modm-donna-32bit.h +++ b/ed25519-donna/modm-donna-32bit.h @@ -80,7 +80,7 @@ barrett_reduce256_modm(bignum256modm r, const bignum256modm q1, const bignum256m /* q1 = x >> 248 = 264 bits = 9 30 bit elements q2 = mu * q1 q3 = (q2 / 256(32+1)) = q2 / (2^8)^(32+1) = q2 >> 264 */ - c = mul32x32_64(modm_mu[0], q1[7]) + mul32x32_64(modm_mu[1], q1[6]) + mul32x32_64(modm_mu[2], q1[5]) + mul32x32_64(modm_mu[3], q1[4]) + mul32x32_64(modm_mu[4], q1[3]) + mul32x32_64(modm_mu[5], q1[2]) + mul32x32_64(modm_mu[6], q1[1]) + mul32x32_64(modm_mu[7], q1[0]); + c = mul32x32_64(modm_mu[0], q1[7]) + mul32x32_64(modm_mu[1], q1[6]) + mul32x32_64(modm_mu[2], q1[5]) + mul32x32_64(modm_mu[3], q1[4]) + mul32x32_64(modm_mu[4], q1[3]) + mul32x32_64(modm_mu[5], q1[2]) + mul32x32_64(modm_mu[6], q1[1]) + mul32x32_64(modm_mu[7], q1[0]); c >>= 30; c += mul32x32_64(modm_mu[0], q1[8]) + mul32x32_64(modm_mu[1], q1[7]) + mul32x32_64(modm_mu[2], q1[6]) + mul32x32_64(modm_mu[3], q1[5]) + mul32x32_64(modm_mu[4], q1[4]) + mul32x32_64(modm_mu[5], q1[3]) + mul32x32_64(modm_mu[6], q1[2]) + mul32x32_64(modm_mu[7], q1[1]) + mul32x32_64(modm_mu[8], q1[0]); f = (bignum256modm_element_t)c; q3[0] = (f >> 24) & 0x3f; c >>= 30; @@ -288,8 +288,6 @@ static void contract256_modm(unsigned char out[32], const bignum256modm in) { U32TO8_LE(out + 28, (in[7] >> 14) | (in[8] << 16)); } - - static void contract256_window4_modm(signed char r[64], const bignum256modm in) { char carry; signed char *quads = r;