1*4724848cSchristos /* 2*4724848cSchristos * Copyright 2002-2021 The OpenSSL Project Authors. All Rights Reserved. 3*4724848cSchristos * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved 4*4724848cSchristos * 5*4724848cSchristos * Licensed under the OpenSSL license (the "License"). You may not use 6*4724848cSchristos * this file except in compliance with the License. You can obtain a copy 7*4724848cSchristos * in the file LICENSE in the source distribution or at 8*4724848cSchristos * https://www.openssl.org/source/license.html 9*4724848cSchristos */ 10*4724848cSchristos 11*4724848cSchristos #ifndef HEADER_EC_H 12*4724848cSchristos # define HEADER_EC_H 13*4724848cSchristos 14*4724848cSchristos # include <openssl/opensslconf.h> 15*4724848cSchristos 16*4724848cSchristos # ifndef OPENSSL_NO_EC 17*4724848cSchristos # include <openssl/asn1.h> 18*4724848cSchristos # include <openssl/symhacks.h> 19*4724848cSchristos # if OPENSSL_API_COMPAT < 0x10100000L 20*4724848cSchristos # include <openssl/bn.h> 21*4724848cSchristos # endif 22*4724848cSchristos # include <openssl/ecerr.h> 23*4724848cSchristos # ifdef __cplusplus 24*4724848cSchristos extern "C" { 25*4724848cSchristos # endif 26*4724848cSchristos 27*4724848cSchristos # ifndef OPENSSL_ECC_MAX_FIELD_BITS 28*4724848cSchristos # define OPENSSL_ECC_MAX_FIELD_BITS 661 29*4724848cSchristos # endif 30*4724848cSchristos 31*4724848cSchristos /** Enum for the point conversion form as defined in X9.62 (ECDSA) 32*4724848cSchristos * for the encoding of a elliptic curve point (x,y) */ 33*4724848cSchristos typedef enum { 34*4724848cSchristos /** the point is encoded as z||x, where the octet z specifies 35*4724848cSchristos * which solution of the quadratic equation y is */ 36*4724848cSchristos POINT_CONVERSION_COMPRESSED = 2, 37*4724848cSchristos /** the point is encoded as z||x||y, where z is the octet 0x04 */ 38*4724848cSchristos POINT_CONVERSION_UNCOMPRESSED = 4, 39*4724848cSchristos /** the point is encoded as z||x||y, where the octet z specifies 40*4724848cSchristos * which solution of the quadratic equation y is */ 41*4724848cSchristos POINT_CONVERSION_HYBRID = 6 42*4724848cSchristos } point_conversion_form_t; 43*4724848cSchristos 44*4724848cSchristos typedef struct ec_method_st EC_METHOD; 45*4724848cSchristos typedef struct ec_group_st EC_GROUP; 46*4724848cSchristos typedef struct ec_point_st EC_POINT; 47*4724848cSchristos typedef struct ecpk_parameters_st ECPKPARAMETERS; 48*4724848cSchristos typedef struct ec_parameters_st ECPARAMETERS; 49*4724848cSchristos 50*4724848cSchristos /********************************************************************/ 51*4724848cSchristos /* EC_METHODs for curves over GF(p) */ 52*4724848cSchristos /********************************************************************/ 53*4724848cSchristos 54*4724848cSchristos /** Returns the basic GFp ec methods which provides the basis for the 55*4724848cSchristos * optimized methods. 56*4724848cSchristos * \return EC_METHOD object 57*4724848cSchristos */ 58*4724848cSchristos const EC_METHOD *EC_GFp_simple_method(void); 59*4724848cSchristos 60*4724848cSchristos /** Returns GFp methods using montgomery multiplication. 61*4724848cSchristos * \return EC_METHOD object 62*4724848cSchristos */ 63*4724848cSchristos const EC_METHOD *EC_GFp_mont_method(void); 64*4724848cSchristos 65*4724848cSchristos /** Returns GFp methods using optimized methods for NIST recommended curves 66*4724848cSchristos * \return EC_METHOD object 67*4724848cSchristos */ 68*4724848cSchristos const EC_METHOD *EC_GFp_nist_method(void); 69*4724848cSchristos 70*4724848cSchristos # ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 71*4724848cSchristos /** Returns 64-bit optimized methods for nistp224 72*4724848cSchristos * \return EC_METHOD object 73*4724848cSchristos */ 74*4724848cSchristos const EC_METHOD *EC_GFp_nistp224_method(void); 75*4724848cSchristos 76*4724848cSchristos /** Returns 64-bit optimized methods for nistp256 77*4724848cSchristos * \return EC_METHOD object 78*4724848cSchristos */ 79*4724848cSchristos const EC_METHOD *EC_GFp_nistp256_method(void); 80*4724848cSchristos 81*4724848cSchristos /** Returns 64-bit optimized methods for nistp521 82*4724848cSchristos * \return EC_METHOD object 83*4724848cSchristos */ 84*4724848cSchristos const EC_METHOD *EC_GFp_nistp521_method(void); 85*4724848cSchristos # endif 86*4724848cSchristos 87*4724848cSchristos # ifndef OPENSSL_NO_EC2M 88*4724848cSchristos /********************************************************************/ 89*4724848cSchristos /* EC_METHOD for curves over GF(2^m) */ 90*4724848cSchristos /********************************************************************/ 91*4724848cSchristos 92*4724848cSchristos /** Returns the basic GF2m ec method 93*4724848cSchristos * \return EC_METHOD object 94*4724848cSchristos */ 95*4724848cSchristos const EC_METHOD *EC_GF2m_simple_method(void); 96*4724848cSchristos 97*4724848cSchristos # endif 98*4724848cSchristos 99*4724848cSchristos /********************************************************************/ 100*4724848cSchristos /* EC_GROUP functions */ 101*4724848cSchristos /********************************************************************/ 102*4724848cSchristos 103*4724848cSchristos /** Creates a new EC_GROUP object 104*4724848cSchristos * \param meth EC_METHOD to use 105*4724848cSchristos * \return newly created EC_GROUP object or NULL in case of an error. 106*4724848cSchristos */ 107*4724848cSchristos EC_GROUP *EC_GROUP_new(const EC_METHOD *meth); 108*4724848cSchristos 109*4724848cSchristos /** Frees a EC_GROUP object 110*4724848cSchristos * \param group EC_GROUP object to be freed. 111*4724848cSchristos */ 112*4724848cSchristos void EC_GROUP_free(EC_GROUP *group); 113*4724848cSchristos 114*4724848cSchristos /** Clears and frees a EC_GROUP object 115*4724848cSchristos * \param group EC_GROUP object to be cleared and freed. 116*4724848cSchristos */ 117*4724848cSchristos void EC_GROUP_clear_free(EC_GROUP *group); 118*4724848cSchristos 119*4724848cSchristos /** Copies EC_GROUP objects. Note: both EC_GROUPs must use the same EC_METHOD. 120*4724848cSchristos * \param dst destination EC_GROUP object 121*4724848cSchristos * \param src source EC_GROUP object 122*4724848cSchristos * \return 1 on success and 0 if an error occurred. 123*4724848cSchristos */ 124*4724848cSchristos int EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src); 125*4724848cSchristos 126*4724848cSchristos /** Creates a new EC_GROUP object and copies the copies the content 127*4724848cSchristos * form src to the newly created EC_KEY object 128*4724848cSchristos * \param src source EC_GROUP object 129*4724848cSchristos * \return newly created EC_GROUP object or NULL in case of an error. 130*4724848cSchristos */ 131*4724848cSchristos EC_GROUP *EC_GROUP_dup(const EC_GROUP *src); 132*4724848cSchristos 133*4724848cSchristos /** Returns the EC_METHOD of the EC_GROUP object. 134*4724848cSchristos * \param group EC_GROUP object 135*4724848cSchristos * \return EC_METHOD used in this EC_GROUP object. 136*4724848cSchristos */ 137*4724848cSchristos const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group); 138*4724848cSchristos 139*4724848cSchristos /** Returns the field type of the EC_METHOD. 140*4724848cSchristos * \param meth EC_METHOD object 141*4724848cSchristos * \return NID of the underlying field type OID. 142*4724848cSchristos */ 143*4724848cSchristos int EC_METHOD_get_field_type(const EC_METHOD *meth); 144*4724848cSchristos 145*4724848cSchristos /** Sets the generator and its order/cofactor of a EC_GROUP object. 146*4724848cSchristos * \param group EC_GROUP object 147*4724848cSchristos * \param generator EC_POINT object with the generator. 148*4724848cSchristos * \param order the order of the group generated by the generator. 149*4724848cSchristos * \param cofactor the index of the sub-group generated by the generator 150*4724848cSchristos * in the group of all points on the elliptic curve. 151*4724848cSchristos * \return 1 on success and 0 if an error occurred 152*4724848cSchristos */ 153*4724848cSchristos int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, 154*4724848cSchristos const BIGNUM *order, const BIGNUM *cofactor); 155*4724848cSchristos 156*4724848cSchristos /** Returns the generator of a EC_GROUP object. 157*4724848cSchristos * \param group EC_GROUP object 158*4724848cSchristos * \return the currently used generator (possibly NULL). 159*4724848cSchristos */ 160*4724848cSchristos const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group); 161*4724848cSchristos 162*4724848cSchristos /** Returns the montgomery data for order(Generator) 163*4724848cSchristos * \param group EC_GROUP object 164*4724848cSchristos * \return the currently used montgomery data (possibly NULL). 165*4724848cSchristos */ 166*4724848cSchristos BN_MONT_CTX *EC_GROUP_get_mont_data(const EC_GROUP *group); 167*4724848cSchristos 168*4724848cSchristos /** Gets the order of a EC_GROUP 169*4724848cSchristos * \param group EC_GROUP object 170*4724848cSchristos * \param order BIGNUM to which the order is copied 171*4724848cSchristos * \param ctx unused 172*4724848cSchristos * \return 1 on success and 0 if an error occurred 173*4724848cSchristos */ 174*4724848cSchristos int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx); 175*4724848cSchristos 176*4724848cSchristos /** Gets the order of an EC_GROUP 177*4724848cSchristos * \param group EC_GROUP object 178*4724848cSchristos * \return the group order 179*4724848cSchristos */ 180*4724848cSchristos const BIGNUM *EC_GROUP_get0_order(const EC_GROUP *group); 181*4724848cSchristos 182*4724848cSchristos /** Gets the number of bits of the order of an EC_GROUP 183*4724848cSchristos * \param group EC_GROUP object 184*4724848cSchristos * \return number of bits of group order. 185*4724848cSchristos */ 186*4724848cSchristos int EC_GROUP_order_bits(const EC_GROUP *group); 187*4724848cSchristos 188*4724848cSchristos /** Gets the cofactor of a EC_GROUP 189*4724848cSchristos * \param group EC_GROUP object 190*4724848cSchristos * \param cofactor BIGNUM to which the cofactor is copied 191*4724848cSchristos * \param ctx unused 192*4724848cSchristos * \return 1 on success and 0 if an error occurred 193*4724848cSchristos */ 194*4724848cSchristos int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, 195*4724848cSchristos BN_CTX *ctx); 196*4724848cSchristos 197*4724848cSchristos /** Gets the cofactor of an EC_GROUP 198*4724848cSchristos * \param group EC_GROUP object 199*4724848cSchristos * \return the group cofactor 200*4724848cSchristos */ 201*4724848cSchristos const BIGNUM *EC_GROUP_get0_cofactor(const EC_GROUP *group); 202*4724848cSchristos 203*4724848cSchristos /** Sets the name of a EC_GROUP object 204*4724848cSchristos * \param group EC_GROUP object 205*4724848cSchristos * \param nid NID of the curve name OID 206*4724848cSchristos */ 207*4724848cSchristos void EC_GROUP_set_curve_name(EC_GROUP *group, int nid); 208*4724848cSchristos 209*4724848cSchristos /** Returns the curve name of a EC_GROUP object 210*4724848cSchristos * \param group EC_GROUP object 211*4724848cSchristos * \return NID of the curve name OID or 0 if not set. 212*4724848cSchristos */ 213*4724848cSchristos int EC_GROUP_get_curve_name(const EC_GROUP *group); 214*4724848cSchristos 215*4724848cSchristos void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag); 216*4724848cSchristos int EC_GROUP_get_asn1_flag(const EC_GROUP *group); 217*4724848cSchristos 218*4724848cSchristos void EC_GROUP_set_point_conversion_form(EC_GROUP *group, 219*4724848cSchristos point_conversion_form_t form); 220*4724848cSchristos point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *); 221*4724848cSchristos 222*4724848cSchristos unsigned char *EC_GROUP_get0_seed(const EC_GROUP *x); 223*4724848cSchristos size_t EC_GROUP_get_seed_len(const EC_GROUP *); 224*4724848cSchristos size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len); 225*4724848cSchristos 226*4724848cSchristos /** Sets the parameters of a ec curve defined by y^2 = x^3 + a*x + b (for GFp) 227*4724848cSchristos * or y^2 + x*y = x^3 + a*x^2 + b (for GF2m) 228*4724848cSchristos * \param group EC_GROUP object 229*4724848cSchristos * \param p BIGNUM with the prime number (GFp) or the polynomial 230*4724848cSchristos * defining the underlying field (GF2m) 231*4724848cSchristos * \param a BIGNUM with parameter a of the equation 232*4724848cSchristos * \param b BIGNUM with parameter b of the equation 233*4724848cSchristos * \param ctx BN_CTX object (optional) 234*4724848cSchristos * \return 1 on success and 0 if an error occurred 235*4724848cSchristos */ 236*4724848cSchristos int EC_GROUP_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, 237*4724848cSchristos const BIGNUM *b, BN_CTX *ctx); 238*4724848cSchristos 239*4724848cSchristos /** Gets the parameters of the ec curve defined by y^2 = x^3 + a*x + b (for GFp) 240*4724848cSchristos * or y^2 + x*y = x^3 + a*x^2 + b (for GF2m) 241*4724848cSchristos * \param group EC_GROUP object 242*4724848cSchristos * \param p BIGNUM with the prime number (GFp) or the polynomial 243*4724848cSchristos * defining the underlying field (GF2m) 244*4724848cSchristos * \param a BIGNUM for parameter a of the equation 245*4724848cSchristos * \param b BIGNUM for parameter b of the equation 246*4724848cSchristos * \param ctx BN_CTX object (optional) 247*4724848cSchristos * \return 1 on success and 0 if an error occurred 248*4724848cSchristos */ 249*4724848cSchristos int EC_GROUP_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, 250*4724848cSchristos BN_CTX *ctx); 251*4724848cSchristos 252*4724848cSchristos /** Sets the parameters of an ec curve. Synonym for EC_GROUP_set_curve 253*4724848cSchristos * \param group EC_GROUP object 254*4724848cSchristos * \param p BIGNUM with the prime number (GFp) or the polynomial 255*4724848cSchristos * defining the underlying field (GF2m) 256*4724848cSchristos * \param a BIGNUM with parameter a of the equation 257*4724848cSchristos * \param b BIGNUM with parameter b of the equation 258*4724848cSchristos * \param ctx BN_CTX object (optional) 259*4724848cSchristos * \return 1 on success and 0 if an error occurred 260*4724848cSchristos */ 261*4724848cSchristos DEPRECATEDIN_1_2_0(int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, 262*4724848cSchristos const BIGNUM *a, const BIGNUM *b, 263*4724848cSchristos BN_CTX *ctx)) 264*4724848cSchristos 265*4724848cSchristos /** Gets the parameters of an ec curve. Synonym for EC_GROUP_get_curve 266*4724848cSchristos * \param group EC_GROUP object 267*4724848cSchristos * \param p BIGNUM with the prime number (GFp) or the polynomial 268*4724848cSchristos * defining the underlying field (GF2m) 269*4724848cSchristos * \param a BIGNUM for parameter a of the equation 270*4724848cSchristos * \param b BIGNUM for parameter b of the equation 271*4724848cSchristos * \param ctx BN_CTX object (optional) 272*4724848cSchristos * \return 1 on success and 0 if an error occurred 273*4724848cSchristos */ 274*4724848cSchristos DEPRECATEDIN_1_2_0(int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, 275*4724848cSchristos BIGNUM *a, BIGNUM *b, 276*4724848cSchristos BN_CTX *ctx)) 277*4724848cSchristos 278*4724848cSchristos # ifndef OPENSSL_NO_EC2M 279*4724848cSchristos /** Sets the parameter of an ec curve. Synonym for EC_GROUP_set_curve 280*4724848cSchristos * \param group EC_GROUP object 281*4724848cSchristos * \param p BIGNUM with the prime number (GFp) or the polynomial 282*4724848cSchristos * defining the underlying field (GF2m) 283*4724848cSchristos * \param a BIGNUM with parameter a of the equation 284*4724848cSchristos * \param b BIGNUM with parameter b of the equation 285*4724848cSchristos * \param ctx BN_CTX object (optional) 286*4724848cSchristos * \return 1 on success and 0 if an error occurred 287*4724848cSchristos */ 288*4724848cSchristos DEPRECATEDIN_1_2_0(int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, 289*4724848cSchristos const BIGNUM *a, const BIGNUM *b, 290*4724848cSchristos BN_CTX *ctx)) 291*4724848cSchristos 292*4724848cSchristos /** Gets the parameters of an ec curve. Synonym for EC_GROUP_get_curve 293*4724848cSchristos * \param group EC_GROUP object 294*4724848cSchristos * \param p BIGNUM with the prime number (GFp) or the polynomial 295*4724848cSchristos * defining the underlying field (GF2m) 296*4724848cSchristos * \param a BIGNUM for parameter a of the equation 297*4724848cSchristos * \param b BIGNUM for parameter b of the equation 298*4724848cSchristos * \param ctx BN_CTX object (optional) 299*4724848cSchristos * \return 1 on success and 0 if an error occurred 300*4724848cSchristos */ 301*4724848cSchristos DEPRECATEDIN_1_2_0(int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, 302*4724848cSchristos BIGNUM *a, BIGNUM *b, 303*4724848cSchristos BN_CTX *ctx)) 304*4724848cSchristos # endif 305*4724848cSchristos /** Returns the number of bits needed to represent a field element 306*4724848cSchristos * \param group EC_GROUP object 307*4724848cSchristos * \return number of bits needed to represent a field element 308*4724848cSchristos */ 309*4724848cSchristos int EC_GROUP_get_degree(const EC_GROUP *group); 310*4724848cSchristos 311*4724848cSchristos /** Checks whether the parameter in the EC_GROUP define a valid ec group 312*4724848cSchristos * \param group EC_GROUP object 313*4724848cSchristos * \param ctx BN_CTX object (optional) 314*4724848cSchristos * \return 1 if group is a valid ec group and 0 otherwise 315*4724848cSchristos */ 316*4724848cSchristos int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx); 317*4724848cSchristos 318*4724848cSchristos /** Checks whether the discriminant of the elliptic curve is zero or not 319*4724848cSchristos * \param group EC_GROUP object 320*4724848cSchristos * \param ctx BN_CTX object (optional) 321*4724848cSchristos * \return 1 if the discriminant is not zero and 0 otherwise 322*4724848cSchristos */ 323*4724848cSchristos int EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx); 324*4724848cSchristos 325*4724848cSchristos /** Compares two EC_GROUP objects 326*4724848cSchristos * \param a first EC_GROUP object 327*4724848cSchristos * \param b second EC_GROUP object 328*4724848cSchristos * \param ctx BN_CTX object (optional) 329*4724848cSchristos * \return 0 if the groups are equal, 1 if not, or -1 on error 330*4724848cSchristos */ 331*4724848cSchristos int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx); 332*4724848cSchristos 333*4724848cSchristos /* 334*4724848cSchristos * EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*() after 335*4724848cSchristos * choosing an appropriate EC_METHOD 336*4724848cSchristos */ 337*4724848cSchristos 338*4724848cSchristos /** Creates a new EC_GROUP object with the specified parameters defined 339*4724848cSchristos * over GFp (defined by the equation y^2 = x^3 + a*x + b) 340*4724848cSchristos * \param p BIGNUM with the prime number 341*4724848cSchristos * \param a BIGNUM with the parameter a of the equation 342*4724848cSchristos * \param b BIGNUM with the parameter b of the equation 343*4724848cSchristos * \param ctx BN_CTX object (optional) 344*4724848cSchristos * \return newly created EC_GROUP object with the specified parameters 345*4724848cSchristos */ 346*4724848cSchristos EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, 347*4724848cSchristos const BIGNUM *b, BN_CTX *ctx); 348*4724848cSchristos # ifndef OPENSSL_NO_EC2M 349*4724848cSchristos /** Creates a new EC_GROUP object with the specified parameters defined 350*4724848cSchristos * over GF2m (defined by the equation y^2 + x*y = x^3 + a*x^2 + b) 351*4724848cSchristos * \param p BIGNUM with the polynomial defining the underlying field 352*4724848cSchristos * \param a BIGNUM with the parameter a of the equation 353*4724848cSchristos * \param b BIGNUM with the parameter b of the equation 354*4724848cSchristos * \param ctx BN_CTX object (optional) 355*4724848cSchristos * \return newly created EC_GROUP object with the specified parameters 356*4724848cSchristos */ 357*4724848cSchristos EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, 358*4724848cSchristos const BIGNUM *b, BN_CTX *ctx); 359*4724848cSchristos # endif 360*4724848cSchristos 361*4724848cSchristos /** Creates a EC_GROUP object with a curve specified by a NID 362*4724848cSchristos * \param nid NID of the OID of the curve name 363*4724848cSchristos * \return newly created EC_GROUP object with specified curve or NULL 364*4724848cSchristos * if an error occurred 365*4724848cSchristos */ 366*4724848cSchristos EC_GROUP *EC_GROUP_new_by_curve_name(int nid); 367*4724848cSchristos 368*4724848cSchristos /** Creates a new EC_GROUP object from an ECPARAMETERS object 369*4724848cSchristos * \param params pointer to the ECPARAMETERS object 370*4724848cSchristos * \return newly created EC_GROUP object with specified curve or NULL 371*4724848cSchristos * if an error occurred 372*4724848cSchristos */ 373*4724848cSchristos EC_GROUP *EC_GROUP_new_from_ecparameters(const ECPARAMETERS *params); 374*4724848cSchristos 375*4724848cSchristos /** Creates an ECPARAMETERS object for the given EC_GROUP object. 376*4724848cSchristos * \param group pointer to the EC_GROUP object 377*4724848cSchristos * \param params pointer to an existing ECPARAMETERS object or NULL 378*4724848cSchristos * \return pointer to the new ECPARAMETERS object or NULL 379*4724848cSchristos * if an error occurred. 380*4724848cSchristos */ 381*4724848cSchristos ECPARAMETERS *EC_GROUP_get_ecparameters(const EC_GROUP *group, 382*4724848cSchristos ECPARAMETERS *params); 383*4724848cSchristos 384*4724848cSchristos /** Creates a new EC_GROUP object from an ECPKPARAMETERS object 385*4724848cSchristos * \param params pointer to an existing ECPKPARAMETERS object, or NULL 386*4724848cSchristos * \return newly created EC_GROUP object with specified curve, or NULL 387*4724848cSchristos * if an error occurred 388*4724848cSchristos */ 389*4724848cSchristos EC_GROUP *EC_GROUP_new_from_ecpkparameters(const ECPKPARAMETERS *params); 390*4724848cSchristos 391*4724848cSchristos /** Creates an ECPKPARAMETERS object for the given EC_GROUP object. 392*4724848cSchristos * \param group pointer to the EC_GROUP object 393*4724848cSchristos * \param params pointer to an existing ECPKPARAMETERS object or NULL 394*4724848cSchristos * \return pointer to the new ECPKPARAMETERS object or NULL 395*4724848cSchristos * if an error occurred. 396*4724848cSchristos */ 397*4724848cSchristos ECPKPARAMETERS *EC_GROUP_get_ecpkparameters(const EC_GROUP *group, 398*4724848cSchristos ECPKPARAMETERS *params); 399*4724848cSchristos 400*4724848cSchristos /********************************************************************/ 401*4724848cSchristos /* handling of internal curves */ 402*4724848cSchristos /********************************************************************/ 403*4724848cSchristos 404*4724848cSchristos typedef struct { 405*4724848cSchristos int nid; 406*4724848cSchristos const char *comment; 407*4724848cSchristos } EC_builtin_curve; 408*4724848cSchristos 409*4724848cSchristos /* 410*4724848cSchristos * EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number of all 411*4724848cSchristos * available curves or zero if a error occurred. In case r is not zero, 412*4724848cSchristos * nitems EC_builtin_curve structures are filled with the data of the first 413*4724848cSchristos * nitems internal groups 414*4724848cSchristos */ 415*4724848cSchristos size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems); 416*4724848cSchristos 417*4724848cSchristos const char *EC_curve_nid2nist(int nid); 418*4724848cSchristos int EC_curve_nist2nid(const char *name); 419*4724848cSchristos 420*4724848cSchristos /********************************************************************/ 421*4724848cSchristos /* EC_POINT functions */ 422*4724848cSchristos /********************************************************************/ 423*4724848cSchristos 424*4724848cSchristos /** Creates a new EC_POINT object for the specified EC_GROUP 425*4724848cSchristos * \param group EC_GROUP the underlying EC_GROUP object 426*4724848cSchristos * \return newly created EC_POINT object or NULL if an error occurred 427*4724848cSchristos */ 428*4724848cSchristos EC_POINT *EC_POINT_new(const EC_GROUP *group); 429*4724848cSchristos 430*4724848cSchristos /** Frees a EC_POINT object 431*4724848cSchristos * \param point EC_POINT object to be freed 432*4724848cSchristos */ 433*4724848cSchristos void EC_POINT_free(EC_POINT *point); 434*4724848cSchristos 435*4724848cSchristos /** Clears and frees a EC_POINT object 436*4724848cSchristos * \param point EC_POINT object to be cleared and freed 437*4724848cSchristos */ 438*4724848cSchristos void EC_POINT_clear_free(EC_POINT *point); 439*4724848cSchristos 440*4724848cSchristos /** Copies EC_POINT object 441*4724848cSchristos * \param dst destination EC_POINT object 442*4724848cSchristos * \param src source EC_POINT object 443*4724848cSchristos * \return 1 on success and 0 if an error occurred 444*4724848cSchristos */ 445*4724848cSchristos int EC_POINT_copy(EC_POINT *dst, const EC_POINT *src); 446*4724848cSchristos 447*4724848cSchristos /** Creates a new EC_POINT object and copies the content of the supplied 448*4724848cSchristos * EC_POINT 449*4724848cSchristos * \param src source EC_POINT object 450*4724848cSchristos * \param group underlying the EC_GROUP object 451*4724848cSchristos * \return newly created EC_POINT object or NULL if an error occurred 452*4724848cSchristos */ 453*4724848cSchristos EC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group); 454*4724848cSchristos 455*4724848cSchristos /** Returns the EC_METHOD used in EC_POINT object 456*4724848cSchristos * \param point EC_POINT object 457*4724848cSchristos * \return the EC_METHOD used 458*4724848cSchristos */ 459*4724848cSchristos const EC_METHOD *EC_POINT_method_of(const EC_POINT *point); 460*4724848cSchristos 461*4724848cSchristos /** Sets a point to infinity (neutral element) 462*4724848cSchristos * \param group underlying EC_GROUP object 463*4724848cSchristos * \param point EC_POINT to set to infinity 464*4724848cSchristos * \return 1 on success and 0 if an error occurred 465*4724848cSchristos */ 466*4724848cSchristos int EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point); 467*4724848cSchristos 468*4724848cSchristos /** Sets the jacobian projective coordinates of a EC_POINT over GFp 469*4724848cSchristos * \param group underlying EC_GROUP object 470*4724848cSchristos * \param p EC_POINT object 471*4724848cSchristos * \param x BIGNUM with the x-coordinate 472*4724848cSchristos * \param y BIGNUM with the y-coordinate 473*4724848cSchristos * \param z BIGNUM with the z-coordinate 474*4724848cSchristos * \param ctx BN_CTX object (optional) 475*4724848cSchristos * \return 1 on success and 0 if an error occurred 476*4724848cSchristos */ 477*4724848cSchristos int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, 478*4724848cSchristos EC_POINT *p, const BIGNUM *x, 479*4724848cSchristos const BIGNUM *y, const BIGNUM *z, 480*4724848cSchristos BN_CTX *ctx); 481*4724848cSchristos 482*4724848cSchristos /** Gets the jacobian projective coordinates of a EC_POINT over GFp 483*4724848cSchristos * \param group underlying EC_GROUP object 484*4724848cSchristos * \param p EC_POINT object 485*4724848cSchristos * \param x BIGNUM for the x-coordinate 486*4724848cSchristos * \param y BIGNUM for the y-coordinate 487*4724848cSchristos * \param z BIGNUM for the z-coordinate 488*4724848cSchristos * \param ctx BN_CTX object (optional) 489*4724848cSchristos * \return 1 on success and 0 if an error occurred 490*4724848cSchristos */ 491*4724848cSchristos int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group, 492*4724848cSchristos const EC_POINT *p, BIGNUM *x, 493*4724848cSchristos BIGNUM *y, BIGNUM *z, 494*4724848cSchristos BN_CTX *ctx); 495*4724848cSchristos 496*4724848cSchristos /** Sets the affine coordinates of an EC_POINT 497*4724848cSchristos * \param group underlying EC_GROUP object 498*4724848cSchristos * \param p EC_POINT object 499*4724848cSchristos * \param x BIGNUM with the x-coordinate 500*4724848cSchristos * \param y BIGNUM with the y-coordinate 501*4724848cSchristos * \param ctx BN_CTX object (optional) 502*4724848cSchristos * \return 1 on success and 0 if an error occurred 503*4724848cSchristos */ 504*4724848cSchristos int EC_POINT_set_affine_coordinates(const EC_GROUP *group, EC_POINT *p, 505*4724848cSchristos const BIGNUM *x, const BIGNUM *y, 506*4724848cSchristos BN_CTX *ctx); 507*4724848cSchristos 508*4724848cSchristos /** Gets the affine coordinates of an EC_POINT. 509*4724848cSchristos * \param group underlying EC_GROUP object 510*4724848cSchristos * \param p EC_POINT object 511*4724848cSchristos * \param x BIGNUM for the x-coordinate 512*4724848cSchristos * \param y BIGNUM for the y-coordinate 513*4724848cSchristos * \param ctx BN_CTX object (optional) 514*4724848cSchristos * \return 1 on success and 0 if an error occurred 515*4724848cSchristos */ 516*4724848cSchristos int EC_POINT_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *p, 517*4724848cSchristos BIGNUM *x, BIGNUM *y, BN_CTX *ctx); 518*4724848cSchristos 519*4724848cSchristos /** Sets the affine coordinates of an EC_POINT. A synonym of 520*4724848cSchristos * EC_POINT_set_affine_coordinates 521*4724848cSchristos * \param group underlying EC_GROUP object 522*4724848cSchristos * \param p EC_POINT object 523*4724848cSchristos * \param x BIGNUM with the x-coordinate 524*4724848cSchristos * \param y BIGNUM with the y-coordinate 525*4724848cSchristos * \param ctx BN_CTX object (optional) 526*4724848cSchristos * \return 1 on success and 0 if an error occurred 527*4724848cSchristos */ 528*4724848cSchristos DEPRECATEDIN_1_2_0(int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, 529*4724848cSchristos EC_POINT *p, 530*4724848cSchristos const BIGNUM *x, 531*4724848cSchristos const BIGNUM *y, 532*4724848cSchristos BN_CTX *ctx)) 533*4724848cSchristos 534*4724848cSchristos /** Gets the affine coordinates of an EC_POINT. A synonym of 535*4724848cSchristos * EC_POINT_get_affine_coordinates 536*4724848cSchristos * \param group underlying EC_GROUP object 537*4724848cSchristos * \param p EC_POINT object 538*4724848cSchristos * \param x BIGNUM for the x-coordinate 539*4724848cSchristos * \param y BIGNUM for the y-coordinate 540*4724848cSchristos * \param ctx BN_CTX object (optional) 541*4724848cSchristos * \return 1 on success and 0 if an error occurred 542*4724848cSchristos */ 543*4724848cSchristos DEPRECATEDIN_1_2_0(int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group, 544*4724848cSchristos const EC_POINT *p, 545*4724848cSchristos BIGNUM *x, 546*4724848cSchristos BIGNUM *y, 547*4724848cSchristos BN_CTX *ctx)) 548*4724848cSchristos 549*4724848cSchristos /** Sets the x9.62 compressed coordinates of a EC_POINT 550*4724848cSchristos * \param group underlying EC_GROUP object 551*4724848cSchristos * \param p EC_POINT object 552*4724848cSchristos * \param x BIGNUM with x-coordinate 553*4724848cSchristos * \param y_bit integer with the y-Bit (either 0 or 1) 554*4724848cSchristos * \param ctx BN_CTX object (optional) 555*4724848cSchristos * \return 1 on success and 0 if an error occurred 556*4724848cSchristos */ 557*4724848cSchristos int EC_POINT_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *p, 558*4724848cSchristos const BIGNUM *x, int y_bit, 559*4724848cSchristos BN_CTX *ctx); 560*4724848cSchristos 561*4724848cSchristos /** Sets the x9.62 compressed coordinates of a EC_POINT. A synonym of 562*4724848cSchristos * EC_POINT_set_compressed_coordinates 563*4724848cSchristos * \param group underlying EC_GROUP object 564*4724848cSchristos * \param p EC_POINT object 565*4724848cSchristos * \param x BIGNUM with x-coordinate 566*4724848cSchristos * \param y_bit integer with the y-Bit (either 0 or 1) 567*4724848cSchristos * \param ctx BN_CTX object (optional) 568*4724848cSchristos * \return 1 on success and 0 if an error occurred 569*4724848cSchristos */ 570*4724848cSchristos DEPRECATEDIN_1_2_0(int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, 571*4724848cSchristos EC_POINT *p, 572*4724848cSchristos const BIGNUM *x, 573*4724848cSchristos int y_bit, 574*4724848cSchristos BN_CTX *ctx)) 575*4724848cSchristos # ifndef OPENSSL_NO_EC2M 576*4724848cSchristos /** Sets the affine coordinates of an EC_POINT. A synonym of 577*4724848cSchristos * EC_POINT_set_affine_coordinates 578*4724848cSchristos * \param group underlying EC_GROUP object 579*4724848cSchristos * \param p EC_POINT object 580*4724848cSchristos * \param x BIGNUM with the x-coordinate 581*4724848cSchristos * \param y BIGNUM with the y-coordinate 582*4724848cSchristos * \param ctx BN_CTX object (optional) 583*4724848cSchristos * \return 1 on success and 0 if an error occurred 584*4724848cSchristos */ 585*4724848cSchristos DEPRECATEDIN_1_2_0(int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, 586*4724848cSchristos EC_POINT *p, 587*4724848cSchristos const BIGNUM *x, 588*4724848cSchristos const BIGNUM *y, 589*4724848cSchristos BN_CTX *ctx)) 590*4724848cSchristos 591*4724848cSchristos /** Gets the affine coordinates of an EC_POINT. A synonym of 592*4724848cSchristos * EC_POINT_get_affine_coordinates 593*4724848cSchristos * \param group underlying EC_GROUP object 594*4724848cSchristos * \param p EC_POINT object 595*4724848cSchristos * \param x BIGNUM for the x-coordinate 596*4724848cSchristos * \param y BIGNUM for the y-coordinate 597*4724848cSchristos * \param ctx BN_CTX object (optional) 598*4724848cSchristos * \return 1 on success and 0 if an error occurred 599*4724848cSchristos */ 600*4724848cSchristos DEPRECATEDIN_1_2_0(int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group, 601*4724848cSchristos const EC_POINT *p, 602*4724848cSchristos BIGNUM *x, 603*4724848cSchristos BIGNUM *y, 604*4724848cSchristos BN_CTX *ctx)) 605*4724848cSchristos 606*4724848cSchristos /** Sets the x9.62 compressed coordinates of a EC_POINT. A synonym of 607*4724848cSchristos * EC_POINT_set_compressed_coordinates 608*4724848cSchristos * \param group underlying EC_GROUP object 609*4724848cSchristos * \param p EC_POINT object 610*4724848cSchristos * \param x BIGNUM with x-coordinate 611*4724848cSchristos * \param y_bit integer with the y-Bit (either 0 or 1) 612*4724848cSchristos * \param ctx BN_CTX object (optional) 613*4724848cSchristos * \return 1 on success and 0 if an error occurred 614*4724848cSchristos */ 615*4724848cSchristos DEPRECATEDIN_1_2_0(int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, 616*4724848cSchristos EC_POINT *p, 617*4724848cSchristos const BIGNUM *x, 618*4724848cSchristos int y_bit, 619*4724848cSchristos BN_CTX *ctx)) 620*4724848cSchristos # endif 621*4724848cSchristos /** Encodes a EC_POINT object to a octet string 622*4724848cSchristos * \param group underlying EC_GROUP object 623*4724848cSchristos * \param p EC_POINT object 624*4724848cSchristos * \param form point conversion form 625*4724848cSchristos * \param buf memory buffer for the result. If NULL the function returns 626*4724848cSchristos * required buffer size. 627*4724848cSchristos * \param len length of the memory buffer 628*4724848cSchristos * \param ctx BN_CTX object (optional) 629*4724848cSchristos * \return the length of the encoded octet string or 0 if an error occurred 630*4724848cSchristos */ 631*4724848cSchristos size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p, 632*4724848cSchristos point_conversion_form_t form, 633*4724848cSchristos unsigned char *buf, size_t len, BN_CTX *ctx); 634*4724848cSchristos 635*4724848cSchristos /** Decodes a EC_POINT from a octet string 636*4724848cSchristos * \param group underlying EC_GROUP object 637*4724848cSchristos * \param p EC_POINT object 638*4724848cSchristos * \param buf memory buffer with the encoded ec point 639*4724848cSchristos * \param len length of the encoded ec point 640*4724848cSchristos * \param ctx BN_CTX object (optional) 641*4724848cSchristos * \return 1 on success and 0 if an error occurred 642*4724848cSchristos */ 643*4724848cSchristos int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p, 644*4724848cSchristos const unsigned char *buf, size_t len, BN_CTX *ctx); 645*4724848cSchristos 646*4724848cSchristos /** Encodes an EC_POINT object to an allocated octet string 647*4724848cSchristos * \param group underlying EC_GROUP object 648*4724848cSchristos * \param point EC_POINT object 649*4724848cSchristos * \param form point conversion form 650*4724848cSchristos * \param pbuf returns pointer to allocated buffer 651*4724848cSchristos * \param ctx BN_CTX object (optional) 652*4724848cSchristos * \return the length of the encoded octet string or 0 if an error occurred 653*4724848cSchristos */ 654*4724848cSchristos size_t EC_POINT_point2buf(const EC_GROUP *group, const EC_POINT *point, 655*4724848cSchristos point_conversion_form_t form, 656*4724848cSchristos unsigned char **pbuf, BN_CTX *ctx); 657*4724848cSchristos 658*4724848cSchristos /* other interfaces to point2oct/oct2point: */ 659*4724848cSchristos BIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *, 660*4724848cSchristos point_conversion_form_t form, BIGNUM *, BN_CTX *); 661*4724848cSchristos EC_POINT *EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *, 662*4724848cSchristos EC_POINT *, BN_CTX *); 663*4724848cSchristos char *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *, 664*4724848cSchristos point_conversion_form_t form, BN_CTX *); 665*4724848cSchristos EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *, 666*4724848cSchristos EC_POINT *, BN_CTX *); 667*4724848cSchristos 668*4724848cSchristos /********************************************************************/ 669*4724848cSchristos /* functions for doing EC_POINT arithmetic */ 670*4724848cSchristos /********************************************************************/ 671*4724848cSchristos 672*4724848cSchristos /** Computes the sum of two EC_POINT 673*4724848cSchristos * \param group underlying EC_GROUP object 674*4724848cSchristos * \param r EC_POINT object for the result (r = a + b) 675*4724848cSchristos * \param a EC_POINT object with the first summand 676*4724848cSchristos * \param b EC_POINT object with the second summand 677*4724848cSchristos * \param ctx BN_CTX object (optional) 678*4724848cSchristos * \return 1 on success and 0 if an error occurred 679*4724848cSchristos */ 680*4724848cSchristos int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, 681*4724848cSchristos const EC_POINT *b, BN_CTX *ctx); 682*4724848cSchristos 683*4724848cSchristos /** Computes the double of a EC_POINT 684*4724848cSchristos * \param group underlying EC_GROUP object 685*4724848cSchristos * \param r EC_POINT object for the result (r = 2 * a) 686*4724848cSchristos * \param a EC_POINT object 687*4724848cSchristos * \param ctx BN_CTX object (optional) 688*4724848cSchristos * \return 1 on success and 0 if an error occurred 689*4724848cSchristos */ 690*4724848cSchristos int EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, 691*4724848cSchristos BN_CTX *ctx); 692*4724848cSchristos 693*4724848cSchristos /** Computes the inverse of a EC_POINT 694*4724848cSchristos * \param group underlying EC_GROUP object 695*4724848cSchristos * \param a EC_POINT object to be inverted (it's used for the result as well) 696*4724848cSchristos * \param ctx BN_CTX object (optional) 697*4724848cSchristos * \return 1 on success and 0 if an error occurred 698*4724848cSchristos */ 699*4724848cSchristos int EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx); 700*4724848cSchristos 701*4724848cSchristos /** Checks whether the point is the neutral element of the group 702*4724848cSchristos * \param group the underlying EC_GROUP object 703*4724848cSchristos * \param p EC_POINT object 704*4724848cSchristos * \return 1 if the point is the neutral element and 0 otherwise 705*4724848cSchristos */ 706*4724848cSchristos int EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *p); 707*4724848cSchristos 708*4724848cSchristos /** Checks whether the point is on the curve 709*4724848cSchristos * \param group underlying EC_GROUP object 710*4724848cSchristos * \param point EC_POINT object to check 711*4724848cSchristos * \param ctx BN_CTX object (optional) 712*4724848cSchristos * \return 1 if the point is on the curve, 0 if not, or -1 on error 713*4724848cSchristos */ 714*4724848cSchristos int EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, 715*4724848cSchristos BN_CTX *ctx); 716*4724848cSchristos 717*4724848cSchristos /** Compares two EC_POINTs 718*4724848cSchristos * \param group underlying EC_GROUP object 719*4724848cSchristos * \param a first EC_POINT object 720*4724848cSchristos * \param b second EC_POINT object 721*4724848cSchristos * \param ctx BN_CTX object (optional) 722*4724848cSchristos * \return 1 if the points are not equal, 0 if they are, or -1 on error 723*4724848cSchristos */ 724*4724848cSchristos int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, 725*4724848cSchristos BN_CTX *ctx); 726*4724848cSchristos 727*4724848cSchristos int EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx); 728*4724848cSchristos int EC_POINTs_make_affine(const EC_GROUP *group, size_t num, 729*4724848cSchristos EC_POINT *points[], BN_CTX *ctx); 730*4724848cSchristos 731*4724848cSchristos /** Computes r = generator * n + sum_{i=0}^{num-1} p[i] * m[i] 732*4724848cSchristos * \param group underlying EC_GROUP object 733*4724848cSchristos * \param r EC_POINT object for the result 734*4724848cSchristos * \param n BIGNUM with the multiplier for the group generator (optional) 735*4724848cSchristos * \param num number further summands 736*4724848cSchristos * \param p array of size num of EC_POINT objects 737*4724848cSchristos * \param m array of size num of BIGNUM objects 738*4724848cSchristos * \param ctx BN_CTX object (optional) 739*4724848cSchristos * \return 1 on success and 0 if an error occurred 740*4724848cSchristos */ 741*4724848cSchristos int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, 742*4724848cSchristos size_t num, const EC_POINT *p[], const BIGNUM *m[], 743*4724848cSchristos BN_CTX *ctx); 744*4724848cSchristos 745*4724848cSchristos /** Computes r = generator * n + q * m 746*4724848cSchristos * \param group underlying EC_GROUP object 747*4724848cSchristos * \param r EC_POINT object for the result 748*4724848cSchristos * \param n BIGNUM with the multiplier for the group generator (optional) 749*4724848cSchristos * \param q EC_POINT object with the first factor of the second summand 750*4724848cSchristos * \param m BIGNUM with the second factor of the second summand 751*4724848cSchristos * \param ctx BN_CTX object (optional) 752*4724848cSchristos * \return 1 on success and 0 if an error occurred 753*4724848cSchristos */ 754*4724848cSchristos int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, 755*4724848cSchristos const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx); 756*4724848cSchristos 757*4724848cSchristos /** Stores multiples of generator for faster point multiplication 758*4724848cSchristos * \param group EC_GROUP object 759*4724848cSchristos * \param ctx BN_CTX object (optional) 760*4724848cSchristos * \return 1 on success and 0 if an error occurred 761*4724848cSchristos */ 762*4724848cSchristos int EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx); 763*4724848cSchristos 764*4724848cSchristos /** Reports whether a precomputation has been done 765*4724848cSchristos * \param group EC_GROUP object 766*4724848cSchristos * \return 1 if a pre-computation has been done and 0 otherwise 767*4724848cSchristos */ 768*4724848cSchristos int EC_GROUP_have_precompute_mult(const EC_GROUP *group); 769*4724848cSchristos 770*4724848cSchristos /********************************************************************/ 771*4724848cSchristos /* ASN1 stuff */ 772*4724848cSchristos /********************************************************************/ 773*4724848cSchristos 774*4724848cSchristos DECLARE_ASN1_ITEM(ECPKPARAMETERS) 775*4724848cSchristos DECLARE_ASN1_ALLOC_FUNCTIONS(ECPKPARAMETERS) 776*4724848cSchristos DECLARE_ASN1_ITEM(ECPARAMETERS) 777*4724848cSchristos DECLARE_ASN1_ALLOC_FUNCTIONS(ECPARAMETERS) 778*4724848cSchristos 779*4724848cSchristos /* 780*4724848cSchristos * EC_GROUP_get_basis_type() returns the NID of the basis type used to 781*4724848cSchristos * represent the field elements 782*4724848cSchristos */ 783*4724848cSchristos int EC_GROUP_get_basis_type(const EC_GROUP *); 784*4724848cSchristos # ifndef OPENSSL_NO_EC2M 785*4724848cSchristos int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k); 786*4724848cSchristos int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1, 787*4724848cSchristos unsigned int *k2, unsigned int *k3); 788*4724848cSchristos # endif 789*4724848cSchristos 790*4724848cSchristos # define OPENSSL_EC_EXPLICIT_CURVE 0x000 791*4724848cSchristos # define OPENSSL_EC_NAMED_CURVE 0x001 792*4724848cSchristos 793*4724848cSchristos EC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len); 794*4724848cSchristos int i2d_ECPKParameters(const EC_GROUP *, unsigned char **out); 795*4724848cSchristos 796*4724848cSchristos # define d2i_ECPKParameters_bio(bp,x) \ 797*4724848cSchristos ASN1_d2i_bio_of(EC_GROUP, NULL, d2i_ECPKParameters, bp, x) 798*4724848cSchristos # define i2d_ECPKParameters_bio(bp,x) \ 799*4724848cSchristos ASN1_i2d_bio_of_const(EC_GROUP, i2d_ECPKParameters, bp, x) 800*4724848cSchristos # define d2i_ECPKParameters_fp(fp,x) \ 801*4724848cSchristos (EC_GROUP *)ASN1_d2i_fp(NULL, (d2i_of_void *)d2i_ECPKParameters, (fp), \ 802*4724848cSchristos (void **)(x)) 803*4724848cSchristos # define i2d_ECPKParameters_fp(fp,x) \ 804*4724848cSchristos ASN1_i2d_fp((i2d_of_void *)i2d_ECPKParameters, (fp), (void *)(x)) 805*4724848cSchristos 806*4724848cSchristos int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off); 807*4724848cSchristos # ifndef OPENSSL_NO_STDIO 808*4724848cSchristos int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off); 809*4724848cSchristos # endif 810*4724848cSchristos 811*4724848cSchristos /********************************************************************/ 812*4724848cSchristos /* EC_KEY functions */ 813*4724848cSchristos /********************************************************************/ 814*4724848cSchristos 815*4724848cSchristos /* some values for the encoding_flag */ 816*4724848cSchristos # define EC_PKEY_NO_PARAMETERS 0x001 817*4724848cSchristos # define EC_PKEY_NO_PUBKEY 0x002 818*4724848cSchristos 819*4724848cSchristos /* some values for the flags field */ 820*4724848cSchristos # define EC_FLAG_NON_FIPS_ALLOW 0x1 821*4724848cSchristos # define EC_FLAG_FIPS_CHECKED 0x2 822*4724848cSchristos # define EC_FLAG_COFACTOR_ECDH 0x1000 823*4724848cSchristos 824*4724848cSchristos /** Creates a new EC_KEY object. 825*4724848cSchristos * \return EC_KEY object or NULL if an error occurred. 826*4724848cSchristos */ 827*4724848cSchristos EC_KEY *EC_KEY_new(void); 828*4724848cSchristos 829*4724848cSchristos int EC_KEY_get_flags(const EC_KEY *key); 830*4724848cSchristos 831*4724848cSchristos void EC_KEY_set_flags(EC_KEY *key, int flags); 832*4724848cSchristos 833*4724848cSchristos void EC_KEY_clear_flags(EC_KEY *key, int flags); 834*4724848cSchristos 835*4724848cSchristos int EC_KEY_decoded_from_explicit_params(const EC_KEY *key); 836*4724848cSchristos 837*4724848cSchristos /** Creates a new EC_KEY object using a named curve as underlying 838*4724848cSchristos * EC_GROUP object. 839*4724848cSchristos * \param nid NID of the named curve. 840*4724848cSchristos * \return EC_KEY object or NULL if an error occurred. 841*4724848cSchristos */ 842*4724848cSchristos EC_KEY *EC_KEY_new_by_curve_name(int nid); 843*4724848cSchristos 844*4724848cSchristos /** Frees a EC_KEY object. 845*4724848cSchristos * \param key EC_KEY object to be freed. 846*4724848cSchristos */ 847*4724848cSchristos void EC_KEY_free(EC_KEY *key); 848*4724848cSchristos 849*4724848cSchristos /** Copies a EC_KEY object. 850*4724848cSchristos * \param dst destination EC_KEY object 851*4724848cSchristos * \param src src EC_KEY object 852*4724848cSchristos * \return dst or NULL if an error occurred. 853*4724848cSchristos */ 854*4724848cSchristos EC_KEY *EC_KEY_copy(EC_KEY *dst, const EC_KEY *src); 855*4724848cSchristos 856*4724848cSchristos /** Creates a new EC_KEY object and copies the content from src to it. 857*4724848cSchristos * \param src the source EC_KEY object 858*4724848cSchristos * \return newly created EC_KEY object or NULL if an error occurred. 859*4724848cSchristos */ 860*4724848cSchristos EC_KEY *EC_KEY_dup(const EC_KEY *src); 861*4724848cSchristos 862*4724848cSchristos /** Increases the internal reference count of a EC_KEY object. 863*4724848cSchristos * \param key EC_KEY object 864*4724848cSchristos * \return 1 on success and 0 if an error occurred. 865*4724848cSchristos */ 866*4724848cSchristos int EC_KEY_up_ref(EC_KEY *key); 867*4724848cSchristos 868*4724848cSchristos /** Returns the ENGINE object of a EC_KEY object 869*4724848cSchristos * \param eckey EC_KEY object 870*4724848cSchristos * \return the ENGINE object (possibly NULL). 871*4724848cSchristos */ 872*4724848cSchristos ENGINE *EC_KEY_get0_engine(const EC_KEY *eckey); 873*4724848cSchristos 874*4724848cSchristos /** Returns the EC_GROUP object of a EC_KEY object 875*4724848cSchristos * \param key EC_KEY object 876*4724848cSchristos * \return the EC_GROUP object (possibly NULL). 877*4724848cSchristos */ 878*4724848cSchristos const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key); 879*4724848cSchristos 880*4724848cSchristos /** Sets the EC_GROUP of a EC_KEY object. 881*4724848cSchristos * \param key EC_KEY object 882*4724848cSchristos * \param group EC_GROUP to use in the EC_KEY object (note: the EC_KEY 883*4724848cSchristos * object will use an own copy of the EC_GROUP). 884*4724848cSchristos * \return 1 on success and 0 if an error occurred. 885*4724848cSchristos */ 886*4724848cSchristos int EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group); 887*4724848cSchristos 888*4724848cSchristos /** Returns the private key of a EC_KEY object. 889*4724848cSchristos * \param key EC_KEY object 890*4724848cSchristos * \return a BIGNUM with the private key (possibly NULL). 891*4724848cSchristos */ 892*4724848cSchristos const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key); 893*4724848cSchristos 894*4724848cSchristos /** Sets the private key of a EC_KEY object. 895*4724848cSchristos * \param key EC_KEY object 896*4724848cSchristos * \param prv BIGNUM with the private key (note: the EC_KEY object 897*4724848cSchristos * will use an own copy of the BIGNUM). 898*4724848cSchristos * \return 1 on success and 0 if an error occurred. 899*4724848cSchristos */ 900*4724848cSchristos int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv); 901*4724848cSchristos 902*4724848cSchristos /** Returns the public key of a EC_KEY object. 903*4724848cSchristos * \param key the EC_KEY object 904*4724848cSchristos * \return a EC_POINT object with the public key (possibly NULL) 905*4724848cSchristos */ 906*4724848cSchristos const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key); 907*4724848cSchristos 908*4724848cSchristos /** Sets the public key of a EC_KEY object. 909*4724848cSchristos * \param key EC_KEY object 910*4724848cSchristos * \param pub EC_POINT object with the public key (note: the EC_KEY object 911*4724848cSchristos * will use an own copy of the EC_POINT object). 912*4724848cSchristos * \return 1 on success and 0 if an error occurred. 913*4724848cSchristos */ 914*4724848cSchristos int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub); 915*4724848cSchristos 916*4724848cSchristos unsigned EC_KEY_get_enc_flags(const EC_KEY *key); 917*4724848cSchristos void EC_KEY_set_enc_flags(EC_KEY *eckey, unsigned int flags); 918*4724848cSchristos point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key); 919*4724848cSchristos void EC_KEY_set_conv_form(EC_KEY *eckey, point_conversion_form_t cform); 920*4724848cSchristos 921*4724848cSchristos #define EC_KEY_get_ex_new_index(l, p, newf, dupf, freef) \ 922*4724848cSchristos CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_EC_KEY, l, p, newf, dupf, freef) 923*4724848cSchristos int EC_KEY_set_ex_data(EC_KEY *key, int idx, void *arg); 924*4724848cSchristos void *EC_KEY_get_ex_data(const EC_KEY *key, int idx); 925*4724848cSchristos 926*4724848cSchristos /* wrapper functions for the underlying EC_GROUP object */ 927*4724848cSchristos void EC_KEY_set_asn1_flag(EC_KEY *eckey, int asn1_flag); 928*4724848cSchristos 929*4724848cSchristos /** Creates a table of pre-computed multiples of the generator to 930*4724848cSchristos * accelerate further EC_KEY operations. 931*4724848cSchristos * \param key EC_KEY object 932*4724848cSchristos * \param ctx BN_CTX object (optional) 933*4724848cSchristos * \return 1 on success and 0 if an error occurred. 934*4724848cSchristos */ 935*4724848cSchristos int EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx); 936*4724848cSchristos 937*4724848cSchristos /** Creates a new ec private (and optional a new public) key. 938*4724848cSchristos * \param key EC_KEY object 939*4724848cSchristos * \return 1 on success and 0 if an error occurred. 940*4724848cSchristos */ 941*4724848cSchristos int EC_KEY_generate_key(EC_KEY *key); 942*4724848cSchristos 943*4724848cSchristos /** Verifies that a private and/or public key is valid. 944*4724848cSchristos * \param key the EC_KEY object 945*4724848cSchristos * \return 1 on success and 0 otherwise. 946*4724848cSchristos */ 947*4724848cSchristos int EC_KEY_check_key(const EC_KEY *key); 948*4724848cSchristos 949*4724848cSchristos /** Indicates if an EC_KEY can be used for signing. 950*4724848cSchristos * \param eckey the EC_KEY object 951*4724848cSchristos * \return 1 if can can sign and 0 otherwise. 952*4724848cSchristos */ 953*4724848cSchristos int EC_KEY_can_sign(const EC_KEY *eckey); 954*4724848cSchristos 955*4724848cSchristos /** Sets a public key from affine coordinates performing 956*4724848cSchristos * necessary NIST PKV tests. 957*4724848cSchristos * \param key the EC_KEY object 958*4724848cSchristos * \param x public key x coordinate 959*4724848cSchristos * \param y public key y coordinate 960*4724848cSchristos * \return 1 on success and 0 otherwise. 961*4724848cSchristos */ 962*4724848cSchristos int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x, 963*4724848cSchristos BIGNUM *y); 964*4724848cSchristos 965*4724848cSchristos /** Encodes an EC_KEY public key to an allocated octet string 966*4724848cSchristos * \param key key to encode 967*4724848cSchristos * \param form point conversion form 968*4724848cSchristos * \param pbuf returns pointer to allocated buffer 969*4724848cSchristos * \param ctx BN_CTX object (optional) 970*4724848cSchristos * \return the length of the encoded octet string or 0 if an error occurred 971*4724848cSchristos */ 972*4724848cSchristos size_t EC_KEY_key2buf(const EC_KEY *key, point_conversion_form_t form, 973*4724848cSchristos unsigned char **pbuf, BN_CTX *ctx); 974*4724848cSchristos 975*4724848cSchristos /** Decodes a EC_KEY public key from a octet string 976*4724848cSchristos * \param key key to decode 977*4724848cSchristos * \param buf memory buffer with the encoded ec point 978*4724848cSchristos * \param len length of the encoded ec point 979*4724848cSchristos * \param ctx BN_CTX object (optional) 980*4724848cSchristos * \return 1 on success and 0 if an error occurred 981*4724848cSchristos */ 982*4724848cSchristos 983*4724848cSchristos int EC_KEY_oct2key(EC_KEY *key, const unsigned char *buf, size_t len, 984*4724848cSchristos BN_CTX *ctx); 985*4724848cSchristos 986*4724848cSchristos /** Decodes an EC_KEY private key from an octet string 987*4724848cSchristos * \param key key to decode 988*4724848cSchristos * \param buf memory buffer with the encoded private key 989*4724848cSchristos * \param len length of the encoded key 990*4724848cSchristos * \return 1 on success and 0 if an error occurred 991*4724848cSchristos */ 992*4724848cSchristos 993*4724848cSchristos int EC_KEY_oct2priv(EC_KEY *key, const unsigned char *buf, size_t len); 994*4724848cSchristos 995*4724848cSchristos /** Encodes a EC_KEY private key to an octet string 996*4724848cSchristos * \param key key to encode 997*4724848cSchristos * \param buf memory buffer for the result. If NULL the function returns 998*4724848cSchristos * required buffer size. 999*4724848cSchristos * \param len length of the memory buffer 1000*4724848cSchristos * \return the length of the encoded octet string or 0 if an error occurred 1001*4724848cSchristos */ 1002*4724848cSchristos 1003*4724848cSchristos size_t EC_KEY_priv2oct(const EC_KEY *key, unsigned char *buf, size_t len); 1004*4724848cSchristos 1005*4724848cSchristos /** Encodes an EC_KEY private key to an allocated octet string 1006*4724848cSchristos * \param eckey key to encode 1007*4724848cSchristos * \param pbuf returns pointer to allocated buffer 1008*4724848cSchristos * \return the length of the encoded octet string or 0 if an error occurred 1009*4724848cSchristos */ 1010*4724848cSchristos size_t EC_KEY_priv2buf(const EC_KEY *eckey, unsigned char **pbuf); 1011*4724848cSchristos 1012*4724848cSchristos /********************************************************************/ 1013*4724848cSchristos /* de- and encoding functions for SEC1 ECPrivateKey */ 1014*4724848cSchristos /********************************************************************/ 1015*4724848cSchristos 1016*4724848cSchristos /** Decodes a private key from a memory buffer. 1017*4724848cSchristos * \param key a pointer to a EC_KEY object which should be used (or NULL) 1018*4724848cSchristos * \param in pointer to memory with the DER encoded private key 1019*4724848cSchristos * \param len length of the DER encoded private key 1020*4724848cSchristos * \return the decoded private key or NULL if an error occurred. 1021*4724848cSchristos */ 1022*4724848cSchristos EC_KEY *d2i_ECPrivateKey(EC_KEY **key, const unsigned char **in, long len); 1023*4724848cSchristos 1024*4724848cSchristos /** Encodes a private key object and stores the result in a buffer. 1025*4724848cSchristos * \param key the EC_KEY object to encode 1026*4724848cSchristos * \param out the buffer for the result (if NULL the function returns number 1027*4724848cSchristos * of bytes needed). 1028*4724848cSchristos * \return 1 on success and 0 if an error occurred. 1029*4724848cSchristos */ 1030*4724848cSchristos int i2d_ECPrivateKey(EC_KEY *key, unsigned char **out); 1031*4724848cSchristos 1032*4724848cSchristos /********************************************************************/ 1033*4724848cSchristos /* de- and encoding functions for EC parameters */ 1034*4724848cSchristos /********************************************************************/ 1035*4724848cSchristos 1036*4724848cSchristos /** Decodes ec parameter from a memory buffer. 1037*4724848cSchristos * \param key a pointer to a EC_KEY object which should be used (or NULL) 1038*4724848cSchristos * \param in pointer to memory with the DER encoded ec parameters 1039*4724848cSchristos * \param len length of the DER encoded ec parameters 1040*4724848cSchristos * \return a EC_KEY object with the decoded parameters or NULL if an error 1041*4724848cSchristos * occurred. 1042*4724848cSchristos */ 1043*4724848cSchristos EC_KEY *d2i_ECParameters(EC_KEY **key, const unsigned char **in, long len); 1044*4724848cSchristos 1045*4724848cSchristos /** Encodes ec parameter and stores the result in a buffer. 1046*4724848cSchristos * \param key the EC_KEY object with ec parameters to encode 1047*4724848cSchristos * \param out the buffer for the result (if NULL the function returns number 1048*4724848cSchristos * of bytes needed). 1049*4724848cSchristos * \return 1 on success and 0 if an error occurred. 1050*4724848cSchristos */ 1051*4724848cSchristos int i2d_ECParameters(EC_KEY *key, unsigned char **out); 1052*4724848cSchristos 1053*4724848cSchristos /********************************************************************/ 1054*4724848cSchristos /* de- and encoding functions for EC public key */ 1055*4724848cSchristos /* (octet string, not DER -- hence 'o2i' and 'i2o') */ 1056*4724848cSchristos /********************************************************************/ 1057*4724848cSchristos 1058*4724848cSchristos /** Decodes a ec public key from a octet string. 1059*4724848cSchristos * \param key a pointer to a EC_KEY object which should be used 1060*4724848cSchristos * \param in memory buffer with the encoded public key 1061*4724848cSchristos * \param len length of the encoded public key 1062*4724848cSchristos * \return EC_KEY object with decoded public key or NULL if an error 1063*4724848cSchristos * occurred. 1064*4724848cSchristos */ 1065*4724848cSchristos EC_KEY *o2i_ECPublicKey(EC_KEY **key, const unsigned char **in, long len); 1066*4724848cSchristos 1067*4724848cSchristos /** Encodes a ec public key in an octet string. 1068*4724848cSchristos * \param key the EC_KEY object with the public key 1069*4724848cSchristos * \param out the buffer for the result (if NULL the function returns number 1070*4724848cSchristos * of bytes needed). 1071*4724848cSchristos * \return 1 on success and 0 if an error occurred 1072*4724848cSchristos */ 1073*4724848cSchristos int i2o_ECPublicKey(const EC_KEY *key, unsigned char **out); 1074*4724848cSchristos 1075*4724848cSchristos /** Prints out the ec parameters on human readable form. 1076*4724848cSchristos * \param bp BIO object to which the information is printed 1077*4724848cSchristos * \param key EC_KEY object 1078*4724848cSchristos * \return 1 on success and 0 if an error occurred 1079*4724848cSchristos */ 1080*4724848cSchristos int ECParameters_print(BIO *bp, const EC_KEY *key); 1081*4724848cSchristos 1082*4724848cSchristos /** Prints out the contents of a EC_KEY object 1083*4724848cSchristos * \param bp BIO object to which the information is printed 1084*4724848cSchristos * \param key EC_KEY object 1085*4724848cSchristos * \param off line offset 1086*4724848cSchristos * \return 1 on success and 0 if an error occurred 1087*4724848cSchristos */ 1088*4724848cSchristos int EC_KEY_print(BIO *bp, const EC_KEY *key, int off); 1089*4724848cSchristos 1090*4724848cSchristos # ifndef OPENSSL_NO_STDIO 1091*4724848cSchristos /** Prints out the ec parameters on human readable form. 1092*4724848cSchristos * \param fp file descriptor to which the information is printed 1093*4724848cSchristos * \param key EC_KEY object 1094*4724848cSchristos * \return 1 on success and 0 if an error occurred 1095*4724848cSchristos */ 1096*4724848cSchristos int ECParameters_print_fp(FILE *fp, const EC_KEY *key); 1097*4724848cSchristos 1098*4724848cSchristos /** Prints out the contents of a EC_KEY object 1099*4724848cSchristos * \param fp file descriptor to which the information is printed 1100*4724848cSchristos * \param key EC_KEY object 1101*4724848cSchristos * \param off line offset 1102*4724848cSchristos * \return 1 on success and 0 if an error occurred 1103*4724848cSchristos */ 1104*4724848cSchristos int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off); 1105*4724848cSchristos 1106*4724848cSchristos # endif 1107*4724848cSchristos 1108*4724848cSchristos const EC_KEY_METHOD *EC_KEY_OpenSSL(void); 1109*4724848cSchristos const EC_KEY_METHOD *EC_KEY_get_default_method(void); 1110*4724848cSchristos void EC_KEY_set_default_method(const EC_KEY_METHOD *meth); 1111*4724848cSchristos const EC_KEY_METHOD *EC_KEY_get_method(const EC_KEY *key); 1112*4724848cSchristos int EC_KEY_set_method(EC_KEY *key, const EC_KEY_METHOD *meth); 1113*4724848cSchristos EC_KEY *EC_KEY_new_method(ENGINE *engine); 1114*4724848cSchristos 1115*4724848cSchristos /** The old name for ecdh_KDF_X9_63 1116*4724848cSchristos * The ECDH KDF specification has been mistakingly attributed to ANSI X9.62, 1117*4724848cSchristos * it is actually specified in ANSI X9.63. 1118*4724848cSchristos * This identifier is retained for backwards compatibility 1119*4724848cSchristos */ 1120*4724848cSchristos int ECDH_KDF_X9_62(unsigned char *out, size_t outlen, 1121*4724848cSchristos const unsigned char *Z, size_t Zlen, 1122*4724848cSchristos const unsigned char *sinfo, size_t sinfolen, 1123*4724848cSchristos const EVP_MD *md); 1124*4724848cSchristos 1125*4724848cSchristos int ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, 1126*4724848cSchristos const EC_KEY *ecdh, 1127*4724848cSchristos void *(*KDF) (const void *in, size_t inlen, 1128*4724848cSchristos void *out, size_t *outlen)); 1129*4724848cSchristos 1130*4724848cSchristos typedef struct ECDSA_SIG_st ECDSA_SIG; 1131*4724848cSchristos 1132*4724848cSchristos /** Allocates and initialize a ECDSA_SIG structure 1133*4724848cSchristos * \return pointer to a ECDSA_SIG structure or NULL if an error occurred 1134*4724848cSchristos */ 1135*4724848cSchristos ECDSA_SIG *ECDSA_SIG_new(void); 1136*4724848cSchristos 1137*4724848cSchristos /** frees a ECDSA_SIG structure 1138*4724848cSchristos * \param sig pointer to the ECDSA_SIG structure 1139*4724848cSchristos */ 1140*4724848cSchristos void ECDSA_SIG_free(ECDSA_SIG *sig); 1141*4724848cSchristos 1142*4724848cSchristos /** DER encode content of ECDSA_SIG object (note: this function modifies *pp 1143*4724848cSchristos * (*pp += length of the DER encoded signature)). 1144*4724848cSchristos * \param sig pointer to the ECDSA_SIG object 1145*4724848cSchristos * \param pp pointer to a unsigned char pointer for the output or NULL 1146*4724848cSchristos * \return the length of the DER encoded ECDSA_SIG object or a negative value 1147*4724848cSchristos * on error 1148*4724848cSchristos */ 1149*4724848cSchristos int i2d_ECDSA_SIG(const ECDSA_SIG *sig, unsigned char **pp); 1150*4724848cSchristos 1151*4724848cSchristos /** Decodes a DER encoded ECDSA signature (note: this function changes *pp 1152*4724848cSchristos * (*pp += len)). 1153*4724848cSchristos * \param sig pointer to ECDSA_SIG pointer (may be NULL) 1154*4724848cSchristos * \param pp memory buffer with the DER encoded signature 1155*4724848cSchristos * \param len length of the buffer 1156*4724848cSchristos * \return pointer to the decoded ECDSA_SIG structure (or NULL) 1157*4724848cSchristos */ 1158*4724848cSchristos ECDSA_SIG *d2i_ECDSA_SIG(ECDSA_SIG **sig, const unsigned char **pp, long len); 1159*4724848cSchristos 1160*4724848cSchristos /** Accessor for r and s fields of ECDSA_SIG 1161*4724848cSchristos * \param sig pointer to ECDSA_SIG structure 1162*4724848cSchristos * \param pr pointer to BIGNUM pointer for r (may be NULL) 1163*4724848cSchristos * \param ps pointer to BIGNUM pointer for s (may be NULL) 1164*4724848cSchristos */ 1165*4724848cSchristos void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps); 1166*4724848cSchristos 1167*4724848cSchristos /** Accessor for r field of ECDSA_SIG 1168*4724848cSchristos * \param sig pointer to ECDSA_SIG structure 1169*4724848cSchristos */ 1170*4724848cSchristos const BIGNUM *ECDSA_SIG_get0_r(const ECDSA_SIG *sig); 1171*4724848cSchristos 1172*4724848cSchristos /** Accessor for s field of ECDSA_SIG 1173*4724848cSchristos * \param sig pointer to ECDSA_SIG structure 1174*4724848cSchristos */ 1175*4724848cSchristos const BIGNUM *ECDSA_SIG_get0_s(const ECDSA_SIG *sig); 1176*4724848cSchristos 1177*4724848cSchristos /** Setter for r and s fields of ECDSA_SIG 1178*4724848cSchristos * \param sig pointer to ECDSA_SIG structure 1179*4724848cSchristos * \param r pointer to BIGNUM for r (may be NULL) 1180*4724848cSchristos * \param s pointer to BIGNUM for s (may be NULL) 1181*4724848cSchristos */ 1182*4724848cSchristos int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s); 1183*4724848cSchristos 1184*4724848cSchristos /** Computes the ECDSA signature of the given hash value using 1185*4724848cSchristos * the supplied private key and returns the created signature. 1186*4724848cSchristos * \param dgst pointer to the hash value 1187*4724848cSchristos * \param dgst_len length of the hash value 1188*4724848cSchristos * \param eckey EC_KEY object containing a private EC key 1189*4724848cSchristos * \return pointer to a ECDSA_SIG structure or NULL if an error occurred 1190*4724848cSchristos */ 1191*4724848cSchristos ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst, int dgst_len, 1192*4724848cSchristos EC_KEY *eckey); 1193*4724848cSchristos 1194*4724848cSchristos /** Computes ECDSA signature of a given hash value using the supplied 1195*4724848cSchristos * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). 1196*4724848cSchristos * \param dgst pointer to the hash value to sign 1197*4724848cSchristos * \param dgstlen length of the hash value 1198*4724848cSchristos * \param kinv BIGNUM with a pre-computed inverse k (optional) 1199*4724848cSchristos * \param rp BIGNUM with a pre-computed rp value (optional), 1200*4724848cSchristos * see ECDSA_sign_setup 1201*4724848cSchristos * \param eckey EC_KEY object containing a private EC key 1202*4724848cSchristos * \return pointer to a ECDSA_SIG structure or NULL if an error occurred 1203*4724848cSchristos */ 1204*4724848cSchristos ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dgstlen, 1205*4724848cSchristos const BIGNUM *kinv, const BIGNUM *rp, 1206*4724848cSchristos EC_KEY *eckey); 1207*4724848cSchristos 1208*4724848cSchristos /** Verifies that the supplied signature is a valid ECDSA 1209*4724848cSchristos * signature of the supplied hash value using the supplied public key. 1210*4724848cSchristos * \param dgst pointer to the hash value 1211*4724848cSchristos * \param dgst_len length of the hash value 1212*4724848cSchristos * \param sig ECDSA_SIG structure 1213*4724848cSchristos * \param eckey EC_KEY object containing a public EC key 1214*4724848cSchristos * \return 1 if the signature is valid, 0 if the signature is invalid 1215*4724848cSchristos * and -1 on error 1216*4724848cSchristos */ 1217*4724848cSchristos int ECDSA_do_verify(const unsigned char *dgst, int dgst_len, 1218*4724848cSchristos const ECDSA_SIG *sig, EC_KEY *eckey); 1219*4724848cSchristos 1220*4724848cSchristos /** Precompute parts of the signing operation 1221*4724848cSchristos * \param eckey EC_KEY object containing a private EC key 1222*4724848cSchristos * \param ctx BN_CTX object (optional) 1223*4724848cSchristos * \param kinv BIGNUM pointer for the inverse of k 1224*4724848cSchristos * \param rp BIGNUM pointer for x coordinate of k * generator 1225*4724848cSchristos * \return 1 on success and 0 otherwise 1226*4724848cSchristos */ 1227*4724848cSchristos int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv, BIGNUM **rp); 1228*4724848cSchristos 1229*4724848cSchristos /** Computes ECDSA signature of a given hash value using the supplied 1230*4724848cSchristos * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). 1231*4724848cSchristos * \param type this parameter is ignored 1232*4724848cSchristos * \param dgst pointer to the hash value to sign 1233*4724848cSchristos * \param dgstlen length of the hash value 1234*4724848cSchristos * \param sig memory for the DER encoded created signature 1235*4724848cSchristos * \param siglen pointer to the length of the returned signature 1236*4724848cSchristos * \param eckey EC_KEY object containing a private EC key 1237*4724848cSchristos * \return 1 on success and 0 otherwise 1238*4724848cSchristos */ 1239*4724848cSchristos int ECDSA_sign(int type, const unsigned char *dgst, int dgstlen, 1240*4724848cSchristos unsigned char *sig, unsigned int *siglen, EC_KEY *eckey); 1241*4724848cSchristos 1242*4724848cSchristos /** Computes ECDSA signature of a given hash value using the supplied 1243*4724848cSchristos * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). 1244*4724848cSchristos * \param type this parameter is ignored 1245*4724848cSchristos * \param dgst pointer to the hash value to sign 1246*4724848cSchristos * \param dgstlen length of the hash value 1247*4724848cSchristos * \param sig buffer to hold the DER encoded signature 1248*4724848cSchristos * \param siglen pointer to the length of the returned signature 1249*4724848cSchristos * \param kinv BIGNUM with a pre-computed inverse k (optional) 1250*4724848cSchristos * \param rp BIGNUM with a pre-computed rp value (optional), 1251*4724848cSchristos * see ECDSA_sign_setup 1252*4724848cSchristos * \param eckey EC_KEY object containing a private EC key 1253*4724848cSchristos * \return 1 on success and 0 otherwise 1254*4724848cSchristos */ 1255*4724848cSchristos int ECDSA_sign_ex(int type, const unsigned char *dgst, int dgstlen, 1256*4724848cSchristos unsigned char *sig, unsigned int *siglen, 1257*4724848cSchristos const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey); 1258*4724848cSchristos 1259*4724848cSchristos /** Verifies that the given signature is valid ECDSA signature 1260*4724848cSchristos * of the supplied hash value using the specified public key. 1261*4724848cSchristos * \param type this parameter is ignored 1262*4724848cSchristos * \param dgst pointer to the hash value 1263*4724848cSchristos * \param dgstlen length of the hash value 1264*4724848cSchristos * \param sig pointer to the DER encoded signature 1265*4724848cSchristos * \param siglen length of the DER encoded signature 1266*4724848cSchristos * \param eckey EC_KEY object containing a public EC key 1267*4724848cSchristos * \return 1 if the signature is valid, 0 if the signature is invalid 1268*4724848cSchristos * and -1 on error 1269*4724848cSchristos */ 1270*4724848cSchristos int ECDSA_verify(int type, const unsigned char *dgst, int dgstlen, 1271*4724848cSchristos const unsigned char *sig, int siglen, EC_KEY *eckey); 1272*4724848cSchristos 1273*4724848cSchristos /** Returns the maximum length of the DER encoded signature 1274*4724848cSchristos * \param eckey EC_KEY object 1275*4724848cSchristos * \return numbers of bytes required for the DER encoded signature 1276*4724848cSchristos */ 1277*4724848cSchristos int ECDSA_size(const EC_KEY *eckey); 1278*4724848cSchristos 1279*4724848cSchristos /********************************************************************/ 1280*4724848cSchristos /* EC_KEY_METHOD constructors, destructors, writers and accessors */ 1281*4724848cSchristos /********************************************************************/ 1282*4724848cSchristos 1283*4724848cSchristos EC_KEY_METHOD *EC_KEY_METHOD_new(const EC_KEY_METHOD *meth); 1284*4724848cSchristos void EC_KEY_METHOD_free(EC_KEY_METHOD *meth); 1285*4724848cSchristos void EC_KEY_METHOD_set_init(EC_KEY_METHOD *meth, 1286*4724848cSchristos int (*init)(EC_KEY *key), 1287*4724848cSchristos void (*finish)(EC_KEY *key), 1288*4724848cSchristos int (*copy)(EC_KEY *dest, const EC_KEY *src), 1289*4724848cSchristos int (*set_group)(EC_KEY *key, const EC_GROUP *grp), 1290*4724848cSchristos int (*set_private)(EC_KEY *key, 1291*4724848cSchristos const BIGNUM *priv_key), 1292*4724848cSchristos int (*set_public)(EC_KEY *key, 1293*4724848cSchristos const EC_POINT *pub_key)); 1294*4724848cSchristos 1295*4724848cSchristos void EC_KEY_METHOD_set_keygen(EC_KEY_METHOD *meth, 1296*4724848cSchristos int (*keygen)(EC_KEY *key)); 1297*4724848cSchristos 1298*4724848cSchristos void EC_KEY_METHOD_set_compute_key(EC_KEY_METHOD *meth, 1299*4724848cSchristos int (*ckey)(unsigned char **psec, 1300*4724848cSchristos size_t *pseclen, 1301*4724848cSchristos const EC_POINT *pub_key, 1302*4724848cSchristos const EC_KEY *ecdh)); 1303*4724848cSchristos 1304*4724848cSchristos void EC_KEY_METHOD_set_sign(EC_KEY_METHOD *meth, 1305*4724848cSchristos int (*sign)(int type, const unsigned char *dgst, 1306*4724848cSchristos int dlen, unsigned char *sig, 1307*4724848cSchristos unsigned int *siglen, 1308*4724848cSchristos const BIGNUM *kinv, const BIGNUM *r, 1309*4724848cSchristos EC_KEY *eckey), 1310*4724848cSchristos int (*sign_setup)(EC_KEY *eckey, BN_CTX *ctx_in, 1311*4724848cSchristos BIGNUM **kinvp, BIGNUM **rp), 1312*4724848cSchristos ECDSA_SIG *(*sign_sig)(const unsigned char *dgst, 1313*4724848cSchristos int dgst_len, 1314*4724848cSchristos const BIGNUM *in_kinv, 1315*4724848cSchristos const BIGNUM *in_r, 1316*4724848cSchristos EC_KEY *eckey)); 1317*4724848cSchristos 1318*4724848cSchristos void EC_KEY_METHOD_set_verify(EC_KEY_METHOD *meth, 1319*4724848cSchristos int (*verify)(int type, const unsigned 1320*4724848cSchristos char *dgst, int dgst_len, 1321*4724848cSchristos const unsigned char *sigbuf, 1322*4724848cSchristos int sig_len, EC_KEY *eckey), 1323*4724848cSchristos int (*verify_sig)(const unsigned char *dgst, 1324*4724848cSchristos int dgst_len, 1325*4724848cSchristos const ECDSA_SIG *sig, 1326*4724848cSchristos EC_KEY *eckey)); 1327*4724848cSchristos 1328*4724848cSchristos void EC_KEY_METHOD_get_init(const EC_KEY_METHOD *meth, 1329*4724848cSchristos int (**pinit)(EC_KEY *key), 1330*4724848cSchristos void (**pfinish)(EC_KEY *key), 1331*4724848cSchristos int (**pcopy)(EC_KEY *dest, const EC_KEY *src), 1332*4724848cSchristos int (**pset_group)(EC_KEY *key, 1333*4724848cSchristos const EC_GROUP *grp), 1334*4724848cSchristos int (**pset_private)(EC_KEY *key, 1335*4724848cSchristos const BIGNUM *priv_key), 1336*4724848cSchristos int (**pset_public)(EC_KEY *key, 1337*4724848cSchristos const EC_POINT *pub_key)); 1338*4724848cSchristos 1339*4724848cSchristos void EC_KEY_METHOD_get_keygen(const EC_KEY_METHOD *meth, 1340*4724848cSchristos int (**pkeygen)(EC_KEY *key)); 1341*4724848cSchristos 1342*4724848cSchristos void EC_KEY_METHOD_get_compute_key(const EC_KEY_METHOD *meth, 1343*4724848cSchristos int (**pck)(unsigned char **psec, 1344*4724848cSchristos size_t *pseclen, 1345*4724848cSchristos const EC_POINT *pub_key, 1346*4724848cSchristos const EC_KEY *ecdh)); 1347*4724848cSchristos 1348*4724848cSchristos void EC_KEY_METHOD_get_sign(const EC_KEY_METHOD *meth, 1349*4724848cSchristos int (**psign)(int type, const unsigned char *dgst, 1350*4724848cSchristos int dlen, unsigned char *sig, 1351*4724848cSchristos unsigned int *siglen, 1352*4724848cSchristos const BIGNUM *kinv, const BIGNUM *r, 1353*4724848cSchristos EC_KEY *eckey), 1354*4724848cSchristos int (**psign_setup)(EC_KEY *eckey, BN_CTX *ctx_in, 1355*4724848cSchristos BIGNUM **kinvp, BIGNUM **rp), 1356*4724848cSchristos ECDSA_SIG *(**psign_sig)(const unsigned char *dgst, 1357*4724848cSchristos int dgst_len, 1358*4724848cSchristos const BIGNUM *in_kinv, 1359*4724848cSchristos const BIGNUM *in_r, 1360*4724848cSchristos EC_KEY *eckey)); 1361*4724848cSchristos 1362*4724848cSchristos void EC_KEY_METHOD_get_verify(const EC_KEY_METHOD *meth, 1363*4724848cSchristos int (**pverify)(int type, const unsigned 1364*4724848cSchristos char *dgst, int dgst_len, 1365*4724848cSchristos const unsigned char *sigbuf, 1366*4724848cSchristos int sig_len, EC_KEY *eckey), 1367*4724848cSchristos int (**pverify_sig)(const unsigned char *dgst, 1368*4724848cSchristos int dgst_len, 1369*4724848cSchristos const ECDSA_SIG *sig, 1370*4724848cSchristos EC_KEY *eckey)); 1371*4724848cSchristos 1372*4724848cSchristos # define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x) 1373*4724848cSchristos 1374*4724848cSchristos # ifndef __cplusplus 1375*4724848cSchristos # if defined(__SUNPRO_C) 1376*4724848cSchristos # if __SUNPRO_C >= 0x520 1377*4724848cSchristos # pragma error_messages (default,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE) 1378*4724848cSchristos # endif 1379*4724848cSchristos # endif 1380*4724848cSchristos # endif 1381*4724848cSchristos 1382*4724848cSchristos # define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid) \ 1383*4724848cSchristos EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ 1384*4724848cSchristos EVP_PKEY_OP_PARAMGEN|EVP_PKEY_OP_KEYGEN, \ 1385*4724848cSchristos EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL) 1386*4724848cSchristos 1387*4724848cSchristos # define EVP_PKEY_CTX_set_ec_param_enc(ctx, flag) \ 1388*4724848cSchristos EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ 1389*4724848cSchristos EVP_PKEY_OP_PARAMGEN|EVP_PKEY_OP_KEYGEN, \ 1390*4724848cSchristos EVP_PKEY_CTRL_EC_PARAM_ENC, flag, NULL) 1391*4724848cSchristos 1392*4724848cSchristos # define EVP_PKEY_CTX_set_ecdh_cofactor_mode(ctx, flag) \ 1393*4724848cSchristos EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ 1394*4724848cSchristos EVP_PKEY_OP_DERIVE, \ 1395*4724848cSchristos EVP_PKEY_CTRL_EC_ECDH_COFACTOR, flag, NULL) 1396*4724848cSchristos 1397*4724848cSchristos # define EVP_PKEY_CTX_get_ecdh_cofactor_mode(ctx) \ 1398*4724848cSchristos EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ 1399*4724848cSchristos EVP_PKEY_OP_DERIVE, \ 1400*4724848cSchristos EVP_PKEY_CTRL_EC_ECDH_COFACTOR, -2, NULL) 1401*4724848cSchristos 1402*4724848cSchristos # define EVP_PKEY_CTX_set_ecdh_kdf_type(ctx, kdf) \ 1403*4724848cSchristos EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ 1404*4724848cSchristos EVP_PKEY_OP_DERIVE, \ 1405*4724848cSchristos EVP_PKEY_CTRL_EC_KDF_TYPE, kdf, NULL) 1406*4724848cSchristos 1407*4724848cSchristos # define EVP_PKEY_CTX_get_ecdh_kdf_type(ctx) \ 1408*4724848cSchristos EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ 1409*4724848cSchristos EVP_PKEY_OP_DERIVE, \ 1410*4724848cSchristos EVP_PKEY_CTRL_EC_KDF_TYPE, -2, NULL) 1411*4724848cSchristos 1412*4724848cSchristos # define EVP_PKEY_CTX_set_ecdh_kdf_md(ctx, md) \ 1413*4724848cSchristos EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ 1414*4724848cSchristos EVP_PKEY_OP_DERIVE, \ 1415*4724848cSchristos EVP_PKEY_CTRL_EC_KDF_MD, 0, (void *)(md)) 1416*4724848cSchristos 1417*4724848cSchristos # define EVP_PKEY_CTX_get_ecdh_kdf_md(ctx, pmd) \ 1418*4724848cSchristos EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ 1419*4724848cSchristos EVP_PKEY_OP_DERIVE, \ 1420*4724848cSchristos EVP_PKEY_CTRL_GET_EC_KDF_MD, 0, (void *)(pmd)) 1421*4724848cSchristos 1422*4724848cSchristos # define EVP_PKEY_CTX_set_ecdh_kdf_outlen(ctx, len) \ 1423*4724848cSchristos EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ 1424*4724848cSchristos EVP_PKEY_OP_DERIVE, \ 1425*4724848cSchristos EVP_PKEY_CTRL_EC_KDF_OUTLEN, len, NULL) 1426*4724848cSchristos 1427*4724848cSchristos # define EVP_PKEY_CTX_get_ecdh_kdf_outlen(ctx, plen) \ 1428*4724848cSchristos EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ 1429*4724848cSchristos EVP_PKEY_OP_DERIVE, \ 1430*4724848cSchristos EVP_PKEY_CTRL_GET_EC_KDF_OUTLEN, 0, \ 1431*4724848cSchristos (void *)(plen)) 1432*4724848cSchristos 1433*4724848cSchristos # define EVP_PKEY_CTX_set0_ecdh_kdf_ukm(ctx, p, plen) \ 1434*4724848cSchristos EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ 1435*4724848cSchristos EVP_PKEY_OP_DERIVE, \ 1436*4724848cSchristos EVP_PKEY_CTRL_EC_KDF_UKM, plen, (void *)(p)) 1437*4724848cSchristos 1438*4724848cSchristos # define EVP_PKEY_CTX_get0_ecdh_kdf_ukm(ctx, p) \ 1439*4724848cSchristos EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ 1440*4724848cSchristos EVP_PKEY_OP_DERIVE, \ 1441*4724848cSchristos EVP_PKEY_CTRL_GET_EC_KDF_UKM, 0, (void *)(p)) 1442*4724848cSchristos 1443*4724848cSchristos /* SM2 will skip the operation check so no need to pass operation here */ 1444*4724848cSchristos # define EVP_PKEY_CTX_set1_id(ctx, id, id_len) \ 1445*4724848cSchristos EVP_PKEY_CTX_ctrl(ctx, -1, -1, \ 1446*4724848cSchristos EVP_PKEY_CTRL_SET1_ID, (int)id_len, (void*)(id)) 1447*4724848cSchristos 1448*4724848cSchristos # define EVP_PKEY_CTX_get1_id(ctx, id) \ 1449*4724848cSchristos EVP_PKEY_CTX_ctrl(ctx, -1, -1, \ 1450*4724848cSchristos EVP_PKEY_CTRL_GET1_ID, 0, (void*)(id)) 1451*4724848cSchristos 1452*4724848cSchristos # define EVP_PKEY_CTX_get1_id_len(ctx, id_len) \ 1453*4724848cSchristos EVP_PKEY_CTX_ctrl(ctx, -1, -1, \ 1454*4724848cSchristos EVP_PKEY_CTRL_GET1_ID_LEN, 0, (void*)(id_len)) 1455*4724848cSchristos 1456*4724848cSchristos # define EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID (EVP_PKEY_ALG_CTRL + 1) 1457*4724848cSchristos # define EVP_PKEY_CTRL_EC_PARAM_ENC (EVP_PKEY_ALG_CTRL + 2) 1458*4724848cSchristos # define EVP_PKEY_CTRL_EC_ECDH_COFACTOR (EVP_PKEY_ALG_CTRL + 3) 1459*4724848cSchristos # define EVP_PKEY_CTRL_EC_KDF_TYPE (EVP_PKEY_ALG_CTRL + 4) 1460*4724848cSchristos # define EVP_PKEY_CTRL_EC_KDF_MD (EVP_PKEY_ALG_CTRL + 5) 1461*4724848cSchristos # define EVP_PKEY_CTRL_GET_EC_KDF_MD (EVP_PKEY_ALG_CTRL + 6) 1462*4724848cSchristos # define EVP_PKEY_CTRL_EC_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 7) 1463*4724848cSchristos # define EVP_PKEY_CTRL_GET_EC_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 8) 1464*4724848cSchristos # define EVP_PKEY_CTRL_EC_KDF_UKM (EVP_PKEY_ALG_CTRL + 9) 1465*4724848cSchristos # define EVP_PKEY_CTRL_GET_EC_KDF_UKM (EVP_PKEY_ALG_CTRL + 10) 1466*4724848cSchristos # define EVP_PKEY_CTRL_SET1_ID (EVP_PKEY_ALG_CTRL + 11) 1467*4724848cSchristos # define EVP_PKEY_CTRL_GET1_ID (EVP_PKEY_ALG_CTRL + 12) 1468*4724848cSchristos # define EVP_PKEY_CTRL_GET1_ID_LEN (EVP_PKEY_ALG_CTRL + 13) 1469*4724848cSchristos /* KDF types */ 1470*4724848cSchristos # define EVP_PKEY_ECDH_KDF_NONE 1 1471*4724848cSchristos # define EVP_PKEY_ECDH_KDF_X9_63 2 1472*4724848cSchristos /** The old name for EVP_PKEY_ECDH_KDF_X9_63 1473*4724848cSchristos * The ECDH KDF specification has been mistakingly attributed to ANSI X9.62, 1474*4724848cSchristos * it is actually specified in ANSI X9.63. 1475*4724848cSchristos * This identifier is retained for backwards compatibility 1476*4724848cSchristos */ 1477*4724848cSchristos # define EVP_PKEY_ECDH_KDF_X9_62 EVP_PKEY_ECDH_KDF_X9_63 1478*4724848cSchristos 1479*4724848cSchristos 1480*4724848cSchristos # ifdef __cplusplus 1481*4724848cSchristos } 1482*4724848cSchristos # endif 1483*4724848cSchristos # endif 1484*4724848cSchristos #endif 1485