[git] GCRYPT - branch, gniibe-T3358, created. libgcrypt-1.8.0-13-g9e8f322
by NIIBE Yutaka
cvs at cvs.gnupg.org
Mon Aug 21 07:34:35 CEST 2017
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU crypto library".
The branch, gniibe-T3358 has been created
at 9e8f3224135898ee8c562f5f974becd1b680ec06 (commit)
- Log -----------------------------------------------------------------
commit 9e8f3224135898ee8c562f5f974becd1b680ec06
Author: NIIBE Yutaka <gniibe at fsij.org>
Date: Mon Aug 21 14:32:08 2017 +0900
ecc: Add field specific computation methods.
* src/ec-context.h (struct mpi_ec_ctx_s): Add methods.
* mpi/ec.c (ec_p_init): Initialize the default methods.
(montgomery_ladder): Use the methods.
Signed-off-by: NIIBE Yutaka <gniibe at fsij.org>
diff --git a/mpi/ec.c b/mpi/ec.c
index a0f7357..4bb9050 100644
--- a/mpi/ec.c
+++ b/mpi/ec.c
@@ -438,6 +438,13 @@ ec_p_init (mpi_ec_t ctx, enum gcry_mpi_ec_models model,
for (i=0; i< DIM(ctx->t.scratch); i++)
ctx->t.scratch[i] = mpi_alloc_like (ctx->p);
+ ctx->mod = ec_mod;
+ ctx->addm = ec_addm;
+ ctx->subm = ec_subm;
+ ctx->mulm = ec_mulm;
+ ctx->pow2 = ec_pow2;
+ ctx->mul2 = ec_mul2;
+
/* Prepare for fast reduction. */
/* FIXME: need a test for NIST values. However it does not gain us
any real advantage, for 384 bits it is actually slower than using
@@ -1146,24 +1153,24 @@ montgomery_ladder (mpi_point_t prd, mpi_point_t sum,
mpi_point_t p1, mpi_point_t p2, gcry_mpi_t dif_x,
mpi_ec_t ctx)
{
- ec_addm (sum->x, p2->x, p2->z, ctx);
- ec_subm (p2->z, p2->x, p2->z, ctx);
- ec_addm (prd->x, p1->x, p1->z, ctx);
- ec_subm (p1->z, p1->x, p1->z, ctx);
- ec_mulm (p2->x, p1->z, sum->x, ctx);
- ec_mulm (p2->z, prd->x, p2->z, ctx);
- ec_pow2 (p1->x, prd->x, ctx);
- ec_pow2 (p1->z, p1->z, ctx);
- ec_addm (sum->x, p2->x, p2->z, ctx);
- ec_subm (p2->z, p2->x, p2->z, ctx);
- ec_mulm (prd->x, p1->x, p1->z, ctx);
- ec_subm (p1->z, p1->x, p1->z, ctx);
- ec_pow2 (sum->x, sum->x, ctx);
- ec_pow2 (sum->z, p2->z, ctx);
- ec_mulm (prd->z, p1->z, ctx->a, ctx); /* CTX->A: (a-2)/4 */
- ec_mulm (sum->z, sum->z, dif_x, ctx);
- ec_addm (prd->z, p1->x, prd->z, ctx);
- ec_mulm (prd->z, prd->z, p1->z, ctx);
+ ctx->addm (sum->x, p2->x, p2->z, ctx);
+ ctx->subm (p2->z, p2->x, p2->z, ctx);
+ ctx->addm (prd->x, p1->x, p1->z, ctx);
+ ctx->subm (p1->z, p1->x, p1->z, ctx);
+ ctx->mulm (p2->x, p1->z, sum->x, ctx);
+ ctx->mulm (p2->z, prd->x, p2->z, ctx);
+ ctx->pow2 (p1->x, prd->x, ctx);
+ ctx->pow2 (p1->z, p1->z, ctx);
+ ctx->addm (sum->x, p2->x, p2->z, ctx);
+ ctx->subm (p2->z, p2->x, p2->z, ctx);
+ ctx->mulm (prd->x, p1->x, p1->z, ctx);
+ ctx->subm (p1->z, p1->x, p1->z, ctx);
+ ctx->pow2 (sum->x, sum->x, ctx);
+ ctx->pow2 (sum->z, p2->z, ctx);
+ ctx->mulm (prd->z, p1->z, ctx->a, ctx); /* CTX->A: (a-2)/4 */
+ ctx->mulm (sum->z, sum->z, dif_x, ctx);
+ ctx->addm (prd->z, p1->x, prd->z, ctx);
+ ctx->mulm (prd->z, prd->z, p1->z, ctx);
}
diff --git a/src/ec-context.h b/src/ec-context.h
index d74fb69..18b26a5 100644
--- a/src/ec-context.h
+++ b/src/ec-context.h
@@ -66,6 +66,14 @@ struct mpi_ec_ctx_s
/* gcry_mpi_t s[10]; */
/* gcry_mpi_t c; */
} t;
+
+ /* Curve specific computation routines for the field. */
+ void (* mod) (gcry_mpi_t w, mpi_ec_t ec);
+ void (* addm) (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, mpi_ec_t ctx);
+ void (* subm) (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, mpi_ec_t ec);
+ void (* mulm) (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, mpi_ec_t ctx);
+ void (* pow2) (gcry_mpi_t w, const gcry_mpi_t b, mpi_ec_t ctx);
+ void (* mul2) (gcry_mpi_t w, gcry_mpi_t u, mpi_ec_t ctx);
};
-----------------------------------------------------------------------
hooks/post-receive
--
The GNU crypto library
http://git.gnupg.org
More information about the Gnupg-commits
mailing list