summaryrefslogtreecommitdiff
path: root/lib/nettle/gost/ecc-gost512a.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2018-06-23 16:54:03 +0000
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2018-06-23 16:54:03 +0000
commit6c4eac569e9b6b332e192e7f37a778e77494496b (patch)
treedb820eec9a645fccdcd2ddfbdecdb9e82a31edfc /lib/nettle/gost/ecc-gost512a.c
parent21df83a28d323768ddd9659a47509f04b64ce7fa (diff)
parentf75559023250c5beabaa49e51cd7b49cadfc5559 (diff)
downloadgnutls-6c4eac569e9b6b332e192e7f37a778e77494496b.tar.gz
Merge branch 'gost-no-tls' into 'master'
GOST certificates/PKCS#7/PKCS#12 support See merge request gnutls/gnutls!654
Diffstat (limited to 'lib/nettle/gost/ecc-gost512a.c')
-rw-r--r--lib/nettle/gost/ecc-gost512a.c132
1 files changed, 132 insertions, 0 deletions
diff --git a/lib/nettle/gost/ecc-gost512a.c b/lib/nettle/gost/ecc-gost512a.c
new file mode 100644
index 0000000000..5a4c7e99b6
--- /dev/null
+++ b/lib/nettle/gost/ecc-gost512a.c
@@ -0,0 +1,132 @@
+/* ecc-gost512a.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 <gnutls_int.h>
+
+#include <nettle/ecc.h>
+#include "ecc-internal.h"
+#include "ecc-gost-curve.h"
+
+#define USE_REDC (ECC_REDC_SIZE != 0)
+
+#if GMP_NUMB_BITS == 32
+#include "ecc-gost512a-32.h"
+#elif GMP_NUMB_BITS == 64
+#include "ecc-gost512a-64.h"
+#else
+#error unsupported configuration
+#endif
+
+#if ECC_REDC_SIZE > 0
+# define ecc_512_redc ecc_pp1_redc
+#elif ECC_REDC_SIZE == 0
+# define ecc_512_redc NULL
+#else
+# error Configuration error
+#endif
+
+#define ecc_512_modp ecc_mod
+#define ecc_512_modq ecc_mod
+
+static const struct ecc_curve _gnutls_gost_512a =
+{
+ {
+ 512,
+ 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_512_modp,
+ USE_REDC ? ecc_512_redc : ecc_512_modp,
+ ecc_mod_inv,
+ NULL,
+ },
+ {
+ 512,
+ 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_512_modq,
+ ecc_512_modq,
+ ecc_mod_inv,
+ NULL,
+ },
+
+ USE_REDC,
+ ECC_PIPPENGER_K,
+ ECC_PIPPENGER_C,
+
+ ECC_ADD_JJJ_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_jjj,
+ ecc_mul_a,
+ ecc_mul_g,
+ ecc_j_to_a,
+
+ ecc_b,
+ ecc_g,
+ NULL,
+ ecc_unit,
+ ecc_table
+};
+
+const struct ecc_curve *nettle_get_gost_512a(void)
+{
+ return &_gnutls_gost_512a;
+}