ec.h 69 KB

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