LCOV - code coverage report
Current view: top level - cipher - ecc-common.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 5 0.0 %
Date: 2016-12-15 12:59:22 Functions: 0 1 0.0 %

          Line data    Source code
       1             : /* ecc-common.h - Declarations of common ECC code
       2             :  * Copyright (C) 2013 g10 Code GmbH
       3             :  *
       4             :  * This file is part of Libgcrypt.
       5             :  *
       6             :  * Libgcrypt is free software; you can redistribute it and/or modify
       7             :  * it under the terms of the GNU Lesser General Public License as
       8             :  * published by the Free Software Foundation; either version 2.1 of
       9             :  * the License, or (at your option) any later version.
      10             :  *
      11             :  * Libgcrypt is distributed in the hope that it will be useful,
      12             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             :  * GNU Lesser General Public License for more details.
      15             :  *
      16             :  * You should have received a copy of the GNU Lesser General Public
      17             :  * License along with this program; if not, see <http://www.gnu.org/licenses/>.
      18             :  */
      19             : 
      20             : #ifndef GCRY_ECC_COMMON_H
      21             : #define GCRY_ECC_COMMON_H
      22             : 
      23             : 
      24             : /* Definition of a curve.  */
      25             : typedef struct
      26             : {
      27             :   enum gcry_mpi_ec_models model;/* The model descrinbing this curve.  */
      28             :   enum ecc_dialects dialect;    /* The dialect used with the curve.   */
      29             :   gcry_mpi_t p;         /* Prime specifying the field GF(p).  */
      30             :   gcry_mpi_t a;         /* First coefficient of the Weierstrass equation.  */
      31             :   gcry_mpi_t b;         /* Second coefficient of the Weierstrass equation.
      32             :                            or d as used by Twisted Edwards curves.  */
      33             :   mpi_point_struct G;   /* Base point (generator).  */
      34             :   gcry_mpi_t n;         /* Order of G.  */
      35             :   gcry_mpi_t h;         /* Cofactor.  */
      36             :   const char *name;     /* Name of the curve or NULL.  */
      37             : } elliptic_curve_t;
      38             : 
      39             : 
      40             : typedef struct
      41             : {
      42             :   elliptic_curve_t E;
      43             :   mpi_point_struct Q; /* Q = [d]G  */
      44             : } ECC_public_key;
      45             : 
      46             : 
      47             : typedef struct
      48             : {
      49             :   elliptic_curve_t E;
      50             :   mpi_point_struct Q;
      51             :   gcry_mpi_t d;
      52             : } ECC_secret_key;
      53             : 
      54             : 
      55             : 
      56             : /* Set the value from S into D.  */
      57             : static inline void
      58           0 : point_set (mpi_point_t d, mpi_point_t s)
      59             : {
      60           0 :   mpi_set (d->x, s->x);
      61           0 :   mpi_set (d->y, s->y);
      62           0 :   mpi_set (d->z, s->z);
      63           0 : }
      64             : 
      65             : #define point_init(a)  _gcry_mpi_point_init ((a))
      66             : #define point_free(a)  _gcry_mpi_point_free_parts ((a))
      67             : 
      68             : 
      69             : /*-- ecc-curves.c --*/
      70             : gpg_err_code_t _gcry_ecc_fill_in_curve (unsigned int nbits,
      71             :                                         const char *name,
      72             :                                         elliptic_curve_t *curve,
      73             :                                         unsigned int *r_nbits);
      74             : gpg_err_code_t _gcry_ecc_update_curve_param (const char *name,
      75             :                                              enum gcry_mpi_ec_models *model,
      76             :                                              enum ecc_dialects *dialect,
      77             :                                              gcry_mpi_t *p, gcry_mpi_t *a,
      78             :                                              gcry_mpi_t *b, gcry_mpi_t *g,
      79             :                                              gcry_mpi_t *n, gcry_mpi_t *h);
      80             : 
      81             : const char *_gcry_ecc_get_curve (gcry_sexp_t keyparms,
      82             :                                  int iterator,
      83             :                                  unsigned int *r_nbits);
      84             : gcry_sexp_t _gcry_ecc_get_param_sexp (const char *name);
      85             : 
      86             : /*-- ecc-misc.c --*/
      87             : void _gcry_ecc_curve_free (elliptic_curve_t *E);
      88             : elliptic_curve_t _gcry_ecc_curve_copy (elliptic_curve_t E);
      89             : const char *_gcry_ecc_model2str (enum gcry_mpi_ec_models model);
      90             : const char *_gcry_ecc_dialect2str (enum ecc_dialects dialect);
      91             : gcry_mpi_t   _gcry_ecc_ec2os (gcry_mpi_t x, gcry_mpi_t y, gcry_mpi_t p);
      92             : 
      93             : mpi_point_t  _gcry_ecc_compute_public (mpi_point_t Q, mpi_ec_t ec,
      94             :                                        mpi_point_t G, gcry_mpi_t d);
      95             : 
      96             : 
      97             : /*-- ecc.c --*/
      98             : 
      99             : /*-- ecc-ecdsa.c --*/
     100             : gpg_err_code_t _gcry_ecc_ecdsa_sign (gcry_mpi_t input, ECC_secret_key *skey,
     101             :                                      gcry_mpi_t r, gcry_mpi_t s,
     102             :                                      int flags, int hashalgo);
     103             : gpg_err_code_t _gcry_ecc_ecdsa_verify (gcry_mpi_t input, ECC_public_key *pkey,
     104             :                                        gcry_mpi_t r, gcry_mpi_t s);
     105             : 
     106             : /*-- ecc-eddsa.c --*/
     107             : gpg_err_code_t _gcry_ecc_eddsa_recover_x (gcry_mpi_t x, gcry_mpi_t y, int sign,
     108             :                                           mpi_ec_t ec);
     109             : gpg_err_code_t _gcry_ecc_eddsa_encodepoint (mpi_point_t point, mpi_ec_t ctx,
     110             :                                             gcry_mpi_t x, gcry_mpi_t y,
     111             :                                             int with_prefix,
     112             :                                             unsigned char **r_buffer,
     113             :                                             unsigned int *r_buflen);
     114             : gpg_err_code_t _gcry_ecc_eddsa_ensure_compact (gcry_mpi_t value,
     115             :                                                unsigned int nbits);
     116             : 
     117             : 
     118             : gpg_err_code_t _gcry_ecc_eddsa_compute_h_d (unsigned char **r_digest,
     119             :                                             gcry_mpi_t d, mpi_ec_t ec);
     120             : 
     121             : gpg_err_code_t _gcry_ecc_eddsa_genkey (ECC_secret_key *sk,
     122             :                                        elliptic_curve_t *E,
     123             :                                        mpi_ec_t ctx,
     124             :                                        int flags);
     125             : gpg_err_code_t _gcry_ecc_eddsa_sign (gcry_mpi_t input,
     126             :                                      ECC_secret_key *sk,
     127             :                                      gcry_mpi_t r_r, gcry_mpi_t s,
     128             :                                      int hashalgo, gcry_mpi_t pk);
     129             : gpg_err_code_t _gcry_ecc_eddsa_verify (gcry_mpi_t input,
     130             :                                        ECC_public_key *pk,
     131             :                                        gcry_mpi_t r, gcry_mpi_t s,
     132             :                                        int hashalgo, gcry_mpi_t pkmpi);
     133             : 
     134             : /*-- ecc-gost.c --*/
     135             : gpg_err_code_t _gcry_ecc_gost_sign (gcry_mpi_t input, ECC_secret_key *skey,
     136             :                                     gcry_mpi_t r, gcry_mpi_t s);
     137             : gpg_err_code_t _gcry_ecc_gost_verify (gcry_mpi_t input, ECC_public_key *pkey,
     138             :                                       gcry_mpi_t r, gcry_mpi_t s);
     139             : 
     140             : 
     141             : #endif /*GCRY_ECC_COMMON_H*/

Generated by: LCOV version 1.12