1656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* crypto/ec/ec.h */
2656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/*
3656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * Originally written by Bodo Moeller for the OpenSSL project.
4656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project */
5221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/**
6221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * \file crypto/ec/ec.h Include file for the OpenSSL EC functions
7221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * \author Originally written by Bodo Moeller for the OpenSSL project
8221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
9656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* ====================================================================
10221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * Copyright (c) 1998-2005 The OpenSSL Project.  All rights reserved.
11656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *
12656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * Redistribution and use in source and binary forms, with or without
13656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * modification, are permitted provided that the following conditions
14656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * are met:
15656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *
16656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * 1. Redistributions of source code must retain the above copyright
17656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *    notice, this list of conditions and the following disclaimer.
18656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *
19656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * 2. Redistributions in binary form must reproduce the above copyright
20656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *    notice, this list of conditions and the following disclaimer in
21656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *    the documentation and/or other materials provided with the
22656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *    distribution.
23656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *
24656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * 3. All advertising materials mentioning features or use of this
25656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *    software must display the following acknowledgment:
26656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *    "This product includes software developed by the OpenSSL Project
27656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
28656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *
29656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
30656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *    endorse or promote products derived from this software without
31656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *    prior written permission. For written permission, please contact
32656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *    openssl-core@openssl.org.
33656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *
34656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * 5. Products derived from this software may not be called "OpenSSL"
35656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *    nor may "OpenSSL" appear in their names without prior written
36656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *    permission of the OpenSSL Project.
37656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *
38656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * 6. Redistributions of any form whatsoever must retain the following
39656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *    acknowledgment:
40656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *    "This product includes software developed by the OpenSSL Project
41656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
42656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *
43656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
44656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
46656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
47656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
49656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
50656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
51656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
52656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
53656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
54656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * OF THE POSSIBILITY OF SUCH DAMAGE.
55656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * ====================================================================
56656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *
57656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * This product includes cryptographic software written by Eric Young
58656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * (eay@cryptsoft.com).  This product includes software written by Tim
59656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * Hudson (tjh@cryptsoft.com).
60656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *
61656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project */
62656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* ====================================================================
63656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
64656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *
65656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * Portions of the attached software ("Contribution") are developed by
66656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
67656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *
68656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * The Contribution is licensed pursuant to the OpenSSL open source
69656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * license provided above.
70656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *
71656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * The elliptic curve binary polynomial software is originally written by
72656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories.
73656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *
74656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project */
75656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
76656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#ifndef HEADER_EC_H
77656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define HEADER_EC_H
78656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
79656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#include <openssl/opensslconf.h>
80656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
81656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#ifdef OPENSSL_NO_EC
82656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#error EC is disabled.
83656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
84656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
85656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#include <openssl/asn1.h>
86656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#include <openssl/symhacks.h>
87656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#ifndef OPENSSL_NO_DEPRECATED
88656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#include <openssl/bn.h>
89656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
90656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
91656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#ifdef  __cplusplus
92656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectextern "C" {
93656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#elif defined(__SUNPRO_C)
94656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project# if __SUNPRO_C >= 0x520
95656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project# pragma error_messages (off,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE)
96656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project# endif
97656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
98656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
99221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
100656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#ifndef OPENSSL_ECC_MAX_FIELD_BITS
101656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project# define OPENSSL_ECC_MAX_FIELD_BITS 661
102656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
103656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
104221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Enum for the point conversion form as defined in X9.62 (ECDSA)
105221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  for the encoding of a elliptic curve point (x,y) */
106656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projecttypedef enum {
107221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom	/** the point is encoded as z||x, where the octet z specifies
108221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom	 *  which solution of the quadratic equation y is  */
109656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	POINT_CONVERSION_COMPRESSED = 2,
110221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom	/** the point is encoded as z||x||y, where z is the octet 0x02  */
111656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	POINT_CONVERSION_UNCOMPRESSED = 4,
112221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom	/** the point is encoded as z||x||y, where the octet z specifies
113221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom         *  which solution of the quadratic equation y is  */
114656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	POINT_CONVERSION_HYBRID = 6
115656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project} point_conversion_form_t;
116656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
117656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
118656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projecttypedef struct ec_method_st EC_METHOD;
119656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
120656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projecttypedef struct ec_group_st
121656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	/*
122656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	 EC_METHOD *meth;
123656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	 -- field definition
124656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	 -- curve coefficients
125656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	 -- optional generator with associated information (order, cofactor)
126656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	 -- optional extra data (precomputed table for fast computation of multiples of generator)
127656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	 -- ASN1 stuff
128656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	*/
129656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	EC_GROUP;
130656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
131656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projecttypedef struct ec_point_st EC_POINT;
132656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
133656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
134221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/********************************************************************/
135221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/*               EC_METHODs for curves over GF(p)                   */
136221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/********************************************************************/
137221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
138221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Returns the basic GFp ec methods which provides the basis for the
139221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  optimized methods.
140221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return  EC_METHOD object
141656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project */
142656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectconst EC_METHOD *EC_GFp_simple_method(void);
143221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
144221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Returns GFp methods using montgomery multiplication.
145221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return  EC_METHOD object
146221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
147656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectconst EC_METHOD *EC_GFp_mont_method(void);
148221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
149221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Returns GFp methods using optimized methods for NIST recommended curves
150221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return  EC_METHOD object
151221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
152656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectconst EC_METHOD *EC_GFp_nist_method(void);
153656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
154392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
155392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom/** Returns 64-bit optimized methods for nistp224
156392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom *  \return  EC_METHOD object
157392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom */
158392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstromconst EC_METHOD *EC_GFp_nistp224_method(void);
159392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom
160392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom/** Returns 64-bit optimized methods for nistp256
161392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom *  \return  EC_METHOD object
162392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom */
163392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstromconst EC_METHOD *EC_GFp_nistp256_method(void);
164392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom
165392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom/** Returns 64-bit optimized methods for nistp521
166392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom *  \return  EC_METHOD object
167392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom */
168392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstromconst EC_METHOD *EC_GFp_nistp521_method(void);
169392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom#endif
170221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
171392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom#ifndef OPENSSL_NO_EC2M
172221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/********************************************************************/
173221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/*           EC_METHOD for curves over GF(2^m)                      */
174221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/********************************************************************/
175221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
176221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Returns the basic GF2m ec method
177221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return  EC_METHOD object
178656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project */
179656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectconst EC_METHOD *EC_GF2m_simple_method(void);
180656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
181392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom#endif
182392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom
183656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
184221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/********************************************************************/
185221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/*                   EC_GROUP functions                             */
186221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/********************************************************************/
187656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
188221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Creates a new EC_GROUP object
189221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param   meth  EC_METHOD to use
190221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return  newly created EC_GROUP object or NULL in case of an error.
191221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
192221304ee937bc0910948a8be1320cb8cc4eb6d36Brian CarlstromEC_GROUP *EC_GROUP_new(const EC_METHOD *meth);
193656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
194221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Frees a EC_GROUP object
195221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  EC_GROUP object to be freed.
196221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
197221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromvoid EC_GROUP_free(EC_GROUP *group);
198656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
199221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Clears and frees a EC_GROUP object
200221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  EC_GROUP object to be cleared and freed.
201221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
202221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromvoid EC_GROUP_clear_free(EC_GROUP *group);
203656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
204221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Copies EC_GROUP objects. Note: both EC_GROUPs must use the same EC_METHOD.
205221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  dst  destination EC_GROUP object
206221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  src  source EC_GROUP object
207221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occurred.
208221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
209221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src);
210221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
211221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Creates a new EC_GROUP object and copies the copies the content
212221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  form src to the newly created EC_KEY object
213221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  src  source EC_GROUP object
214221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return newly created EC_GROUP object or NULL in case of an error.
215221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
216221304ee937bc0910948a8be1320cb8cc4eb6d36Brian CarlstromEC_GROUP *EC_GROUP_dup(const EC_GROUP *src);
217221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
218221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Returns the EC_METHOD of the EC_GROUP object.
219221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  EC_GROUP object
220221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return EC_METHOD used in this EC_GROUP object.
221221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
222221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromconst EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group);
223221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
224221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Returns the field type of the EC_METHOD.
225221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  meth  EC_METHOD object
226221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return NID of the underlying field type OID.
227221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
228221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_METHOD_get_field_type(const EC_METHOD *meth);
229221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
230221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Sets the generator and it's order/cofactor of a EC_GROUP object.
231221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group      EC_GROUP object
232221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  generator  EC_POINT object with the generator.
233221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  order      the order of the group generated by the generator.
234221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  cofactor   the index of the sub-group generated by the generator
235221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *                     in the group of all points on the elliptic curve.
236221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occured
237221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
238221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor);
239221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
240221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Returns the generator of a EC_GROUP object.
241221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  EC_GROUP object
242221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return the currently used generator (possibly NULL).
243221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
244221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromconst EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group);
245221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
246221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Gets the order of a EC_GROUP
247221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  EC_GROUP object
248221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  order  BIGNUM to which the order is copied
249221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  ctx    BN_CTX object (optional)
250221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occured
251221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
252221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx);
253221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
254221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Gets the cofactor of a EC_GROUP
255221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group     EC_GROUP object
256221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  cofactor  BIGNUM to which the cofactor is copied
257221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  ctx       BN_CTX object (optional)
258221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occured
259221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
260221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, BN_CTX *ctx);
261221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
262221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Sets the name of a EC_GROUP object
263221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  EC_GROUP object
264221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  nid    NID of the curve name OID
265221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
266221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromvoid EC_GROUP_set_curve_name(EC_GROUP *group, int nid);
267221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
268221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Returns the curve name of a EC_GROUP object
269221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  EC_GROUP object
270221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return NID of the curve name OID or 0 if not set.
271221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
272221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_GROUP_get_curve_name(const EC_GROUP *group);
273221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
274221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromvoid EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag);
275221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_GROUP_get_asn1_flag(const EC_GROUP *group);
276656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
27704ef91b390dfcc6125913e2f2af502d23d7a5112Brian Carlstromvoid EC_GROUP_set_point_conversion_form(EC_GROUP *group, point_conversion_form_t form);
278656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectpoint_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *);
279656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
28004ef91b390dfcc6125913e2f2af502d23d7a5112Brian Carlstromunsigned char *EC_GROUP_get0_seed(const EC_GROUP *x);
281656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectsize_t EC_GROUP_get_seed_len(const EC_GROUP *);
282656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectsize_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len);
283656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
284221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Sets the parameter of a ec over GFp defined by y^2 = x^3 + a*x + b
285221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  EC_GROUP object
286221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  p      BIGNUM with the prime number
287221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  a      BIGNUM with parameter a of the equation
288221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  b      BIGNUM with parameter b of the equation
289221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  ctx    BN_CTX object (optional)
290221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occured
291221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
292221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
293221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
294221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Gets the parameter of the ec over GFp defined by y^2 = x^3 + a*x + b
295221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  EC_GROUP object
296221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  p      BIGNUM for the prime number
297221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  a      BIGNUM for parameter a of the equation
298221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  b      BIGNUM for parameter b of the equation
299221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  ctx    BN_CTX object (optional)
300221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occured
301221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
302221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
303221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
304392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom#ifndef OPENSSL_NO_EC2M
305221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Sets the parameter of a ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b
306221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  EC_GROUP object
307221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  p      BIGNUM with the polynomial defining the underlying field
308221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  a      BIGNUM with parameter a of the equation
309221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  b      BIGNUM with parameter b of the equation
310221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  ctx    BN_CTX object (optional)
311221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occured
312221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
313221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
314221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
315221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Gets the parameter of the ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b
316221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  EC_GROUP object
317221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  p      BIGNUM for the polynomial defining the underlying field
318221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  a      BIGNUM for parameter a of the equation
319221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  b      BIGNUM for parameter b of the equation
320221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  ctx    BN_CTX object (optional)
321221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occured
322221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
323221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
324392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom#endif
325221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Returns the number of bits needed to represent a field element
326221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  EC_GROUP object
327221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return number of bits needed to represent a field element
328221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
329221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_GROUP_get_degree(const EC_GROUP *group);
330656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
331221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Checks whether the parameter in the EC_GROUP define a valid ec group
332221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  EC_GROUP object
333221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  ctx    BN_CTX object (optional)
334221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 if group is a valid ec group and 0 otherwise
335221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
336656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectint EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx);
337656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
338221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Checks whether the discriminant of the elliptic curve is zero or not
339221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  EC_GROUP object
340221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  ctx    BN_CTX object (optional)
341221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 if the discriminant is not zero and 0 otherwise
342221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
343221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx);
344221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
345221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Compares two EC_GROUP objects
346221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  a    first EC_GROUP object
347221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  b    second EC_GROUP object
348221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  ctx  BN_CTX object (optional)
349221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 0 if both groups are equal and 1 otherwise
350221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
351221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx);
352656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
353656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*()
354656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * after choosing an appropriate EC_METHOD */
355656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
356221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Creates a new EC_GROUP object with the specified parameters defined
357221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  over GFp (defined by the equation y^2 = x^3 + a*x + b)
358221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  p    BIGNUM with the prime number
359221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  a    BIGNUM with the parameter a of the equation
360221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  b    BIGNUM with the parameter b of the equation
361221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  ctx  BN_CTX object (optional)
362221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return newly created EC_GROUP object with the specified parameters
363221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
364221304ee937bc0910948a8be1320cb8cc4eb6d36Brian CarlstromEC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
365392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom#ifndef OPENSSL_NO_EC2M
366221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Creates a new EC_GROUP object with the specified parameters defined
367221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  over GF2m (defined by the equation y^2 + x*y = x^3 + a*x^2 + b)
368221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  p    BIGNUM with the polynomial defining the underlying field
369221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  a    BIGNUM with the parameter a of the equation
370221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  b    BIGNUM with the parameter b of the equation
371221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  ctx  BN_CTX object (optional)
372221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return newly created EC_GROUP object with the specified parameters
373221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
374221304ee937bc0910948a8be1320cb8cc4eb6d36Brian CarlstromEC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
375392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom#endif
376221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Creates a EC_GROUP object with a curve specified by a NID
377221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  nid  NID of the OID of the curve name
378221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return newly created EC_GROUP object with specified curve or NULL
379221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *          if an error occurred
380221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
381656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectEC_GROUP *EC_GROUP_new_by_curve_name(int nid);
382221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
383221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
384221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/********************************************************************/
385221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/*               handling of internal curves                        */
386221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/********************************************************************/
387221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
388656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projecttypedef struct {
389656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	int nid;
390656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	const char *comment;
391656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	} EC_builtin_curve;
392221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
393656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number
394656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * of all available curves or zero if a error occurred.
395656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * In case r ist not zero nitems EC_builtin_curve structures
396656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * are filled with the data of the first nitems internal groups */
397656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectsize_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems);
398656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
399656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
400221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/********************************************************************/
401221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/*                    EC_POINT functions                            */
402221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/********************************************************************/
403221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
404221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Creates a new EC_POINT object for the specified EC_GROUP
405221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  EC_GROUP the underlying EC_GROUP object
406221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return newly created EC_POINT object or NULL if an error occurred
407221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
408221304ee937bc0910948a8be1320cb8cc4eb6d36Brian CarlstromEC_POINT *EC_POINT_new(const EC_GROUP *group);
409221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
410221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Frees a EC_POINT object
411221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  point  EC_POINT object to be freed
412221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
413221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromvoid EC_POINT_free(EC_POINT *point);
414221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
415221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Clears and frees a EC_POINT object
416221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  point  EC_POINT object to be cleared and freed
417221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
418221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromvoid EC_POINT_clear_free(EC_POINT *point);
419221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
420221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Copies EC_POINT object
421221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  dst  destination EC_POINT object
422221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  src  source EC_POINT object
423221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occured
424221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
425221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_POINT_copy(EC_POINT *dst, const EC_POINT *src);
426656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
427221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Creates a new EC_POINT object and copies the content of the supplied
428221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  EC_POINT
429221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  src    source EC_POINT object
430221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  underlying the EC_GROUP object
431221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return newly created EC_POINT object or NULL if an error occurred
432221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
433221304ee937bc0910948a8be1320cb8cc4eb6d36Brian CarlstromEC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group);
434656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
435221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Returns the EC_METHOD used in EC_POINT object
436221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  point  EC_POINT object
437221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return the EC_METHOD used
438221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
439221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromconst EC_METHOD *EC_POINT_method_of(const EC_POINT *point);
440221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
441221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Sets a point to infinity (neutral element)
442221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  underlying EC_GROUP object
443221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  point  EC_POINT to set to infinity
444221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occured
445221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
446221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point);
447221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
448221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Sets the jacobian projective coordinates of a EC_POINT over GFp
449221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  underlying EC_GROUP object
450221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  p      EC_POINT object
451221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  x      BIGNUM with the x-coordinate
452221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  y      BIGNUM with the y-coordinate
453221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  z      BIGNUM with the z-coordinate
454221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  ctx    BN_CTX object (optional)
455221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occured
456221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
457221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
458221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom	const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *ctx);
459221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
460221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Gets the jacobian projective coordinates of a EC_POINT over GFp
461221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  underlying EC_GROUP object
462221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  p      EC_POINT object
463221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  x      BIGNUM for the x-coordinate
464221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  y      BIGNUM for the y-coordinate
465221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  z      BIGNUM for the z-coordinate
466221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  ctx    BN_CTX object (optional)
467221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occured
468221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
469221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group,
470221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom	const EC_POINT *p, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx);
471221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
472221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Sets the affine coordinates of a EC_POINT over GFp
473221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  underlying EC_GROUP object
474221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  p      EC_POINT object
475221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  x      BIGNUM with the x-coordinate
476221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  y      BIGNUM with the y-coordinate
477221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  ctx    BN_CTX object (optional)
478221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occured
479221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
480221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
481221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom	const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx);
482221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
483221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Gets the affine coordinates of a EC_POINT over GFp
484221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  underlying EC_GROUP object
485221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  p      EC_POINT object
486221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  x      BIGNUM for the x-coordinate
487221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  y      BIGNUM for the y-coordinate
488221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  ctx    BN_CTX object (optional)
489221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occured
490221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
491221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,
492221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom	const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx);
493221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
494221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Sets the x9.62 compressed coordinates of a EC_POINT over GFp
495221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  underlying EC_GROUP object
496221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  p      EC_POINT object
497221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  x      BIGNUM with x-coordinate
498221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  y_bit  integer with the y-Bit (either 0 or 1)
499221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  ctx    BN_CTX object (optional)
500221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occured
501221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
502221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
503221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom	const BIGNUM *x, int y_bit, BN_CTX *ctx);
504392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom#ifndef OPENSSL_NO_EC2M
505221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Sets the affine coordinates of a EC_POINT over GF2m
506221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  underlying EC_GROUP object
507221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  p      EC_POINT object
508221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  x      BIGNUM with the x-coordinate
509221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  y      BIGNUM with the y-coordinate
510221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  ctx    BN_CTX object (optional)
511221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occured
512221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
513221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p,
514221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom	const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx);
515221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
516221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Gets the affine coordinates of a EC_POINT over GF2m
517221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  underlying EC_GROUP object
518221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  p      EC_POINT object
519221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  x      BIGNUM for the x-coordinate
520221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  y      BIGNUM for the y-coordinate
521221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  ctx    BN_CTX object (optional)
522221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occured
523221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
524221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group,
525221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom	const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx);
526221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
527221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Sets the x9.62 compressed coordinates of a EC_POINT over GF2m
528221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  underlying EC_GROUP object
529221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  p      EC_POINT object
530221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  x      BIGNUM with x-coordinate
531221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  y_bit  integer with the y-Bit (either 0 or 1)
532221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  ctx    BN_CTX object (optional)
533221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occured
534221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
535221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p,
536221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom	const BIGNUM *x, int y_bit, BN_CTX *ctx);
537392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom#endif
538221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Encodes a EC_POINT object to a octet string
539221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  underlying EC_GROUP object
540221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  p      EC_POINT object
541221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  form   point conversion form
542221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  buf    memory buffer for the result. If NULL the function returns
543221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *                 required buffer size.
544221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  len    length of the memory buffer
545221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  ctx    BN_CTX object (optional)
546221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return the length of the encoded octet string or 0 if an error occurred
547221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
548221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromsize_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p,
549221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom	point_conversion_form_t form,
550221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom        unsigned char *buf, size_t len, BN_CTX *ctx);
551221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
552221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Decodes a EC_POINT from a octet string
553221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  underlying EC_GROUP object
554221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  p      EC_POINT object
555221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  buf    memory buffer with the encoded ec point
556221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  len    length of the encoded ec point
557221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  ctx    BN_CTX object (optional)
558221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occured
559221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
560221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p,
561221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom        const unsigned char *buf, size_t len, BN_CTX *ctx);
562656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
563656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* other interfaces to point2oct/oct2point: */
564656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectBIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *,
565656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	point_conversion_form_t form, BIGNUM *, BN_CTX *);
566656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectEC_POINT *EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *,
567656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	EC_POINT *, BN_CTX *);
568656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectchar *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *,
569656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	point_conversion_form_t form, BN_CTX *);
570656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectEC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *,
571656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	EC_POINT *, BN_CTX *);
572656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
573656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
574221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/********************************************************************/
575221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/*         functions for doing EC_POINT arithmetic                  */
576221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/********************************************************************/
577221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
578221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Computes the sum of two EC_POINT
579221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  underlying EC_GROUP object
580221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  r      EC_POINT object for the result (r = a + b)
581221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  a      EC_POINT object with the first summand
582221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  b      EC_POINT object with the second summand
583221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  ctx    BN_CTX object (optional)
584221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occured
585221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
586221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx);
587221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
588221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Computes the double of a EC_POINT
589221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  underlying EC_GROUP object
590221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  r      EC_POINT object for the result (r = 2 * a)
591221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  a      EC_POINT object
592221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  ctx    BN_CTX object (optional)
593221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occured
594221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
595221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx);
596221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
597221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Computes the inverse of a EC_POINT
598221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  underlying EC_GROUP object
599221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  a      EC_POINT object to be inverted (it's used for the result as well)
600221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  ctx    BN_CTX object (optional)
601221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occured
602221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
603221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx);
604221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
605221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Checks whether the point is the neutral element of the group
606221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  the underlying EC_GROUP object
607221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  p      EC_POINT object
608221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 if the point is the neutral element and 0 otherwise
609221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
610221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *p);
611221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
612221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Checks whether the point is on the curve
613221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  underlying EC_GROUP object
614221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  point  EC_POINT object to check
615221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  ctx    BN_CTX object (optional)
616221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 if point if on the curve and 0 otherwise
617221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
618221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx);
619221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
620221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Compares two EC_POINTs
621221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  underlying EC_GROUP object
622221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  a      first EC_POINT object
623221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  b      second EC_POINT object
624221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  ctx    BN_CTX object (optional)
625221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 0 if both points are equal and a value != 0 otherwise
626221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
627221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx);
628656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
62904ef91b390dfcc6125913e2f2af502d23d7a5112Brian Carlstromint EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx);
63004ef91b390dfcc6125913e2f2af502d23d7a5112Brian Carlstromint EC_POINTs_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], BN_CTX *ctx);
631656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
632c64f6fe2be99cb3fa8e491b5bede9a217de87a4cKenny Root/** Computes r = generator * n sum_{i=0}^{num-1} p[i] * m[i]
633221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  underlying EC_GROUP object
634221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  r      EC_POINT object for the result
635221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  n      BIGNUM with the multiplier for the group generator (optional)
636221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  num    number futher summands
637221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  p      array of size num of EC_POINT objects
638221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  m      array of size num of BIGNUM objects
639221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  ctx    BN_CTX object (optional)
640221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occured
641221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
642221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, size_t num, const EC_POINT *p[], const BIGNUM *m[], BN_CTX *ctx);
643221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
644221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Computes r = generator * n + q * m
645221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  underlying EC_GROUP object
646221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  r      EC_POINT object for the result
647221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  n      BIGNUM with the multiplier for the group generator (optional)
648221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  q      EC_POINT object with the first factor of the second summand
649221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  m      BIGNUM with the second factor of the second summand
650221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  ctx    BN_CTX object (optional)
651221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occured
652221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
653221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx);
654656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
655221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Stores multiples of generator for faster point multiplication
656221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  EC_GROUP object
657221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  ctx    BN_CTX object (optional)
658221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occured
659221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
660221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx);
661656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
662221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Reports whether a precomputation has been done
663221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  EC_GROUP object
664221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 if a pre-computation has been done and 0 otherwise
665221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
666221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_GROUP_have_precompute_mult(const EC_GROUP *group);
667656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
668656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
669221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/********************************************************************/
670221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/*                       ASN1 stuff                                 */
671221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/********************************************************************/
672656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
673656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* EC_GROUP_get_basis_type() returns the NID of the basis type
674656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * used to represent the field elements */
675656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectint EC_GROUP_get_basis_type(const EC_GROUP *);
676392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom#ifndef OPENSSL_NO_EC2M
677656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectint EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k);
678656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectint EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1,
679656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	unsigned int *k2, unsigned int *k3);
680392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom#endif
681656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
682656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define OPENSSL_EC_NAMED_CURVE	0x001
683656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
684656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projecttypedef struct ecpk_parameters_st ECPKPARAMETERS;
685656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
686656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectEC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len);
687656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectint i2d_ECPKParameters(const EC_GROUP *, unsigned char **out);
688656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
689656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define d2i_ECPKParameters_bio(bp,x) ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x)
690656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define i2d_ECPKParameters_bio(bp,x) ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x)
691656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define d2i_ECPKParameters_fp(fp,x) (EC_GROUP *)ASN1_d2i_fp(NULL, \
692656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project                (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x))
693656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define i2d_ECPKParameters_fp(fp,x) ASN1_i2d_fp(i2d_ECPKParameters,(fp), \
694656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project		(unsigned char *)(x))
695656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
696656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#ifndef OPENSSL_NO_BIO
697656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectint     ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off);
698656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
699656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#ifndef OPENSSL_NO_FP_API
700656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectint     ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off);
701656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
702656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
703221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
704221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/********************************************************************/
705221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/*                      EC_KEY functions                            */
706221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/********************************************************************/
707221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
708656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projecttypedef struct ec_key_st EC_KEY;
709656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
710656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* some values for the encoding_flag */
711656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_PKEY_NO_PARAMETERS	0x001
712656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_PKEY_NO_PUBKEY	0x002
713656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
714392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom/* some values for the flags field */
715392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom#define EC_FLAG_NON_FIPS_ALLOW	0x1
716392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom#define EC_FLAG_FIPS_CHECKED	0x2
717392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom
718221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Creates a new EC_KEY object.
719221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return EC_KEY object or NULL if an error occurred.
720221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
721656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectEC_KEY *EC_KEY_new(void);
722221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
723392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstromint EC_KEY_get_flags(const EC_KEY *key);
724392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom
725392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstromvoid EC_KEY_set_flags(EC_KEY *key, int flags);
726392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom
727392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstromvoid EC_KEY_clear_flags(EC_KEY *key, int flags);
728392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom
729221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Creates a new EC_KEY object using a named curve as underlying
730221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  EC_GROUP object.
731221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  nid  NID of the named curve.
732221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return EC_KEY object or NULL if an error occurred.
733221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
734656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source ProjectEC_KEY *EC_KEY_new_by_curve_name(int nid);
735221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
736221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Frees a EC_KEY object.
737221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  key  EC_KEY object to be freed.
738221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
739221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromvoid EC_KEY_free(EC_KEY *key);
740221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
741221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Copies a EC_KEY object.
742221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  dst  destination EC_KEY object
743221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  src  src EC_KEY object
744221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return dst or NULL if an error occurred.
745221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
746221304ee937bc0910948a8be1320cb8cc4eb6d36Brian CarlstromEC_KEY *EC_KEY_copy(EC_KEY *dst, const EC_KEY *src);
747221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
748221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Creates a new EC_KEY object and copies the content from src to it.
749221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  src  the source EC_KEY object
750221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return newly created EC_KEY object or NULL if an error occurred.
751221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
752221304ee937bc0910948a8be1320cb8cc4eb6d36Brian CarlstromEC_KEY *EC_KEY_dup(const EC_KEY *src);
753221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
754221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Increases the internal reference count of a EC_KEY object.
755221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  key  EC_KEY object
756221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occurred.
757221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
758221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_KEY_up_ref(EC_KEY *key);
759221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
760221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Returns the EC_GROUP object of a EC_KEY object
761221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  key  EC_KEY object
762221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return the EC_GROUP object (possibly NULL).
763221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
764221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromconst EC_GROUP *EC_KEY_get0_group(const EC_KEY *key);
765221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
766221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Sets the EC_GROUP of a EC_KEY object.
767221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  key    EC_KEY object
768221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  group  EC_GROUP to use in the EC_KEY object (note: the EC_KEY
769221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *                 object will use an own copy of the EC_GROUP).
770221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occurred.
771221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
772221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group);
773221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
774221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Returns the private key of a EC_KEY object.
775221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  key  EC_KEY object
776221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return a BIGNUM with the private key (possibly NULL).
777221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
778221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromconst BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key);
779221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
780221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Sets the private key of a EC_KEY object.
781221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  key  EC_KEY object
782221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  prv  BIGNUM with the private key (note: the EC_KEY object
783221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *               will use an own copy of the BIGNUM).
784221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occurred.
785221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
786221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv);
787221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
788221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Returns the public key of a EC_KEY object.
789221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  key  the EC_KEY object
790221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return a EC_POINT object with the public key (possibly NULL)
791221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
792221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromconst EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key);
793221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
794221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Sets the public key of a EC_KEY object.
795221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  key  EC_KEY object
796221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  pub  EC_POINT object with the public key (note: the EC_KEY object
797221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *               will use an own copy of the EC_POINT object).
798221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occurred.
799221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
800221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub);
801221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
802221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromunsigned EC_KEY_get_enc_flags(const EC_KEY *key);
80304ef91b390dfcc6125913e2f2af502d23d7a5112Brian Carlstromvoid EC_KEY_set_enc_flags(EC_KEY *eckey, unsigned int flags);
80404ef91b390dfcc6125913e2f2af502d23d7a5112Brian Carlstrompoint_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key);
80504ef91b390dfcc6125913e2f2af502d23d7a5112Brian Carlstromvoid EC_KEY_set_conv_form(EC_KEY *eckey, point_conversion_form_t cform);
806656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* functions to set/get method specific data  */
80704ef91b390dfcc6125913e2f2af502d23d7a5112Brian Carlstromvoid *EC_KEY_get_key_method_data(EC_KEY *key,
808656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *));
80904ef91b390dfcc6125913e2f2af502d23d7a5112Brian Carlstrom/** Sets the key method data of an EC_KEY object, if none has yet been set.
81004ef91b390dfcc6125913e2f2af502d23d7a5112Brian Carlstrom *  \param  key              EC_KEY object
81104ef91b390dfcc6125913e2f2af502d23d7a5112Brian Carlstrom *  \param  data             opaque data to install.
81204ef91b390dfcc6125913e2f2af502d23d7a5112Brian Carlstrom *  \param  dup_func         a function that duplicates |data|.
81304ef91b390dfcc6125913e2f2af502d23d7a5112Brian Carlstrom *  \param  free_func        a function that frees |data|.
81404ef91b390dfcc6125913e2f2af502d23d7a5112Brian Carlstrom *  \param  clear_free_func  a function that wipes and frees |data|.
81504ef91b390dfcc6125913e2f2af502d23d7a5112Brian Carlstrom *  \return the previously set data pointer, or NULL if |data| was inserted.
81604ef91b390dfcc6125913e2f2af502d23d7a5112Brian Carlstrom */
81704ef91b390dfcc6125913e2f2af502d23d7a5112Brian Carlstromvoid *EC_KEY_insert_key_method_data(EC_KEY *key, void *data,
818656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *));
819656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* wrapper functions for the underlying EC_GROUP object */
82004ef91b390dfcc6125913e2f2af502d23d7a5112Brian Carlstromvoid EC_KEY_set_asn1_flag(EC_KEY *eckey, int asn1_flag);
821221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
82223b9568fd705172c870175f42556ae21861da399Adam Langley/** Sets whether ECDSA operations with the given key will calculate their k
82323b9568fd705172c870175f42556ae21861da399Adam Langley * value from SHA512(private_key + message + random) in order to protect
82423b9568fd705172c870175f42556ae21861da399Adam Langley * against a weak PRNG.
82523b9568fd705172c870175f42556ae21861da399Adam Langley * \param  on  Whether to calculate k from a hash or not
82623b9568fd705172c870175f42556ae21861da399Adam Langley */
82723b9568fd705172c870175f42556ae21861da399Adam Langleyvoid EC_KEY_set_nonce_from_hash(EC_KEY *key, int on);
82823b9568fd705172c870175f42556ae21861da399Adam Langley
82923b9568fd705172c870175f42556ae21861da399Adam Langley/** Returns the value of nonce_from_hash
83023b9568fd705172c870175f42556ae21861da399Adam Langley */
83123b9568fd705172c870175f42556ae21861da399Adam Langleyint EC_KEY_get_nonce_from_hash(const EC_KEY *key);
83223b9568fd705172c870175f42556ae21861da399Adam Langley
833221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Creates a table of pre-computed multiples of the generator to
834221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  accelerate further EC_KEY operations.
835221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  key  EC_KEY object
836221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  ctx  BN_CTX object (optional)
837221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occurred.
838221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
839221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx);
840221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
841221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Creates a new ec private (and optional a new public) key.
842221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  key  EC_KEY object
843221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occurred.
844221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
845221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_KEY_generate_key(EC_KEY *key);
846221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
847221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Verifies that a private and/or public key is valid.
848221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  key  the EC_KEY object
849221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 otherwise.
850221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
851221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint EC_KEY_check_key(const EC_KEY *key);
852221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
853392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom/** Sets a public key from affine coordindates performing
854392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom *  neccessary NIST PKV tests.
855392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom *  \param  key  the EC_KEY object
856392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom *  \param  x    public key x coordinate
857392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom *  \param  y    public key y coordinate
858392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom *  \return 1 on success and 0 otherwise.
859392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom */
860392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstromint EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x, BIGNUM *y);
861392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom
862221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
863221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/********************************************************************/
864221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/*        de- and encoding functions for SEC1 ECPrivateKey          */
865221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/********************************************************************/
866221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
867221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Decodes a private key from a memory buffer.
868221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  key  a pointer to a EC_KEY object which should be used (or NULL)
869221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  in   pointer to memory with the DER encoded private key
870221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  len  length of the DER encoded private key
871221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return the decoded private key or NULL if an error occurred.
872221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
873221304ee937bc0910948a8be1320cb8cc4eb6d36Brian CarlstromEC_KEY *d2i_ECPrivateKey(EC_KEY **key, const unsigned char **in, long len);
874221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
875221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Encodes a private key object and stores the result in a buffer.
876221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  key  the EC_KEY object to encode
877221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  out  the buffer for the result (if NULL the function returns number
878221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *               of bytes needed).
879221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occurred.
880221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
881221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint i2d_ECPrivateKey(EC_KEY *key, unsigned char **out);
882221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
883221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
884221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/********************************************************************/
885221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/*        de- and encoding functions for EC parameters              */
886221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/********************************************************************/
887221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
888221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Decodes ec parameter from a memory buffer.
889221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  key  a pointer to a EC_KEY object which should be used (or NULL)
890221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  in   pointer to memory with the DER encoded ec parameters
891221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  len  length of the DER encoded ec parameters
892221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return a EC_KEY object with the decoded parameters or NULL if an error
893221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *          occurred.
894221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
895221304ee937bc0910948a8be1320cb8cc4eb6d36Brian CarlstromEC_KEY *d2i_ECParameters(EC_KEY **key, const unsigned char **in, long len);
896221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
897221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Encodes ec parameter and stores the result in a buffer.
898221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  key  the EC_KEY object with ec paramters to encode
899221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  out  the buffer for the result (if NULL the function returns number
900221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *               of bytes needed).
901221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occurred.
902221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
903221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint i2d_ECParameters(EC_KEY *key, unsigned char **out);
904221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
905221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
906221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/********************************************************************/
907221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/*         de- and encoding functions for EC public key             */
908221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/*         (octet string, not DER -- hence 'o2i' and 'i2o')         */
909221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/********************************************************************/
910221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
911221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Decodes a ec public key from a octet string.
912221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  key  a pointer to a EC_KEY object which should be used
913221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  in   memory buffer with the encoded public key
914221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  len  length of the encoded public key
915221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return EC_KEY object with decoded public key or NULL if an error
916221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *          occurred.
917221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
918221304ee937bc0910948a8be1320cb8cc4eb6d36Brian CarlstromEC_KEY *o2i_ECPublicKey(EC_KEY **key, const unsigned char **in, long len);
919221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
920221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Encodes a ec public key in an octet string.
921221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  key  the EC_KEY object with the public key
922221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  out  the buffer for the result (if NULL the function returns number
923221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *               of bytes needed).
924221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occurred
925221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
926221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint i2o_ECPublicKey(EC_KEY *key, unsigned char **out);
927656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
928656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#ifndef OPENSSL_NO_BIO
929221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Prints out the ec parameters on human readable form.
930221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  bp   BIO object to which the information is printed
931221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  key  EC_KEY object
932221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occurred
933221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
934221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint	ECParameters_print(BIO *bp, const EC_KEY *key);
935221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
936221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Prints out the contents of a EC_KEY object
937221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  bp   BIO object to which the information is printed
938221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  key  EC_KEY object
939221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  off  line offset
940221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occurred
941221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
942221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint	EC_KEY_print(BIO *bp, const EC_KEY *key, int off);
943221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
944656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
945656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#ifndef OPENSSL_NO_FP_API
946221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Prints out the ec parameters on human readable form.
947221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  fp   file descriptor to which the information is printed
948221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  key  EC_KEY object
949221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occurred
950221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
951221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint	ECParameters_print_fp(FILE *fp, const EC_KEY *key);
952221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
953221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/** Prints out the contents of a EC_KEY object
954221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  fp   file descriptor to which the information is printed
955221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  key  EC_KEY object
956221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \param  off  line offset
957221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom *  \return 1 on success and 0 if an error occurred
958221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
959221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstromint	EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off);
960221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
961656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
962656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
963656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x)
964656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
965656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#ifndef __cplusplus
966656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#if defined(__SUNPRO_C)
967656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  if __SUNPRO_C >= 0x520
968656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project# pragma error_messages (default,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE)
969656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  endif
970656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project# endif
971656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
972656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
973221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid) \
974221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom	EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, EVP_PKEY_OP_PARAMGEN, \
975221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom				EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL)
976221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
977221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
978221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#define EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID		(EVP_PKEY_ALG_CTRL + 1)
979221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
980656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* BEGIN ERROR CODES */
981656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* The following lines are auto generated by the script mkerr.pl. Any changes
982656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * made after this point may be overwritten when the script is next run.
983656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project */
984656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectvoid ERR_load_EC_strings(void);
985656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
986656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* Error codes for the EC functions. */
987656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
988656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* Function codes. */
989392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom#define EC_F_BN_TO_FELEM				 224
990656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_COMPUTE_WNAF				 143
991656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_D2I_ECPARAMETERS				 144
992656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_D2I_ECPKPARAMETERS				 145
993656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_D2I_ECPRIVATEKEY				 146
994221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#define EC_F_DO_EC_KEY_PRINT				 221
995221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#define EC_F_ECKEY_PARAM2TYPE				 223
996221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#define EC_F_ECKEY_PARAM_DECODE				 212
997221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#define EC_F_ECKEY_PRIV_DECODE				 213
998221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#define EC_F_ECKEY_PRIV_ENCODE				 214
999221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#define EC_F_ECKEY_PUB_DECODE				 215
1000221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#define EC_F_ECKEY_PUB_ENCODE				 216
1001221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#define EC_F_ECKEY_TYPE2PARAM				 220
1002656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_ECPARAMETERS_PRINT				 147
1003656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_ECPARAMETERS_PRINT_FP			 148
1004656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_ECPKPARAMETERS_PRINT			 149
1005656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_ECPKPARAMETERS_PRINT_FP			 150
1006656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_ECP_NIST_MOD_192				 203
1007656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_ECP_NIST_MOD_224				 204
1008656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_ECP_NIST_MOD_256				 205
1009656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_ECP_NIST_MOD_521				 206
1010656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_ASN1_GROUP2CURVE			 153
1011656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_ASN1_GROUP2FIELDID			 154
1012656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_ASN1_GROUP2PARAMETERS			 155
1013656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_ASN1_GROUP2PKPARAMETERS			 156
1014656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_ASN1_PARAMETERS2GROUP			 157
1015656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_ASN1_PKPARAMETERS2GROUP			 158
1016656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_EX_DATA_SET_DATA			 211
1017656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY		 208
1018656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT	 159
1019656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE		 195
1020656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GF2M_SIMPLE_OCT2POINT			 160
1021656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GF2M_SIMPLE_POINT2OCT			 161
1022656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 162
1023656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 163
1024656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES	 164
1025656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GFP_MONT_FIELD_DECODE			 133
1026656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GFP_MONT_FIELD_ENCODE			 134
1027656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GFP_MONT_FIELD_MUL			 131
1028656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE		 209
1029656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GFP_MONT_FIELD_SQR			 132
1030656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GFP_MONT_GROUP_SET_CURVE		 189
1031656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GFP_MONT_GROUP_SET_CURVE_GFP		 135
1032392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom#define EC_F_EC_GFP_NISTP224_GROUP_SET_CURVE		 225
1033392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom#define EC_F_EC_GFP_NISTP224_POINTS_MUL			 228
1034392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom#define EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES 226
1035392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom#define EC_F_EC_GFP_NISTP256_GROUP_SET_CURVE		 230
1036392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom#define EC_F_EC_GFP_NISTP256_POINTS_MUL			 231
1037392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom#define EC_F_EC_GFP_NISTP256_POINT_GET_AFFINE_COORDINATES 232
1038392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom#define EC_F_EC_GFP_NISTP521_GROUP_SET_CURVE		 233
1039392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom#define EC_F_EC_GFP_NISTP521_POINTS_MUL			 234
1040392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom#define EC_F_EC_GFP_NISTP521_POINT_GET_AFFINE_COORDINATES 235
1041656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GFP_NIST_FIELD_MUL			 200
1042656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GFP_NIST_FIELD_SQR			 201
1043656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GFP_NIST_GROUP_SET_CURVE		 202
1044656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT	 165
1045656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE		 166
1046656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE_GFP		 100
1047656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GFP_SIMPLE_GROUP_SET_GENERATOR		 101
1048656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE			 102
1049656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GFP_SIMPLE_OCT2POINT			 103
1050656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GFP_SIMPLE_POINT2OCT			 104
1051656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE		 137
1052656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES	 167
1053656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP 105
1054656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES	 168
1055656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES_GFP 128
1056656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES	 169
1057656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP 129
1058656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GROUP_CHECK				 170
1059656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GROUP_CHECK_DISCRIMINANT		 171
1060656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GROUP_COPY				 106
1061656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GROUP_GET0_GENERATOR			 139
1062656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GROUP_GET_COFACTOR			 140
1063656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GROUP_GET_CURVE_GF2M			 172
1064656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GROUP_GET_CURVE_GFP			 130
1065656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GROUP_GET_DEGREE			 173
1066656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GROUP_GET_ORDER				 141
1067656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS		 193
1068656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS		 194
1069656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GROUP_NEW				 108
1070656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GROUP_NEW_BY_CURVE_NAME			 174
1071656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GROUP_NEW_FROM_DATA			 175
1072656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GROUP_PRECOMPUTE_MULT			 142
1073656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GROUP_SET_CURVE_GF2M			 176
1074656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GROUP_SET_CURVE_GFP			 109
1075656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GROUP_SET_EXTRA_DATA			 110
1076656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_GROUP_SET_GENERATOR			 111
1077656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_KEY_CHECK_KEY				 177
1078656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_KEY_COPY				 178
1079656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_KEY_GENERATE_KEY			 179
1080656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_KEY_NEW					 182
1081656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_KEY_PRINT				 180
1082656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_KEY_PRINT_FP				 181
1083392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom#define EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES	 229
1084656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_POINTS_MAKE_AFFINE			 136
1085656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_POINT_ADD				 112
1086656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_POINT_CMP				 113
1087656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_POINT_COPY				 114
1088656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_POINT_DBL				 115
1089656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M	 183
1090656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP	 116
1091656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP	 117
1092656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_POINT_INVERT				 210
1093656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_POINT_IS_AT_INFINITY			 118
1094656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_POINT_IS_ON_CURVE			 119
1095656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_POINT_MAKE_AFFINE			 120
1096656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_POINT_MUL				 184
1097656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_POINT_NEW				 121
1098656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_POINT_OCT2POINT				 122
1099656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_POINT_POINT2OCT				 123
1100656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M	 185
1101656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP	 124
1102656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M	 186
1103656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP	 125
1104656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP	 126
1105656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_POINT_SET_TO_INFINITY			 127
1106656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_PRE_COMP_DUP				 207
1107656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_PRE_COMP_NEW				 196
1108656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_WNAF_MUL				 187
1109656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_EC_WNAF_PRECOMPUTE_MULT			 188
1110656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_I2D_ECPARAMETERS				 190
1111656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_I2D_ECPKPARAMETERS				 191
1112656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_I2D_ECPRIVATEKEY				 192
1113656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_I2O_ECPUBLICKEY				 151
1114392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom#define EC_F_NISTP224_PRE_COMP_NEW			 227
1115392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom#define EC_F_NISTP256_PRE_COMP_NEW			 236
1116392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom#define EC_F_NISTP521_PRE_COMP_NEW			 237
1117656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_F_O2I_ECPUBLICKEY				 152
1118221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#define EC_F_OLD_EC_PRIV_DECODE				 222
1119221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#define EC_F_PKEY_EC_CTRL				 197
1120221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#define EC_F_PKEY_EC_CTRL_STR				 198
1121221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#define EC_F_PKEY_EC_DERIVE				 217
1122221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#define EC_F_PKEY_EC_KEYGEN				 199
1123221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#define EC_F_PKEY_EC_PARAMGEN				 219
1124221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#define EC_F_PKEY_EC_SIGN				 218
1125656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
1126656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* Reason codes. */
1127656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_ASN1_ERROR					 115
1128656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_ASN1_UNKNOWN_FIELD				 116
1129392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom#define EC_R_BIGNUM_OUT_OF_RANGE			 144
1130656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_BUFFER_TOO_SMALL				 100
1131392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom#define EC_R_COORDINATES_OUT_OF_RANGE			 146
1132656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_D2I_ECPKPARAMETERS_FAILURE			 117
1133221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#define EC_R_DECODE_ERROR				 142
1134656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_DISCRIMINANT_IS_ZERO			 118
1135656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE		 119
1136221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#define EC_R_FIELD_TOO_LARGE				 143
1137392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom#define EC_R_GF2M_NOT_SUPPORTED				 147
1138656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_GROUP2PKPARAMETERS_FAILURE			 120
1139656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_I2D_ECPKPARAMETERS_FAILURE			 121
1140656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_INCOMPATIBLE_OBJECTS			 101
1141656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_INVALID_ARGUMENT				 112
1142656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_INVALID_COMPRESSED_POINT			 110
1143656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_INVALID_COMPRESSION_BIT			 109
1144221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#define EC_R_INVALID_CURVE				 141
1145221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#define EC_R_INVALID_DIGEST_TYPE			 138
1146656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_INVALID_ENCODING				 102
1147656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_INVALID_FIELD				 103
1148656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_INVALID_FORM				 104
1149656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_INVALID_GROUP_ORDER			 122
1150656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_INVALID_PENTANOMIAL_BASIS			 132
1151656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_INVALID_PRIVATE_KEY			 123
1152656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_INVALID_TRINOMIAL_BASIS			 137
1153221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#define EC_R_KEYS_NOT_SET				 140
1154656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_MISSING_PARAMETERS				 124
1155656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_MISSING_PRIVATE_KEY			 125
1156656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_NOT_A_NIST_PRIME				 135
1157656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_NOT_A_SUPPORTED_NIST_PRIME			 136
1158656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_NOT_IMPLEMENTED				 126
1159656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_NOT_INITIALIZED				 111
1160656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_NO_FIELD_MOD				 133
1161221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#define EC_R_NO_PARAMETERS_SET				 139
1162656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_PASSED_NULL_PARAMETER			 134
1163656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_PKPARAMETERS2GROUP_FAILURE			 127
1164656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_POINT_AT_INFINITY				 106
1165656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_POINT_IS_NOT_ON_CURVE			 107
1166656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_SLOT_FULL					 108
1167656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_UNDEFINED_GENERATOR			 113
1168656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_UNDEFINED_ORDER				 128
1169656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_UNKNOWN_GROUP				 129
1170656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_UNKNOWN_ORDER				 114
1171656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_UNSUPPORTED_FIELD				 131
1172392aa7cc7d2b122614c5393c3e357da07fd07af3Brian Carlstrom#define EC_R_WRONG_CURVE_PARAMETERS			 145
1173656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define EC_R_WRONG_ORDER				 130
1174656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
1175656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#ifdef  __cplusplus
1176656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project}
1177656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
1178656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
1179