diff --git a/ChangeLog b/ChangeLog index 8e192fb0c4c9fa1e1b6cdf02c4d68eff64e1e3fe..8e6b350e95500c5efbeb78ce8b2254c8ade36cc8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2014-09-22 Niels Möller <nisse@lysator.liu.se> + * ecc-internal.h (ecc_mod_inv_func): New typedef. + (struct ecc_modulo): Added mp1h constant and invert function + pointer. Updated all callers. + * ecc-modp.c (ecc_modp_inv): Deleted wrapper function. + * ecc-modq.c (ecc_modq_inv): Deleted wrapper function. + + * ecc-mod-inv.c (ecc_mod_inv): Renamed file and function. Also + take a struct ecc_modulo * as argument. + * sec-modinv.c (sec_modinv): ... the old names. Deleted. + * Makefile.in (hogweed_SOURCES): Updated accordingly. + * examples/ecc-benchmark.c (bench_modinv_powm, bench_curve): Updated benchmarking of mpn_sec_powm. diff --git a/Makefile.in b/Makefile.in index 8b04b101f3eb25b36d5bc0cb3c24ce068813955a..aae7c1aa173d288554365c901536aaaaf64c6034 100644 --- a/Makefile.in +++ b/Makefile.in @@ -160,9 +160,9 @@ hogweed_SOURCES = sexp.c sexp-format.c \ dsa2sexp.c sexp2dsa.c \ pgp-encode.c rsa2openpgp.c \ der-iterator.c der2rsa.c der2dsa.c \ - sec-add-1.c sec-sub-1.c sec-modinv.c sec-tabselect.c \ + sec-add-1.c sec-sub-1.c sec-tabselect.c \ gmp-glue.c cnd-copy.c \ - ecc-mod.c \ + ecc-mod.c ecc-mod-inv.c \ ecc-modp.c ecc-modq.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 \ diff --git a/curve25519-eh-to-x.c b/curve25519-eh-to-x.c index 4d05a6bf583b6622088bdf19c22bd67b381c187b..47f071290055ef73c2ba090c77163754ac4b38eb 100644 --- a/curve25519-eh-to-x.c +++ b/curve25519-eh-to-x.c @@ -66,7 +66,7 @@ curve25519_eh_to_x (mp_limb_t *xp, const mp_limb_t *p, in this case. */ ecc_modp_sub (ecc, t0, wp, vp); /* Needs 3*size scratch, for a total of 5*size */ - ecc_modp_inv (ecc, t1, t0, t2); + ecc->p.invert (&ecc->p, t1, t0, t2); ecc_modp_add (ecc, t0, wp, vp); ecc_modp_mul (ecc, t2, t0, t1); diff --git a/curve25519-mul.c b/curve25519-mul.c index 263a33aa45063cfb27476a94394d27626e897f23..f4e4fa7b870266f10fc5a634f3ce0b761d81eefe 100644 --- a/curve25519-mul.c +++ b/curve25519-mul.c @@ -132,7 +132,7 @@ curve25519_mul (uint8_t *q, const uint8_t *n, const uint8_t *p) ecc_modp_addmul_1 (ecc, AA, E, 121665); ecc_modp_mul (ecc, z2, E, AA); } - ecc_modp_inv (ecc, x3, z2, z3); + ecc->p.invert (&ecc->p, x3, z2, z3); 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); diff --git a/ecc-192.c b/ecc-192.c index 683363352087a17425d9dc8f9daaf88b1663c3ac..6d4010f27874048ccff280ffe7ed52fe2df31b1d 100644 --- a/ecc-192.c +++ b/ecc-192.c @@ -121,8 +121,11 @@ const struct ecc_curve nettle_secp_192r1 = ecc_Bmodp, ecc_Bmodp_shifted, ecc_redc_ppm1, + ecc_pp1h, + ecc_192_modp, ecc_192_modp, + ecc_mod_inv, }, { 192, @@ -133,8 +136,11 @@ const struct ecc_curve nettle_secp_192r1 = ecc_Bmodq, ecc_Bmodq_shifted, NULL, + ecc_qp1h, + ecc_mod, ecc_mod, + ecc_mod_inv, }, USE_REDC, @@ -154,9 +160,7 @@ const struct ecc_curve nettle_secp_192r1 = ecc_b, ecc_g, NULL, - ecc_pp1h, ecc_unit, - ecc_qp1h, ecc_table }; diff --git a/ecc-224.c b/ecc-224.c index f0f211ceb081378d4f28fe09959cda572f65fadf..ecd3f2179bb526dee260b20b75a36fb6e08f07a7 100644 --- a/ecc-224.c +++ b/ecc-224.c @@ -73,8 +73,11 @@ const struct ecc_curve nettle_secp_224r1 = ecc_Bmodp, ecc_Bmodp_shifted, ecc_redc_ppm1, + ecc_pp1h, + ecc_224_modp, USE_REDC ? ecc_224_redc : ecc_224_modp, + ecc_mod_inv, }, { 224, @@ -85,8 +88,11 @@ const struct ecc_curve nettle_secp_224r1 = ecc_Bmodq, ecc_Bmodq_shifted, NULL, + ecc_qp1h, + ecc_mod, ecc_mod, + ecc_mod_inv, }, USE_REDC, @@ -106,8 +112,6 @@ const struct ecc_curve nettle_secp_224r1 = ecc_b, ecc_g, NULL, - ecc_pp1h, ecc_unit, - ecc_qp1h, ecc_table }; diff --git a/ecc-25519.c b/ecc-25519.c index c557ae41dffdde426f4c348738f7647333c3c17f..5416b74fcc1b5f7a114279abd9345c36946f00f1 100644 --- a/ecc-25519.c +++ b/ecc-25519.c @@ -241,8 +241,11 @@ const struct ecc_curve nettle_curve25519 = ecc_Bmodp, ecc_Bmodp_shifted, NULL, + ecc_pp1h, + ecc_25519_modp, ecc_25519_modp, + ecc_mod_inv, }, { 253, @@ -253,8 +256,11 @@ const struct ecc_curve nettle_curve25519 = ecc_Bmodq, ecc_mBmodq_shifted, /* Use q - 2^{252} instead. */ NULL, + ecc_qp1h, + ecc_25519_modq, ecc_25519_modq, + ecc_mod_inv, }, 0, /* No redc */ @@ -274,8 +280,6 @@ const struct ecc_curve nettle_curve25519 = ecc_d, /* Use the Edwards curve constant. */ ecc_g, ecc_edwards, - ecc_pp1h, ecc_unit, - ecc_qp1h, ecc_table }; diff --git a/ecc-256.c b/ecc-256.c index 259b9c9c04b27d91b247f34d0bbdec1ee5e57046..95b719ed77c4cd293f8adc150c80591c8e853d38 100644 --- a/ecc-256.c +++ b/ecc-256.c @@ -236,8 +236,11 @@ const struct ecc_curve nettle_secp_256r1 = ecc_Bmodp, ecc_Bmodp_shifted, ecc_redc_ppm1, + + ecc_pp1h, ecc_256_modp, USE_REDC ? ecc_256_redc : ecc_256_modp, + ecc_mod_inv, }, { 256, @@ -248,8 +251,11 @@ const struct ecc_curve nettle_secp_256r1 = ecc_Bmodq, ecc_Bmodq_shifted, NULL, + ecc_qp1h, + ecc_256_modq, ecc_256_modq, + ecc_mod_inv, }, USE_REDC, @@ -269,8 +275,6 @@ const struct ecc_curve nettle_secp_256r1 = ecc_b, ecc_g, NULL, - ecc_pp1h, ecc_unit, - ecc_qp1h, ecc_table }; diff --git a/ecc-384.c b/ecc-384.c index 7fff282005f8b3b0eff15a9c03173f3f54c6375a..e6a744c818a46cbcfaad4eeff1f908519624064b 100644 --- a/ecc-384.c +++ b/ecc-384.c @@ -158,8 +158,11 @@ const struct ecc_curve nettle_secp_384r1 = ecc_Bmodp, ecc_Bmodp_shifted, ecc_redc_ppm1, + ecc_pp1h, + ecc_384_modp, ecc_384_modp, + ecc_mod_inv, }, { 384, @@ -170,8 +173,11 @@ const struct ecc_curve nettle_secp_384r1 = ecc_Bmodq, ecc_Bmodq_shifted, NULL, + ecc_qp1h, + ecc_mod, ecc_mod, + ecc_mod_inv, }, USE_REDC, @@ -191,8 +197,6 @@ const struct ecc_curve nettle_secp_384r1 = ecc_b, ecc_g, NULL, - ecc_pp1h, ecc_unit, - ecc_qp1h, ecc_table }; diff --git a/ecc-521.c b/ecc-521.c index 66ed8b0d450d452dddeea518352b2d1a38ffaeca..ae6f29f29c232998f53c3bc294f092b608e23123 100644 --- a/ecc-521.c +++ b/ecc-521.c @@ -86,8 +86,11 @@ const struct ecc_curve nettle_secp_521r1 = ecc_Bmodp, ecc_Bmodp_shifted, ecc_redc_ppm1, + ecc_pp1h, + ecc_521_modp, ecc_521_modp, + ecc_mod_inv, }, { 521, @@ -98,8 +101,11 @@ const struct ecc_curve nettle_secp_521r1 = ecc_Bmodq, ecc_Bmodq_shifted, NULL, + ecc_qp1h, + ecc_mod, ecc_mod, + ecc_mod_inv, }, USE_REDC, @@ -119,9 +125,7 @@ const struct ecc_curve nettle_secp_521r1 = ecc_b, ecc_g, NULL, - ecc_pp1h, ecc_unit, - ecc_qp1h, ecc_table }; diff --git a/ecc-ecdsa-sign.c b/ecc-ecdsa-sign.c index 61a75e547934b3ccad1d6ad28718cb4f4c9709f8..de17ac4cef643b7f007dbcbdcced49d910e9113c 100644 --- a/ecc-ecdsa-sign.c +++ b/ecc-ecdsa-sign.c @@ -84,7 +84,7 @@ ecc_ecdsa_sign (const struct ecc_curve *ecc, /* Invert k, uses 5 * ecc->p.size including scratch */ mpn_copyi (hp, kp, ecc->p.size); - ecc_modq_inv (ecc, kinv, hp, tp); + ecc->q.invert (&ecc->q, kinv, hp, tp); /* Process hash digest */ ecc_hash (ecc, hp, length, digest); diff --git a/ecc-ecdsa-verify.c b/ecc-ecdsa-verify.c index 5f4229b39d2f1b4275f9c700a813cb4b33767594..a259962e34c587e7f025d0b2bae759115a7645d7 100644 --- a/ecc-ecdsa-verify.c +++ b/ecc-ecdsa-verify.c @@ -108,7 +108,7 @@ ecc_ecdsa_verify (const struct ecc_curve *ecc, /* Compute sinv, use P2 as scratch */ mpn_copyi (sinv + ecc->p.size, sp, ecc->p.size); - ecc_modq_inv (ecc, sinv, sinv + ecc->p.size, P2); + ecc->q.invert (&ecc->q, sinv, sinv + ecc->p.size, P2); /* u2 = r / s, P2 = u2 * Y */ ecc_modq_mul (ecc, u2, rp, sinv); diff --git a/ecc-eh-to-a.c b/ecc-eh-to-a.c index aed176c11bb5ac5296ed2877b674f93630d57050..a018230819fdbfccf660b61b5e1569d6d2b06ee2 100644 --- a/ecc-eh-to-a.c +++ b/ecc-eh-to-a.c @@ -65,7 +65,7 @@ ecc_eh_to_a (const struct ecc_curve *ecc, mpn_copyi (tp, zp, ecc->p.size); /* Needs 3*size scratch */ - ecc_modp_inv (ecc, izp, tp, tp + ecc->p.size); + ecc->p.invert (&ecc->p, izp, tp, tp + ecc->p.size); ecc_modp_mul (ecc, tp, xp, izp); cy = mpn_sub_n (r, tp, ecc->p.m, ecc->p.size); diff --git a/ecc-internal.h b/ecc-internal.h index f8be2647dd746b0fee26c36b41fdcc0898882fdf..263b82168df67d35b3a3f3ab36fb2d440b65ec20 100644 --- a/ecc-internal.h +++ b/ecc-internal.h @@ -49,12 +49,11 @@ #define ecc_modp_submul_1 _nettle_ecc_modp_submul_1 #define ecc_modp_mul _nettle_ecc_modp_mul #define ecc_modp_sqr _nettle_ecc_modp_sqr -#define ecc_modp_inv _nettle_ecc_modp_inv #define ecc_modq_mul _nettle_ecc_modq_mul #define ecc_modq_add _nettle_ecc_modq_add -#define ecc_modq_inv _nettle_ecc_modq_inv #define ecc_modq_random _nettle_ecc_modq_random #define ecc_mod _nettle_ecc_mod +#define ecc_mod_inv _nettle_ecc_mod_inv #define ecc_hash _nettle_ecc_hash #define cnd_copy _nettle_cnd_copy #define sec_add_1 _nettle_sec_add_1 @@ -82,6 +81,10 @@ struct ecc_modulo; modp_mul and modp_sqr. */ typedef void ecc_mod_func (const struct ecc_modulo *m, mp_limb_t *rp); +typedef void ecc_mod_inv_func (const struct ecc_modulo *m, + mp_limb_t *vp, mp_limb_t *ap, + mp_limb_t *scratch); + typedef void ecc_add_func (const struct ecc_curve *ecc, mp_limb_t *r, const mp_limb_t *p, const mp_limb_t *q, @@ -115,9 +118,12 @@ struct ecc_modulo const mp_limb_t *B_shifted; /* m +/- 1, for redc, excluding redc_size low limbs. */ const mp_limb_t *redc_mpm1; + /* (m+1)/2 */ + const mp_limb_t *mp1h; ecc_mod_func *mod; ecc_mod_func *reduce; + ecc_mod_inv_func *invert; }; /* Represents an elliptic curve of the form @@ -156,14 +162,9 @@ struct ecc_curve equivalent Edwards curve. */ const mp_limb_t *edwards_root; - /* (p+1)/2 */ - const mp_limb_t *pp1h; /* For redc, same as Bmodp, otherwise 1. */ const mp_limb_t *unit; - /* (q+1)/2 */ - const mp_limb_t *qp1h; - /* Tables for multiplying by the generator, size determined by k and c. The first 2^c entries are defined by @@ -182,6 +183,8 @@ ecc_mod_func ecc_mod; ecc_mod_func ecc_pp1_redc; ecc_mod_func ecc_pm1_redc; +ecc_mod_inv_func ecc_mod_inv; + void ecc_modp_add (const struct ecc_curve *ecc, mp_limb_t *rp, const mp_limb_t *ap, const mp_limb_t *bp); @@ -209,10 +212,6 @@ void ecc_modp_sqr (const struct ecc_curve *ecc, mp_limb_t *rp, const mp_limb_t *ap); -void -ecc_modp_inv (const struct ecc_curve *ecc, mp_limb_t *rp, mp_limb_t *ap, - mp_limb_t *scratch); - /* mod q operations. */ void ecc_modq_mul (const struct ecc_curve *ecc, mp_limb_t *rp, @@ -221,10 +220,6 @@ void ecc_modq_add (const struct ecc_curve *ecc, mp_limb_t *rp, const mp_limb_t *ap, const mp_limb_t *bp); -void -ecc_modq_inv (const struct ecc_curve *ecc, mp_limb_t *rp, mp_limb_t *ap, - mp_limb_t *scratch); - void ecc_modq_random (const struct ecc_curve *ecc, mp_limb_t *xp, void *ctx, nettle_random_func *random, mp_limb_t *scratch); @@ -248,10 +243,6 @@ sec_tabselect (mp_limb_t *rp, mp_size_t rn, const mp_limb_t *table, unsigned tn, unsigned k); -void -sec_modinv (mp_limb_t *vp, mp_limb_t *ap, mp_size_t n, - const mp_limb_t *mp, const mp_limb_t *mp1h, mp_size_t bit_size, - mp_limb_t *scratch); int ecc_25519_sqrt(mp_limb_t *rp, const mp_limb_t *ap); diff --git a/ecc-j-to-a.c b/ecc-j-to-a.c index 91b97e701256fae6d3ec7912aa465efbc8af5da9..8c52eb36f7c82827680fc8fb6baee97d37627cdf 100644 --- a/ecc-j-to-a.c +++ b/ecc-j-to-a.c @@ -77,7 +77,7 @@ ecc_j_to_a (const struct ecc_curve *ecc, mpn_zero (up + ecc->p.size, ecc->p.size); ecc->p.reduce (&ecc->p, up); - ecc_modp_inv (ecc, izp, up, up + ecc->p.size); + ecc->p.invert (&ecc->p, izp, up, up + ecc->p.size); /* Divide this common factor by B */ mpn_copyi (izBp, izp, ecc->p.size); @@ -91,7 +91,7 @@ ecc_j_to_a (const struct ecc_curve *ecc, /* Set s = p_z^{-1}, r_x = p_x s^2, r_y = p_y s^3 */ mpn_copyi (up, p+2*ecc->p.size, ecc->p.size); /* p_z */ - ecc_modp_inv (ecc, izp, up, up + ecc->p.size); + ecc->p.invert (&ecc->p, izp, up, up + ecc->p.size); ecc_modp_sqr (ecc, iz2p, izp); } diff --git a/sec-modinv.c b/ecc-mod-inv.c similarity index 87% rename from sec-modinv.c rename to ecc-mod-inv.c index 7f80ba85815d7a84559b82bd70c9c77eae45f5b4..22e533f2f5ac5ecb7a6924153f53e2444ee15e18 100644 --- a/sec-modinv.c +++ b/ecc-mod-inv.c @@ -1,6 +1,6 @@ -/* sec-modinv.c +/* ecc-mod-inv.c - Copyright (C) 2013 Niels Möller + Copyright (C) 2013, 2014 Niels Möller This file is part of GNU Nettle. @@ -57,15 +57,19 @@ cnd_neg (int cnd, mp_limb_t *rp, const mp_limb_t *ap, mp_size_t n) /* Compute a^{-1} mod m, with running time depending only on the size. Returns zero if a == 0 (mod m), to be consistent with a^{phi(m)-1}. Also needs (m+1)/2, and m must be odd. */ + +/* FIXME: Could use mpn_sec_invert (in GMP-6), but with a bit more + scratch need since it doesn't precompute (m+1)/2. */ void -sec_modinv (mp_limb_t *vp, mp_limb_t *ap, mp_size_t n, - const mp_limb_t *mp, const mp_limb_t *mp1h, mp_size_t bit_size, - mp_limb_t *scratch) +ecc_mod_inv (const struct ecc_modulo *m, + mp_limb_t *vp, mp_limb_t *ap, + mp_limb_t *scratch) { #define bp scratch #define dp (scratch + n) #define up (scratch + 2*n) + mp_size_t n = m->size; /* Avoid the mp_bitcnt_t type for compatibility with older GMP versions. */ unsigned i; @@ -85,10 +89,10 @@ sec_modinv (mp_limb_t *vp, mp_limb_t *ap, mp_size_t n, up[0] = 1; mpn_zero (up+1, n - 1); - mpn_copyi (bp, mp, n); + mpn_copyi (bp, m->m, n); mpn_zero (vp, n); - for (i = bit_size + GMP_NUMB_BITS * n; i-- > 0; ) + for (i = m->bit_size + GMP_NUMB_BITS * n; i-- > 0; ) { mp_limb_t odd, swap, cy; @@ -146,17 +150,17 @@ sec_modinv (mp_limb_t *vp, mp_limb_t *ap, mp_size_t n, #if 1 cnd_swap (swap, up, vp, n); cy = cnd_sub_n (odd, up, vp, n); - cy -= cnd_add_n (cy, up, mp, n); + cy -= cnd_add_n (cy, up, m->m, n); #else cy = cnd_sub_n (odd, up, vp, n); cnd_add_n (swap, vp, up, n); cnd_neg (swap, up, up, n); - cnd_add_n (cy ^ swap, up, mp, n); + cnd_add_n (cy ^ swap, up, m->p, n); #endif cy = mpn_rshift (ap, ap, n, 1); assert (cy == 0); cy = mpn_rshift (up, up, n, 1); - cy = cnd_add_n (cy, up, mp1h, n); + cy = cnd_add_n (cy, up, m->mp1h, n); assert (cy == 0); } assert ( (ap[0] | ap[n-1]) == 0); diff --git a/ecc-modp.c b/ecc-modp.c index f48f7840830d31f25389c966d6dc36420e2abda5..9f196243fdfa69c229d34d857648787ec53698db 100644 --- a/ecc-modp.c +++ b/ecc-modp.c @@ -125,11 +125,3 @@ ecc_modp_sqr (const struct ecc_curve *ecc, mp_limb_t *rp, mpn_sqr (rp, ap, ecc->p.size); ecc->p.reduce (&ecc->p, rp); } - -void -ecc_modp_inv (const struct ecc_curve *ecc, mp_limb_t *rp, mp_limb_t *ap, - mp_limb_t *scratch) -{ - sec_modinv (rp, ap, ecc->p.size, ecc->p.m, ecc->pp1h, ecc->p.bit_size, scratch); -} - diff --git a/ecc-modq.c b/ecc-modq.c index 48bb2ba54419a796c69db53d16fb0d7373c1a203..c15f2a463e39c2ced356ff8968664819615d44e5 100644 --- a/ecc-modq.c +++ b/ecc-modq.c @@ -59,10 +59,3 @@ ecc_modq_mul (const struct ecc_curve *ecc, mp_limb_t *rp, mpn_mul_n (rp, ap, bp, ecc->q.size); ecc->q.mod (&ecc->q, rp); } - -void -ecc_modq_inv (const struct ecc_curve *ecc, mp_limb_t *rp, mp_limb_t *ap, - mp_limb_t *scratch) -{ - sec_modinv (rp, ap, ecc->q.size, ecc->q.m, ecc->qp1h, ecc->q.bit_size, scratch); -} diff --git a/examples/ecc-benchmark.c b/examples/ecc-benchmark.c index c4bb7f5163fb9926e7bd3a6bff1458eb3237810d..0ecf3658dc014e074c218695aae4cbc2704f4faf 100644 --- a/examples/ecc-benchmark.c +++ b/examples/ecc-benchmark.c @@ -174,7 +174,7 @@ bench_modinv (void *p) { struct ecc_ctx *ctx = (struct ecc_ctx *) p; mpn_copyi (ctx->rp + ctx->ecc->p.size, ctx->ap, ctx->ecc->p.size); - ecc_modp_inv (ctx->ecc, ctx->rp, ctx->rp + ctx->ecc->p.size, ctx->tp); + ctx->ecc->p.invert (&ctx->ecc->p, ctx->rp, ctx->rp + ctx->ecc->p.size, ctx->tp); } #if !NETTLE_USE_MINI_GMP diff --git a/testsuite/ecc-modinv-test.c b/testsuite/ecc-modinv-test.c index 734700c6bb3348868713cefe2056ea1a8997e44d..8c78c700459210c2a6b02870e4c84bb24a6772a4 100644 --- a/testsuite/ecc-modinv-test.c +++ b/testsuite/ecc-modinv-test.c @@ -58,10 +58,10 @@ test_main (void) /* Check behaviour for zero input */ mpn_zero (a, ecc->p.size); memset (ai, 17, ecc->p.size * sizeof(*ai)); - ecc_modp_inv (ecc, ai, a, scratch); + ecc->p.invert (&ecc->p, ai, a, scratch); if (!mpn_zero_p (ai, ecc->p.size)) { - fprintf (stderr, "ecc_modp_inv failed for zero input (bit size %u):\n", + fprintf (stderr, "ecc->p.invert failed for zero input (bit size %u):\n", ecc->p.bit_size); gmp_fprintf (stderr, "p = %Nx\n" "t = %Nx (bad)\n", @@ -73,10 +73,10 @@ test_main (void) /* Check behaviour for a = p */ mpn_copyi (a, ecc->p.m, ecc->p.size); memset (ai, 17, ecc->p.size * sizeof(*ai)); - ecc_modp_inv (ecc, ai, a, scratch); + ecc->p.invert (&ecc->p, ai, a, scratch); if (!mpn_zero_p (ai, ecc->p.size)) { - fprintf (stderr, "ecc_modp_inv failed for a = p input (bit size %u):\n", + fprintf (stderr, "ecc->p.invert failed for a = p input (bit size %u):\n", ecc->p.bit_size); gmp_fprintf (stderr, "p = %Nx\n" "t = %Nx (bad)\n", @@ -101,10 +101,10 @@ test_main (void) j, ecc->p.bit_size); continue; } - ecc_modp_inv (ecc, ai, a, scratch); + ecc->p.invert (&ecc->p, ai, a, scratch); if (mpn_cmp (ref, ai, ecc->p.size)) { - fprintf (stderr, "ecc_modp_inv failed (test %u, bit size %u):\n", + fprintf (stderr, "ecc->p.invert failed (test %u, bit size %u):\n", j, ecc->p.bit_size); gmp_fprintf (stderr, "a = %Zx\n" "p = %Nx\n" @@ -124,10 +124,10 @@ test_main (void) j, ecc->q.bit_size); continue; } - ecc_modq_inv (ecc, ai, a, scratch); + ecc->q.invert (&ecc->q, ai, a, scratch); if (mpn_cmp (ref, ai, ecc->p.size)) { - fprintf (stderr, "ecc_modq_inv failed (test %u, bit size %u):\n", + fprintf (stderr, "ecc->q.invert failed (test %u, bit size %u):\n", j, ecc->q.bit_size); gmp_fprintf (stderr, "a = %Zx\n" "p = %Nx\n"