summaryrefslogtreecommitdiff
path: root/ecc-secp224r1.c
diff options
context:
space:
mode:
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>2020-01-07 01:16:43 +0300
committerNiels Möller <nisse@lysator.liu.se>2020-01-10 20:16:50 +0100
commitabfaf8be2fa06786da94fa6e3b90773d6f178739 (patch)
treeb2cb016740b8c9ad920d0ff59c5482686ece98ab /ecc-secp224r1.c
parentaedc4a3c9f3282dd8809005e0bb4c10c616cfa08 (diff)
downloadnettle-abfaf8be2fa06786da94fa6e3b90773d6f178739.tar.gz
ecc: rename source files with curves data
In preparation to adding GOST curves support, rename source files and use curve name as eccdata parameter. Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Diffstat (limited to 'ecc-secp224r1.c')
-rw-r--r--ecc-secp224r1.c133
1 files changed, 133 insertions, 0 deletions
diff --git a/ecc-secp224r1.c b/ecc-secp224r1.c
new file mode 100644
index 00000000..4d82f54b
--- /dev/null
+++ b/ecc-secp224r1.c
@@ -0,0 +1,133 @@
+/* ecc-secp224r1.c
+
+ Compile time constant (but machine dependent) tables.
+
+ Copyright (C) 2013, 2014 Niels Möller
+
+ 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/.
+*/
+
+/* Development of Nettle's ECC support was funded by the .SE Internet Fund. */
+
+#if HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "ecc.h"
+#include "ecc-internal.h"
+
+#if HAVE_NATIVE_ecc_224_modp
+
+#define USE_REDC 0
+#define ecc_224_modp nettle_ecc_224_modp
+void
+ecc_224_modp (const struct ecc_modulo *m, mp_limb_t *rp);
+
+#else
+#define USE_REDC (ECC_REDC_SIZE != 0)
+#define ecc_224_modp ecc_mod
+#endif
+
+#include "ecc-secp224r1.h"
+
+#if ECC_REDC_SIZE < 0
+# define ecc_224_redc ecc_pm1_redc
+#elif ECC_REDC_SIZE == 0
+# define ecc_224_redc NULL
+#else
+# error Configuration error
+#endif
+
+const struct ecc_curve _nettle_secp_224r1 =
+{
+ {
+ 224,
+ ECC_LIMB_SIZE,
+ ECC_BMODP_SIZE,
+ -ECC_REDC_SIZE,
+ ECC_MOD_INV_ITCH (ECC_LIMB_SIZE),
+ 0,
+
+ ecc_p,
+ ecc_Bmodp,
+ ecc_Bmodp_shifted,
+ ecc_redc_ppm1,
+ ecc_pp1h,
+
+ ecc_224_modp,
+ USE_REDC ? ecc_224_redc : ecc_224_modp,
+ ecc_mod_inv,
+ NULL,
+ },
+ {
+ 224,
+ 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,
+ ecc_mod,
+ ecc_mod_inv,
+ NULL,
+ },
+
+ USE_REDC,
+ ECC_PIPPENGER_K,
+ ECC_PIPPENGER_C,
+
+ ECC_ADD_JJA_ITCH (ECC_LIMB_SIZE),
+ ECC_ADD_JJJ_ITCH (ECC_LIMB_SIZE),
+ ECC_DUP_JJ_ITCH (ECC_LIMB_SIZE),
+ ECC_MUL_A_ITCH (ECC_LIMB_SIZE),
+ ECC_MUL_G_ITCH (ECC_LIMB_SIZE),
+ ECC_J_TO_A_ITCH (ECC_LIMB_SIZE),
+
+ ecc_add_jja,
+ ecc_add_jjj,
+ ecc_dup_jj,
+ ecc_mul_a,
+ ecc_mul_g,
+ ecc_j_to_a,
+
+ ecc_b,
+ ecc_g,
+ ecc_unit,
+ ecc_table
+};
+
+const struct ecc_curve *nettle_get_secp_224r1(void)
+{
+ return &_nettle_secp_224r1;
+}