diff options
author | Daiki Ueno <dueno@redhat.com> | 2019-11-30 10:29:23 +0100 |
---|---|---|
committer | Niels Möller <nisse@lysator.liu.se> | 2019-11-30 10:31:16 +0100 |
commit | 389c787e790fe81036f2ff5303c7afe21ceb2afd (patch) | |
tree | d7a62be30918072d8680f0608d0d93802984aff4 /ecc-point.c | |
parent | cdbbe64a60ae509fc5a74ae70f31f7e9ca4e54a5 (diff) | |
download | nettle-389c787e790fe81036f2ff5303c7afe21ceb2afd.tar.gz |
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.
Diffstat (limited to 'ecc-point.c')
-rw-r--r-- | ecc-point.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/ecc-point.c b/ecc-point.c index 31e3115a..4733b344 100644 --- a/ecc-point.c +++ b/ecc-point.c @@ -85,6 +85,21 @@ ecc_point_set (struct ecc_point *p, const mpz_t x, const mpz_t y) mpz_mul_ui (rhs, rhs, 121665); mpz_clear (x2); } + else if (p->ecc->p.bit_size == 448) + { + /* curve448 special case. FIXME: Do in some cleaner way? */ + mpz_t x2, d; + mpz_init (x2); + mpz_init_set_ui (d, 39081); + mpz_mul (x2, x, x); /* x^2 */ + mpz_mul (d, d, x2); /* 39081 x^2 */ + mpz_set_ui (rhs, 1); + mpz_submul (rhs, d, lhs); /* 1 - 39081 x^2 y^2 */ + /* Check that x^2 + y^2 = 1 - 39081 x^2 y^2 */ + mpz_add (lhs, x2, lhs); /* x^2 + y^2 */ + mpz_clear (d); + mpz_clear (x2); + } else { /* Check that y^2 = x^3 - 3*x + b (mod p) */ |