1 /* ec-context.h - Private definitions for CONTEXT_TYPE_EC.
2 * Copyright (C) 2013 g10 Code GmbH
4 * This file is part of Libgcrypt.
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.
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.
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/>.
20 #ifndef GCRY_EC_CONTEXT_H
21 #define GCRY_EC_CONTEXT_H
23 /* This context is used with all our EC functions. */
26 /* Domain parameters. Note that they may not all be set and if set
27 the MPIs may be flaged as constant.*/
28 gcry_mpi_t p; /* Prime specifying the field GF(p). */
29 gcry_mpi_t a; /* First coefficient of the Weierstrass equation. */
30 gcry_mpi_t b; /* Second coefficient of the Weierstrass equation. */
31 gcry_mpi_point_t G; /* Base point (generator). */
32 gcry_mpi_t n; /* Order of G. */
34 /* The actual key. May not be set. */
35 gcry_mpi_point_t Q; /* Public key. */
36 gcry_mpi_t d; /* Private key. */
39 /* This structure is private to mpi/ec.c! */
42 unsigned int a_is_pminus3:1;
43 unsigned int two_inv_p:1;
44 } valid; /* Flags to help setting the helper vars below. */
46 int a_is_pminus3; /* True if A = P - 3. */
50 /* Scratch variables. */
51 gcry_mpi_t scratch[11];
53 /* Helper for fast reduction. */
54 /* int nist_nbits; /\* If this is a NIST curve, the # of bits. *\/ */
55 /* gcry_mpi_t s[10]; */
62 #endif /*GCRY_EC_CONTEXT_H*/