Commit 389c787e authored by Daiki Ueno's avatar Daiki Ueno Committed by Niels Möller

Implement Curve448 primitives

This patch adds the necessary primitives for "curve448", defined in
RFC 7748.  Those primitives are namely: addition, doubling, scalar
multiplication of the generator or an arbitrary point, inversion, and
square root.
parent cdbbe64a
......@@ -49,6 +49,7 @@ core
/ecc-384.h
/ecc-521.h
/ecc-25519.h
/ecc-448.h
/version.h
/nettle.aux
/nettle.cp
......
......@@ -175,7 +175,7 @@ hogweed_SOURCES = sexp.c sexp-format.c \
ecc-mod.c ecc-mod-inv.c \
ecc-mod-arith.c ecc-pp1-redc.c ecc-pm1-redc.c \
ecc-192.c ecc-224.c ecc-256.c ecc-384.c ecc-521.c \
ecc-25519.c \
ecc-25519.c ecc-448.c \
ecc-size.c ecc-j-to-a.c ecc-a-to-j.c \
ecc-dup-jj.c ecc-add-jja.c ecc-add-jjj.c \
ecc-eh-to-a.c \
......@@ -186,6 +186,7 @@ hogweed_SOURCES = sexp.c sexp-format.c \
ecc-ecdsa-sign.c ecdsa-sign.c \
ecc-ecdsa-verify.c ecdsa-verify.c ecdsa-keygen.c \
curve25519-mul-g.c curve25519-mul.c curve25519-eh-to-x.c \
curve448-mul-g.c curve448-mul.c curve448-eh-to-x.c \
eddsa-compress.c eddsa-decompress.c eddsa-expand.c \
eddsa-hash.c eddsa-pubkey.c eddsa-sign.c eddsa-verify.c \
ed25519-sha512-pubkey.c \
......@@ -196,7 +197,7 @@ OPT_SOURCES = fat-x86_64.c fat-arm.c mini-gmp.c
HEADERS = aes.h arcfour.h arctwo.h asn1.h blowfish.h \
base16.h base64.h bignum.h buffer.h camellia.h cast128.h \
cbc.h ccm.h cfb.h chacha.h chacha-poly1305.h ctr.h \
curve25519.h des.h dsa.h dsa-compat.h eax.h \
curve25519.h curve448.h des.h dsa.h dsa-compat.h eax.h \
ecc-curve.h ecc.h ecdsa.h eddsa.h \
gcm.h gost28147.h gosthash94.h hmac.h \
knuth-lfib.h hkdf.h \
......@@ -387,6 +388,9 @@ ecc-521.h: eccdata.stamp
ecc-25519.h: eccdata.stamp
./eccdata$(EXEEXT_FOR_BUILD) 255 11 6 $(NUMB_BITS) > $@T && mv $@T $@
ecc-448.h: eccdata.stamp
./eccdata$(EXEEXT_FOR_BUILD) 448 38 6 $(NUMB_BITS) > $@T && mv $@T $@
eccdata.stamp: eccdata.c
$(MAKE) eccdata$(EXEEXT_FOR_BUILD)
echo stamp > eccdata.stamp
......@@ -397,6 +401,7 @@ ecc-256.$(OBJEXT): ecc-256.h
ecc-384.$(OBJEXT): ecc-384.h
ecc-521.$(OBJEXT): ecc-521.h
ecc-25519.$(OBJEXT): ecc-25519.h
ecc-448.$(OBJEXT): ecc-448.h
.asm.$(OBJEXT): $(srcdir)/asm.m4 machine.m4 config.m4
$(M4) $(srcdir)/asm.m4 machine.m4 config.m4 $< >$*.s
......@@ -650,6 +655,7 @@ distcheck: dist
clean-here:
-rm -f $(TARGETS) *.$(OBJEXT) *.s *.so *.dll *.a \
ecc-192.h ecc-224.h ecc-256.h ecc-384.h ecc-521.h ecc-25519.h \
ecc-448.h \
aesdata$(EXEEXT_FOR_BUILD) \
desdata$(EXEEXT_FOR_BUILD) \
twofishdata$(EXEEXT_FOR_BUILD) \
......
/* curve448-eh-to-x.c
Copyright (C) 2017 Daiki Ueno
Copyright (C) 2017 Red Hat, Inc.
This file is part of GNU Nettle.
GNU Nettle is free software: you can redistribute it and/or
modify it under the terms of either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your
option) any later version.
or both in parallel, as here.
GNU Nettle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received copies of the GNU General Public License and
the GNU Lesser General Public License along with this program. If
not, see http://www.gnu.org/licenses/.
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include <string.h>
#include "curve448.h"
#include "ecc.h"
#include "ecc-internal.h"
/* Transform a point on the edwards448 Edwards curve to the curve448
Montgomery curve, and return the x coordinate. */
void
curve448_eh_to_x (mp_limb_t *xp, const mp_limb_t *p, mp_limb_t *scratch)
{
#define vp (p + ecc->p.size)
#define t0 scratch
#define t1 (scratch + ecc->p.size)
#define t2 (scratch + 2*ecc->p.size)
const struct ecc_curve *ecc = &_nettle_curve448;
mp_limb_t cy;
/* If u = U/W and v = V/W are the coordinates of the point on
edwards448 we get the curve448 x coordinate as
x = v^2 / u^2 = (V/W)^2 / (U/W)^2 = (V/U)^2
*/
/* Needs a total of 9*size storage. */
ecc->p.invert (&ecc->p, t0, p, t1 + ecc->p.size);
ecc_modp_mul (ecc, t1, t0, vp);
ecc_modp_mul (ecc, t2, t1, t1);
cy = mpn_sub_n (xp, t2, ecc->p.m, ecc->p.size);
cnd_copy (cy, xp, t2, ecc->p.size);
#undef vp
#undef t0
#undef t1
#undef t2
}
/* curve448-mul-g.c
Copyright (C) 2017 Daiki Ueno
Copyright (C) 2017 Red Hat, Inc.
This file is part of GNU Nettle.
GNU Nettle is free software: you can redistribute it and/or
modify it under the terms of either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your
option) any later version.
or both in parallel, as here.
GNU Nettle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received copies of the GNU General Public License and
the GNU Lesser General Public License along with this program. If
not, see http://www.gnu.org/licenses/.
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include <string.h>
#include "curve448.h"
#include "ecc.h"
#include "ecc-internal.h"
/* Intended to be compatible with NaCl's crypto_scalarmult_base. */
void
curve448_mul_g (uint8_t *r, const uint8_t *n)
{
const struct ecc_curve *ecc = &_nettle_curve448;
uint8_t t[CURVE448_SIZE];
mp_limb_t *scratch;
mp_size_t itch;
#define ng scratch
#define x (scratch + 3*ecc->p.size)
#define scratch_out (scratch + 4*ecc->p.size)
memcpy (t, n, sizeof(t));
t[0] &= ~3;
t[CURVE448_SIZE-1] = (t[CURVE448_SIZE-1] & 0x7f) | 0x80;
itch = 5*ecc->p.size + ecc->mul_g_itch;
scratch = gmp_alloc_limbs (itch);
mpn_set_base256_le (x, ecc->p.size, t, CURVE448_SIZE);
ecc_mul_g_eh (ecc, ng, x, scratch_out);
curve448_eh_to_x (x, ng, scratch_out);
mpn_get_base256_le (r, CURVE448_SIZE, x, ecc->p.size);
gmp_free_limbs (scratch, itch);
#undef ng
#undef x
#undef scratch_out
}
/* curve448-mul.c
Copyright (C) 2017 Daiki Ueno
Copyright (C) 2017 Red Hat, Inc.
This file is part of GNU Nettle.
GNU Nettle is free software: you can redistribute it and/or
modify it under the terms of either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your
option) any later version.
or both in parallel, as here.
GNU Nettle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received copies of the GNU General Public License and
the GNU Lesser General Public License along with this program. If
not, see http://www.gnu.org/licenses/.
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include <string.h>
#include "curve448.h"
#include "ecc.h"
#include "ecc-internal.h"
/* Intended to be compatible with NaCl's crypto_scalarmult. */
void
curve448_mul (uint8_t *q, const uint8_t *n, const uint8_t *p)
{
const struct ecc_curve *ecc = &_nettle_curve448;
mp_size_t itch;
mp_limb_t *scratch;
int i;
mp_limb_t cy;
/* FIXME: Could save some more scratch space, e.g., by letting BB
overlap C, D, and CB overlap A, D. And possibly reusing some of
x2, z2, x3, z3. */
#define x1 scratch
#define x2 (scratch + ecc->p.size)
#define z2 (scratch + 2*ecc->p.size)
#define x3 (scratch + 3*ecc->p.size)
#define z3 (scratch + 4*ecc->p.size)
#define A (scratch + 5*ecc->p.size)
#define B (scratch + 6*ecc->p.size)
#define C (scratch + 7*ecc->p.size)
#define D (scratch + 8*ecc->p.size)
#define AA (scratch + 9*ecc->p.size)
#define BB (scratch + 10*ecc->p.size)
#define E (scratch + 10*ecc->p.size) /* Overlap BB */
#define DA (scratch + 9*ecc->p.size) /* Overlap AA */
#define CB (scratch + 10*ecc->p.size) /* Overlap BB */
#define a24 39081
itch = ecc->p.size * 14;
scratch = gmp_alloc_limbs (itch);
/* Note that 255 % GMP_NUMB_BITS == 0 isn't supported, so x1 always
holds at least 256 bits. */
mpn_set_base256_le (x1, ecc->p.size, p, CURVE448_SIZE);
/* Initialize, x2 = x1, z2 = 1 */
mpn_copyi (x2, x1, ecc->p.size);
z2[0] = 1;
mpn_zero (z2+1, ecc->p.size - 1);
/* Get x3, z3 from doubling. Since bit 447 is forced to 1. */
ecc_modp_add (ecc, A, x2, z2);
ecc_modp_sub (ecc, B, x2, z2);
ecc_modp_sqr (ecc, AA, A);
ecc_modp_sqr (ecc, BB, B);
ecc_modp_mul (ecc, x3, AA, BB);
ecc_modp_sub (ecc, E, AA, BB);
ecc_modp_addmul_1 (ecc, AA, E, a24);
ecc_modp_mul (ecc, z3, E, AA);
for (i = 446; i >= 2; i--)
{
int bit = (n[i/8] >> (i & 7)) & 1;
cnd_swap (bit, x2, x3, 2*ecc->p.size);
/* Formulas from RFC 7748. We compute new coordinates in
memory-address order, since mul and sqr clobbers higher
limbs. */
ecc_modp_add (ecc, A, x2, z2);
ecc_modp_sub (ecc, B, x2, z2);
ecc_modp_sqr (ecc, AA, A);
ecc_modp_sqr (ecc, BB, B);
ecc_modp_mul (ecc, x2, AA, BB);
ecc_modp_sub (ecc, E, AA, BB); /* Last use of BB */
ecc_modp_addmul_1 (ecc, AA, E, a24);
ecc_modp_add (ecc, C, x3, z3);
ecc_modp_sub (ecc, D, x3, z3);
ecc_modp_mul (ecc, z2, E, AA); /* Last use of E and AA */
ecc_modp_mul (ecc, DA, D, A); /* Last use of D, A. FIXME: could
let CB overlap. */
ecc_modp_mul (ecc, CB, C, B);
ecc_modp_add (ecc, C, DA, CB);
ecc_modp_sqr (ecc, x3, C);
ecc_modp_sub (ecc, C, DA, CB);
ecc_modp_sqr (ecc, DA, C);
ecc_modp_mul (ecc, z3, DA, x1);
/* FIXME: Could be combined with the loop's initial cnd_swap. */
cnd_swap (bit, x2, x3, 2*ecc->p.size);
}
/* Do the 2 low zero bits, just duplicating x2 */
for ( ; i >= 0; i--)
{
ecc_modp_add (ecc, A, x2, z2);
ecc_modp_sub (ecc, B, x2, z2);
ecc_modp_sqr (ecc, AA, A);
ecc_modp_sqr (ecc, BB, B);
ecc_modp_mul (ecc, x2, AA, BB);
ecc_modp_sub (ecc, E, AA, BB);
ecc_modp_addmul_1 (ecc, AA, E, a24);
ecc_modp_mul (ecc, z2, E, AA);
}
ecc->p.invert (&ecc->p, x3, z2, z3 + ecc->p.size);
ecc_modp_mul (ecc, z3, x2, x3);
cy = mpn_sub_n (x2, z3, ecc->p.m, ecc->p.size);
cnd_copy (cy, x2, z3, ecc->p.size);
mpn_get_base256_le (q, CURVE448_SIZE, x2, ecc->p.size);
gmp_free_limbs (scratch, itch);
}
/* curve448.h
Copyright (C) 2017 Daiki Ueno
Copyright (C) 2017 Red Hat, Inc.
This file is part of GNU Nettle.
GNU Nettle is free software: you can redistribute it and/or
modify it under the terms of either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your
option) any later version.
or both in parallel, as here.
GNU Nettle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received copies of the GNU General Public License and
the GNU Lesser General Public License along with this program. If
not, see http://www.gnu.org/licenses/.
*/
#ifndef NETTLE_CURVE448_H
#define NETTLE_CURVE448_H
#include "nettle-types.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Name mangling */
#define curve448_mul_g nettle_curve448_mul_g
#define curve448_mul nettle_curve448_mul
#define CURVE448_SIZE 56
void
curve448_mul_g (uint8_t *q, const uint8_t *n);
void
curve448_mul (uint8_t *q, const uint8_t *n, const uint8_t *p);
#ifdef __cplusplus
}
#endif
#endif /* NETTLE_CURVE448_H */
/* ecc-448.c
Arithmetic and tables for curve448,
Copyright (C) 2017 Daiki Ueno
Copyright (C) 2017 Red Hat, Inc.
This file is part of GNU Nettle.
GNU Nettle is free software: you can redistribute it and/or
modify it under the terms of either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your
option) any later version.
or both in parallel, as here.
GNU Nettle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received copies of the GNU General Public License and
the GNU Lesser General Public License along with this program. If
not, see http://www.gnu.org/licenses/.
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include "ecc.h"
#include "ecc-internal.h"
#define USE_REDC 0
#include "ecc-448.h"
/* Needs 2*ecc->size limbs at rp, and 2*ecc->size additional limbs of
scratch space. No overlap allowed. */
static void
ecc_mod_pow_2k (const struct ecc_modulo *m,
mp_limb_t *rp, const mp_limb_t *xp,
unsigned k, mp_limb_t *tp)
{
if (k & 1)
{
ecc_mod_sqr (m, rp, xp);
k--;
}
else
{
ecc_mod_sqr (m, tp, xp);
ecc_mod_sqr (m, rp, tp);
k -= 2;
}
while (k > 0)
{
ecc_mod_sqr (m, tp, rp);
ecc_mod_sqr (m, rp, tp);
k -= 2;
}
}
/* Computes a^{(p-3)/4} = a^{2^446-2^222-1} mod m. Needs 9 * n scratch
space. */
static void
ecc_mod_pow_446m224m1 (const struct ecc_modulo *p,
mp_limb_t *rp, const mp_limb_t *ap,
mp_limb_t *scratch)
{
#define t0 scratch
#define t1 (scratch + 3*ECC_LIMB_SIZE)
#define t2 (scratch + 6*ECC_LIMB_SIZE)
ecc_mod_sqr (p, rp, ap); /* a^2 */
ecc_mod_mul (p, t0, ap, rp); /* a^3 */
ecc_mod_sqr (p, rp, t0); /* a^6 */
ecc_mod_mul (p, t0, ap, rp); /* a^{2^3-1} */
ecc_mod_pow_2k (p, rp, t0, 3, t2); /* a^{2^6-2^3} */
ecc_mod_mul (p, t1, t0, rp); /* a^{2^6-1} */
ecc_mod_pow_2k (p, rp, t1, 3, t2); /* a^{2^9-2^3} */
ecc_mod_mul (p, t1, t0, rp); /* a^{2^9-1} */
ecc_mod_pow_2k (p, t0, t1, 9, t2); /* a^{2^18-2^9} */
ecc_mod_mul (p, rp, t1, t0); /* a^{2^18-1} */
ecc_mod_sqr (p, t1, rp); /* a^{2^19-2} */
ecc_mod_mul (p, t0, ap, t1); /* a^{2^19-1} */
ecc_mod_pow_2k (p, t1, t0, 18, t2); /* a^{2^37-2^18} */
ecc_mod_mul (p, t0, rp, t1); /* a^{2^37-1} */
ecc_mod_pow_2k (p, t1, t0, 37, t2); /* a^{2^74-2^37} */
ecc_mod_mul (p, rp, t0, t1); /* a^{2^74-1} */
ecc_mod_pow_2k (p, t1, rp, 37, t2); /* a^{2^111-2^37} */
ecc_mod_mul (p, rp, t0, t1); /* a^{2^111-1} */
ecc_mod_pow_2k (p, t1, rp, 111, t2); /* a^{2^222-2^111} */
ecc_mod_mul (p, t0, rp, t1); /* a^{2^222-1} */
ecc_mod_sqr (p, t1, t0); /* a^{2^223-2} */
ecc_mod_mul (p, rp, ap, t1); /* a^{2^223-1} */
ecc_mod_pow_2k (p, t1, rp, 223, t2); /* a^{2^446-2^223} */
ecc_mod_mul (p, rp, t0, t1); /* a^{2^446-2^222-1} */
#undef t0
#undef t1
#undef t2
}
/* Needs 9*ECC_LIMB_SIZE scratch space. */
#define ECC_448_INV_ITCH (9*ECC_LIMB_SIZE)
static void ecc_448_inv (const struct ecc_modulo *p,
mp_limb_t *rp, const mp_limb_t *ap,
mp_limb_t *scratch)
{
#define t0 scratch
ecc_mod_pow_446m224m1 (p, rp, ap, scratch); /* a^{2^446-2^222-1} */
ecc_mod_sqr (p, t0, rp); /* a^{2^447-2^223-2} */
ecc_mod_sqr (p, rp, t0); /* a^{2^448-2^224-4} */
ecc_mod_mul (p, t0, ap, rp); /* a^{2^448-2^224-3} */
mpn_copyi (rp, t0, ECC_LIMB_SIZE); /* FIXME: Eliminate copy? */
#undef t0
}
/* First, do a canonical reduction, then check if zero */
static int
ecc_448_zero_p (const struct ecc_modulo *p, mp_limb_t *xp)
{
mp_limb_t cy;
mp_limb_t w;
mp_size_t i;
cy = mpn_sub_n (xp, xp, p->m, ECC_LIMB_SIZE);
cnd_add_n (cy, xp, p->m, ECC_LIMB_SIZE);
for (i = 0, w = 0; i < ECC_LIMB_SIZE; i++)
w |= xp[i];
return w == 0;
}
/* Compute x such that x^2 = u/v (mod p). Returns one on success, zero
on failure.
To avoid a separate inversion, we use a trick of djb's, to
compute the candidate root as
x = (u/v)^{(p+1)/4} = u^3 v (u^5 v^3)^{(p-3)/4}.
*/
/* Needs 4*n space + scratch for ecc_mod_pow_446m224m1. */
#define ECC_448_SQRT_ITCH (13*ECC_LIMB_SIZE)
static int
ecc_448_sqrt(const struct ecc_modulo *p, mp_limb_t *rp,
const mp_limb_t *up, const mp_limb_t *vp,
mp_limb_t *scratch)
{
#define u3v scratch
#define u5v3 (scratch + ECC_LIMB_SIZE)
#define u5v3p (scratch + 2*ECC_LIMB_SIZE)
#define u2 (scratch + 2*ECC_LIMB_SIZE)
#define u3 (scratch + 3*ECC_LIMB_SIZE)
#define uv (scratch + 2*ECC_LIMB_SIZE)
#define u2v2 (scratch + 3*ECC_LIMB_SIZE)
#define scratch_out (scratch + 4 * ECC_LIMB_SIZE)
#define x2 scratch
#define vx2 (scratch + ECC_LIMB_SIZE)
#define t0 (scratch + 2*ECC_LIMB_SIZE)
/* Live values */
ecc_mod_sqr (p, u2, up); /* u2 */
ecc_mod_mul (p, u3, u2, up); /* u3 */
ecc_mod_mul (p, u3v, u3, vp); /* u3v */
ecc_mod_mul (p, uv, up, vp); /* u3v, uv */
ecc_mod_sqr (p, u2v2, uv); /* u3v, u2v2 */
ecc_mod_mul (p, u5v3, u3v, u2v2); /* u3v, u5v3 */
ecc_mod_pow_446m224m1 (p, u5v3p, u5v3, scratch_out); /* u3v, u5v3p */
ecc_mod_mul (p, rp, u5v3p, u3v); /* none */
/* If square root exists, have v x^2 = u */
ecc_mod_sqr (p, x2, rp);
ecc_mod_mul (p, vx2, x2, vp);
ecc_mod_sub (p, t0, vx2, up);
return ecc_448_zero_p (p, t0);
#undef u3v
#undef u5v3
#undef u5v3p
#undef u2
#undef u3
#undef uv
#undef u2v2
#undef scratch_out
#undef x2
#undef vx2
#undef t0
}
const struct ecc_curve _nettle_curve448 =
{
{
448,
ECC_LIMB_SIZE,
ECC_BMODP_SIZE,
0,
ECC_448_INV_ITCH,
ECC_448_SQRT_ITCH,
ecc_p,
ecc_Bmodp,
ecc_Bmodp_shifted,
NULL,
ecc_pp1h,
ecc_mod, /* FIXME: Implement optimized mod function */
ecc_mod, /* FIXME: Implement optimized reduce function */
ecc_448_inv,
ecc_448_sqrt,
},
{
446,
ECC_LIMB_SIZE,
ECC_BMODQ_SIZE,
0,
ECC_MOD_INV_ITCH (ECC_LIMB_SIZE),
0,
ecc_q,
ecc_Bmodq,
ecc_Bmodq_shifted,
NULL,
ecc_qp1h,
ecc_mod, /* FIXME: Implement optimized mod function */
ecc_mod, /* FIXME: Implement optimized reduce function */
ecc_mod_inv,
NULL,
},
0, /* No redc */
ECC_PIPPENGER_K,
ECC_PIPPENGER_C,
ECC_ADD_EH_ITCH (ECC_LIMB_SIZE),
ECC_ADD_EHH_ITCH (ECC_LIMB_SIZE),
ECC_DUP_EH_ITCH (ECC_LIMB_SIZE),
ECC_MUL_A_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_add_eh_untwisted,
ecc_add_ehh_untwisted,
ecc_dup_eh_untwisted,
ecc_mul_a_eh,
ecc_mul_g_eh,
ecc_eh_to_a,
ecc_b,
ecc_g,
ecc_unit,
ecc_table
};
......@@ -73,11 +73,11 @@ ecc_add_eh (const struct ecc_curve *ecc,
#define C (scratch)
#define D (scratch + 1*ecc->p.size)
#define T (scratch + 2*ecc->p.size)
#define E (scratch + 3*ecc->p.size)
#define E (scratch + 3*ecc->p.size)
#define B (scratch + 4*ecc->p.size)
#define F D
#define G E
ecc_modp_mul (ecc, C, x1, x2);
ecc_modp_mul (ecc, D, y1, y2);
ecc_modp_add (ecc, x3, x1, y1);
......@@ -91,7 +91,7 @@ ecc_add_eh (const struct ecc_curve *ecc,
ecc_modp_add (ecc, C, D, C); /* ! */
ecc_modp_sqr (ecc, B, z1);
ecc_modp_sub (ecc, F, B, E);
ecc_modp_add (ecc, G, B, E);
ecc_modp_add (ecc, G, B, E);