Blame lib/nettle/gost/ecc-gost512a.c

Packit aea12f
/* ecc-gost512a.c
Packit aea12f
Packit aea12f
   Compile time constant (but machine dependent) tables.
Packit aea12f
Packit aea12f
   Copyright (C) 2013, 2014 Niels Möller
Packit aea12f
Packit aea12f
   This file is part of GNU Nettle.
Packit aea12f
Packit aea12f
   GNU Nettle is free software: you can redistribute it and/or
Packit aea12f
   modify it under the terms of either:
Packit aea12f
Packit aea12f
     * the GNU Lesser General Public License as published by the Free
Packit aea12f
       Software Foundation; either version 3 of the License, or (at your
Packit aea12f
       option) any later version.
Packit aea12f
Packit aea12f
   or
Packit aea12f
Packit aea12f
     * the GNU General Public License as published by the Free
Packit aea12f
       Software Foundation; either version 2 of the License, or (at your
Packit aea12f
       option) any later version.
Packit aea12f
Packit aea12f
   or both in parallel, as here.
Packit aea12f
Packit aea12f
   GNU Nettle is distributed in the hope that it will be useful,
Packit aea12f
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit aea12f
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit aea12f
   General Public License for more details.
Packit aea12f
Packit aea12f
   You should have received copies of the GNU General Public License and
Packit aea12f
   the GNU Lesser General Public License along with this program.  If
Packit aea12f
   not, see https://www.gnu.org/licenses/.
Packit aea12f
*/
Packit aea12f
Packit aea12f
/* Development of Nettle's ECC support was funded by the .SE Internet Fund. */
Packit aea12f
Packit aea12f
#if HAVE_CONFIG_H
Packit aea12f
# include "config.h"
Packit aea12f
#endif
Packit aea12f
Packit aea12f
#include <gnutls_int.h>
Packit aea12f
Packit aea12f
#include <nettle/ecc.h>
Packit aea12f
#include "ecc-internal.h"
Packit aea12f
#include "ecc-gost-curve.h"
Packit aea12f
Packit aea12f
#define USE_REDC (ECC_REDC_SIZE != 0)
Packit aea12f
Packit aea12f
#if GMP_NUMB_BITS == 32
Packit aea12f
#include "ecc-gost512a-32.h"
Packit aea12f
#elif GMP_NUMB_BITS == 64
Packit aea12f
#include "ecc-gost512a-64.h"
Packit aea12f
#else
Packit aea12f
#error unsupported configuration
Packit aea12f
#endif
Packit aea12f
Packit aea12f
#if ECC_REDC_SIZE > 0
Packit aea12f
#  define ecc_512_redc ecc_pp1_redc
Packit aea12f
#elif ECC_REDC_SIZE == 0
Packit aea12f
#  define ecc_512_redc NULL
Packit aea12f
#else
Packit aea12f
# error Configuration error
Packit aea12f
#endif
Packit aea12f
Packit aea12f
#define ecc_512_modp ecc_mod
Packit aea12f
#define ecc_512_modq ecc_mod
Packit aea12f
Packit aea12f
static const struct ecc_curve _gnutls_gost_512a =
Packit aea12f
{
Packit aea12f
  {
Packit aea12f
    512,
Packit aea12f
    ECC_LIMB_SIZE,
Packit aea12f
    ECC_BMODP_SIZE,
Packit aea12f
    ECC_REDC_SIZE,
Packit aea12f
    ECC_MOD_INV_ITCH (ECC_LIMB_SIZE),
Packit aea12f
    0,
Packit aea12f
Packit aea12f
    ecc_p,
Packit aea12f
    ecc_Bmodp,
Packit aea12f
    ecc_Bmodp_shifted,
Packit aea12f
    ecc_redc_ppm1,
Packit aea12f
Packit aea12f
    ecc_pp1h,
Packit aea12f
    ecc_512_modp,
Packit aea12f
    USE_REDC ? ecc_512_redc : ecc_512_modp,
Packit aea12f
    ecc_mod_inv,
Packit aea12f
    NULL,
Packit aea12f
  },
Packit aea12f
  {
Packit aea12f
    512,
Packit aea12f
    ECC_LIMB_SIZE,
Packit aea12f
    ECC_BMODQ_SIZE,
Packit aea12f
    0,
Packit aea12f
    ECC_MOD_INV_ITCH (ECC_LIMB_SIZE),
Packit aea12f
    0,
Packit aea12f
Packit aea12f
    ecc_q,
Packit aea12f
    ecc_Bmodq,
Packit aea12f
    ecc_Bmodq_shifted,
Packit aea12f
    NULL,
Packit aea12f
    ecc_qp1h,
Packit aea12f
Packit aea12f
    ecc_512_modq,
Packit aea12f
    ecc_512_modq,
Packit aea12f
    ecc_mod_inv,
Packit aea12f
    NULL,
Packit aea12f
  },
Packit aea12f
Packit aea12f
  USE_REDC,
Packit aea12f
  ECC_PIPPENGER_K,
Packit aea12f
  ECC_PIPPENGER_C,
Packit aea12f
Packit aea12f
  ECC_ADD_JJJ_ITCH (ECC_LIMB_SIZE),
Packit aea12f
  ECC_MUL_A_ITCH (ECC_LIMB_SIZE),
Packit aea12f
  ECC_MUL_G_ITCH (ECC_LIMB_SIZE),
Packit aea12f
  ECC_J_TO_A_ITCH (ECC_LIMB_SIZE),
Packit aea12f
Packit aea12f
  ecc_add_jjj,
Packit aea12f
  ecc_mul_a,
Packit aea12f
  ecc_mul_g,
Packit aea12f
  ecc_j_to_a,
Packit aea12f
Packit aea12f
  ecc_b,
Packit aea12f
  ecc_g,
Packit aea12f
  NULL,
Packit aea12f
  ecc_unit,
Packit aea12f
  ecc_table
Packit aea12f
};
Packit aea12f
Packit aea12f
const struct ecc_curve *nettle_get_gost_512a(void)
Packit aea12f
{
Packit aea12f
  return &_gnutls_gost_512a;
Packit aea12f
}