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 17296341Sdelphij * 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 * 65296341Sdelphij * 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 * 71296341Sdelphij * 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 77296341Sdelphij# define HEADER_EC_H 78109998Smarkm 79296341Sdelphij# include <openssl/opensslconf.h> 80160814Ssimon 81296341Sdelphij# ifdef OPENSSL_NO_EC 82296341Sdelphij# error EC is disabled. 83296341Sdelphij# endif 84109998Smarkm 85296341Sdelphij# include <openssl/asn1.h> 86296341Sdelphij# include <openssl/symhacks.h> 87296341Sdelphij# ifndef OPENSSL_NO_DEPRECATED 88296341Sdelphij# include <openssl/bn.h> 89296341Sdelphij# endif 90109998Smarkm 91296341Sdelphij# ifdef __cplusplus 92109998Smarkmextern "C" { 93296341Sdelphij# elif defined(__SUNPRO_C) 94296341Sdelphij# if __SUNPRO_C >= 0x520 95296341Sdelphij# pragma error_messages (off,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE) 96296341Sdelphij# endif 97160814Ssimon# endif 98109998Smarkm 99296341Sdelphij# ifndef OPENSSL_ECC_MAX_FIELD_BITS 100296341Sdelphij# define OPENSSL_ECC_MAX_FIELD_BITS 661 101296341Sdelphij# endif 102162911Ssimon 103238405Sjkim/** Enum for the point conversion form as defined in X9.62 (ECDSA) 104238405Sjkim * for the encoding of a elliptic curve point (x,y) */ 105109998Smarkmtypedef enum { 106296341Sdelphij /** the point is encoded as z||x, where the octet z specifies 107238405Sjkim * which solution of the quadratic equation y is */ 108296341Sdelphij POINT_CONVERSION_COMPRESSED = 2, 109296341Sdelphij /** the point is encoded as z||x||y, where z is the octet 0x02 */ 110296341Sdelphij POINT_CONVERSION_UNCOMPRESSED = 4, 111296341Sdelphij /** the point is encoded as z||x||y, where the octet z specifies 112296341Sdelphij * which solution of the quadratic equation y is */ 113296341Sdelphij POINT_CONVERSION_HYBRID = 6 114109998Smarkm} point_conversion_form_t; 115109998Smarkm 116109998Smarkmtypedef struct ec_method_st EC_METHOD; 117109998Smarkm 118109998Smarkmtypedef struct ec_group_st 119296341Sdelphij /*- 120296341Sdelphij EC_METHOD *meth; 121296341Sdelphij -- field definition 122296341Sdelphij -- curve coefficients 123296341Sdelphij -- optional generator with associated information (order, cofactor) 124296341Sdelphij -- optional extra data (precomputed table for fast computation of multiples of generator) 125296341Sdelphij -- ASN1 stuff 126296341Sdelphij */ 127296341Sdelphij EC_GROUP; 128109998Smarkm 129109998Smarkmtypedef struct ec_point_st EC_POINT; 130109998Smarkm 131238405Sjkim/********************************************************************/ 132296341Sdelphij/* EC_METHODs for curves over GF(p) */ 133238405Sjkim/********************************************************************/ 134238405Sjkim 135238405Sjkim/** Returns the basic GFp ec methods which provides the basis for the 136296341Sdelphij * optimized methods. 137238405Sjkim * \return EC_METHOD object 138109998Smarkm */ 139109998Smarkmconst EC_METHOD *EC_GFp_simple_method(void); 140238405Sjkim 141238405Sjkim/** Returns GFp methods using montgomery multiplication. 142238405Sjkim * \return EC_METHOD object 143238405Sjkim */ 144109998Smarkmconst EC_METHOD *EC_GFp_mont_method(void); 145238405Sjkim 146238405Sjkim/** Returns GFp methods using optimized methods for NIST recommended curves 147238405Sjkim * \return EC_METHOD object 148238405Sjkim */ 149160814Ssimonconst EC_METHOD *EC_GFp_nist_method(void); 150109998Smarkm 151296341Sdelphij# ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 152238405Sjkim/** Returns 64-bit optimized methods for nistp224 153238405Sjkim * \return EC_METHOD object 154160814Ssimon */ 155238405Sjkimconst EC_METHOD *EC_GFp_nistp224_method(void); 156238405Sjkim 157238405Sjkim/** Returns 64-bit optimized methods for nistp256 158238405Sjkim * \return EC_METHOD object 159238405Sjkim */ 160238405Sjkimconst EC_METHOD *EC_GFp_nistp256_method(void); 161238405Sjkim 162238405Sjkim/** Returns 64-bit optimized methods for nistp521 163238405Sjkim * \return EC_METHOD object 164238405Sjkim */ 165238405Sjkimconst EC_METHOD *EC_GFp_nistp521_method(void); 166296341Sdelphij# endif 167238405Sjkim 168296341Sdelphij# ifndef OPENSSL_NO_EC2M 169296341Sdelphij/********************************************************************/ 170238405Sjkim/* EC_METHOD for curves over GF(2^m) */ 171238405Sjkim/********************************************************************/ 172238405Sjkim 173296341Sdelphij/** Returns the basic GF2m ec method 174238405Sjkim * \return EC_METHOD object 175238405Sjkim */ 176160814Ssimonconst EC_METHOD *EC_GF2m_simple_method(void); 177109998Smarkm 178296341Sdelphij# endif 179160814Ssimon 180238405Sjkim/********************************************************************/ 181238405Sjkim/* EC_GROUP functions */ 182238405Sjkim/********************************************************************/ 183109998Smarkm 184238405Sjkim/** Creates a new EC_GROUP object 185238405Sjkim * \param meth EC_METHOD to use 186238405Sjkim * \return newly created EC_GROUP object or NULL in case of an error. 187238405Sjkim */ 188238405SjkimEC_GROUP *EC_GROUP_new(const EC_METHOD *meth); 189160814Ssimon 190238405Sjkim/** Frees a EC_GROUP object 191238405Sjkim * \param group EC_GROUP object to be freed. 192238405Sjkim */ 193238405Sjkimvoid EC_GROUP_free(EC_GROUP *group); 194160814Ssimon 195238405Sjkim/** Clears and frees a EC_GROUP object 196238405Sjkim * \param group EC_GROUP object to be cleared and freed. 197238405Sjkim */ 198238405Sjkimvoid EC_GROUP_clear_free(EC_GROUP *group); 199160814Ssimon 200238405Sjkim/** Copies EC_GROUP objects. Note: both EC_GROUPs must use the same EC_METHOD. 201238405Sjkim * \param dst destination EC_GROUP object 202238405Sjkim * \param src source EC_GROUP object 203238405Sjkim * \return 1 on success and 0 if an error occurred. 204238405Sjkim */ 205238405Sjkimint EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src); 206238405Sjkim 207238405Sjkim/** Creates a new EC_GROUP object and copies the copies the content 208238405Sjkim * form src to the newly created EC_KEY object 209238405Sjkim * \param src source EC_GROUP object 210238405Sjkim * \return newly created EC_GROUP object or NULL in case of an error. 211238405Sjkim */ 212238405SjkimEC_GROUP *EC_GROUP_dup(const EC_GROUP *src); 213238405Sjkim 214238405Sjkim/** Returns the EC_METHOD of the EC_GROUP object. 215296341Sdelphij * \param group EC_GROUP object 216238405Sjkim * \return EC_METHOD used in this EC_GROUP object. 217238405Sjkim */ 218238405Sjkimconst EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group); 219238405Sjkim 220238405Sjkim/** Returns the field type of the EC_METHOD. 221238405Sjkim * \param meth EC_METHOD object 222238405Sjkim * \return NID of the underlying field type OID. 223238405Sjkim */ 224238405Sjkimint EC_METHOD_get_field_type(const EC_METHOD *meth); 225238405Sjkim 226238405Sjkim/** Sets the generator and it's order/cofactor of a EC_GROUP object. 227296341Sdelphij * \param group EC_GROUP object 228238405Sjkim * \param generator EC_POINT object with the generator. 229238405Sjkim * \param order the order of the group generated by the generator. 230238405Sjkim * \param cofactor the index of the sub-group generated by the generator 231238405Sjkim * in the group of all points on the elliptic curve. 232238405Sjkim * \return 1 on success and 0 if an error occured 233238405Sjkim */ 234296341Sdelphijint EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, 235296341Sdelphij const BIGNUM *order, const BIGNUM *cofactor); 236238405Sjkim 237238405Sjkim/** Returns the generator of a EC_GROUP object. 238238405Sjkim * \param group EC_GROUP object 239238405Sjkim * \return the currently used generator (possibly NULL). 240238405Sjkim */ 241238405Sjkimconst EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group); 242238405Sjkim 243238405Sjkim/** Gets the order of a EC_GROUP 244238405Sjkim * \param group EC_GROUP object 245238405Sjkim * \param order BIGNUM to which the order is copied 246238405Sjkim * \param ctx BN_CTX object (optional) 247238405Sjkim * \return 1 on success and 0 if an error occured 248238405Sjkim */ 249238405Sjkimint EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx); 250238405Sjkim 251238405Sjkim/** Gets the cofactor of a EC_GROUP 252238405Sjkim * \param group EC_GROUP object 253238405Sjkim * \param cofactor BIGNUM to which the cofactor is copied 254238405Sjkim * \param ctx BN_CTX object (optional) 255238405Sjkim * \return 1 on success and 0 if an error occured 256238405Sjkim */ 257296341Sdelphijint EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, 258296341Sdelphij BN_CTX *ctx); 259238405Sjkim 260238405Sjkim/** Sets the name of a EC_GROUP object 261238405Sjkim * \param group EC_GROUP object 262238405Sjkim * \param nid NID of the curve name OID 263238405Sjkim */ 264238405Sjkimvoid EC_GROUP_set_curve_name(EC_GROUP *group, int nid); 265238405Sjkim 266238405Sjkim/** Returns the curve name of a EC_GROUP object 267238405Sjkim * \param group EC_GROUP object 268238405Sjkim * \return NID of the curve name OID or 0 if not set. 269238405Sjkim */ 270238405Sjkimint EC_GROUP_get_curve_name(const EC_GROUP *group); 271238405Sjkim 272238405Sjkimvoid EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag); 273238405Sjkimint EC_GROUP_get_asn1_flag(const EC_GROUP *group); 274238405Sjkim 275296341Sdelphijvoid EC_GROUP_set_point_conversion_form(EC_GROUP *group, 276296341Sdelphij point_conversion_form_t form); 277160814Ssimonpoint_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *); 278160814Ssimon 279246772Sjkimunsigned char *EC_GROUP_get0_seed(const EC_GROUP *x); 280160814Ssimonsize_t EC_GROUP_get_seed_len(const EC_GROUP *); 281160814Ssimonsize_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len); 282160814Ssimon 283238405Sjkim/** Sets the parameter of a ec over GFp defined by y^2 = x^3 + a*x + b 284238405Sjkim * \param group EC_GROUP object 285238405Sjkim * \param p BIGNUM with the prime number 286238405Sjkim * \param a BIGNUM with parameter a of the equation 287238405Sjkim * \param b BIGNUM with parameter b of the equation 288238405Sjkim * \param ctx BN_CTX object (optional) 289238405Sjkim * \return 1 on success and 0 if an error occured 290238405Sjkim */ 291296341Sdelphijint EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, 292296341Sdelphij 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 */ 302296341Sdelphijint EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, 303296341Sdelphij BIGNUM *b, BN_CTX *ctx); 304160814Ssimon 305296341Sdelphij# ifndef OPENSSL_NO_EC2M 306238405Sjkim/** Sets the parameter of a ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b 307238405Sjkim * \param group EC_GROUP object 308238405Sjkim * \param p BIGNUM with the polynomial defining the underlying field 309238405Sjkim * \param a BIGNUM with parameter a of the equation 310238405Sjkim * \param b BIGNUM with parameter b of the equation 311238405Sjkim * \param ctx BN_CTX object (optional) 312238405Sjkim * \return 1 on success and 0 if an error occured 313238405Sjkim */ 314296341Sdelphijint EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, 315296341Sdelphij const BIGNUM *b, BN_CTX *ctx); 316238405Sjkim 317238405Sjkim/** Gets the parameter of the ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b 318238405Sjkim * \param group EC_GROUP object 319238405Sjkim * \param p BIGNUM for the polynomial defining the underlying field 320238405Sjkim * \param a BIGNUM for parameter a of the equation 321238405Sjkim * \param b BIGNUM for parameter b of the equation 322238405Sjkim * \param ctx BN_CTX object (optional) 323238405Sjkim * \return 1 on success and 0 if an error occured 324238405Sjkim */ 325296341Sdelphijint EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, 326296341Sdelphij BIGNUM *b, BN_CTX *ctx); 327296341Sdelphij# endif 328296341Sdelphij/** Returns the number of bits needed to represent a field element 329238405Sjkim * \param group EC_GROUP object 330238405Sjkim * \return number of bits needed to represent a field element 331238405Sjkim */ 332238405Sjkimint EC_GROUP_get_degree(const EC_GROUP *group); 333238405Sjkim 334238405Sjkim/** Checks whether the parameter in the EC_GROUP define a valid ec group 335238405Sjkim * \param group EC_GROUP object 336238405Sjkim * \param ctx BN_CTX object (optional) 337238405Sjkim * \return 1 if group is a valid ec group and 0 otherwise 338238405Sjkim */ 339160814Ssimonint EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx); 340160814Ssimon 341238405Sjkim/** Checks whether the discriminant of the elliptic curve is zero or not 342238405Sjkim * \param group EC_GROUP object 343238405Sjkim * \param ctx BN_CTX object (optional) 344238405Sjkim * \return 1 if the discriminant is not zero and 0 otherwise 345238405Sjkim */ 346238405Sjkimint EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx); 347160814Ssimon 348238405Sjkim/** Compares two EC_GROUP objects 349238405Sjkim * \param a first EC_GROUP object 350238405Sjkim * \param b second EC_GROUP object 351238405Sjkim * \param ctx BN_CTX object (optional) 352238405Sjkim * \return 0 if both groups are equal and 1 otherwise 353238405Sjkim */ 354238405Sjkimint EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx); 355238405Sjkim 356296341Sdelphij/* 357296341Sdelphij * EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*() after 358296341Sdelphij * choosing an appropriate EC_METHOD 359296341Sdelphij */ 360109998Smarkm 361238405Sjkim/** Creates a new EC_GROUP object with the specified parameters defined 362238405Sjkim * over GFp (defined by the equation y^2 = x^3 + a*x + b) 363238405Sjkim * \param p BIGNUM with the prime number 364238405Sjkim * \param a BIGNUM with the parameter a of the equation 365238405Sjkim * \param b BIGNUM with the parameter b of the equation 366238405Sjkim * \param ctx BN_CTX object (optional) 367238405Sjkim * \return newly created EC_GROUP object with the specified parameters 368238405Sjkim */ 369296341SdelphijEC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, 370296341Sdelphij const BIGNUM *b, BN_CTX *ctx); 371296341Sdelphij# ifndef OPENSSL_NO_EC2M 372238405Sjkim/** Creates a new EC_GROUP object with the specified parameters defined 373238405Sjkim * over GF2m (defined by the equation y^2 + x*y = x^3 + a*x^2 + b) 374238405Sjkim * \param p BIGNUM with the polynomial defining the underlying field 375238405Sjkim * \param a BIGNUM with the parameter a of the equation 376238405Sjkim * \param b BIGNUM with the parameter b of the equation 377238405Sjkim * \param ctx BN_CTX object (optional) 378238405Sjkim * \return newly created EC_GROUP object with the specified parameters 379238405Sjkim */ 380296341SdelphijEC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, 381296341Sdelphij const BIGNUM *b, BN_CTX *ctx); 382296341Sdelphij# endif 383238405Sjkim/** Creates a EC_GROUP object with a curve specified by a NID 384238405Sjkim * \param nid NID of the OID of the curve name 385238405Sjkim * \return newly created EC_GROUP object with specified curve or NULL 386238405Sjkim * if an error occurred 387238405Sjkim */ 388160814SsimonEC_GROUP *EC_GROUP_new_by_curve_name(int nid); 389238405Sjkim 390238405Sjkim/********************************************************************/ 391238405Sjkim/* handling of internal curves */ 392238405Sjkim/********************************************************************/ 393238405Sjkim 394296341Sdelphijtypedef struct { 395296341Sdelphij int nid; 396296341Sdelphij const char *comment; 397296341Sdelphij} EC_builtin_curve; 398238405Sjkim 399296341Sdelphij/* 400296341Sdelphij * EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number of all 401296341Sdelphij * available curves or zero if a error occurred. In case r ist not zero 402296341Sdelphij * nitems EC_builtin_curve structures are filled with the data of the first 403296341Sdelphij * nitems internal groups 404296341Sdelphij */ 405160814Ssimonsize_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems); 406109998Smarkm 407238405Sjkim/********************************************************************/ 408238405Sjkim/* EC_POINT functions */ 409238405Sjkim/********************************************************************/ 410160814Ssimon 411238405Sjkim/** Creates a new EC_POINT object for the specified EC_GROUP 412238405Sjkim * \param group EC_GROUP the underlying EC_GROUP object 413238405Sjkim * \return newly created EC_POINT object or NULL if an error occurred 414238405Sjkim */ 415238405SjkimEC_POINT *EC_POINT_new(const EC_GROUP *group); 416238405Sjkim 417238405Sjkim/** Frees a EC_POINT object 418238405Sjkim * \param point EC_POINT object to be freed 419238405Sjkim */ 420238405Sjkimvoid EC_POINT_free(EC_POINT *point); 421238405Sjkim 422238405Sjkim/** Clears and frees a EC_POINT object 423238405Sjkim * \param point EC_POINT object to be cleared and freed 424238405Sjkim */ 425238405Sjkimvoid EC_POINT_clear_free(EC_POINT *point); 426238405Sjkim 427238405Sjkim/** Copies EC_POINT object 428238405Sjkim * \param dst destination EC_POINT object 429238405Sjkim * \param src source EC_POINT object 430238405Sjkim * \return 1 on success and 0 if an error occured 431238405Sjkim */ 432238405Sjkimint EC_POINT_copy(EC_POINT *dst, const EC_POINT *src); 433238405Sjkim 434238405Sjkim/** Creates a new EC_POINT object and copies the content of the supplied 435238405Sjkim * EC_POINT 436238405Sjkim * \param src source EC_POINT object 437238405Sjkim * \param group underlying the EC_GROUP object 438296341Sdelphij * \return newly created EC_POINT object or NULL if an error occurred 439238405Sjkim */ 440238405SjkimEC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group); 441296341Sdelphij 442296341Sdelphij/** Returns the EC_METHOD used in EC_POINT object 443238405Sjkim * \param point EC_POINT object 444238405Sjkim * \return the EC_METHOD used 445238405Sjkim */ 446238405Sjkimconst EC_METHOD *EC_POINT_method_of(const EC_POINT *point); 447109998Smarkm 448238405Sjkim/** Sets a point to infinity (neutral element) 449238405Sjkim * \param group underlying EC_GROUP object 450238405Sjkim * \param point EC_POINT to set to infinity 451238405Sjkim * \return 1 on success and 0 if an error occured 452238405Sjkim */ 453238405Sjkimint EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point); 454109998Smarkm 455238405Sjkim/** Sets the jacobian projective coordinates of a EC_POINT over GFp 456238405Sjkim * \param group underlying EC_GROUP object 457238405Sjkim * \param p EC_POINT object 458238405Sjkim * \param x BIGNUM with the x-coordinate 459238405Sjkim * \param y BIGNUM with the y-coordinate 460238405Sjkim * \param z BIGNUM with the z-coordinate 461238405Sjkim * \param ctx BN_CTX object (optional) 462238405Sjkim * \return 1 on success and 0 if an error occured 463238405Sjkim */ 464296341Sdelphijint EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, 465296341Sdelphij EC_POINT *p, const BIGNUM *x, 466296341Sdelphij const BIGNUM *y, const BIGNUM *z, 467296341Sdelphij BN_CTX *ctx); 468160814Ssimon 469238405Sjkim/** Gets the jacobian projective coordinates of a EC_POINT over GFp 470238405Sjkim * \param group underlying EC_GROUP object 471238405Sjkim * \param p EC_POINT object 472238405Sjkim * \param x BIGNUM for the x-coordinate 473238405Sjkim * \param y BIGNUM for the y-coordinate 474238405Sjkim * \param z BIGNUM for the z-coordinate 475238405Sjkim * \param ctx BN_CTX object (optional) 476238405Sjkim * \return 1 on success and 0 if an error occured 477238405Sjkim */ 478238405Sjkimint EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group, 479296341Sdelphij const EC_POINT *p, BIGNUM *x, 480296341Sdelphij BIGNUM *y, BIGNUM *z, 481296341Sdelphij BN_CTX *ctx); 482109998Smarkm 483238405Sjkim/** Sets 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 with the x-coordinate 487238405Sjkim * \param y BIGNUM with 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_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *p, 492296341Sdelphij const BIGNUM *x, const BIGNUM *y, 493296341Sdelphij BN_CTX *ctx); 494238405Sjkim 495238405Sjkim/** Gets the affine coordinates of a EC_POINT over GFp 496238405Sjkim * \param group underlying EC_GROUP object 497238405Sjkim * \param p EC_POINT object 498238405Sjkim * \param x BIGNUM for the x-coordinate 499238405Sjkim * \param y BIGNUM for the y-coordinate 500238405Sjkim * \param ctx BN_CTX object (optional) 501238405Sjkim * \return 1 on success and 0 if an error occured 502238405Sjkim */ 503238405Sjkimint EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group, 504296341Sdelphij const EC_POINT *p, BIGNUM *x, 505296341Sdelphij BIGNUM *y, BN_CTX *ctx); 506238405Sjkim 507238405Sjkim/** Sets the x9.62 compressed coordinates of a EC_POINT over GFp 508238405Sjkim * \param group underlying EC_GROUP object 509238405Sjkim * \param p EC_POINT object 510238405Sjkim * \param x BIGNUM with x-coordinate 511238405Sjkim * \param y_bit integer with the y-Bit (either 0 or 1) 512238405Sjkim * \param ctx BN_CTX object (optional) 513238405Sjkim * \return 1 on success and 0 if an error occured 514238405Sjkim */ 515296341Sdelphijint EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, 516296341Sdelphij EC_POINT *p, const BIGNUM *x, 517296341Sdelphij int y_bit, BN_CTX *ctx); 518296341Sdelphij# ifndef OPENSSL_NO_EC2M 519238405Sjkim/** Sets the affine coordinates of a EC_POINT over GF2m 520238405Sjkim * \param group underlying EC_GROUP object 521238405Sjkim * \param p EC_POINT object 522238405Sjkim * \param x BIGNUM with the x-coordinate 523238405Sjkim * \param y BIGNUM with the y-coordinate 524238405Sjkim * \param ctx BN_CTX object (optional) 525238405Sjkim * \return 1 on success and 0 if an error occured 526238405Sjkim */ 527238405Sjkimint EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p, 528296341Sdelphij const BIGNUM *x, const BIGNUM *y, 529296341Sdelphij BN_CTX *ctx); 530238405Sjkim 531238405Sjkim/** Gets the affine coordinates of a EC_POINT over GF2m 532238405Sjkim * \param group underlying EC_GROUP object 533238405Sjkim * \param p EC_POINT object 534238405Sjkim * \param x BIGNUM for the x-coordinate 535238405Sjkim * \param y BIGNUM for the y-coordinate 536238405Sjkim * \param ctx BN_CTX object (optional) 537238405Sjkim * \return 1 on success and 0 if an error occured 538238405Sjkim */ 539238405Sjkimint EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group, 540296341Sdelphij const EC_POINT *p, BIGNUM *x, 541296341Sdelphij BIGNUM *y, BN_CTX *ctx); 542238405Sjkim 543238405Sjkim/** Sets the x9.62 compressed coordinates of a EC_POINT over GF2m 544238405Sjkim * \param group underlying EC_GROUP object 545238405Sjkim * \param p EC_POINT object 546238405Sjkim * \param x BIGNUM with x-coordinate 547238405Sjkim * \param y_bit integer with the y-Bit (either 0 or 1) 548238405Sjkim * \param ctx BN_CTX object (optional) 549238405Sjkim * \return 1 on success and 0 if an error occured 550238405Sjkim */ 551296341Sdelphijint EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, 552296341Sdelphij EC_POINT *p, const BIGNUM *x, 553296341Sdelphij int y_bit, BN_CTX *ctx); 554296341Sdelphij# endif 555238405Sjkim/** Encodes a EC_POINT object to a octet string 556238405Sjkim * \param group underlying EC_GROUP object 557238405Sjkim * \param p EC_POINT object 558238405Sjkim * \param form point conversion form 559238405Sjkim * \param buf memory buffer for the result. If NULL the function returns 560238405Sjkim * required buffer size. 561238405Sjkim * \param len length of the memory buffer 562238405Sjkim * \param ctx BN_CTX object (optional) 563238405Sjkim * \return the length of the encoded octet string or 0 if an error occurred 564238405Sjkim */ 565238405Sjkimsize_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p, 566296341Sdelphij point_conversion_form_t form, 567296341Sdelphij unsigned char *buf, size_t len, BN_CTX *ctx); 568238405Sjkim 569238405Sjkim/** Decodes a EC_POINT from a octet string 570238405Sjkim * \param group underlying EC_GROUP object 571238405Sjkim * \param p EC_POINT object 572238405Sjkim * \param buf memory buffer with the encoded ec point 573238405Sjkim * \param len length of the encoded ec point 574238405Sjkim * \param ctx BN_CTX object (optional) 575238405Sjkim * \return 1 on success and 0 if an error occured 576238405Sjkim */ 577238405Sjkimint EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p, 578296341Sdelphij const unsigned char *buf, size_t len, BN_CTX *ctx); 579238405Sjkim 580160814Ssimon/* other interfaces to point2oct/oct2point: */ 581160814SsimonBIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *, 582296341Sdelphij point_conversion_form_t form, BIGNUM *, BN_CTX *); 583160814SsimonEC_POINT *EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *, 584296341Sdelphij EC_POINT *, BN_CTX *); 585160814Ssimonchar *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *, 586296341Sdelphij point_conversion_form_t form, BN_CTX *); 587160814SsimonEC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *, 588296341Sdelphij EC_POINT *, BN_CTX *); 589160814Ssimon 590238405Sjkim/********************************************************************/ 591238405Sjkim/* functions for doing EC_POINT arithmetic */ 592238405Sjkim/********************************************************************/ 593109998Smarkm 594296341Sdelphij/** Computes the sum of two EC_POINT 595238405Sjkim * \param group underlying EC_GROUP object 596238405Sjkim * \param r EC_POINT object for the result (r = a + b) 597238405Sjkim * \param a EC_POINT object with the first summand 598238405Sjkim * \param b EC_POINT object with the second summand 599238405Sjkim * \param ctx BN_CTX object (optional) 600238405Sjkim * \return 1 on success and 0 if an error occured 601238405Sjkim */ 602296341Sdelphijint EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, 603296341Sdelphij const EC_POINT *b, BN_CTX *ctx); 604238405Sjkim 605238405Sjkim/** Computes the double of a EC_POINT 606238405Sjkim * \param group underlying EC_GROUP object 607238405Sjkim * \param r EC_POINT object for the result (r = 2 * a) 608296341Sdelphij * \param a EC_POINT object 609238405Sjkim * \param ctx BN_CTX object (optional) 610238405Sjkim * \return 1 on success and 0 if an error occured 611238405Sjkim */ 612296341Sdelphijint EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, 613296341Sdelphij BN_CTX *ctx); 614238405Sjkim 615238405Sjkim/** Computes the inverse of a EC_POINT 616238405Sjkim * \param group underlying EC_GROUP object 617238405Sjkim * \param a EC_POINT object to be inverted (it's used for the result as well) 618238405Sjkim * \param ctx BN_CTX object (optional) 619238405Sjkim * \return 1 on success and 0 if an error occured 620238405Sjkim */ 621238405Sjkimint EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx); 622238405Sjkim 623238405Sjkim/** Checks whether the point is the neutral element of the group 624238405Sjkim * \param group the underlying EC_GROUP object 625238405Sjkim * \param p EC_POINT object 626238405Sjkim * \return 1 if the point is the neutral element and 0 otherwise 627238405Sjkim */ 628238405Sjkimint EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *p); 629238405Sjkim 630296341Sdelphij/** Checks whether the point is on the curve 631238405Sjkim * \param group underlying EC_GROUP object 632238405Sjkim * \param point EC_POINT object to check 633238405Sjkim * \param ctx BN_CTX object (optional) 634238405Sjkim * \return 1 if point if on the curve and 0 otherwise 635238405Sjkim */ 636296341Sdelphijint EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, 637296341Sdelphij BN_CTX *ctx); 638238405Sjkim 639296341Sdelphij/** Compares two EC_POINTs 640238405Sjkim * \param group underlying EC_GROUP object 641238405Sjkim * \param a first EC_POINT object 642238405Sjkim * \param b second EC_POINT object 643238405Sjkim * \param ctx BN_CTX object (optional) 644238405Sjkim * \return 0 if both points are equal and a value != 0 otherwise 645238405Sjkim */ 646296341Sdelphijint EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, 647296341Sdelphij BN_CTX *ctx); 648238405Sjkim 649246772Sjkimint EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx); 650296341Sdelphijint EC_POINTs_make_affine(const EC_GROUP *group, size_t num, 651296341Sdelphij EC_POINT *points[], BN_CTX *ctx); 652109998Smarkm 653273399Sdelphij/** Computes r = generator * n sum_{i=0}^{num-1} p[i] * m[i] 654238405Sjkim * \param group underlying EC_GROUP object 655238405Sjkim * \param r EC_POINT object for the result 656238405Sjkim * \param n BIGNUM with the multiplier for the group generator (optional) 657238405Sjkim * \param num number futher summands 658238405Sjkim * \param p array of size num of EC_POINT objects 659238405Sjkim * \param m array of size num of BIGNUM objects 660238405Sjkim * \param ctx BN_CTX object (optional) 661238405Sjkim * \return 1 on success and 0 if an error occured 662238405Sjkim */ 663296341Sdelphijint EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, 664296341Sdelphij size_t num, const EC_POINT *p[], const BIGNUM *m[], 665296341Sdelphij BN_CTX *ctx); 666109998Smarkm 667238405Sjkim/** Computes r = generator * n + q * m 668238405Sjkim * \param group underlying EC_GROUP object 669238405Sjkim * \param r EC_POINT object for the result 670238405Sjkim * \param n BIGNUM with the multiplier for the group generator (optional) 671238405Sjkim * \param q EC_POINT object with the first factor of the second summand 672238405Sjkim * \param m BIGNUM with the second factor of the second summand 673238405Sjkim * \param ctx BN_CTX object (optional) 674238405Sjkim * \return 1 on success and 0 if an error occured 675238405Sjkim */ 676296341Sdelphijint EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, 677296341Sdelphij const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx); 678160814Ssimon 679238405Sjkim/** Stores multiples of generator for faster point multiplication 680238405Sjkim * \param group EC_GROUP object 681238405Sjkim * \param ctx BN_CTX object (optional) 682238405Sjkim * \return 1 on success and 0 if an error occured 683238405Sjkim */ 684238405Sjkimint EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx); 685109998Smarkm 686238405Sjkim/** Reports whether a precomputation has been done 687238405Sjkim * \param group EC_GROUP object 688238405Sjkim * \return 1 if a pre-computation has been done and 0 otherwise 689238405Sjkim */ 690238405Sjkimint EC_GROUP_have_precompute_mult(const EC_GROUP *group); 691109998Smarkm 692238405Sjkim/********************************************************************/ 693238405Sjkim/* ASN1 stuff */ 694238405Sjkim/********************************************************************/ 695160814Ssimon 696296341Sdelphij/* 697296341Sdelphij * EC_GROUP_get_basis_type() returns the NID of the basis type used to 698296341Sdelphij * represent the field elements 699296341Sdelphij */ 700160814Ssimonint EC_GROUP_get_basis_type(const EC_GROUP *); 701296341Sdelphij# ifndef OPENSSL_NO_EC2M 702160814Ssimonint EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k); 703296341Sdelphijint EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1, 704296341Sdelphij unsigned int *k2, unsigned int *k3); 705296341Sdelphij# endif 706160814Ssimon 707296341Sdelphij# define OPENSSL_EC_NAMED_CURVE 0x001 708160814Ssimon 709160814Ssimontypedef struct ecpk_parameters_st ECPKPARAMETERS; 710160814Ssimon 711160814SsimonEC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len); 712160814Ssimonint i2d_ECPKParameters(const EC_GROUP *, unsigned char **out); 713160814Ssimon 714296341Sdelphij# define d2i_ECPKParameters_bio(bp,x) ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x) 715296341Sdelphij# define i2d_ECPKParameters_bio(bp,x) ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x) 716296341Sdelphij# define d2i_ECPKParameters_fp(fp,x) (EC_GROUP *)ASN1_d2i_fp(NULL, \ 717160814Ssimon (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x)) 718296341Sdelphij# define i2d_ECPKParameters_fp(fp,x) ASN1_i2d_fp(i2d_ECPKParameters,(fp), \ 719296341Sdelphij (unsigned char *)(x)) 720160814Ssimon 721296341Sdelphij# ifndef OPENSSL_NO_BIO 722296341Sdelphijint ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off); 723296341Sdelphij# endif 724296341Sdelphij# ifndef OPENSSL_NO_FP_API 725296341Sdelphijint ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off); 726296341Sdelphij# endif 727160814Ssimon 728238405Sjkim/********************************************************************/ 729238405Sjkim/* EC_KEY functions */ 730238405Sjkim/********************************************************************/ 731238405Sjkim 732160814Ssimontypedef struct ec_key_st EC_KEY; 733160814Ssimon 734160814Ssimon/* some values for the encoding_flag */ 735296341Sdelphij# define EC_PKEY_NO_PARAMETERS 0x001 736296341Sdelphij# define EC_PKEY_NO_PUBKEY 0x002 737160814Ssimon 738238405Sjkim/* some values for the flags field */ 739296341Sdelphij# define EC_FLAG_NON_FIPS_ALLOW 0x1 740296341Sdelphij# define EC_FLAG_FIPS_CHECKED 0x2 741238405Sjkim 742238405Sjkim/** Creates a new EC_KEY object. 743238405Sjkim * \return EC_KEY object or NULL if an error occurred. 744238405Sjkim */ 745160814SsimonEC_KEY *EC_KEY_new(void); 746238405Sjkim 747238405Sjkimint EC_KEY_get_flags(const EC_KEY *key); 748238405Sjkim 749238405Sjkimvoid EC_KEY_set_flags(EC_KEY *key, int flags); 750238405Sjkim 751238405Sjkimvoid EC_KEY_clear_flags(EC_KEY *key, int flags); 752238405Sjkim 753238405Sjkim/** Creates a new EC_KEY object using a named curve as underlying 754238405Sjkim * EC_GROUP object. 755238405Sjkim * \param nid NID of the named curve. 756296341Sdelphij * \return EC_KEY object or NULL if an error occurred. 757238405Sjkim */ 758160814SsimonEC_KEY *EC_KEY_new_by_curve_name(int nid); 759160814Ssimon 760238405Sjkim/** Frees a EC_KEY object. 761238405Sjkim * \param key EC_KEY object to be freed. 762238405Sjkim */ 763238405Sjkimvoid EC_KEY_free(EC_KEY *key); 764160814Ssimon 765238405Sjkim/** Copies a EC_KEY object. 766238405Sjkim * \param dst destination EC_KEY object 767238405Sjkim * \param src src EC_KEY object 768238405Sjkim * \return dst or NULL if an error occurred. 769238405Sjkim */ 770238405SjkimEC_KEY *EC_KEY_copy(EC_KEY *dst, const EC_KEY *src); 771238405Sjkim 772238405Sjkim/** Creates a new EC_KEY object and copies the content from src to it. 773238405Sjkim * \param src the source EC_KEY object 774238405Sjkim * \return newly created EC_KEY object or NULL if an error occurred. 775238405Sjkim */ 776238405SjkimEC_KEY *EC_KEY_dup(const EC_KEY *src); 777238405Sjkim 778238405Sjkim/** Increases the internal reference count of a EC_KEY object. 779238405Sjkim * \param key EC_KEY object 780238405Sjkim * \return 1 on success and 0 if an error occurred. 781238405Sjkim */ 782238405Sjkimint EC_KEY_up_ref(EC_KEY *key); 783238405Sjkim 784238405Sjkim/** Returns the EC_GROUP object of a EC_KEY object 785238405Sjkim * \param key EC_KEY object 786238405Sjkim * \return the EC_GROUP object (possibly NULL). 787238405Sjkim */ 788238405Sjkimconst EC_GROUP *EC_KEY_get0_group(const EC_KEY *key); 789238405Sjkim 790238405Sjkim/** Sets the EC_GROUP of a EC_KEY object. 791238405Sjkim * \param key EC_KEY object 792238405Sjkim * \param group EC_GROUP to use in the EC_KEY object (note: the EC_KEY 793238405Sjkim * object will use an own copy of the EC_GROUP). 794238405Sjkim * \return 1 on success and 0 if an error occurred. 795238405Sjkim */ 796238405Sjkimint EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group); 797238405Sjkim 798238405Sjkim/** Returns the private key of a EC_KEY object. 799238405Sjkim * \param key EC_KEY object 800238405Sjkim * \return a BIGNUM with the private key (possibly NULL). 801238405Sjkim */ 802238405Sjkimconst BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key); 803238405Sjkim 804238405Sjkim/** Sets the private key of a EC_KEY object. 805238405Sjkim * \param key EC_KEY object 806238405Sjkim * \param prv BIGNUM with the private key (note: the EC_KEY object 807238405Sjkim * will use an own copy of the BIGNUM). 808238405Sjkim * \return 1 on success and 0 if an error occurred. 809238405Sjkim */ 810238405Sjkimint EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv); 811238405Sjkim 812238405Sjkim/** Returns the public key of a EC_KEY object. 813238405Sjkim * \param key the EC_KEY object 814238405Sjkim * \return a EC_POINT object with the public key (possibly NULL) 815238405Sjkim */ 816238405Sjkimconst EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key); 817238405Sjkim 818238405Sjkim/** Sets the public key of a EC_KEY object. 819238405Sjkim * \param key EC_KEY object 820238405Sjkim * \param pub EC_POINT object with the public key (note: the EC_KEY object 821238405Sjkim * will use an own copy of the EC_POINT object). 822238405Sjkim * \return 1 on success and 0 if an error occurred. 823238405Sjkim */ 824238405Sjkimint EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub); 825238405Sjkim 826238405Sjkimunsigned EC_KEY_get_enc_flags(const EC_KEY *key); 827246772Sjkimvoid EC_KEY_set_enc_flags(EC_KEY *eckey, unsigned int flags); 828246772Sjkimpoint_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key); 829246772Sjkimvoid EC_KEY_set_conv_form(EC_KEY *eckey, point_conversion_form_t cform); 830160814Ssimon/* functions to set/get method specific data */ 831296341Sdelphijvoid *EC_KEY_get_key_method_data(EC_KEY *key, 832296341Sdelphij void *(*dup_func) (void *), 833296341Sdelphij void (*free_func) (void *), 834296341Sdelphij void (*clear_free_func) (void *)); 835246772Sjkim/** Sets the key method data of an EC_KEY object, if none has yet been set. 836246772Sjkim * \param key EC_KEY object 837246772Sjkim * \param data opaque data to install. 838246772Sjkim * \param dup_func a function that duplicates |data|. 839246772Sjkim * \param free_func a function that frees |data|. 840246772Sjkim * \param clear_free_func a function that wipes and frees |data|. 841246772Sjkim * \return the previously set data pointer, or NULL if |data| was inserted. 842246772Sjkim */ 843246772Sjkimvoid *EC_KEY_insert_key_method_data(EC_KEY *key, void *data, 844296341Sdelphij void *(*dup_func) (void *), 845296341Sdelphij void (*free_func) (void *), 846296341Sdelphij void (*clear_free_func) (void *)); 847160814Ssimon/* wrapper functions for the underlying EC_GROUP object */ 848246772Sjkimvoid EC_KEY_set_asn1_flag(EC_KEY *eckey, int asn1_flag); 849160814Ssimon 850296341Sdelphij/** Creates a table of pre-computed multiples of the generator to 851238405Sjkim * accelerate further EC_KEY operations. 852238405Sjkim * \param key EC_KEY object 853238405Sjkim * \param ctx BN_CTX object (optional) 854238405Sjkim * \return 1 on success and 0 if an error occurred. 855238405Sjkim */ 856238405Sjkimint EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx); 857160814Ssimon 858238405Sjkim/** Creates a new ec private (and optional a new public) key. 859238405Sjkim * \param key EC_KEY object 860238405Sjkim * \return 1 on success and 0 if an error occurred. 861238405Sjkim */ 862238405Sjkimint EC_KEY_generate_key(EC_KEY *key); 863160814Ssimon 864238405Sjkim/** Verifies that a private and/or public key is valid. 865238405Sjkim * \param key the EC_KEY object 866238405Sjkim * \return 1 on success and 0 otherwise. 867238405Sjkim */ 868238405Sjkimint EC_KEY_check_key(const EC_KEY *key); 869238405Sjkim 870238405Sjkim/** Sets a public key from affine coordindates performing 871238405Sjkim * neccessary NIST PKV tests. 872238405Sjkim * \param key the EC_KEY object 873238405Sjkim * \param x public key x coordinate 874238405Sjkim * \param y public key y coordinate 875238405Sjkim * \return 1 on success and 0 otherwise. 876238405Sjkim */ 877296341Sdelphijint EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x, 878296341Sdelphij BIGNUM *y); 879238405Sjkim 880238405Sjkim/********************************************************************/ 881238405Sjkim/* de- and encoding functions for SEC1 ECPrivateKey */ 882238405Sjkim/********************************************************************/ 883238405Sjkim 884238405Sjkim/** Decodes a private key from a memory buffer. 885238405Sjkim * \param key a pointer to a EC_KEY object which should be used (or NULL) 886238405Sjkim * \param in pointer to memory with the DER encoded private key 887238405Sjkim * \param len length of the DER encoded private key 888238405Sjkim * \return the decoded private key or NULL if an error occurred. 889238405Sjkim */ 890238405SjkimEC_KEY *d2i_ECPrivateKey(EC_KEY **key, const unsigned char **in, long len); 891238405Sjkim 892238405Sjkim/** Encodes a private key object and stores the result in a buffer. 893238405Sjkim * \param key the EC_KEY object to encode 894238405Sjkim * \param out the buffer for the result (if NULL the function returns number 895238405Sjkim * of bytes needed). 896238405Sjkim * \return 1 on success and 0 if an error occurred. 897238405Sjkim */ 898238405Sjkimint i2d_ECPrivateKey(EC_KEY *key, unsigned char **out); 899238405Sjkim 900238405Sjkim/********************************************************************/ 901238405Sjkim/* de- and encoding functions for EC parameters */ 902238405Sjkim/********************************************************************/ 903238405Sjkim 904238405Sjkim/** Decodes ec parameter from a memory buffer. 905238405Sjkim * \param key a pointer to a EC_KEY object which should be used (or NULL) 906238405Sjkim * \param in pointer to memory with the DER encoded ec parameters 907238405Sjkim * \param len length of the DER encoded ec parameters 908238405Sjkim * \return a EC_KEY object with the decoded parameters or NULL if an error 909238405Sjkim * occurred. 910238405Sjkim */ 911238405SjkimEC_KEY *d2i_ECParameters(EC_KEY **key, const unsigned char **in, long len); 912238405Sjkim 913238405Sjkim/** Encodes ec parameter and stores the result in a buffer. 914238405Sjkim * \param key the EC_KEY object with ec paramters to encode 915238405Sjkim * \param out the buffer for the result (if NULL the function returns number 916238405Sjkim * of bytes needed). 917238405Sjkim * \return 1 on success and 0 if an error occurred. 918238405Sjkim */ 919238405Sjkimint i2d_ECParameters(EC_KEY *key, unsigned char **out); 920238405Sjkim 921238405Sjkim/********************************************************************/ 922238405Sjkim/* de- and encoding functions for EC public key */ 923238405Sjkim/* (octet string, not DER -- hence 'o2i' and 'i2o') */ 924238405Sjkim/********************************************************************/ 925238405Sjkim 926238405Sjkim/** Decodes a ec public key from a octet string. 927238405Sjkim * \param key a pointer to a EC_KEY object which should be used 928238405Sjkim * \param in memory buffer with the encoded public key 929238405Sjkim * \param len length of the encoded public key 930238405Sjkim * \return EC_KEY object with decoded public key or NULL if an error 931238405Sjkim * occurred. 932238405Sjkim */ 933238405SjkimEC_KEY *o2i_ECPublicKey(EC_KEY **key, const unsigned char **in, long len); 934238405Sjkim 935238405Sjkim/** Encodes a ec public key in an octet string. 936238405Sjkim * \param key the EC_KEY object with the public key 937238405Sjkim * \param out the buffer for the result (if NULL the function returns number 938238405Sjkim * of bytes needed). 939238405Sjkim * \return 1 on success and 0 if an error occurred 940238405Sjkim */ 941238405Sjkimint i2o_ECPublicKey(EC_KEY *key, unsigned char **out); 942238405Sjkim 943296341Sdelphij# ifndef OPENSSL_NO_BIO 944238405Sjkim/** Prints out the ec parameters on human readable form. 945238405Sjkim * \param bp BIO object to which the information is printed 946238405Sjkim * \param key EC_KEY object 947238405Sjkim * \return 1 on success and 0 if an error occurred 948238405Sjkim */ 949296341Sdelphijint ECParameters_print(BIO *bp, const EC_KEY *key); 950238405Sjkim 951238405Sjkim/** Prints out the contents of a EC_KEY object 952238405Sjkim * \param bp BIO object to which the information is printed 953238405Sjkim * \param key EC_KEY object 954296341Sdelphij * \param off line offset 955238405Sjkim * \return 1 on success and 0 if an error occurred 956238405Sjkim */ 957296341Sdelphijint EC_KEY_print(BIO *bp, const EC_KEY *key, int off); 958238405Sjkim 959296341Sdelphij# endif 960296341Sdelphij# ifndef OPENSSL_NO_FP_API 961238405Sjkim/** Prints out the ec parameters on human readable form. 962238405Sjkim * \param fp file descriptor to which the information is printed 963238405Sjkim * \param key EC_KEY object 964238405Sjkim * \return 1 on success and 0 if an error occurred 965238405Sjkim */ 966296341Sdelphijint ECParameters_print_fp(FILE *fp, const EC_KEY *key); 967238405Sjkim 968238405Sjkim/** Prints out the contents of a EC_KEY object 969238405Sjkim * \param fp file descriptor to which the information is printed 970238405Sjkim * \param key EC_KEY object 971296341Sdelphij * \param off line offset 972238405Sjkim * \return 1 on success and 0 if an error occurred 973238405Sjkim */ 974296341Sdelphijint EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off); 975238405Sjkim 976296341Sdelphij# endif 977160814Ssimon 978296341Sdelphij# define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x) 979160814Ssimon 980296341Sdelphij# ifndef __cplusplus 981296341Sdelphij# if defined(__SUNPRO_C) 982296341Sdelphij# if __SUNPRO_C >= 0x520 983296341Sdelphij# pragma error_messages (default,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE) 984296341Sdelphij# endif 985160814Ssimon# endif 986160814Ssimon# endif 987160814Ssimon 988296341Sdelphij# define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid) \ 989296341Sdelphij EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, EVP_PKEY_OP_PARAMGEN, \ 990296341Sdelphij EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL) 991238405Sjkim 992296341Sdelphij# define EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID (EVP_PKEY_ALG_CTRL + 1) 993238405Sjkim 994109998Smarkm/* BEGIN ERROR CODES */ 995296341Sdelphij/* 996296341Sdelphij * The following lines are auto generated by the script mkerr.pl. Any changes 997109998Smarkm * made after this point may be overwritten when the script is next run. 998109998Smarkm */ 999109998Smarkmvoid ERR_load_EC_strings(void); 1000109998Smarkm 1001109998Smarkm/* Error codes for the EC functions. */ 1002109998Smarkm 1003109998Smarkm/* Function codes. */ 1004296341Sdelphij# define EC_F_BN_TO_FELEM 224 1005296341Sdelphij# define EC_F_COMPUTE_WNAF 143 1006296341Sdelphij# define EC_F_D2I_ECPARAMETERS 144 1007296341Sdelphij# define EC_F_D2I_ECPKPARAMETERS 145 1008296341Sdelphij# define EC_F_D2I_ECPRIVATEKEY 146 1009296341Sdelphij# define EC_F_DO_EC_KEY_PRINT 221 1010296341Sdelphij# define EC_F_ECKEY_PARAM2TYPE 223 1011296341Sdelphij# define EC_F_ECKEY_PARAM_DECODE 212 1012296341Sdelphij# define EC_F_ECKEY_PRIV_DECODE 213 1013296341Sdelphij# define EC_F_ECKEY_PRIV_ENCODE 214 1014296341Sdelphij# define EC_F_ECKEY_PUB_DECODE 215 1015296341Sdelphij# define EC_F_ECKEY_PUB_ENCODE 216 1016296341Sdelphij# define EC_F_ECKEY_TYPE2PARAM 220 1017296341Sdelphij# define EC_F_ECPARAMETERS_PRINT 147 1018296341Sdelphij# define EC_F_ECPARAMETERS_PRINT_FP 148 1019296341Sdelphij# define EC_F_ECPKPARAMETERS_PRINT 149 1020296341Sdelphij# define EC_F_ECPKPARAMETERS_PRINT_FP 150 1021296341Sdelphij# define EC_F_ECP_NIST_MOD_192 203 1022296341Sdelphij# define EC_F_ECP_NIST_MOD_224 204 1023296341Sdelphij# define EC_F_ECP_NIST_MOD_256 205 1024296341Sdelphij# define EC_F_ECP_NIST_MOD_521 206 1025296341Sdelphij# define EC_F_EC_ASN1_GROUP2CURVE 153 1026296341Sdelphij# define EC_F_EC_ASN1_GROUP2FIELDID 154 1027296341Sdelphij# define EC_F_EC_ASN1_GROUP2PARAMETERS 155 1028296341Sdelphij# define EC_F_EC_ASN1_GROUP2PKPARAMETERS 156 1029296341Sdelphij# define EC_F_EC_ASN1_PARAMETERS2GROUP 157 1030296341Sdelphij# define EC_F_EC_ASN1_PKPARAMETERS2GROUP 158 1031296341Sdelphij# define EC_F_EC_EX_DATA_SET_DATA 211 1032296341Sdelphij# define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY 208 1033296341Sdelphij# define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT 159 1034296341Sdelphij# define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE 195 1035296341Sdelphij# define EC_F_EC_GF2M_SIMPLE_OCT2POINT 160 1036296341Sdelphij# define EC_F_EC_GF2M_SIMPLE_POINT2OCT 161 1037296341Sdelphij# define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 162 1038296341Sdelphij# define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 163 1039296341Sdelphij# define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES 164 1040296341Sdelphij# define EC_F_EC_GFP_MONT_FIELD_DECODE 133 1041296341Sdelphij# define EC_F_EC_GFP_MONT_FIELD_ENCODE 134 1042296341Sdelphij# define EC_F_EC_GFP_MONT_FIELD_MUL 131 1043296341Sdelphij# define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE 209 1044296341Sdelphij# define EC_F_EC_GFP_MONT_FIELD_SQR 132 1045296341Sdelphij# define EC_F_EC_GFP_MONT_GROUP_SET_CURVE 189 1046296341Sdelphij# define EC_F_EC_GFP_MONT_GROUP_SET_CURVE_GFP 135 1047296341Sdelphij# define EC_F_EC_GFP_NISTP224_GROUP_SET_CURVE 225 1048296341Sdelphij# define EC_F_EC_GFP_NISTP224_POINTS_MUL 228 1049296341Sdelphij# define EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES 226 1050296341Sdelphij# define EC_F_EC_GFP_NISTP256_GROUP_SET_CURVE 230 1051296341Sdelphij# define EC_F_EC_GFP_NISTP256_POINTS_MUL 231 1052296341Sdelphij# define EC_F_EC_GFP_NISTP256_POINT_GET_AFFINE_COORDINATES 232 1053296341Sdelphij# define EC_F_EC_GFP_NISTP521_GROUP_SET_CURVE 233 1054296341Sdelphij# define EC_F_EC_GFP_NISTP521_POINTS_MUL 234 1055296341Sdelphij# define EC_F_EC_GFP_NISTP521_POINT_GET_AFFINE_COORDINATES 235 1056296341Sdelphij# define EC_F_EC_GFP_NIST_FIELD_MUL 200 1057296341Sdelphij# define EC_F_EC_GFP_NIST_FIELD_SQR 201 1058296341Sdelphij# define EC_F_EC_GFP_NIST_GROUP_SET_CURVE 202 1059296341Sdelphij# define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT 165 1060296341Sdelphij# define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE 166 1061296341Sdelphij# define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE_GFP 100 1062296341Sdelphij# define EC_F_EC_GFP_SIMPLE_GROUP_SET_GENERATOR 101 1063296341Sdelphij# define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE 102 1064296341Sdelphij# define EC_F_EC_GFP_SIMPLE_OCT2POINT 103 1065296341Sdelphij# define EC_F_EC_GFP_SIMPLE_POINT2OCT 104 1066296341Sdelphij# define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE 137 1067296341Sdelphij# define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES 167 1068296341Sdelphij# define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP 105 1069296341Sdelphij# define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES 168 1070296341Sdelphij# define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES_GFP 128 1071296341Sdelphij# define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES 169 1072296341Sdelphij# define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP 129 1073296341Sdelphij# define EC_F_EC_GROUP_CHECK 170 1074296341Sdelphij# define EC_F_EC_GROUP_CHECK_DISCRIMINANT 171 1075296341Sdelphij# define EC_F_EC_GROUP_COPY 106 1076296341Sdelphij# define EC_F_EC_GROUP_GET0_GENERATOR 139 1077296341Sdelphij# define EC_F_EC_GROUP_GET_COFACTOR 140 1078296341Sdelphij# define EC_F_EC_GROUP_GET_CURVE_GF2M 172 1079296341Sdelphij# define EC_F_EC_GROUP_GET_CURVE_GFP 130 1080296341Sdelphij# define EC_F_EC_GROUP_GET_DEGREE 173 1081296341Sdelphij# define EC_F_EC_GROUP_GET_ORDER 141 1082296341Sdelphij# define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS 193 1083296341Sdelphij# define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS 194 1084296341Sdelphij# define EC_F_EC_GROUP_NEW 108 1085296341Sdelphij# define EC_F_EC_GROUP_NEW_BY_CURVE_NAME 174 1086296341Sdelphij# define EC_F_EC_GROUP_NEW_FROM_DATA 175 1087296341Sdelphij# define EC_F_EC_GROUP_PRECOMPUTE_MULT 142 1088296341Sdelphij# define EC_F_EC_GROUP_SET_CURVE_GF2M 176 1089296341Sdelphij# define EC_F_EC_GROUP_SET_CURVE_GFP 109 1090296341Sdelphij# define EC_F_EC_GROUP_SET_EXTRA_DATA 110 1091296341Sdelphij# define EC_F_EC_GROUP_SET_GENERATOR 111 1092296341Sdelphij# define EC_F_EC_KEY_CHECK_KEY 177 1093296341Sdelphij# define EC_F_EC_KEY_COPY 178 1094296341Sdelphij# define EC_F_EC_KEY_GENERATE_KEY 179 1095296341Sdelphij# define EC_F_EC_KEY_NEW 182 1096296341Sdelphij# define EC_F_EC_KEY_PRINT 180 1097296341Sdelphij# define EC_F_EC_KEY_PRINT_FP 181 1098296341Sdelphij# define EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES 229 1099296341Sdelphij# define EC_F_EC_POINTS_MAKE_AFFINE 136 1100296341Sdelphij# define EC_F_EC_POINT_ADD 112 1101296341Sdelphij# define EC_F_EC_POINT_CMP 113 1102296341Sdelphij# define EC_F_EC_POINT_COPY 114 1103296341Sdelphij# define EC_F_EC_POINT_DBL 115 1104296341Sdelphij# define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M 183 1105296341Sdelphij# define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP 116 1106296341Sdelphij# define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP 117 1107296341Sdelphij# define EC_F_EC_POINT_INVERT 210 1108296341Sdelphij# define EC_F_EC_POINT_IS_AT_INFINITY 118 1109296341Sdelphij# define EC_F_EC_POINT_IS_ON_CURVE 119 1110296341Sdelphij# define EC_F_EC_POINT_MAKE_AFFINE 120 1111296341Sdelphij# define EC_F_EC_POINT_MUL 184 1112296341Sdelphij# define EC_F_EC_POINT_NEW 121 1113296341Sdelphij# define EC_F_EC_POINT_OCT2POINT 122 1114296341Sdelphij# define EC_F_EC_POINT_POINT2OCT 123 1115296341Sdelphij# define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M 185 1116296341Sdelphij# define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP 124 1117296341Sdelphij# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M 186 1118296341Sdelphij# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP 125 1119296341Sdelphij# define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP 126 1120296341Sdelphij# define EC_F_EC_POINT_SET_TO_INFINITY 127 1121296341Sdelphij# define EC_F_EC_PRE_COMP_DUP 207 1122296341Sdelphij# define EC_F_EC_PRE_COMP_NEW 196 1123296341Sdelphij# define EC_F_EC_WNAF_MUL 187 1124296341Sdelphij# define EC_F_EC_WNAF_PRECOMPUTE_MULT 188 1125296341Sdelphij# define EC_F_I2D_ECPARAMETERS 190 1126296341Sdelphij# define EC_F_I2D_ECPKPARAMETERS 191 1127296341Sdelphij# define EC_F_I2D_ECPRIVATEKEY 192 1128296341Sdelphij# define EC_F_I2O_ECPUBLICKEY 151 1129296341Sdelphij# define EC_F_NISTP224_PRE_COMP_NEW 227 1130296341Sdelphij# define EC_F_NISTP256_PRE_COMP_NEW 236 1131296341Sdelphij# define EC_F_NISTP521_PRE_COMP_NEW 237 1132296341Sdelphij# define EC_F_O2I_ECPUBLICKEY 152 1133296341Sdelphij# define EC_F_OLD_EC_PRIV_DECODE 222 1134296341Sdelphij# define EC_F_PKEY_EC_CTRL 197 1135296341Sdelphij# define EC_F_PKEY_EC_CTRL_STR 198 1136296341Sdelphij# define EC_F_PKEY_EC_DERIVE 217 1137296341Sdelphij# define EC_F_PKEY_EC_KEYGEN 199 1138296341Sdelphij# define EC_F_PKEY_EC_PARAMGEN 219 1139296341Sdelphij# define EC_F_PKEY_EC_SIGN 218 1140109998Smarkm 1141109998Smarkm/* Reason codes. */ 1142296341Sdelphij# define EC_R_ASN1_ERROR 115 1143296341Sdelphij# define EC_R_ASN1_UNKNOWN_FIELD 116 1144296341Sdelphij# define EC_R_BIGNUM_OUT_OF_RANGE 144 1145296341Sdelphij# define EC_R_BUFFER_TOO_SMALL 100 1146296341Sdelphij# define EC_R_COORDINATES_OUT_OF_RANGE 146 1147296341Sdelphij# define EC_R_D2I_ECPKPARAMETERS_FAILURE 117 1148296341Sdelphij# define EC_R_DECODE_ERROR 142 1149296341Sdelphij# define EC_R_DISCRIMINANT_IS_ZERO 118 1150296341Sdelphij# define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 119 1151296341Sdelphij# define EC_R_FIELD_TOO_LARGE 143 1152296341Sdelphij# define EC_R_GF2M_NOT_SUPPORTED 147 1153296341Sdelphij# define EC_R_GROUP2PKPARAMETERS_FAILURE 120 1154296341Sdelphij# define EC_R_I2D_ECPKPARAMETERS_FAILURE 121 1155296341Sdelphij# define EC_R_INCOMPATIBLE_OBJECTS 101 1156296341Sdelphij# define EC_R_INVALID_ARGUMENT 112 1157296341Sdelphij# define EC_R_INVALID_COMPRESSED_POINT 110 1158296341Sdelphij# define EC_R_INVALID_COMPRESSION_BIT 109 1159296341Sdelphij# define EC_R_INVALID_CURVE 141 1160296341Sdelphij# define EC_R_INVALID_DIGEST_TYPE 138 1161296341Sdelphij# define EC_R_INVALID_ENCODING 102 1162296341Sdelphij# define EC_R_INVALID_FIELD 103 1163296341Sdelphij# define EC_R_INVALID_FORM 104 1164296341Sdelphij# define EC_R_INVALID_GROUP_ORDER 122 1165296341Sdelphij# define EC_R_INVALID_PENTANOMIAL_BASIS 132 1166296341Sdelphij# define EC_R_INVALID_PRIVATE_KEY 123 1167296341Sdelphij# define EC_R_INVALID_TRINOMIAL_BASIS 137 1168296341Sdelphij# define EC_R_KEYS_NOT_SET 140 1169296341Sdelphij# define EC_R_MISSING_PARAMETERS 124 1170296341Sdelphij# define EC_R_MISSING_PRIVATE_KEY 125 1171296341Sdelphij# define EC_R_NOT_A_NIST_PRIME 135 1172296341Sdelphij# define EC_R_NOT_A_SUPPORTED_NIST_PRIME 136 1173296341Sdelphij# define EC_R_NOT_IMPLEMENTED 126 1174296341Sdelphij# define EC_R_NOT_INITIALIZED 111 1175296341Sdelphij# define EC_R_NO_FIELD_MOD 133 1176296341Sdelphij# define EC_R_NO_PARAMETERS_SET 139 1177296341Sdelphij# define EC_R_PASSED_NULL_PARAMETER 134 1178296341Sdelphij# define EC_R_PKPARAMETERS2GROUP_FAILURE 127 1179296341Sdelphij# define EC_R_POINT_AT_INFINITY 106 1180296341Sdelphij# define EC_R_POINT_IS_NOT_ON_CURVE 107 1181296341Sdelphij# define EC_R_SLOT_FULL 108 1182296341Sdelphij# define EC_R_UNDEFINED_GENERATOR 113 1183296341Sdelphij# define EC_R_UNDEFINED_ORDER 128 1184296341Sdelphij# define EC_R_UNKNOWN_GROUP 129 1185296341Sdelphij# define EC_R_UNKNOWN_ORDER 114 1186296341Sdelphij# define EC_R_UNSUPPORTED_FIELD 131 1187296341Sdelphij# define EC_R_WRONG_CURVE_PARAMETERS 145 1188296341Sdelphij# define EC_R_WRONG_ORDER 130 1189109998Smarkm 1190109998Smarkm#ifdef __cplusplus 1191109998Smarkm} 1192109998Smarkm#endif 1193109998Smarkm#endif 1194