Commit 0a5e2524 authored by Dmitry Baryshkov's avatar Dmitry Baryshkov Committed by Niels Möller

ecc: rename functions to contain curve names instead of bits

Rename curve functions to use curve names instead of just bits.
Otherwise function names can easily become confusing after adding other
curves.
Signed-off-by: Dmitry Baryshkov's avatarDmitry Eremin-Solenikov <dbaryshkov@gmail.com>
parent 34fbd991
...@@ -49,11 +49,11 @@ define(<H1>, <T1>) ...@@ -49,11 +49,11 @@ define(<H1>, <T1>)
define(<C2>, <HP>) define(<C2>, <HP>)
define(<C4>, <r12>) define(<C4>, <r12>)
C ecc_192_modp (const struct ecc_modulo *m, mp_limb_t *rp) C ecc_secp192r1_modp (const struct ecc_modulo *m, mp_limb_t *rp)
.text .text
.align 2 .align 2
PROLOGUE(_nettle_ecc_192_modp) PROLOGUE(_nettle_ecc_secp192r1_modp)
push {r4,r5,r6,r7,r8,r10} push {r4,r5,r6,r7,r8,r10}
C Reduce two words at a time C Reduce two words at a time
add HP, RP, #48 add HP, RP, #48
...@@ -103,4 +103,4 @@ PROLOGUE(_nettle_ecc_192_modp) ...@@ -103,4 +103,4 @@ PROLOGUE(_nettle_ecc_192_modp)
pop {r4,r5,r6,r7,r8,r10} pop {r4,r5,r6,r7,r8,r10}
bx lr bx lr
EPILOGUE(_nettle_ecc_192_modp) EPILOGUE(_nettle_ecc_secp192r1_modp)
...@@ -48,11 +48,11 @@ define(<L0>, <r11>) ...@@ -48,11 +48,11 @@ define(<L0>, <r11>)
define(<L1>, <r12>) define(<L1>, <r12>)
define(<L2>, <lr>) define(<L2>, <lr>)
C ecc_224_modp (const struct ecc_modulo *m, mp_limb_t *rp) C ecc_secp224r1_modp (const struct ecc_modulo *m, mp_limb_t *rp)
.text .text
.align 2 .align 2
PROLOGUE(_nettle_ecc_224_modp) PROLOGUE(_nettle_ecc_secp224r1_modp)
push {r4,r5,r6,r7,r8,r10,r11,lr} push {r4,r5,r6,r7,r8,r10,r11,lr}
add L2, RP, #28 add L2, RP, #28
...@@ -121,4 +121,4 @@ PROLOGUE(_nettle_ecc_224_modp) ...@@ -121,4 +121,4 @@ PROLOGUE(_nettle_ecc_224_modp)
stmdb RP, {T0,T1,T2,T3,T4,T5,T6} stmdb RP, {T0,T1,T2,T3,T4,T5,T6}
pop {r4,r5,r6,r7,r8,r10,r11,pc} pop {r4,r5,r6,r7,r8,r10,r11,pc}
EPILOGUE(_nettle_ecc_224_modp) EPILOGUE(_nettle_ecc_secp224r1_modp)
...@@ -48,11 +48,11 @@ define(<F1>, <r11>) ...@@ -48,11 +48,11 @@ define(<F1>, <r11>)
define(<F2>, <r12>) define(<F2>, <r12>)
define(<F3>, <lr>) define(<F3>, <lr>)
C ecc_256_redc (const struct ecc_modulo *m, mp_limb_t *rp) C ecc_secp256r1_redc (const struct ecc_modulo *m, mp_limb_t *rp)
.text .text
.align 2 .align 2
PROLOGUE(_nettle_ecc_256_redc) PROLOGUE(_nettle_ecc_secp256r1_redc)
push {r4,r5,r6,r7,r8,r10,r11,lr} push {r4,r5,r6,r7,r8,r10,r11,lr}
ldm RP!, {T0,T1,T2,T3,T4,T5,T6,T7} ldm RP!, {T0,T1,T2,T3,T4,T5,T6,T7}
...@@ -170,4 +170,4 @@ PROLOGUE(_nettle_ecc_256_redc) ...@@ -170,4 +170,4 @@ PROLOGUE(_nettle_ecc_256_redc)
stm RP, {T0,T1,T2,T3,T4,T5,T6,T7} stm RP, {T0,T1,T2,T3,T4,T5,T6,T7}
pop {r4,r5,r6,r7,r8,r10,r11,pc} pop {r4,r5,r6,r7,r8,r10,r11,pc}
EPILOGUE(_nettle_ecc_256_redc) EPILOGUE(_nettle_ecc_secp256r1_redc)
...@@ -46,11 +46,11 @@ define(<F4>, <r10>) ...@@ -46,11 +46,11 @@ define(<F4>, <r10>)
define(<N>, <r12>) define(<N>, <r12>)
define(<H>, <lr>) define(<H>, <lr>)
C ecc_384_modp (const struct ecc_modulo *m, mp_limb_t *rp) C ecc_secp384r1_modp (const struct ecc_modulo *m, mp_limb_t *rp)
.text .text
.align 2 .align 2
PROLOGUE(_nettle_ecc_384_modp) PROLOGUE(_nettle_ecc_secp384r1_modp)
push {r4,r5,r6,r7,r8,r10,lr} push {r4,r5,r6,r7,r8,r10,lr}
add RP, RP, #80 add RP, RP, #80
...@@ -267,4 +267,4 @@ PROLOGUE(_nettle_ecc_384_modp) ...@@ -267,4 +267,4 @@ PROLOGUE(_nettle_ecc_384_modp)
adcs T3, T3, H adcs T3, T3, H
stm RP!, {T0,T1,T2,T3} C 8-11 stm RP!, {T0,T1,T2,T3} C 8-11
pop {r4,r5,r6,r7,r8,r10,pc} pop {r4,r5,r6,r7,r8,r10,pc}
EPILOGUE(_nettle_ecc_384_modp) EPILOGUE(_nettle_ecc_secp384r1_modp)
...@@ -45,14 +45,14 @@ define(<F3>, <r8>) ...@@ -45,14 +45,14 @@ define(<F3>, <r8>)
define(<H>, <r12>) define(<H>, <r12>)
define(<N>, <lr>) define(<N>, <lr>)
C ecc_521_modp (const struct ecc_modulo *m, mp_limb_t *rp) C ecc_secp521r1_modp (const struct ecc_modulo *m, mp_limb_t *rp)
.text .text
.Lc511: .Lc511:
.int 511 .int 511
.align 2 .align 2
PROLOGUE(_nettle_ecc_521_modp) PROLOGUE(_nettle_ecc_secp521r1_modp)
push {r4,r5,r6,r7,r8,lr} push {r4,r5,r6,r7,r8,lr}
C Use that B^17 = 2^23 (mod p) C Use that B^17 = 2^23 (mod p)
...@@ -124,4 +124,4 @@ PROLOGUE(_nettle_ecc_521_modp) ...@@ -124,4 +124,4 @@ PROLOGUE(_nettle_ecc_521_modp)
stm RP, {T0,T1,T2,F0,F1,F2,F3,H} C 9-16 stm RP, {T0,T1,T2,F0,F1,F2,F3,H} C 9-16
pop {r4,r5,r6,r7,r8,pc} pop {r4,r5,r6,r7,r8,pc}
EPILOGUE(_nettle_ecc_521_modp) EPILOGUE(_nettle_ecc_secp521r1_modp)
...@@ -572,18 +572,18 @@ AH_VERBATIM([HAVE_NATIVE], ...@@ -572,18 +572,18 @@ AH_VERBATIM([HAVE_NATIVE],
[/* Define to 1 each of the following for which a native (ie. CPU specific) [/* Define to 1 each of the following for which a native (ie. CPU specific)
implementation of the corresponding routine exists. */ implementation of the corresponding routine exists. */
#undef HAVE_NATIVE_chacha_core #undef HAVE_NATIVE_chacha_core
#undef HAVE_NATIVE_ecc_192_modp #undef HAVE_NATIVE_ecc_curve25519_modp
#undef HAVE_NATIVE_ecc_192_redc
#undef HAVE_NATIVE_ecc_224_modp
#undef HAVE_NATIVE_ecc_224_redc
#undef HAVE_NATIVE_ecc_25519_modp
#undef HAVE_NATIVE_ecc_256_modp
#undef HAVE_NATIVE_ecc_256_redc
#undef HAVE_NATIVE_ecc_384_modp
#undef HAVE_NATIVE_ecc_384_redc
#undef HAVE_NATIVE_ecc_curve448_modp #undef HAVE_NATIVE_ecc_curve448_modp
#undef HAVE_NATIVE_ecc_521_modp #undef HAVE_NATIVE_ecc_secp192r1_modp
#undef HAVE_NATIVE_ecc_521_redc #undef HAVE_NATIVE_ecc_secp192r1_redc
#undef HAVE_NATIVE_ecc_secp224r1_modp
#undef HAVE_NATIVE_ecc_secp224r1_redc
#undef HAVE_NATIVE_ecc_secp256r1_modp
#undef HAVE_NATIVE_ecc_secp256r1_redc
#undef HAVE_NATIVE_ecc_secp384r1_modp
#undef HAVE_NATIVE_ecc_secp384r1_redc
#undef HAVE_NATIVE_ecc_secp521r1_modp
#undef HAVE_NATIVE_ecc_secp521r1_redc
#undef HAVE_NATIVE_gcm_hash8 #undef HAVE_NATIVE_gcm_hash8
#undef HAVE_NATIVE_salsa20_core #undef HAVE_NATIVE_salsa20_core
#undef HAVE_NATIVE_sha1_compress #undef HAVE_NATIVE_sha1_compress
......
...@@ -46,11 +46,11 @@ ...@@ -46,11 +46,11 @@
#define PHIGH_BITS (GMP_NUMB_BITS * ECC_LIMB_SIZE - 255) #define PHIGH_BITS (GMP_NUMB_BITS * ECC_LIMB_SIZE - 255)
#if HAVE_NATIVE_ecc_25519_modp #if HAVE_NATIVE_ecc_curve25519_modp
#define ecc_25519_modp _nettle_ecc_25519_modp #define ecc_curve25519_modp _nettle_ecc_curve25519_modp
void void
ecc_25519_modp (const struct ecc_modulo *m, mp_limb_t *rp); ecc_curve25519_modp (const struct ecc_modulo *m, mp_limb_t *rp);
#else #else
#if PHIGH_BITS == 0 #if PHIGH_BITS == 0
...@@ -58,7 +58,7 @@ ecc_25519_modp (const struct ecc_modulo *m, mp_limb_t *rp); ...@@ -58,7 +58,7 @@ ecc_25519_modp (const struct ecc_modulo *m, mp_limb_t *rp);
#endif #endif
static void static void
ecc_25519_modp(const struct ecc_modulo *m UNUSED, mp_limb_t *rp) ecc_curve25519_modp(const struct ecc_modulo *m UNUSED, mp_limb_t *rp)
{ {
mp_limb_t hi, cy; mp_limb_t hi, cy;
...@@ -69,7 +69,7 @@ ecc_25519_modp(const struct ecc_modulo *m UNUSED, mp_limb_t *rp) ...@@ -69,7 +69,7 @@ ecc_25519_modp(const struct ecc_modulo *m UNUSED, mp_limb_t *rp)
rp[ECC_LIMB_SIZE-1] = (hi & (GMP_NUMB_MASK >> PHIGH_BITS)) rp[ECC_LIMB_SIZE-1] = (hi & (GMP_NUMB_MASK >> PHIGH_BITS))
+ sec_add_1 (rp, rp, ECC_LIMB_SIZE - 1, 19 * cy); + sec_add_1 (rp, rp, ECC_LIMB_SIZE - 1, 19 * cy);
} }
#endif /* HAVE_NATIVE_ecc_25519_modp */ #endif /* HAVE_NATIVE_ecc_curve25519_modp */
#define QHIGH_BITS (GMP_NUMB_BITS * ECC_LIMB_SIZE - 252) #define QHIGH_BITS (GMP_NUMB_BITS * ECC_LIMB_SIZE - 252)
...@@ -78,7 +78,7 @@ ecc_25519_modp(const struct ecc_modulo *m UNUSED, mp_limb_t *rp) ...@@ -78,7 +78,7 @@ ecc_25519_modp(const struct ecc_modulo *m UNUSED, mp_limb_t *rp)
#endif #endif
static void static void
ecc_25519_modq (const struct ecc_modulo *q, mp_limb_t *rp) ecc_curve25519_modq (const struct ecc_modulo *q, mp_limb_t *rp)
{ {
mp_size_t n; mp_size_t n;
mp_limb_t cy; mp_limb_t cy;
...@@ -180,7 +180,7 @@ ecc_mod_pow_252m3 (const struct ecc_modulo *m, ...@@ -180,7 +180,7 @@ ecc_mod_pow_252m3 (const struct ecc_modulo *m,
/* Needs 5*ECC_LIMB_SIZE scratch space. */ /* Needs 5*ECC_LIMB_SIZE scratch space. */
#define ECC_25519_INV_ITCH (5*ECC_LIMB_SIZE) #define ECC_25519_INV_ITCH (5*ECC_LIMB_SIZE)
static void ecc_25519_inv (const struct ecc_modulo *p, static void ecc_curve25519_inv (const struct ecc_modulo *p,
mp_limb_t *rp, const mp_limb_t *ap, mp_limb_t *rp, const mp_limb_t *ap,
mp_limb_t *scratch) mp_limb_t *scratch)
{ {
...@@ -203,7 +203,7 @@ static void ecc_25519_inv (const struct ecc_modulo *p, ...@@ -203,7 +203,7 @@ static void ecc_25519_inv (const struct ecc_modulo *p,
/* First, do a canonical reduction, then check if zero */ /* First, do a canonical reduction, then check if zero */
static int static int
ecc_25519_zero_p (const struct ecc_modulo *p, mp_limb_t *xp) ecc_curve25519_zero_p (const struct ecc_modulo *p, mp_limb_t *xp)
{ {
mp_limb_t cy; mp_limb_t cy;
mp_limb_t w; mp_limb_t w;
...@@ -239,7 +239,7 @@ ecc_25519_zero_p (const struct ecc_modulo *p, mp_limb_t *xp) ...@@ -239,7 +239,7 @@ ecc_25519_zero_p (const struct ecc_modulo *p, mp_limb_t *xp)
#define ECC_25519_SQRT_ITCH (9*ECC_LIMB_SIZE) #define ECC_25519_SQRT_ITCH (9*ECC_LIMB_SIZE)
static int static int
ecc_25519_sqrt(const struct ecc_modulo *p, mp_limb_t *rp, ecc_curve25519_sqrt(const struct ecc_modulo *p, mp_limb_t *rp,
const mp_limb_t *up, const mp_limb_t *vp, const mp_limb_t *up, const mp_limb_t *vp,
mp_limb_t *scratch) mp_limb_t *scratch)
{ {
...@@ -271,9 +271,9 @@ ecc_25519_sqrt(const struct ecc_modulo *p, mp_limb_t *rp, ...@@ -271,9 +271,9 @@ ecc_25519_sqrt(const struct ecc_modulo *p, mp_limb_t *rp,
ecc_mod_sqr (p, x2, rp); ecc_mod_sqr (p, x2, rp);
ecc_mod_mul (p, vx2, x2, vp); ecc_mod_mul (p, vx2, x2, vp);
ecc_mod_add (p, t0, vx2, up); ecc_mod_add (p, t0, vx2, up);
neg = ecc_25519_zero_p (p, t0); neg = ecc_curve25519_zero_p (p, t0);
ecc_mod_sub (p, t0, up, vx2); ecc_mod_sub (p, t0, up, vx2);
pos = ecc_25519_zero_p (p, t0); pos = ecc_curve25519_zero_p (p, t0);
ecc_mod_mul (p, t0, rp, ecc_sqrt_z); ecc_mod_mul (p, t0, rp, ecc_sqrt_z);
cnd_copy (neg, rp, t0, ECC_LIMB_SIZE); cnd_copy (neg, rp, t0, ECC_LIMB_SIZE);
...@@ -306,10 +306,10 @@ const struct ecc_curve _nettle_curve25519 = ...@@ -306,10 +306,10 @@ const struct ecc_curve _nettle_curve25519 =
NULL, NULL,
ecc_pp1h, ecc_pp1h,
ecc_25519_modp, ecc_curve25519_modp,
ecc_25519_modp, ecc_curve25519_modp,
ecc_25519_inv, ecc_curve25519_inv,
ecc_25519_sqrt, ecc_curve25519_sqrt,
}, },
{ {
253, 253,
...@@ -325,8 +325,8 @@ const struct ecc_curve _nettle_curve25519 = ...@@ -325,8 +325,8 @@ const struct ecc_curve _nettle_curve25519 =
NULL, NULL,
ecc_qp1h, ecc_qp1h,
ecc_25519_modq, ecc_curve25519_modq,
ecc_25519_modq, ecc_curve25519_modq,
ecc_mod_inv, ecc_mod_inv,
NULL, NULL,
}, },
......
...@@ -46,12 +46,12 @@ ...@@ -46,12 +46,12 @@
#include "ecc-curve448.h" #include "ecc-curve448.h"
#if HAVE_NATIVE_ecc_curve448_modp #if HAVE_NATIVE_ecc_curve448_modp
#define ecc_448_modp _nettle_ecc_curve448_modp #define ecc_curve448_modp _nettle_ecc_curve448_modp
void void
ecc_448_modp (const struct ecc_modulo *m, mp_limb_t *rp); ecc_curve448_modp (const struct ecc_modulo *m, mp_limb_t *rp);
#elif GMP_NUMB_BITS == 64 #elif GMP_NUMB_BITS == 64
static void static void
ecc_448_modp(const struct ecc_modulo *m, mp_limb_t *rp) ecc_curve448_modp(const struct ecc_modulo *m, mp_limb_t *rp)
{ {
/* Let B = 2^64, b = 2^32 = sqrt(B). /* Let B = 2^64, b = 2^32 = sqrt(B).
p = B^7 - b B^3 - 1 ==> B^7 = b B^3 + 1 p = B^7 - b B^3 - 1 ==> B^7 = b B^3 + 1
...@@ -95,7 +95,7 @@ ecc_448_modp(const struct ecc_modulo *m, mp_limb_t *rp) ...@@ -95,7 +95,7 @@ ecc_448_modp(const struct ecc_modulo *m, mp_limb_t *rp)
assert (c7 == 0); assert (c7 == 0);
} }
#else #else
#define ecc_448_modp ecc_mod #define ecc_curve448_modp ecc_mod
#endif #endif
/* Needs 2*ecc->size limbs at rp, and 2*ecc->size additional limbs of /* Needs 2*ecc->size limbs at rp, and 2*ecc->size additional limbs of
...@@ -175,9 +175,9 @@ ecc_mod_pow_446m224m1 (const struct ecc_modulo *p, ...@@ -175,9 +175,9 @@ ecc_mod_pow_446m224m1 (const struct ecc_modulo *p,
#undef t2 #undef t2
} }
#define ECC_448_INV_ITCH (5*ECC_LIMB_SIZE) #define ECC_CURVE448_INV_ITCH (5*ECC_LIMB_SIZE)
static void ecc_448_inv (const struct ecc_modulo *p, static void ecc_curve448_inv (const struct ecc_modulo *p,
mp_limb_t *rp, const mp_limb_t *ap, mp_limb_t *rp, const mp_limb_t *ap,
mp_limb_t *scratch) mp_limb_t *scratch)
{ {
...@@ -194,7 +194,7 @@ static void ecc_448_inv (const struct ecc_modulo *p, ...@@ -194,7 +194,7 @@ static void ecc_448_inv (const struct ecc_modulo *p,
/* First, do a canonical reduction, then check if zero */ /* First, do a canonical reduction, then check if zero */
static int static int
ecc_448_zero_p (const struct ecc_modulo *p, mp_limb_t *xp) ecc_curve448_zero_p (const struct ecc_modulo *p, mp_limb_t *xp)
{ {
mp_limb_t cy; mp_limb_t cy;
mp_limb_t w; mp_limb_t w;
...@@ -217,10 +217,10 @@ ecc_448_zero_p (const struct ecc_modulo *p, mp_limb_t *xp) ...@@ -217,10 +217,10 @@ ecc_448_zero_p (const struct ecc_modulo *p, mp_limb_t *xp)
*/ */
/* Needs 4*n space + scratch for ecc_mod_pow_446m224m1. */ /* Needs 4*n space + scratch for ecc_mod_pow_446m224m1. */
#define ECC_448_SQRT_ITCH (9*ECC_LIMB_SIZE) #define ECC_CURVE448_SQRT_ITCH (9*ECC_LIMB_SIZE)
static int static int
ecc_448_sqrt(const struct ecc_modulo *p, mp_limb_t *rp, ecc_curve448_sqrt(const struct ecc_modulo *p, mp_limb_t *rp,
const mp_limb_t *up, const mp_limb_t *vp, const mp_limb_t *up, const mp_limb_t *vp,
mp_limb_t *scratch) mp_limb_t *scratch)
{ {
...@@ -253,7 +253,7 @@ ecc_448_sqrt(const struct ecc_modulo *p, mp_limb_t *rp, ...@@ -253,7 +253,7 @@ ecc_448_sqrt(const struct ecc_modulo *p, mp_limb_t *rp,
ecc_mod_mul (p, vx2, x2, vp); ecc_mod_mul (p, vx2, x2, vp);
ecc_mod_sub (p, t0, vx2, up); ecc_mod_sub (p, t0, vx2, up);
return ecc_448_zero_p (p, t0); return ecc_curve448_zero_p (p, t0);
#undef u3v #undef u3v
#undef u5v3 #undef u5v3
...@@ -275,8 +275,8 @@ const struct ecc_curve _nettle_curve448 = ...@@ -275,8 +275,8 @@ const struct ecc_curve _nettle_curve448 =
ECC_LIMB_SIZE, ECC_LIMB_SIZE,
ECC_BMODP_SIZE, ECC_BMODP_SIZE,
0, 0,
ECC_448_INV_ITCH, ECC_CURVE448_INV_ITCH,
ECC_448_SQRT_ITCH, ECC_CURVE448_SQRT_ITCH,
ecc_p, ecc_p,
ecc_Bmodp, ecc_Bmodp,
...@@ -284,10 +284,10 @@ const struct ecc_curve _nettle_curve448 = ...@@ -284,10 +284,10 @@ const struct ecc_curve _nettle_curve448 =
NULL, NULL,
ecc_pp1h, ecc_pp1h,
ecc_448_modp, ecc_curve448_modp,
ecc_448_modp, ecc_curve448_modp,
ecc_448_inv, ecc_curve448_inv,
ecc_448_sqrt, ecc_curve448_sqrt,
}, },
{ {
446, 446,
...@@ -318,7 +318,7 @@ const struct ecc_curve _nettle_curve448 = ...@@ -318,7 +318,7 @@ const struct ecc_curve _nettle_curve448 =
ECC_DUP_EH_ITCH (ECC_LIMB_SIZE), ECC_DUP_EH_ITCH (ECC_LIMB_SIZE),
ECC_MUL_A_EH_ITCH (ECC_LIMB_SIZE), ECC_MUL_A_EH_ITCH (ECC_LIMB_SIZE),
ECC_MUL_G_EH_ITCH (ECC_LIMB_SIZE), ECC_MUL_G_EH_ITCH (ECC_LIMB_SIZE),
ECC_EH_TO_A_ITCH (ECC_LIMB_SIZE, ECC_448_INV_ITCH), ECC_EH_TO_A_ITCH (ECC_LIMB_SIZE, ECC_CURVE448_INV_ITCH),
ecc_add_eh, ecc_add_eh,
ecc_add_ehh, ecc_add_ehh,
......
...@@ -48,18 +48,18 @@ ...@@ -48,18 +48,18 @@
#include "ecc-secp192r1.h" #include "ecc-secp192r1.h"
#if HAVE_NATIVE_ecc_192_modp #if HAVE_NATIVE_ecc_secp192r1_modp
#define ecc_192_modp _nettle_ecc_192_modp #define ecc_secp192r1_modp _nettle_ecc_secp192r1_modp
void void
ecc_192_modp (const struct ecc_modulo *m, mp_limb_t *rp); ecc_secp192r1_modp (const struct ecc_modulo *m, mp_limb_t *rp);
/* Use that p = 2^{192} - 2^64 - 1, to eliminate 128 bits at a time. */ /* Use that p = 2^{192} - 2^64 - 1, to eliminate 128 bits at a time. */
#elif GMP_NUMB_BITS == 32 #elif GMP_NUMB_BITS == 32
/* p is 6 limbs, p = B^6 - B^2 - 1 */ /* p is 6 limbs, p = B^6 - B^2 - 1 */
static void static void
ecc_192_modp (const struct ecc_modulo *m UNUSED, mp_limb_t *rp) ecc_secp192r1_modp (const struct ecc_modulo *m UNUSED, mp_limb_t *rp)
{ {
mp_limb_t cy; mp_limb_t cy;
...@@ -84,7 +84,7 @@ ecc_192_modp (const struct ecc_modulo *m UNUSED, mp_limb_t *rp) ...@@ -84,7 +84,7 @@ ecc_192_modp (const struct ecc_modulo *m UNUSED, mp_limb_t *rp)
#elif GMP_NUMB_BITS == 64 #elif GMP_NUMB_BITS == 64
/* p is 3 limbs, p = B^3 - B - 1 */ /* p is 3 limbs, p = B^3 - B - 1 */
static void static void
ecc_192_modp (const struct ecc_modulo *m UNUSED, mp_limb_t *rp) ecc_secp192r1_modp (const struct ecc_modulo *m UNUSED, mp_limb_t *rp)
{ {
mp_limb_t cy; mp_limb_t cy;
...@@ -107,7 +107,7 @@ ecc_192_modp (const struct ecc_modulo *m UNUSED, mp_limb_t *rp) ...@@ -107,7 +107,7 @@ ecc_192_modp (const struct ecc_modulo *m UNUSED, mp_limb_t *rp)
} }
#else #else
#define ecc_192_modp ecc_mod #define ecc_secp192r1_modp ecc_mod
#endif #endif
const struct ecc_curve _nettle_secp_192r1 = const struct ecc_curve _nettle_secp_192r1 =
...@@ -126,8 +126,8 @@ const struct ecc_curve _nettle_secp_192r1 = ...@@ -126,8 +126,8 @@ const struct ecc_curve _nettle_secp_192r1 =
ecc_redc_ppm1, ecc_redc_ppm1,
ecc_pp1h, ecc_pp1h,
ecc_192_modp, ecc_secp192r1_modp,
ecc_192_modp, ecc_secp192r1_modp,
ecc_mod_inv, ecc_mod_inv,
NULL, NULL,
}, },
......
...@@ -40,24 +40,24 @@ ...@@ -40,24 +40,24 @@
#include "ecc.h" #include "ecc.h"
#include "ecc-internal.h" #include "ecc-internal.h"
#if HAVE_NATIVE_ecc_224_modp #if HAVE_NATIVE_ecc_secp224r1_modp
#define USE_REDC 0 #define USE_REDC 0
#define ecc_224_modp _nettle_ecc_224_modp #define ecc_secp224r1_modp _nettle_ecc_secp224r1_modp
void void
ecc_224_modp (const struct ecc_modulo *m, mp_limb_t *rp); ecc_secp224r1_modp (const struct ecc_modulo *m, mp_limb_t *rp);
#else #else
#define USE_REDC (ECC_REDC_SIZE != 0) #define USE_REDC (ECC_REDC_SIZE != 0)
#define ecc_224_modp ecc_mod #define ecc_secp224r1_modp ecc_mod
#endif #endif
#include "ecc-secp224r1.h" #include "ecc-secp224r1.h"
#if ECC_REDC_SIZE < 0 #if ECC_REDC_SIZE < 0
# define ecc_224_redc ecc_pm1_redc # define ecc_secp224r1_redc ecc_pm1_redc
#elif ECC_REDC_SIZE == 0 #elif ECC_REDC_SIZE == 0
# define ecc_224_redc NULL # define ecc_secp224r1_redc NULL
#else #else
# error Configuration error # error Configuration error
#endif #endif
...@@ -78,8 +78,8 @@ const struct ecc_curve _nettle_secp_224r1 = ...@@ -78,8 +78,8 @@ const struct ecc_curve _nettle_secp_224r1 =
ecc_redc_ppm1, ecc_redc_ppm1,
ecc_pp1h, ecc_pp1h,
ecc_224_modp, ecc_secp224r1_modp,
USE_REDC ? ecc_224_redc : ecc_224_modp, USE_REDC ? ecc_secp224r1_redc : ecc_secp224r1_modp,
ecc_mod_inv, ecc_mod_inv,
NULL, NULL,
}, },
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
#include "ecc.h" #include "ecc.h"
#include "ecc-internal.h" #include "ecc-internal.h"
#if HAVE_NATIVE_ecc_256_redc #if HAVE_NATIVE_ecc_secp256r1_redc
# define USE_REDC 1 # define USE_REDC 1
#else #else
# define USE_REDC (ECC_REDC_SIZE != 0) # define USE_REDC (ECC_REDC_SIZE != 0)
...@@ -50,27 +50,27 @@ ...@@ -50,27 +50,27 @@
#include "ecc-secp256r1.h" #include "ecc-secp256r1.h"
#if HAVE_NATIVE_ecc_256_redc #if HAVE_NATIVE_ecc_secp256r1_redc
# define ecc_256_redc _nettle_ecc_256_redc # define ecc_secp256r1_redc _nettle_ecc_secp256r1_redc
void void
ecc_256_redc (const struct ecc_modulo *p, mp_limb_t *rp); ecc_secp256r1_redc (const struct ecc_modulo *p, mp_limb_t *rp);
#else /* !HAVE_NATIVE_ecc_256_redc */ #else /* !HAVE_NATIVE_ecc_secp256r1_redc */
# if ECC_REDC_SIZE > 0 # if ECC_REDC_SIZE > 0
# define ecc_256_redc ecc_pp1_redc # define ecc_secp256r1_redc ecc_pp1_redc
# elif ECC_REDC_SIZE == 0 # elif ECC_REDC_SIZE == 0
# define ecc_256_redc NULL # define ecc_secp256r1_redc NULL
# else # else
# error Configuration error # error Configuration error
# endif # endif
#endif /* !HAVE_NATIVE_ecc_256_redc */ #endif /* !HAVE_NATIVE_ecc_secp256r1_redc */
#if ECC_BMODP_SIZE < ECC_LIMB_SIZE #if ECC_BMODP_SIZE < ECC_LIMB_SIZE
#define ecc_256_modp ecc_mod #define ecc_secp256r1_modp ecc_mod
#define ecc_256_modq ecc_mod #define ecc_secp256r1_modq ecc_mod
#elif GMP_NUMB_BITS == 64 #elif GMP_NUMB_BITS == 64
static void static void
ecc_256_modp (const struct ecc_modulo *p, mp_limb_t *rp) ecc_secp256r1_modp (const struct ecc_modulo *p, mp_limb_t *rp)
{ {
mp_limb_t u1, u0; mp_limb_t u1, u0;
mp_size_t n; mp_size_t n;
...@@ -146,7 +146,7 @@ ecc_256_modp (const struct ecc_modulo *p, mp_limb_t *rp) ...@@ -146,7 +146,7 @@ ecc_256_modp (const struct ecc_modulo *p, mp_limb_t *rp)
} }
static void static void
ecc_256_modq (const struct ecc_modulo *q, mp_limb_t *rp) ecc_secp256r1_modq (const struct ecc_modulo *q, mp_limb_t *rp)
{ {
mp_limb_t u2, u1, u0; mp_limb_t u2, u1, u0;
mp_size_t n; mp_size_t n;
...@@ -255,8 +255,8 @@ const struct ecc_curve _nettle_secp_256r1 = ...@@ -255,8 +255,8 @@ const struct ecc_curve _nettle_secp_256r1 =
ecc_redc_ppm1, ecc_redc_ppm1,
ecc_pp1h, ecc_pp1h,
ecc_256_modp, ecc_secp256r1_modp,
USE_REDC ? ecc_256_redc : ecc_256_modp, USE_REDC ? ecc_secp256r1_redc : ecc_secp256r1_modp,
ecc_mod_inv, ecc_mod_inv,
NULL, NULL,
}, },
...@@ -274,8 +274,8 @@ const struct ecc_curve _nettle_secp_256r1 = ...@@ -274,8 +274,8 @@ const struct ecc_curve _nettle_secp_256r1 =
NULL, NULL,
ecc_qp1h, ecc_qp1h,
ecc_256_modq, ecc_secp256r1_modq,
ecc_256_modq, ecc_secp256r1_modq,
ecc_mod_inv, ecc_mod_inv,
NULL, NULL,
}, },
......
...@@ -46,10 +46,10 @@ ...@@ -46,10 +46,10 @@
#include "ecc-secp384r1.h" #include "ecc-secp384r1.h"
#if HAVE_NATIVE_ecc_384_modp #if HAVE_NATIVE_ecc_secp384r1_modp
#define ecc_384_modp _nettle_ecc_384_modp #define ecc_secp384r1_modp _nettle_ecc_secp384r1_modp
void void
ecc_384_modp (const struct ecc_modulo *m, mp_limb_t *rp); ecc_secp384r1_modp (const struct ecc_modulo *m, mp_limb_t *rp);
#elif GMP_NUMB_BITS == 32 #elif GMP_NUMB_BITS == 32
/* Use that 2^{384} = 2^{128} + 2^{96} - 2^{32} + 1, and eliminate 256 /* Use that 2^{384} = 2^{128} + 2^{96} - 2^{32} + 1, and eliminate 256
...@@ -62,7 +62,7 @@ ecc_384_modp (const struct ecc_modulo *m, mp_limb_t *rp); ...@@ -62,7 +62,7 @@ ecc_384_modp (const struct ecc_modulo *m, mp_limb_t *rp);
almost 8 at a time. Do only 7, to avoid additional carry almost 8 at a time. Do only 7, to avoid additional carry
propagation, followed by 5. */ propagation, followed by 5. */
static void static void
ecc_384_modp (const struct ecc_modulo *p, mp_limb_t *rp) ecc_secp384r1_modp (const struct ecc_modulo *p, mp_limb_t *rp)
{ {
mp_limb_t cy, bw; mp_limb_t cy, bw;
...@@ -106,7 +106,7 @@ ecc_384_modp (const struct ecc_modulo *p, mp_limb_t *rp) ...@@ -106,7 +106,7 @@ ecc_384_modp (const struct ecc_modulo *p, mp_limb_t *rp)
/* p is 6 limbs, and B^6 - p = B^2 + 2^32 (B - 1) + 1. Eliminate 3 /* p is 6 limbs, and B^6 - p = B^2 + 2^32 (B - 1) + 1. Eliminate 3
(almost 4) limbs at a time. */ (almost 4) limbs at a time. */
static void static void
ecc_384_modp (const struct ecc_modulo *p, mp_limb_t *rp) ecc_secp384r1_modp (const struct ecc_modulo *p, mp_limb_t *rp)