ec.h revision 238405
1109998Smarkm/* crypto/ec/ec.h */
2160814Ssimon/*
3160814Ssimon * Originally written by Bodo Moeller for the OpenSSL project.
4160814Ssimon */
5238405Sjkim/**
6238405Sjkim * \file crypto/ec/ec.h Include file for the OpenSSL EC functions
7238405Sjkim * \author Originally written by Bodo Moeller for the OpenSSL project
8238405Sjkim */
9109998Smarkm/* ====================================================================
10238405Sjkim * Copyright (c) 1998-2005 The OpenSSL Project.  All rights reserved.
11109998Smarkm *
12109998Smarkm * Redistribution and use in source and binary forms, with or without
13109998Smarkm * modification, are permitted provided that the following conditions
14109998Smarkm * are met:
15109998Smarkm *
16109998Smarkm * 1. Redistributions of source code must retain the above copyright
17109998Smarkm *    notice, this list of conditions and the following disclaimer.
18109998Smarkm *
19109998Smarkm * 2. Redistributions in binary form must reproduce the above copyright
20109998Smarkm *    notice, this list of conditions and the following disclaimer in
21109998Smarkm *    the documentation and/or other materials provided with the
22109998Smarkm *    distribution.
23109998Smarkm *
24109998Smarkm * 3. All advertising materials mentioning features or use of this
25109998Smarkm *    software must display the following acknowledgment:
26109998Smarkm *    "This product includes software developed by the OpenSSL Project
27109998Smarkm *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
28109998Smarkm *
29109998Smarkm * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
30109998Smarkm *    endorse or promote products derived from this software without
31109998Smarkm *    prior written permission. For written permission, please contact
32109998Smarkm *    openssl-core@openssl.org.
33109998Smarkm *
34109998Smarkm * 5. Products derived from this software may not be called "OpenSSL"
35109998Smarkm *    nor may "OpenSSL" appear in their names without prior written
36109998Smarkm *    permission of the OpenSSL Project.
37109998Smarkm *
38109998Smarkm * 6. Redistributions of any form whatsoever must retain the following
39109998Smarkm *    acknowledgment:
40109998Smarkm *    "This product includes software developed by the OpenSSL Project
41109998Smarkm *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
42109998Smarkm *
43109998Smarkm * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
44109998Smarkm * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45109998Smarkm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
46109998Smarkm * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
47109998Smarkm * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48109998Smarkm * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
49109998Smarkm * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
50109998Smarkm * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
51109998Smarkm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
52109998Smarkm * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
53109998Smarkm * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
54109998Smarkm * OF THE POSSIBILITY OF SUCH DAMAGE.
55109998Smarkm * ====================================================================
56109998Smarkm *
57109998Smarkm * This product includes cryptographic software written by Eric Young
58109998Smarkm * (eay@cryptsoft.com).  This product includes software written by Tim
59109998Smarkm * Hudson (tjh@cryptsoft.com).
60109998Smarkm *
61109998Smarkm */
62160814Ssimon/* ====================================================================
63160814Ssimon * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
64160814Ssimon *
65160814Ssimon * Portions of the attached software ("Contribution") are developed by
66160814Ssimon * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
67160814Ssimon *
68160814Ssimon * The Contribution is licensed pursuant to the OpenSSL open source
69160814Ssimon * license provided above.
70160814Ssimon *
71160814Ssimon * The elliptic curve binary polynomial software is originally written by
72160814Ssimon * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories.
73160814Ssimon *
74160814Ssimon */
75109998Smarkm
76109998Smarkm#ifndef HEADER_EC_H
77109998Smarkm#define HEADER_EC_H
78109998Smarkm
79160814Ssimon#include <openssl/opensslconf.h>
80160814Ssimon
81109998Smarkm#ifdef OPENSSL_NO_EC
82109998Smarkm#error EC is disabled.
83109998Smarkm#endif
84109998Smarkm
85160814Ssimon#include <openssl/asn1.h>
86160814Ssimon#include <openssl/symhacks.h>
87160814Ssimon#ifndef OPENSSL_NO_DEPRECATED
88109998Smarkm#include <openssl/bn.h>
89160814Ssimon#endif
90109998Smarkm
91109998Smarkm#ifdef  __cplusplus
92109998Smarkmextern "C" {
93160814Ssimon#elif defined(__SUNPRO_C)
94160814Ssimon# if __SUNPRO_C >= 0x520
95160814Ssimon# pragma error_messages (off,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE)
96160814Ssimon# endif
97109998Smarkm#endif
98109998Smarkm
99238405Sjkim
100162911Ssimon#ifndef OPENSSL_ECC_MAX_FIELD_BITS
101162911Ssimon# define OPENSSL_ECC_MAX_FIELD_BITS 661
102162911Ssimon#endif
103162911Ssimon
104238405Sjkim/** Enum for the point conversion form as defined in X9.62 (ECDSA)
105238405Sjkim *  for the encoding of a elliptic curve point (x,y) */
106109998Smarkmtypedef enum {
107238405Sjkim	/** the point is encoded as z||x, where the octet z specifies
108238405Sjkim	 *  which solution of the quadratic equation y is  */
109109998Smarkm	POINT_CONVERSION_COMPRESSED = 2,
110238405Sjkim	/** the point is encoded as z||x||y, where z is the octet 0x02  */
111109998Smarkm	POINT_CONVERSION_UNCOMPRESSED = 4,
112238405Sjkim	/** the point is encoded as z||x||y, where the octet z specifies
113238405Sjkim         *  which solution of the quadratic equation y is  */
114109998Smarkm	POINT_CONVERSION_HYBRID = 6
115109998Smarkm} point_conversion_form_t;
116109998Smarkm
117109998Smarkm
118109998Smarkmtypedef struct ec_method_st EC_METHOD;
119109998Smarkm
120109998Smarkmtypedef struct ec_group_st
121109998Smarkm	/*
122109998Smarkm	 EC_METHOD *meth;
123109998Smarkm	 -- field definition
124109998Smarkm	 -- curve coefficients
125109998Smarkm	 -- optional generator with associated information (order, cofactor)
126160814Ssimon	 -- optional extra data (precomputed table for fast computation of multiples of generator)
127160814Ssimon	 -- ASN1 stuff
128109998Smarkm	*/
129109998Smarkm	EC_GROUP;
130109998Smarkm
131109998Smarkmtypedef struct ec_point_st EC_POINT;
132109998Smarkm
133109998Smarkm
134238405Sjkim/********************************************************************/
135238405Sjkim/*               EC_METHODs for curves over GF(p)                   */
136238405Sjkim/********************************************************************/
137238405Sjkim
138238405Sjkim/** Returns the basic GFp ec methods which provides the basis for the
139238405Sjkim *  optimized methods.
140238405Sjkim *  \return  EC_METHOD object
141109998Smarkm */
142109998Smarkmconst EC_METHOD *EC_GFp_simple_method(void);
143238405Sjkim
144238405Sjkim/** Returns GFp methods using montgomery multiplication.
145238405Sjkim *  \return  EC_METHOD object
146238405Sjkim */
147109998Smarkmconst EC_METHOD *EC_GFp_mont_method(void);
148238405Sjkim
149238405Sjkim/** Returns GFp methods using optimized methods for NIST recommended curves
150238405Sjkim *  \return  EC_METHOD object
151238405Sjkim */
152160814Ssimonconst EC_METHOD *EC_GFp_nist_method(void);
153109998Smarkm
154238405Sjkim#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
155238405Sjkim/** Returns 64-bit optimized methods for nistp224
156238405Sjkim *  \return  EC_METHOD object
157160814Ssimon */
158238405Sjkimconst EC_METHOD *EC_GFp_nistp224_method(void);
159238405Sjkim
160238405Sjkim/** Returns 64-bit optimized methods for nistp256
161238405Sjkim *  \return  EC_METHOD object
162238405Sjkim */
163238405Sjkimconst EC_METHOD *EC_GFp_nistp256_method(void);
164238405Sjkim
165238405Sjkim/** Returns 64-bit optimized methods for nistp521
166238405Sjkim *  \return  EC_METHOD object
167238405Sjkim */
168238405Sjkimconst EC_METHOD *EC_GFp_nistp521_method(void);
169238405Sjkim#endif
170238405Sjkim
171238405Sjkim#ifndef OPENSSL_NO_EC2M
172238405Sjkim/********************************************************************/
173238405Sjkim/*           EC_METHOD for curves over GF(2^m)                      */
174238405Sjkim/********************************************************************/
175238405Sjkim
176238405Sjkim/** Returns the basic GF2m ec method
177238405Sjkim *  \return  EC_METHOD object
178238405Sjkim */
179160814Ssimonconst EC_METHOD *EC_GF2m_simple_method(void);
180109998Smarkm
181238405Sjkim#endif
182160814Ssimon
183109998Smarkm
184238405Sjkim/********************************************************************/
185238405Sjkim/*                   EC_GROUP functions                             */
186238405Sjkim/********************************************************************/
187109998Smarkm
188238405Sjkim/** Creates a new EC_GROUP object
189238405Sjkim *  \param   meth  EC_METHOD to use
190238405Sjkim *  \return  newly created EC_GROUP object or NULL in case of an error.
191238405Sjkim */
192238405SjkimEC_GROUP *EC_GROUP_new(const EC_METHOD *meth);
193160814Ssimon
194238405Sjkim/** Frees a EC_GROUP object
195238405Sjkim *  \param  group  EC_GROUP object to be freed.
196238405Sjkim */
197238405Sjkimvoid EC_GROUP_free(EC_GROUP *group);
198160814Ssimon
199238405Sjkim/** Clears and frees a EC_GROUP object
200238405Sjkim *  \param  group  EC_GROUP object to be cleared and freed.
201238405Sjkim */
202238405Sjkimvoid EC_GROUP_clear_free(EC_GROUP *group);
203160814Ssimon
204238405Sjkim/** Copies EC_GROUP objects. Note: both EC_GROUPs must use the same EC_METHOD.
205238405Sjkim *  \param  dst  destination EC_GROUP object
206238405Sjkim *  \param  src  source EC_GROUP object
207238405Sjkim *  \return 1 on success and 0 if an error occurred.
208238405Sjkim */
209238405Sjkimint EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src);
210238405Sjkim
211238405Sjkim/** Creates a new EC_GROUP object and copies the copies the content
212238405Sjkim *  form src to the newly created EC_KEY object
213238405Sjkim *  \param  src  source EC_GROUP object
214238405Sjkim *  \return newly created EC_GROUP object or NULL in case of an error.
215238405Sjkim */
216238405SjkimEC_GROUP *EC_GROUP_dup(const EC_GROUP *src);
217238405Sjkim
218238405Sjkim/** Returns the EC_METHOD of the EC_GROUP object.
219238405Sjkim *  \param  group  EC_GROUP object
220238405Sjkim *  \return EC_METHOD used in this EC_GROUP object.
221238405Sjkim */
222238405Sjkimconst EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group);
223238405Sjkim
224238405Sjkim/** Returns the field type of the EC_METHOD.
225238405Sjkim *  \param  meth  EC_METHOD object
226238405Sjkim *  \return NID of the underlying field type OID.
227238405Sjkim */
228238405Sjkimint EC_METHOD_get_field_type(const EC_METHOD *meth);
229238405Sjkim
230238405Sjkim/** Sets the generator and it's order/cofactor of a EC_GROUP object.
231238405Sjkim *  \param  group      EC_GROUP object
232238405Sjkim *  \param  generator  EC_POINT object with the generator.
233238405Sjkim *  \param  order      the order of the group generated by the generator.
234238405Sjkim *  \param  cofactor   the index of the sub-group generated by the generator
235238405Sjkim *                     in the group of all points on the elliptic curve.
236238405Sjkim *  \return 1 on success and 0 if an error occured
237238405Sjkim */
238238405Sjkimint EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor);
239238405Sjkim
240238405Sjkim/** Returns the generator of a EC_GROUP object.
241238405Sjkim *  \param  group  EC_GROUP object
242238405Sjkim *  \return the currently used generator (possibly NULL).
243238405Sjkim */
244238405Sjkimconst EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group);
245238405Sjkim
246238405Sjkim/** Gets the order of a EC_GROUP
247238405Sjkim *  \param  group  EC_GROUP object
248238405Sjkim *  \param  order  BIGNUM to which the order is copied
249238405Sjkim *  \param  ctx    BN_CTX object (optional)
250238405Sjkim *  \return 1 on success and 0 if an error occured
251238405Sjkim */
252238405Sjkimint EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx);
253238405Sjkim
254238405Sjkim/** Gets the cofactor of a EC_GROUP
255238405Sjkim *  \param  group     EC_GROUP object
256238405Sjkim *  \param  cofactor  BIGNUM to which the cofactor is copied
257238405Sjkim *  \param  ctx       BN_CTX object (optional)
258238405Sjkim *  \return 1 on success and 0 if an error occured
259238405Sjkim */
260238405Sjkimint EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, BN_CTX *ctx);
261238405Sjkim
262238405Sjkim/** Sets the name of a EC_GROUP object
263238405Sjkim *  \param  group  EC_GROUP object
264238405Sjkim *  \param  nid    NID of the curve name OID
265238405Sjkim */
266238405Sjkimvoid EC_GROUP_set_curve_name(EC_GROUP *group, int nid);
267238405Sjkim
268238405Sjkim/** Returns the curve name of a EC_GROUP object
269238405Sjkim *  \param  group  EC_GROUP object
270238405Sjkim *  \return NID of the curve name OID or 0 if not set.
271238405Sjkim */
272238405Sjkimint EC_GROUP_get_curve_name(const EC_GROUP *group);
273238405Sjkim
274238405Sjkimvoid EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag);
275238405Sjkimint EC_GROUP_get_asn1_flag(const EC_GROUP *group);
276238405Sjkim
277160814Ssimonvoid EC_GROUP_set_point_conversion_form(EC_GROUP *, point_conversion_form_t);
278160814Ssimonpoint_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *);
279160814Ssimon
280160814Ssimonunsigned char *EC_GROUP_get0_seed(const EC_GROUP *);
281160814Ssimonsize_t EC_GROUP_get_seed_len(const EC_GROUP *);
282160814Ssimonsize_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len);
283160814Ssimon
284238405Sjkim/** Sets the parameter of a ec over GFp defined by y^2 = x^3 + a*x + b
285238405Sjkim *  \param  group  EC_GROUP object
286238405Sjkim *  \param  p      BIGNUM with the prime number
287238405Sjkim *  \param  a      BIGNUM with parameter a of the equation
288238405Sjkim *  \param  b      BIGNUM with parameter b of the equation
289238405Sjkim *  \param  ctx    BN_CTX object (optional)
290238405Sjkim *  \return 1 on success and 0 if an error occured
291238405Sjkim */
292238405Sjkimint EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
293109998Smarkm
294238405Sjkim/** Gets the parameter of the ec over GFp defined by y^2 = x^3 + a*x + b
295238405Sjkim *  \param  group  EC_GROUP object
296238405Sjkim *  \param  p      BIGNUM for the prime number
297238405Sjkim *  \param  a      BIGNUM for parameter a of the equation
298238405Sjkim *  \param  b      BIGNUM for parameter b of the equation
299238405Sjkim *  \param  ctx    BN_CTX object (optional)
300238405Sjkim *  \return 1 on success and 0 if an error occured
301238405Sjkim */
302238405Sjkimint EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
303160814Ssimon
304238405Sjkim#ifndef OPENSSL_NO_EC2M
305238405Sjkim/** Sets the parameter of a ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b
306238405Sjkim *  \param  group  EC_GROUP object
307238405Sjkim *  \param  p      BIGNUM with the polynomial defining the underlying field
308238405Sjkim *  \param  a      BIGNUM with parameter a of the equation
309238405Sjkim *  \param  b      BIGNUM with parameter b of the equation
310238405Sjkim *  \param  ctx    BN_CTX object (optional)
311238405Sjkim *  \return 1 on success and 0 if an error occured
312238405Sjkim */
313238405Sjkimint EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
314238405Sjkim
315238405Sjkim/** Gets the parameter of the ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b
316238405Sjkim *  \param  group  EC_GROUP object
317238405Sjkim *  \param  p      BIGNUM for the polynomial defining the underlying field
318238405Sjkim *  \param  a      BIGNUM for parameter a of the equation
319238405Sjkim *  \param  b      BIGNUM for parameter b of the equation
320238405Sjkim *  \param  ctx    BN_CTX object (optional)
321238405Sjkim *  \return 1 on success and 0 if an error occured
322238405Sjkim */
323238405Sjkimint EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
324238405Sjkim#endif
325238405Sjkim/** Returns the number of bits needed to represent a field element
326238405Sjkim *  \param  group  EC_GROUP object
327238405Sjkim *  \return number of bits needed to represent a field element
328238405Sjkim */
329238405Sjkimint EC_GROUP_get_degree(const EC_GROUP *group);
330238405Sjkim
331238405Sjkim/** Checks whether the parameter in the EC_GROUP define a valid ec group
332238405Sjkim *  \param  group  EC_GROUP object
333238405Sjkim *  \param  ctx    BN_CTX object (optional)
334238405Sjkim *  \return 1 if group is a valid ec group and 0 otherwise
335238405Sjkim */
336160814Ssimonint EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx);
337160814Ssimon
338238405Sjkim/** Checks whether the discriminant of the elliptic curve is zero or not
339238405Sjkim *  \param  group  EC_GROUP object
340238405Sjkim *  \param  ctx    BN_CTX object (optional)
341238405Sjkim *  \return 1 if the discriminant is not zero and 0 otherwise
342238405Sjkim */
343238405Sjkimint EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx);
344160814Ssimon
345238405Sjkim/** Compares two EC_GROUP objects
346238405Sjkim *  \param  a    first EC_GROUP object
347238405Sjkim *  \param  b    second EC_GROUP object
348238405Sjkim *  \param  ctx  BN_CTX object (optional)
349238405Sjkim *  \return 0 if both groups are equal and 1 otherwise
350238405Sjkim */
351238405Sjkimint EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx);
352238405Sjkim
353160814Ssimon/* EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*()
354109998Smarkm * after choosing an appropriate EC_METHOD */
355109998Smarkm
356238405Sjkim/** Creates a new EC_GROUP object with the specified parameters defined
357238405Sjkim *  over GFp (defined by the equation y^2 = x^3 + a*x + b)
358238405Sjkim *  \param  p    BIGNUM with the prime number
359238405Sjkim *  \param  a    BIGNUM with the parameter a of the equation
360238405Sjkim *  \param  b    BIGNUM with the parameter b of the equation
361238405Sjkim *  \param  ctx  BN_CTX object (optional)
362238405Sjkim *  \return newly created EC_GROUP object with the specified parameters
363238405Sjkim */
364238405SjkimEC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
365238405Sjkim#ifndef OPENSSL_NO_EC2M
366238405Sjkim/** Creates a new EC_GROUP object with the specified parameters defined
367238405Sjkim *  over GF2m (defined by the equation y^2 + x*y = x^3 + a*x^2 + b)
368238405Sjkim *  \param  p    BIGNUM with the polynomial defining the underlying field
369238405Sjkim *  \param  a    BIGNUM with the parameter a of the equation
370238405Sjkim *  \param  b    BIGNUM with the parameter b of the equation
371238405Sjkim *  \param  ctx  BN_CTX object (optional)
372238405Sjkim *  \return newly created EC_GROUP object with the specified parameters
373238405Sjkim */
374238405SjkimEC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
375238405Sjkim#endif
376238405Sjkim/** Creates a EC_GROUP object with a curve specified by a NID
377238405Sjkim *  \param  nid  NID of the OID of the curve name
378238405Sjkim *  \return newly created EC_GROUP object with specified curve or NULL
379238405Sjkim *          if an error occurred
380238405Sjkim */
381160814SsimonEC_GROUP *EC_GROUP_new_by_curve_name(int nid);
382238405Sjkim
383238405Sjkim
384238405Sjkim/********************************************************************/
385238405Sjkim/*               handling of internal curves                        */
386238405Sjkim/********************************************************************/
387238405Sjkim
388160814Ssimontypedef struct {
389160814Ssimon	int nid;
390160814Ssimon	const char *comment;
391160814Ssimon	} EC_builtin_curve;
392238405Sjkim
393160814Ssimon/* EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number
394160814Ssimon * of all available curves or zero if a error occurred.
395160814Ssimon * In case r ist not zero nitems EC_builtin_curve structures
396160814Ssimon * are filled with the data of the first nitems internal groups */
397160814Ssimonsize_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems);
398109998Smarkm
399160814Ssimon
400238405Sjkim/********************************************************************/
401238405Sjkim/*                    EC_POINT functions                            */
402238405Sjkim/********************************************************************/
403160814Ssimon
404238405Sjkim/** Creates a new EC_POINT object for the specified EC_GROUP
405238405Sjkim *  \param  group  EC_GROUP the underlying EC_GROUP object
406238405Sjkim *  \return newly created EC_POINT object or NULL if an error occurred
407238405Sjkim */
408238405SjkimEC_POINT *EC_POINT_new(const EC_GROUP *group);
409238405Sjkim
410238405Sjkim/** Frees a EC_POINT object
411238405Sjkim *  \param  point  EC_POINT object to be freed
412238405Sjkim */
413238405Sjkimvoid EC_POINT_free(EC_POINT *point);
414238405Sjkim
415238405Sjkim/** Clears and frees a EC_POINT object
416238405Sjkim *  \param  point  EC_POINT object to be cleared and freed
417238405Sjkim */
418238405Sjkimvoid EC_POINT_clear_free(EC_POINT *point);
419238405Sjkim
420238405Sjkim/** Copies EC_POINT object
421238405Sjkim *  \param  dst  destination EC_POINT object
422238405Sjkim *  \param  src  source EC_POINT object
423238405Sjkim *  \return 1 on success and 0 if an error occured
424238405Sjkim */
425238405Sjkimint EC_POINT_copy(EC_POINT *dst, const EC_POINT *src);
426238405Sjkim
427238405Sjkim/** Creates a new EC_POINT object and copies the content of the supplied
428238405Sjkim *  EC_POINT
429238405Sjkim *  \param  src    source EC_POINT object
430238405Sjkim *  \param  group  underlying the EC_GROUP object
431238405Sjkim *  \return newly created EC_POINT object or NULL if an error occurred
432238405Sjkim */
433238405SjkimEC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group);
434109998Smarkm
435238405Sjkim/** Returns the EC_METHOD used in EC_POINT object
436238405Sjkim *  \param  point  EC_POINT object
437238405Sjkim *  \return the EC_METHOD used
438238405Sjkim */
439238405Sjkimconst EC_METHOD *EC_POINT_method_of(const EC_POINT *point);
440109998Smarkm
441238405Sjkim/** Sets a point to infinity (neutral element)
442238405Sjkim *  \param  group  underlying EC_GROUP object
443238405Sjkim *  \param  point  EC_POINT to set to infinity
444238405Sjkim *  \return 1 on success and 0 if an error occured
445238405Sjkim */
446238405Sjkimint EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point);
447109998Smarkm
448238405Sjkim/** Sets the jacobian projective coordinates of a EC_POINT over GFp
449238405Sjkim *  \param  group  underlying EC_GROUP object
450238405Sjkim *  \param  p      EC_POINT object
451238405Sjkim *  \param  x      BIGNUM with the x-coordinate
452238405Sjkim *  \param  y      BIGNUM with the y-coordinate
453238405Sjkim *  \param  z      BIGNUM with the z-coordinate
454238405Sjkim *  \param  ctx    BN_CTX object (optional)
455238405Sjkim *  \return 1 on success and 0 if an error occured
456238405Sjkim */
457238405Sjkimint EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
458238405Sjkim	const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *ctx);
459160814Ssimon
460238405Sjkim/** Gets the jacobian projective coordinates of a EC_POINT over GFp
461238405Sjkim *  \param  group  underlying EC_GROUP object
462238405Sjkim *  \param  p      EC_POINT object
463238405Sjkim *  \param  x      BIGNUM for the x-coordinate
464238405Sjkim *  \param  y      BIGNUM for the y-coordinate
465238405Sjkim *  \param  z      BIGNUM for the z-coordinate
466238405Sjkim *  \param  ctx    BN_CTX object (optional)
467238405Sjkim *  \return 1 on success and 0 if an error occured
468238405Sjkim */
469238405Sjkimint EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group,
470238405Sjkim	const EC_POINT *p, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx);
471109998Smarkm
472238405Sjkim/** Sets the affine coordinates of a EC_POINT over GFp
473238405Sjkim *  \param  group  underlying EC_GROUP object
474238405Sjkim *  \param  p      EC_POINT object
475238405Sjkim *  \param  x      BIGNUM with the x-coordinate
476238405Sjkim *  \param  y      BIGNUM with the y-coordinate
477238405Sjkim *  \param  ctx    BN_CTX object (optional)
478238405Sjkim *  \return 1 on success and 0 if an error occured
479238405Sjkim */
480238405Sjkimint EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
481238405Sjkim	const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx);
482238405Sjkim
483238405Sjkim/** Gets the affine coordinates of a EC_POINT over GFp
484238405Sjkim *  \param  group  underlying EC_GROUP object
485238405Sjkim *  \param  p      EC_POINT object
486238405Sjkim *  \param  x      BIGNUM for the x-coordinate
487238405Sjkim *  \param  y      BIGNUM for the y-coordinate
488238405Sjkim *  \param  ctx    BN_CTX object (optional)
489238405Sjkim *  \return 1 on success and 0 if an error occured
490238405Sjkim */
491238405Sjkimint EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,
492238405Sjkim	const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx);
493238405Sjkim
494238405Sjkim/** Sets the x9.62 compressed coordinates of a EC_POINT over GFp
495238405Sjkim *  \param  group  underlying EC_GROUP object
496238405Sjkim *  \param  p      EC_POINT object
497238405Sjkim *  \param  x      BIGNUM with x-coordinate
498238405Sjkim *  \param  y_bit  integer with the y-Bit (either 0 or 1)
499238405Sjkim *  \param  ctx    BN_CTX object (optional)
500238405Sjkim *  \return 1 on success and 0 if an error occured
501238405Sjkim */
502238405Sjkimint EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
503238405Sjkim	const BIGNUM *x, int y_bit, BN_CTX *ctx);
504238405Sjkim#ifndef OPENSSL_NO_EC2M
505238405Sjkim/** Sets the affine coordinates of a EC_POINT over GF2m
506238405Sjkim *  \param  group  underlying EC_GROUP object
507238405Sjkim *  \param  p      EC_POINT object
508238405Sjkim *  \param  x      BIGNUM with the x-coordinate
509238405Sjkim *  \param  y      BIGNUM with the y-coordinate
510238405Sjkim *  \param  ctx    BN_CTX object (optional)
511238405Sjkim *  \return 1 on success and 0 if an error occured
512238405Sjkim */
513238405Sjkimint EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p,
514238405Sjkim	const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx);
515238405Sjkim
516238405Sjkim/** Gets the affine coordinates of a EC_POINT over GF2m
517238405Sjkim *  \param  group  underlying EC_GROUP object
518238405Sjkim *  \param  p      EC_POINT object
519238405Sjkim *  \param  x      BIGNUM for the x-coordinate
520238405Sjkim *  \param  y      BIGNUM for the y-coordinate
521238405Sjkim *  \param  ctx    BN_CTX object (optional)
522238405Sjkim *  \return 1 on success and 0 if an error occured
523238405Sjkim */
524238405Sjkimint EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group,
525238405Sjkim	const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx);
526238405Sjkim
527238405Sjkim/** Sets the x9.62 compressed coordinates of a EC_POINT over GF2m
528238405Sjkim *  \param  group  underlying EC_GROUP object
529238405Sjkim *  \param  p      EC_POINT object
530238405Sjkim *  \param  x      BIGNUM with x-coordinate
531238405Sjkim *  \param  y_bit  integer with the y-Bit (either 0 or 1)
532238405Sjkim *  \param  ctx    BN_CTX object (optional)
533238405Sjkim *  \return 1 on success and 0 if an error occured
534238405Sjkim */
535238405Sjkimint EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p,
536238405Sjkim	const BIGNUM *x, int y_bit, BN_CTX *ctx);
537238405Sjkim#endif
538238405Sjkim/** Encodes a EC_POINT object to a octet string
539238405Sjkim *  \param  group  underlying EC_GROUP object
540238405Sjkim *  \param  p      EC_POINT object
541238405Sjkim *  \param  form   point conversion form
542238405Sjkim *  \param  buf    memory buffer for the result. If NULL the function returns
543238405Sjkim *                 required buffer size.
544238405Sjkim *  \param  len    length of the memory buffer
545238405Sjkim *  \param  ctx    BN_CTX object (optional)
546238405Sjkim *  \return the length of the encoded octet string or 0 if an error occurred
547238405Sjkim */
548238405Sjkimsize_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p,
549238405Sjkim	point_conversion_form_t form,
550238405Sjkim        unsigned char *buf, size_t len, BN_CTX *ctx);
551238405Sjkim
552238405Sjkim/** Decodes a EC_POINT from a octet string
553238405Sjkim *  \param  group  underlying EC_GROUP object
554238405Sjkim *  \param  p      EC_POINT object
555238405Sjkim *  \param  buf    memory buffer with the encoded ec point
556238405Sjkim *  \param  len    length of the encoded ec point
557238405Sjkim *  \param  ctx    BN_CTX object (optional)
558238405Sjkim *  \return 1 on success and 0 if an error occured
559238405Sjkim */
560238405Sjkimint EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p,
561238405Sjkim        const unsigned char *buf, size_t len, BN_CTX *ctx);
562238405Sjkim
563160814Ssimon/* other interfaces to point2oct/oct2point: */
564160814SsimonBIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *,
565160814Ssimon	point_conversion_form_t form, BIGNUM *, BN_CTX *);
566160814SsimonEC_POINT *EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *,
567160814Ssimon	EC_POINT *, BN_CTX *);
568160814Ssimonchar *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *,
569160814Ssimon	point_conversion_form_t form, BN_CTX *);
570160814SsimonEC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *,
571160814Ssimon	EC_POINT *, BN_CTX *);
572160814Ssimon
573109998Smarkm
574238405Sjkim/********************************************************************/
575238405Sjkim/*         functions for doing EC_POINT arithmetic                  */
576238405Sjkim/********************************************************************/
577109998Smarkm
578238405Sjkim/** Computes the sum of two EC_POINT
579238405Sjkim *  \param  group  underlying EC_GROUP object
580238405Sjkim *  \param  r      EC_POINT object for the result (r = a + b)
581238405Sjkim *  \param  a      EC_POINT object with the first summand
582238405Sjkim *  \param  b      EC_POINT object with the second summand
583238405Sjkim *  \param  ctx    BN_CTX object (optional)
584238405Sjkim *  \return 1 on success and 0 if an error occured
585238405Sjkim */
586238405Sjkimint EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx);
587238405Sjkim
588238405Sjkim/** Computes the double of a EC_POINT
589238405Sjkim *  \param  group  underlying EC_GROUP object
590238405Sjkim *  \param  r      EC_POINT object for the result (r = 2 * a)
591238405Sjkim *  \param  a      EC_POINT object
592238405Sjkim *  \param  ctx    BN_CTX object (optional)
593238405Sjkim *  \return 1 on success and 0 if an error occured
594238405Sjkim */
595238405Sjkimint EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx);
596238405Sjkim
597238405Sjkim/** Computes the inverse of a EC_POINT
598238405Sjkim *  \param  group  underlying EC_GROUP object
599238405Sjkim *  \param  a      EC_POINT object to be inverted (it's used for the result as well)
600238405Sjkim *  \param  ctx    BN_CTX object (optional)
601238405Sjkim *  \return 1 on success and 0 if an error occured
602238405Sjkim */
603238405Sjkimint EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx);
604238405Sjkim
605238405Sjkim/** Checks whether the point is the neutral element of the group
606238405Sjkim *  \param  group  the underlying EC_GROUP object
607238405Sjkim *  \param  p      EC_POINT object
608238405Sjkim *  \return 1 if the point is the neutral element and 0 otherwise
609238405Sjkim */
610238405Sjkimint EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *p);
611238405Sjkim
612238405Sjkim/** Checks whether the point is on the curve
613238405Sjkim *  \param  group  underlying EC_GROUP object
614238405Sjkim *  \param  point  EC_POINT object to check
615238405Sjkim *  \param  ctx    BN_CTX object (optional)
616238405Sjkim *  \return 1 if point if on the curve and 0 otherwise
617238405Sjkim */
618238405Sjkimint EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx);
619238405Sjkim
620238405Sjkim/** Compares two EC_POINTs
621238405Sjkim *  \param  group  underlying EC_GROUP object
622238405Sjkim *  \param  a      first EC_POINT object
623238405Sjkim *  \param  b      second EC_POINT object
624238405Sjkim *  \param  ctx    BN_CTX object (optional)
625238405Sjkim *  \return 0 if both points are equal and a value != 0 otherwise
626238405Sjkim */
627238405Sjkimint EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx);
628238405Sjkim
629109998Smarkmint EC_POINT_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *);
630109998Smarkmint EC_POINTs_make_affine(const EC_GROUP *, size_t num, EC_POINT *[], BN_CTX *);
631109998Smarkm
632238405Sjkim/** Computes r = generator * n sum_{i=0}^num p[i] * m[i]
633238405Sjkim *  \param  group  underlying EC_GROUP object
634238405Sjkim *  \param  r      EC_POINT object for the result
635238405Sjkim *  \param  n      BIGNUM with the multiplier for the group generator (optional)
636238405Sjkim *  \param  num    number futher summands
637238405Sjkim *  \param  p      array of size num of EC_POINT objects
638238405Sjkim *  \param  m      array of size num of BIGNUM objects
639238405Sjkim *  \param  ctx    BN_CTX object (optional)
640238405Sjkim *  \return 1 on success and 0 if an error occured
641238405Sjkim */
642238405Sjkimint 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);
643109998Smarkm
644238405Sjkim/** Computes r = generator * n + q * m
645238405Sjkim *  \param  group  underlying EC_GROUP object
646238405Sjkim *  \param  r      EC_POINT object for the result
647238405Sjkim *  \param  n      BIGNUM with the multiplier for the group generator (optional)
648238405Sjkim *  \param  q      EC_POINT object with the first factor of the second summand
649238405Sjkim *  \param  m      BIGNUM with the second factor of the second summand
650238405Sjkim *  \param  ctx    BN_CTX object (optional)
651238405Sjkim *  \return 1 on success and 0 if an error occured
652238405Sjkim */
653238405Sjkimint EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx);
654160814Ssimon
655238405Sjkim/** Stores multiples of generator for faster point multiplication
656238405Sjkim *  \param  group  EC_GROUP object
657238405Sjkim *  \param  ctx    BN_CTX object (optional)
658238405Sjkim *  \return 1 on success and 0 if an error occured
659238405Sjkim */
660238405Sjkimint EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx);
661109998Smarkm
662238405Sjkim/** Reports whether a precomputation has been done
663238405Sjkim *  \param  group  EC_GROUP object
664238405Sjkim *  \return 1 if a pre-computation has been done and 0 otherwise
665238405Sjkim */
666238405Sjkimint EC_GROUP_have_precompute_mult(const EC_GROUP *group);
667109998Smarkm
668109998Smarkm
669238405Sjkim/********************************************************************/
670238405Sjkim/*                       ASN1 stuff                                 */
671238405Sjkim/********************************************************************/
672160814Ssimon
673160814Ssimon/* EC_GROUP_get_basis_type() returns the NID of the basis type
674160814Ssimon * used to represent the field elements */
675160814Ssimonint EC_GROUP_get_basis_type(const EC_GROUP *);
676238405Sjkim#ifndef OPENSSL_NO_EC2M
677160814Ssimonint EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k);
678160814Ssimonint EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1,
679160814Ssimon	unsigned int *k2, unsigned int *k3);
680238405Sjkim#endif
681160814Ssimon
682160814Ssimon#define OPENSSL_EC_NAMED_CURVE	0x001
683160814Ssimon
684160814Ssimontypedef struct ecpk_parameters_st ECPKPARAMETERS;
685160814Ssimon
686160814SsimonEC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len);
687160814Ssimonint i2d_ECPKParameters(const EC_GROUP *, unsigned char **out);
688160814Ssimon
689160814Ssimon#define d2i_ECPKParameters_bio(bp,x) ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x)
690160814Ssimon#define i2d_ECPKParameters_bio(bp,x) ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x)
691160814Ssimon#define d2i_ECPKParameters_fp(fp,x) (EC_GROUP *)ASN1_d2i_fp(NULL, \
692160814Ssimon                (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x))
693160814Ssimon#define i2d_ECPKParameters_fp(fp,x) ASN1_i2d_fp(i2d_ECPKParameters,(fp), \
694160814Ssimon		(unsigned char *)(x))
695160814Ssimon
696160814Ssimon#ifndef OPENSSL_NO_BIO
697160814Ssimonint     ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off);
698160814Ssimon#endif
699160814Ssimon#ifndef OPENSSL_NO_FP_API
700160814Ssimonint     ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off);
701160814Ssimon#endif
702160814Ssimon
703238405Sjkim
704238405Sjkim/********************************************************************/
705238405Sjkim/*                      EC_KEY functions                            */
706238405Sjkim/********************************************************************/
707238405Sjkim
708160814Ssimontypedef struct ec_key_st EC_KEY;
709160814Ssimon
710160814Ssimon/* some values for the encoding_flag */
711160814Ssimon#define EC_PKEY_NO_PARAMETERS	0x001
712160814Ssimon#define EC_PKEY_NO_PUBKEY	0x002
713160814Ssimon
714238405Sjkim/* some values for the flags field */
715238405Sjkim#define EC_FLAG_NON_FIPS_ALLOW	0x1
716238405Sjkim#define EC_FLAG_FIPS_CHECKED	0x2
717238405Sjkim
718238405Sjkim/** Creates a new EC_KEY object.
719238405Sjkim *  \return EC_KEY object or NULL if an error occurred.
720238405Sjkim */
721160814SsimonEC_KEY *EC_KEY_new(void);
722238405Sjkim
723238405Sjkimint EC_KEY_get_flags(const EC_KEY *key);
724238405Sjkim
725238405Sjkimvoid EC_KEY_set_flags(EC_KEY *key, int flags);
726238405Sjkim
727238405Sjkimvoid EC_KEY_clear_flags(EC_KEY *key, int flags);
728238405Sjkim
729238405Sjkim/** Creates a new EC_KEY object using a named curve as underlying
730238405Sjkim *  EC_GROUP object.
731238405Sjkim *  \param  nid  NID of the named curve.
732238405Sjkim *  \return EC_KEY object or NULL if an error occurred.
733238405Sjkim */
734160814SsimonEC_KEY *EC_KEY_new_by_curve_name(int nid);
735160814Ssimon
736238405Sjkim/** Frees a EC_KEY object.
737238405Sjkim *  \param  key  EC_KEY object to be freed.
738238405Sjkim */
739238405Sjkimvoid EC_KEY_free(EC_KEY *key);
740160814Ssimon
741238405Sjkim/** Copies a EC_KEY object.
742238405Sjkim *  \param  dst  destination EC_KEY object
743238405Sjkim *  \param  src  src EC_KEY object
744238405Sjkim *  \return dst or NULL if an error occurred.
745238405Sjkim */
746238405SjkimEC_KEY *EC_KEY_copy(EC_KEY *dst, const EC_KEY *src);
747238405Sjkim
748238405Sjkim/** Creates a new EC_KEY object and copies the content from src to it.
749238405Sjkim *  \param  src  the source EC_KEY object
750238405Sjkim *  \return newly created EC_KEY object or NULL if an error occurred.
751238405Sjkim */
752238405SjkimEC_KEY *EC_KEY_dup(const EC_KEY *src);
753238405Sjkim
754238405Sjkim/** Increases the internal reference count of a EC_KEY object.
755238405Sjkim *  \param  key  EC_KEY object
756238405Sjkim *  \return 1 on success and 0 if an error occurred.
757238405Sjkim */
758238405Sjkimint EC_KEY_up_ref(EC_KEY *key);
759238405Sjkim
760238405Sjkim/** Returns the EC_GROUP object of a EC_KEY object
761238405Sjkim *  \param  key  EC_KEY object
762238405Sjkim *  \return the EC_GROUP object (possibly NULL).
763238405Sjkim */
764238405Sjkimconst EC_GROUP *EC_KEY_get0_group(const EC_KEY *key);
765238405Sjkim
766238405Sjkim/** Sets the EC_GROUP of a EC_KEY object.
767238405Sjkim *  \param  key    EC_KEY object
768238405Sjkim *  \param  group  EC_GROUP to use in the EC_KEY object (note: the EC_KEY
769238405Sjkim *                 object will use an own copy of the EC_GROUP).
770238405Sjkim *  \return 1 on success and 0 if an error occurred.
771238405Sjkim */
772238405Sjkimint EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group);
773238405Sjkim
774238405Sjkim/** Returns the private key of a EC_KEY object.
775238405Sjkim *  \param  key  EC_KEY object
776238405Sjkim *  \return a BIGNUM with the private key (possibly NULL).
777238405Sjkim */
778238405Sjkimconst BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key);
779238405Sjkim
780238405Sjkim/** Sets the private key of a EC_KEY object.
781238405Sjkim *  \param  key  EC_KEY object
782238405Sjkim *  \param  prv  BIGNUM with the private key (note: the EC_KEY object
783238405Sjkim *               will use an own copy of the BIGNUM).
784238405Sjkim *  \return 1 on success and 0 if an error occurred.
785238405Sjkim */
786238405Sjkimint EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv);
787238405Sjkim
788238405Sjkim/** Returns the public key of a EC_KEY object.
789238405Sjkim *  \param  key  the EC_KEY object
790238405Sjkim *  \return a EC_POINT object with the public key (possibly NULL)
791238405Sjkim */
792238405Sjkimconst EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key);
793238405Sjkim
794238405Sjkim/** Sets the public key of a EC_KEY object.
795238405Sjkim *  \param  key  EC_KEY object
796238405Sjkim *  \param  pub  EC_POINT object with the public key (note: the EC_KEY object
797238405Sjkim *               will use an own copy of the EC_POINT object).
798238405Sjkim *  \return 1 on success and 0 if an error occurred.
799238405Sjkim */
800238405Sjkimint EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub);
801238405Sjkim
802238405Sjkimunsigned EC_KEY_get_enc_flags(const EC_KEY *key);
803160814Ssimonvoid EC_KEY_set_enc_flags(EC_KEY *, unsigned int);
804160814Ssimonpoint_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *);
805160814Ssimonvoid EC_KEY_set_conv_form(EC_KEY *, point_conversion_form_t);
806160814Ssimon/* functions to set/get method specific data  */
807160814Ssimonvoid *EC_KEY_get_key_method_data(EC_KEY *,
808160814Ssimon	void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *));
809160814Ssimonvoid EC_KEY_insert_key_method_data(EC_KEY *, void *data,
810160814Ssimon	void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *));
811160814Ssimon/* wrapper functions for the underlying EC_GROUP object */
812160814Ssimonvoid EC_KEY_set_asn1_flag(EC_KEY *, int);
813160814Ssimon
814238405Sjkim/** Creates a table of pre-computed multiples of the generator to
815238405Sjkim *  accelerate further EC_KEY operations.
816238405Sjkim *  \param  key  EC_KEY object
817238405Sjkim *  \param  ctx  BN_CTX object (optional)
818238405Sjkim *  \return 1 on success and 0 if an error occurred.
819238405Sjkim */
820238405Sjkimint EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx);
821160814Ssimon
822238405Sjkim/** Creates a new ec private (and optional a new public) key.
823238405Sjkim *  \param  key  EC_KEY object
824238405Sjkim *  \return 1 on success and 0 if an error occurred.
825238405Sjkim */
826238405Sjkimint EC_KEY_generate_key(EC_KEY *key);
827160814Ssimon
828238405Sjkim/** Verifies that a private and/or public key is valid.
829238405Sjkim *  \param  key  the EC_KEY object
830238405Sjkim *  \return 1 on success and 0 otherwise.
831238405Sjkim */
832238405Sjkimint EC_KEY_check_key(const EC_KEY *key);
833238405Sjkim
834238405Sjkim/** Sets a public key from affine coordindates performing
835238405Sjkim *  neccessary NIST PKV tests.
836238405Sjkim *  \param  key  the EC_KEY object
837238405Sjkim *  \param  x    public key x coordinate
838238405Sjkim *  \param  y    public key y coordinate
839238405Sjkim *  \return 1 on success and 0 otherwise.
840238405Sjkim */
841238405Sjkimint EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x, BIGNUM *y);
842238405Sjkim
843238405Sjkim
844238405Sjkim/********************************************************************/
845238405Sjkim/*        de- and encoding functions for SEC1 ECPrivateKey          */
846238405Sjkim/********************************************************************/
847238405Sjkim
848238405Sjkim/** Decodes a private key from a memory buffer.
849238405Sjkim *  \param  key  a pointer to a EC_KEY object which should be used (or NULL)
850238405Sjkim *  \param  in   pointer to memory with the DER encoded private key
851238405Sjkim *  \param  len  length of the DER encoded private key
852238405Sjkim *  \return the decoded private key or NULL if an error occurred.
853238405Sjkim */
854238405SjkimEC_KEY *d2i_ECPrivateKey(EC_KEY **key, const unsigned char **in, long len);
855238405Sjkim
856238405Sjkim/** Encodes a private key object and stores the result in a buffer.
857238405Sjkim *  \param  key  the EC_KEY object to encode
858238405Sjkim *  \param  out  the buffer for the result (if NULL the function returns number
859238405Sjkim *               of bytes needed).
860238405Sjkim *  \return 1 on success and 0 if an error occurred.
861238405Sjkim */
862238405Sjkimint i2d_ECPrivateKey(EC_KEY *key, unsigned char **out);
863238405Sjkim
864238405Sjkim
865238405Sjkim/********************************************************************/
866238405Sjkim/*        de- and encoding functions for EC parameters              */
867238405Sjkim/********************************************************************/
868238405Sjkim
869238405Sjkim/** Decodes ec parameter from a memory buffer.
870238405Sjkim *  \param  key  a pointer to a EC_KEY object which should be used (or NULL)
871238405Sjkim *  \param  in   pointer to memory with the DER encoded ec parameters
872238405Sjkim *  \param  len  length of the DER encoded ec parameters
873238405Sjkim *  \return a EC_KEY object with the decoded parameters or NULL if an error
874238405Sjkim *          occurred.
875238405Sjkim */
876238405SjkimEC_KEY *d2i_ECParameters(EC_KEY **key, const unsigned char **in, long len);
877238405Sjkim
878238405Sjkim/** Encodes ec parameter and stores the result in a buffer.
879238405Sjkim *  \param  key  the EC_KEY object with ec paramters to encode
880238405Sjkim *  \param  out  the buffer for the result (if NULL the function returns number
881238405Sjkim *               of bytes needed).
882238405Sjkim *  \return 1 on success and 0 if an error occurred.
883238405Sjkim */
884238405Sjkimint i2d_ECParameters(EC_KEY *key, unsigned char **out);
885238405Sjkim
886238405Sjkim
887238405Sjkim/********************************************************************/
888238405Sjkim/*         de- and encoding functions for EC public key             */
889238405Sjkim/*         (octet string, not DER -- hence 'o2i' and 'i2o')         */
890238405Sjkim/********************************************************************/
891238405Sjkim
892238405Sjkim/** Decodes a ec public key from a octet string.
893238405Sjkim *  \param  key  a pointer to a EC_KEY object which should be used
894238405Sjkim *  \param  in   memory buffer with the encoded public key
895238405Sjkim *  \param  len  length of the encoded public key
896238405Sjkim *  \return EC_KEY object with decoded public key or NULL if an error
897238405Sjkim *          occurred.
898238405Sjkim */
899238405SjkimEC_KEY *o2i_ECPublicKey(EC_KEY **key, const unsigned char **in, long len);
900238405Sjkim
901238405Sjkim/** Encodes a ec public key in an octet string.
902238405Sjkim *  \param  key  the EC_KEY object with the public key
903238405Sjkim *  \param  out  the buffer for the result (if NULL the function returns number
904238405Sjkim *               of bytes needed).
905238405Sjkim *  \return 1 on success and 0 if an error occurred
906238405Sjkim */
907238405Sjkimint i2o_ECPublicKey(EC_KEY *key, unsigned char **out);
908238405Sjkim
909160814Ssimon#ifndef OPENSSL_NO_BIO
910238405Sjkim/** Prints out the ec parameters on human readable form.
911238405Sjkim *  \param  bp   BIO object to which the information is printed
912238405Sjkim *  \param  key  EC_KEY object
913238405Sjkim *  \return 1 on success and 0 if an error occurred
914238405Sjkim */
915238405Sjkimint	ECParameters_print(BIO *bp, const EC_KEY *key);
916238405Sjkim
917238405Sjkim/** Prints out the contents of a EC_KEY object
918238405Sjkim *  \param  bp   BIO object to which the information is printed
919238405Sjkim *  \param  key  EC_KEY object
920238405Sjkim *  \param  off  line offset
921238405Sjkim *  \return 1 on success and 0 if an error occurred
922238405Sjkim */
923238405Sjkimint	EC_KEY_print(BIO *bp, const EC_KEY *key, int off);
924238405Sjkim
925160814Ssimon#endif
926160814Ssimon#ifndef OPENSSL_NO_FP_API
927238405Sjkim/** Prints out the ec parameters on human readable form.
928238405Sjkim *  \param  fp   file descriptor to which the information is printed
929238405Sjkim *  \param  key  EC_KEY object
930238405Sjkim *  \return 1 on success and 0 if an error occurred
931238405Sjkim */
932238405Sjkimint	ECParameters_print_fp(FILE *fp, const EC_KEY *key);
933238405Sjkim
934238405Sjkim/** Prints out the contents of a EC_KEY object
935238405Sjkim *  \param  fp   file descriptor to which the information is printed
936238405Sjkim *  \param  key  EC_KEY object
937238405Sjkim *  \param  off  line offset
938238405Sjkim *  \return 1 on success and 0 if an error occurred
939238405Sjkim */
940238405Sjkimint	EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off);
941238405Sjkim
942160814Ssimon#endif
943160814Ssimon
944160814Ssimon#define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x)
945160814Ssimon
946160814Ssimon#ifndef __cplusplus
947160814Ssimon#if defined(__SUNPRO_C)
948160814Ssimon#  if __SUNPRO_C >= 0x520
949160814Ssimon# pragma error_messages (default,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE)
950160814Ssimon#  endif
951160814Ssimon# endif
952160814Ssimon#endif
953160814Ssimon
954238405Sjkim#define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid) \
955238405Sjkim	EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, EVP_PKEY_OP_PARAMGEN, \
956238405Sjkim				EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL)
957238405Sjkim
958238405Sjkim
959238405Sjkim#define EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID		(EVP_PKEY_ALG_CTRL + 1)
960238405Sjkim
961109998Smarkm/* BEGIN ERROR CODES */
962109998Smarkm/* The following lines are auto generated by the script mkerr.pl. Any changes
963109998Smarkm * made after this point may be overwritten when the script is next run.
964109998Smarkm */
965109998Smarkmvoid ERR_load_EC_strings(void);
966109998Smarkm
967109998Smarkm/* Error codes for the EC functions. */
968109998Smarkm
969109998Smarkm/* Function codes. */
970238405Sjkim#define EC_F_BN_TO_FELEM				 224
971109998Smarkm#define EC_F_COMPUTE_WNAF				 143
972160814Ssimon#define EC_F_D2I_ECPARAMETERS				 144
973160814Ssimon#define EC_F_D2I_ECPKPARAMETERS				 145
974160814Ssimon#define EC_F_D2I_ECPRIVATEKEY				 146
975238405Sjkim#define EC_F_DO_EC_KEY_PRINT				 221
976238405Sjkim#define EC_F_ECKEY_PARAM2TYPE				 223
977238405Sjkim#define EC_F_ECKEY_PARAM_DECODE				 212
978238405Sjkim#define EC_F_ECKEY_PRIV_DECODE				 213
979238405Sjkim#define EC_F_ECKEY_PRIV_ENCODE				 214
980238405Sjkim#define EC_F_ECKEY_PUB_DECODE				 215
981238405Sjkim#define EC_F_ECKEY_PUB_ENCODE				 216
982238405Sjkim#define EC_F_ECKEY_TYPE2PARAM				 220
983160814Ssimon#define EC_F_ECPARAMETERS_PRINT				 147
984160814Ssimon#define EC_F_ECPARAMETERS_PRINT_FP			 148
985160814Ssimon#define EC_F_ECPKPARAMETERS_PRINT			 149
986160814Ssimon#define EC_F_ECPKPARAMETERS_PRINT_FP			 150
987160814Ssimon#define EC_F_ECP_NIST_MOD_192				 203
988160814Ssimon#define EC_F_ECP_NIST_MOD_224				 204
989160814Ssimon#define EC_F_ECP_NIST_MOD_256				 205
990160814Ssimon#define EC_F_ECP_NIST_MOD_521				 206
991160814Ssimon#define EC_F_EC_ASN1_GROUP2CURVE			 153
992160814Ssimon#define EC_F_EC_ASN1_GROUP2FIELDID			 154
993160814Ssimon#define EC_F_EC_ASN1_GROUP2PARAMETERS			 155
994160814Ssimon#define EC_F_EC_ASN1_GROUP2PKPARAMETERS			 156
995160814Ssimon#define EC_F_EC_ASN1_PARAMETERS2GROUP			 157
996160814Ssimon#define EC_F_EC_ASN1_PKPARAMETERS2GROUP			 158
997160814Ssimon#define EC_F_EC_EX_DATA_SET_DATA			 211
998160814Ssimon#define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY		 208
999160814Ssimon#define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT	 159
1000160814Ssimon#define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE		 195
1001160814Ssimon#define EC_F_EC_GF2M_SIMPLE_OCT2POINT			 160
1002160814Ssimon#define EC_F_EC_GF2M_SIMPLE_POINT2OCT			 161
1003160814Ssimon#define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 162
1004160814Ssimon#define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 163
1005160814Ssimon#define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES	 164
1006109998Smarkm#define EC_F_EC_GFP_MONT_FIELD_DECODE			 133
1007109998Smarkm#define EC_F_EC_GFP_MONT_FIELD_ENCODE			 134
1008109998Smarkm#define EC_F_EC_GFP_MONT_FIELD_MUL			 131
1009160814Ssimon#define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE		 209
1010109998Smarkm#define EC_F_EC_GFP_MONT_FIELD_SQR			 132
1011160814Ssimon#define EC_F_EC_GFP_MONT_GROUP_SET_CURVE		 189
1012160814Ssimon#define EC_F_EC_GFP_MONT_GROUP_SET_CURVE_GFP		 135
1013238405Sjkim#define EC_F_EC_GFP_NISTP224_GROUP_SET_CURVE		 225
1014238405Sjkim#define EC_F_EC_GFP_NISTP224_POINTS_MUL			 228
1015238405Sjkim#define EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES 226
1016238405Sjkim#define EC_F_EC_GFP_NISTP256_GROUP_SET_CURVE		 230
1017238405Sjkim#define EC_F_EC_GFP_NISTP256_POINTS_MUL			 231
1018238405Sjkim#define EC_F_EC_GFP_NISTP256_POINT_GET_AFFINE_COORDINATES 232
1019238405Sjkim#define EC_F_EC_GFP_NISTP521_GROUP_SET_CURVE		 233
1020238405Sjkim#define EC_F_EC_GFP_NISTP521_POINTS_MUL			 234
1021238405Sjkim#define EC_F_EC_GFP_NISTP521_POINT_GET_AFFINE_COORDINATES 235
1022160814Ssimon#define EC_F_EC_GFP_NIST_FIELD_MUL			 200
1023160814Ssimon#define EC_F_EC_GFP_NIST_FIELD_SQR			 201
1024160814Ssimon#define EC_F_EC_GFP_NIST_GROUP_SET_CURVE		 202
1025160814Ssimon#define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT	 165
1026160814Ssimon#define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE		 166
1027109998Smarkm#define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE_GFP		 100
1028109998Smarkm#define EC_F_EC_GFP_SIMPLE_GROUP_SET_GENERATOR		 101
1029109998Smarkm#define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE			 102
1030109998Smarkm#define EC_F_EC_GFP_SIMPLE_OCT2POINT			 103
1031109998Smarkm#define EC_F_EC_GFP_SIMPLE_POINT2OCT			 104
1032109998Smarkm#define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE		 137
1033160814Ssimon#define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES	 167
1034109998Smarkm#define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP 105
1035160814Ssimon#define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES	 168
1036109998Smarkm#define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES_GFP 128
1037160814Ssimon#define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES	 169
1038109998Smarkm#define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP 129
1039160814Ssimon#define EC_F_EC_GROUP_CHECK				 170
1040160814Ssimon#define EC_F_EC_GROUP_CHECK_DISCRIMINANT		 171
1041109998Smarkm#define EC_F_EC_GROUP_COPY				 106
1042109998Smarkm#define EC_F_EC_GROUP_GET0_GENERATOR			 139
1043109998Smarkm#define EC_F_EC_GROUP_GET_COFACTOR			 140
1044160814Ssimon#define EC_F_EC_GROUP_GET_CURVE_GF2M			 172
1045109998Smarkm#define EC_F_EC_GROUP_GET_CURVE_GFP			 130
1046160814Ssimon#define EC_F_EC_GROUP_GET_DEGREE			 173
1047109998Smarkm#define EC_F_EC_GROUP_GET_ORDER				 141
1048160814Ssimon#define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS		 193
1049160814Ssimon#define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS		 194
1050109998Smarkm#define EC_F_EC_GROUP_NEW				 108
1051160814Ssimon#define EC_F_EC_GROUP_NEW_BY_CURVE_NAME			 174
1052160814Ssimon#define EC_F_EC_GROUP_NEW_FROM_DATA			 175
1053109998Smarkm#define EC_F_EC_GROUP_PRECOMPUTE_MULT			 142
1054160814Ssimon#define EC_F_EC_GROUP_SET_CURVE_GF2M			 176
1055109998Smarkm#define EC_F_EC_GROUP_SET_CURVE_GFP			 109
1056109998Smarkm#define EC_F_EC_GROUP_SET_EXTRA_DATA			 110
1057109998Smarkm#define EC_F_EC_GROUP_SET_GENERATOR			 111
1058160814Ssimon#define EC_F_EC_KEY_CHECK_KEY				 177
1059160814Ssimon#define EC_F_EC_KEY_COPY				 178
1060160814Ssimon#define EC_F_EC_KEY_GENERATE_KEY			 179
1061160814Ssimon#define EC_F_EC_KEY_NEW					 182
1062160814Ssimon#define EC_F_EC_KEY_PRINT				 180
1063160814Ssimon#define EC_F_EC_KEY_PRINT_FP				 181
1064238405Sjkim#define EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES	 229
1065109998Smarkm#define EC_F_EC_POINTS_MAKE_AFFINE			 136
1066109998Smarkm#define EC_F_EC_POINT_ADD				 112
1067109998Smarkm#define EC_F_EC_POINT_CMP				 113
1068109998Smarkm#define EC_F_EC_POINT_COPY				 114
1069109998Smarkm#define EC_F_EC_POINT_DBL				 115
1070160814Ssimon#define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M	 183
1071109998Smarkm#define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP	 116
1072109998Smarkm#define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP	 117
1073160814Ssimon#define EC_F_EC_POINT_INVERT				 210
1074109998Smarkm#define EC_F_EC_POINT_IS_AT_INFINITY			 118
1075109998Smarkm#define EC_F_EC_POINT_IS_ON_CURVE			 119
1076109998Smarkm#define EC_F_EC_POINT_MAKE_AFFINE			 120
1077160814Ssimon#define EC_F_EC_POINT_MUL				 184
1078109998Smarkm#define EC_F_EC_POINT_NEW				 121
1079109998Smarkm#define EC_F_EC_POINT_OCT2POINT				 122
1080109998Smarkm#define EC_F_EC_POINT_POINT2OCT				 123
1081160814Ssimon#define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M	 185
1082109998Smarkm#define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP	 124
1083160814Ssimon#define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M	 186
1084109998Smarkm#define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP	 125
1085109998Smarkm#define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP	 126
1086109998Smarkm#define EC_F_EC_POINT_SET_TO_INFINITY			 127
1087160814Ssimon#define EC_F_EC_PRE_COMP_DUP				 207
1088194206Ssimon#define EC_F_EC_PRE_COMP_NEW				 196
1089160814Ssimon#define EC_F_EC_WNAF_MUL				 187
1090160814Ssimon#define EC_F_EC_WNAF_PRECOMPUTE_MULT			 188
1091160814Ssimon#define EC_F_I2D_ECPARAMETERS				 190
1092160814Ssimon#define EC_F_I2D_ECPKPARAMETERS				 191
1093160814Ssimon#define EC_F_I2D_ECPRIVATEKEY				 192
1094160814Ssimon#define EC_F_I2O_ECPUBLICKEY				 151
1095238405Sjkim#define EC_F_NISTP224_PRE_COMP_NEW			 227
1096238405Sjkim#define EC_F_NISTP256_PRE_COMP_NEW			 236
1097238405Sjkim#define EC_F_NISTP521_PRE_COMP_NEW			 237
1098160814Ssimon#define EC_F_O2I_ECPUBLICKEY				 152
1099238405Sjkim#define EC_F_OLD_EC_PRIV_DECODE				 222
1100238405Sjkim#define EC_F_PKEY_EC_CTRL				 197
1101238405Sjkim#define EC_F_PKEY_EC_CTRL_STR				 198
1102238405Sjkim#define EC_F_PKEY_EC_DERIVE				 217
1103238405Sjkim#define EC_F_PKEY_EC_KEYGEN				 199
1104238405Sjkim#define EC_F_PKEY_EC_PARAMGEN				 219
1105238405Sjkim#define EC_F_PKEY_EC_SIGN				 218
1106109998Smarkm
1107109998Smarkm/* Reason codes. */
1108160814Ssimon#define EC_R_ASN1_ERROR					 115
1109160814Ssimon#define EC_R_ASN1_UNKNOWN_FIELD				 116
1110238405Sjkim#define EC_R_BIGNUM_OUT_OF_RANGE			 144
1111109998Smarkm#define EC_R_BUFFER_TOO_SMALL				 100
1112238405Sjkim#define EC_R_COORDINATES_OUT_OF_RANGE			 146
1113160814Ssimon#define EC_R_D2I_ECPKPARAMETERS_FAILURE			 117
1114238405Sjkim#define EC_R_DECODE_ERROR				 142
1115160814Ssimon#define EC_R_DISCRIMINANT_IS_ZERO			 118
1116160814Ssimon#define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE		 119
1117238405Sjkim#define EC_R_FIELD_TOO_LARGE				 143
1118238405Sjkim#define EC_R_GF2M_NOT_SUPPORTED				 147
1119160814Ssimon#define EC_R_GROUP2PKPARAMETERS_FAILURE			 120
1120160814Ssimon#define EC_R_I2D_ECPKPARAMETERS_FAILURE			 121
1121109998Smarkm#define EC_R_INCOMPATIBLE_OBJECTS			 101
1122109998Smarkm#define EC_R_INVALID_ARGUMENT				 112
1123109998Smarkm#define EC_R_INVALID_COMPRESSED_POINT			 110
1124109998Smarkm#define EC_R_INVALID_COMPRESSION_BIT			 109
1125238405Sjkim#define EC_R_INVALID_CURVE				 141
1126238405Sjkim#define EC_R_INVALID_DIGEST_TYPE			 138
1127109998Smarkm#define EC_R_INVALID_ENCODING				 102
1128109998Smarkm#define EC_R_INVALID_FIELD				 103
1129109998Smarkm#define EC_R_INVALID_FORM				 104
1130160814Ssimon#define EC_R_INVALID_GROUP_ORDER			 122
1131162911Ssimon#define EC_R_INVALID_PENTANOMIAL_BASIS			 132
1132160814Ssimon#define EC_R_INVALID_PRIVATE_KEY			 123
1133162911Ssimon#define EC_R_INVALID_TRINOMIAL_BASIS			 137
1134238405Sjkim#define EC_R_KEYS_NOT_SET				 140
1135160814Ssimon#define EC_R_MISSING_PARAMETERS				 124
1136160814Ssimon#define EC_R_MISSING_PRIVATE_KEY			 125
1137160814Ssimon#define EC_R_NOT_A_NIST_PRIME				 135
1138160814Ssimon#define EC_R_NOT_A_SUPPORTED_NIST_PRIME			 136
1139160814Ssimon#define EC_R_NOT_IMPLEMENTED				 126
1140109998Smarkm#define EC_R_NOT_INITIALIZED				 111
1141160814Ssimon#define EC_R_NO_FIELD_MOD				 133
1142238405Sjkim#define EC_R_NO_PARAMETERS_SET				 139
1143160814Ssimon#define EC_R_PASSED_NULL_PARAMETER			 134
1144160814Ssimon#define EC_R_PKPARAMETERS2GROUP_FAILURE			 127
1145109998Smarkm#define EC_R_POINT_AT_INFINITY				 106
1146109998Smarkm#define EC_R_POINT_IS_NOT_ON_CURVE			 107
1147109998Smarkm#define EC_R_SLOT_FULL					 108
1148109998Smarkm#define EC_R_UNDEFINED_GENERATOR			 113
1149160814Ssimon#define EC_R_UNDEFINED_ORDER				 128
1150160814Ssimon#define EC_R_UNKNOWN_GROUP				 129
1151109998Smarkm#define EC_R_UNKNOWN_ORDER				 114
1152160814Ssimon#define EC_R_UNSUPPORTED_FIELD				 131
1153238405Sjkim#define EC_R_WRONG_CURVE_PARAMETERS			 145
1154160814Ssimon#define EC_R_WRONG_ORDER				 130
1155109998Smarkm
1156109998Smarkm#ifdef  __cplusplus
1157109998Smarkm}
1158109998Smarkm#endif
1159109998Smarkm#endif
1160