ec.h 69 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576
  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 ctx BN_CTX object (optional)
  504. * \return the length of the encoded octet string or 0 if an error occurred
  505. */
  506. size_t EC_POINT_point2buf(const EC_GROUP *group, const EC_POINT *point,
  507. point_conversion_form_t form,
  508. unsigned char **pbuf, BN_CTX *ctx);
  509. /* other interfaces to point2oct/oct2point: */
  510. BIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *,
  511. point_conversion_form_t form, BIGNUM *, BN_CTX *);
  512. EC_POINT *EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *,
  513. EC_POINT *, BN_CTX *);
  514. char *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *,
  515. point_conversion_form_t form, BN_CTX *);
  516. EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *,
  517. EC_POINT *, BN_CTX *);
  518. /********************************************************************/
  519. /* functions for doing EC_POINT arithmetic */
  520. /********************************************************************/
  521. /** Computes the sum of two EC_POINT
  522. * \param group underlying EC_GROUP object
  523. * \param r EC_POINT object for the result (r = a + b)
  524. * \param a EC_POINT object with the first summand
  525. * \param b EC_POINT object with the second summand
  526. * \param ctx BN_CTX object (optional)
  527. * \return 1 on success and 0 if an error occurred
  528. */
  529. int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,
  530. const EC_POINT *b, BN_CTX *ctx);
  531. /** Computes the double of a EC_POINT
  532. * \param group underlying EC_GROUP object
  533. * \param r EC_POINT object for the result (r = 2 * a)
  534. * \param a EC_POINT object
  535. * \param ctx BN_CTX object (optional)
  536. * \return 1 on success and 0 if an error occurred
  537. */
  538. int EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,
  539. BN_CTX *ctx);
  540. /** Computes the inverse of a EC_POINT
  541. * \param group underlying EC_GROUP object
  542. * \param a EC_POINT object to be inverted (it's used for the result as well)
  543. * \param ctx BN_CTX object (optional)
  544. * \return 1 on success and 0 if an error occurred
  545. */
  546. int EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx);
  547. /** Checks whether the point is the neutral element of the group
  548. * \param group the underlying EC_GROUP object
  549. * \param p EC_POINT object
  550. * \return 1 if the point is the neutral element and 0 otherwise
  551. */
  552. int EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *p);
  553. /** Checks whether the point is on the curve
  554. * \param group underlying EC_GROUP object
  555. * \param point EC_POINT object to check
  556. * \param ctx BN_CTX object (optional)
  557. * \return 1 if the point is on the curve, 0 if not, or -1 on error
  558. */
  559. int EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point,
  560. BN_CTX *ctx);
  561. /** Compares two EC_POINTs
  562. * \param group underlying EC_GROUP object
  563. * \param a first EC_POINT object
  564. * \param b second EC_POINT object
  565. * \param ctx BN_CTX object (optional)
  566. * \return 1 if the points are not equal, 0 if they are, or -1 on error
  567. */
  568. int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b,
  569. BN_CTX *ctx);
  570. int EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx);
  571. int EC_POINTs_make_affine(const EC_GROUP *group, size_t num,
  572. EC_POINT *points[], BN_CTX *ctx);
  573. /** Computes r = generator * n + sum_{i=0}^{num-1} p[i] * m[i]
  574. * \param group underlying EC_GROUP object
  575. * \param r EC_POINT object for the result
  576. * \param n BIGNUM with the multiplier for the group generator (optional)
  577. * \param num number further summands
  578. * \param p array of size num of EC_POINT objects
  579. * \param m array of size num of BIGNUM objects
  580. * \param ctx BN_CTX object (optional)
  581. * \return 1 on success and 0 if an error occurred
  582. */
  583. int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n,
  584. size_t num, const EC_POINT *p[], const BIGNUM *m[],
  585. BN_CTX *ctx);
  586. /** Computes r = generator * n + q * m
  587. * \param group underlying EC_GROUP object
  588. * \param r EC_POINT object for the result
  589. * \param n BIGNUM with the multiplier for the group generator (optional)
  590. * \param q EC_POINT object with the first factor of the second summand
  591. * \param m BIGNUM with the second factor of the second summand
  592. * \param ctx BN_CTX object (optional)
  593. * \return 1 on success and 0 if an error occurred
  594. */
  595. int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n,
  596. const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx);
  597. /** Stores multiples of generator for faster point multiplication
  598. * \param group EC_GROUP object
  599. * \param ctx BN_CTX object (optional)
  600. * \return 1 on success and 0 if an error occurred
  601. */
  602. int EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx);
  603. /** Reports whether a precomputation has been done
  604. * \param group EC_GROUP object
  605. * \return 1 if a pre-computation has been done and 0 otherwise
  606. */
  607. int EC_GROUP_have_precompute_mult(const EC_GROUP *group);
  608. /********************************************************************/
  609. /* ASN1 stuff */
  610. /********************************************************************/
  611. DECLARE_ASN1_ITEM(ECPKPARAMETERS)
  612. DECLARE_ASN1_ALLOC_FUNCTIONS(ECPKPARAMETERS)
  613. DECLARE_ASN1_ITEM(ECPARAMETERS)
  614. DECLARE_ASN1_ALLOC_FUNCTIONS(ECPARAMETERS)
  615. /*
  616. * EC_GROUP_get_basis_type() returns the NID of the basis type used to
  617. * represent the field elements
  618. */
  619. int EC_GROUP_get_basis_type(const EC_GROUP *);
  620. # ifndef OPENSSL_NO_EC2M
  621. int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k);
  622. int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1,
  623. unsigned int *k2, unsigned int *k3);
  624. # endif
  625. # define OPENSSL_EC_EXPLICIT_CURVE 0x000
  626. # define OPENSSL_EC_NAMED_CURVE 0x001
  627. EC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len);
  628. int i2d_ECPKParameters(const EC_GROUP *, unsigned char **out);
  629. # define d2i_ECPKParameters_bio(bp,x) ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x)
  630. # define i2d_ECPKParameters_bio(bp,x) ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x)
  631. # define d2i_ECPKParameters_fp(fp,x) (EC_GROUP *)ASN1_d2i_fp(NULL, \
  632. (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x))
  633. # define i2d_ECPKParameters_fp(fp,x) ASN1_i2d_fp(i2d_ECPKParameters,(fp), \
  634. (unsigned char *)(x))
  635. int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off);
  636. # ifndef OPENSSL_NO_STDIO
  637. int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off);
  638. # endif
  639. /********************************************************************/
  640. /* EC_KEY functions */
  641. /********************************************************************/
  642. /* some values for the encoding_flag */
  643. # define EC_PKEY_NO_PARAMETERS 0x001
  644. # define EC_PKEY_NO_PUBKEY 0x002
  645. /* some values for the flags field */
  646. # define EC_FLAG_NON_FIPS_ALLOW 0x1
  647. # define EC_FLAG_FIPS_CHECKED 0x2
  648. # define EC_FLAG_COFACTOR_ECDH 0x1000
  649. /** Creates a new EC_KEY object.
  650. * \return EC_KEY object or NULL if an error occurred.
  651. */
  652. EC_KEY *EC_KEY_new(void);
  653. int EC_KEY_get_flags(const EC_KEY *key);
  654. void EC_KEY_set_flags(EC_KEY *key, int flags);
  655. void EC_KEY_clear_flags(EC_KEY *key, int flags);
  656. /** Creates a new EC_KEY object using a named curve as underlying
  657. * EC_GROUP object.
  658. * \param nid NID of the named curve.
  659. * \return EC_KEY object or NULL if an error occurred.
  660. */
  661. EC_KEY *EC_KEY_new_by_curve_name(int nid);
  662. /** Frees a EC_KEY object.
  663. * \param key EC_KEY object to be freed.
  664. */
  665. void EC_KEY_free(EC_KEY *key);
  666. /** Copies a EC_KEY object.
  667. * \param dst destination EC_KEY object
  668. * \param src src EC_KEY object
  669. * \return dst or NULL if an error occurred.
  670. */
  671. EC_KEY *EC_KEY_copy(EC_KEY *dst, const EC_KEY *src);
  672. /** Creates a new EC_KEY object and copies the content from src to it.
  673. * \param src the source EC_KEY object
  674. * \return newly created EC_KEY object or NULL if an error occurred.
  675. */
  676. EC_KEY *EC_KEY_dup(const EC_KEY *src);
  677. /** Increases the internal reference count of a EC_KEY object.
  678. * \param key EC_KEY object
  679. * \return 1 on success and 0 if an error occurred.
  680. */
  681. int EC_KEY_up_ref(EC_KEY *key);
  682. /** Returns the EC_GROUP object of a EC_KEY object
  683. * \param key EC_KEY object
  684. * \return the EC_GROUP object (possibly NULL).
  685. */
  686. const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key);
  687. /** Sets the EC_GROUP of a EC_KEY object.
  688. * \param key EC_KEY object
  689. * \param group EC_GROUP to use in the EC_KEY object (note: the EC_KEY
  690. * object will use an own copy of the EC_GROUP).
  691. * \return 1 on success and 0 if an error occurred.
  692. */
  693. int EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group);
  694. /** Returns the private key of a EC_KEY object.
  695. * \param key EC_KEY object
  696. * \return a BIGNUM with the private key (possibly NULL).
  697. */
  698. const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key);
  699. /** Sets the private key of a EC_KEY object.
  700. * \param key EC_KEY object
  701. * \param prv BIGNUM with the private key (note: the EC_KEY object
  702. * will use an own copy of the BIGNUM).
  703. * \return 1 on success and 0 if an error occurred.
  704. */
  705. int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv);
  706. /** Returns the public key of a EC_KEY object.
  707. * \param key the EC_KEY object
  708. * \return a EC_POINT object with the public key (possibly NULL)
  709. */
  710. const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key);
  711. /** Sets the public key of a EC_KEY object.
  712. * \param key EC_KEY object
  713. * \param pub EC_POINT object with the public key (note: the EC_KEY object
  714. * will use an own copy of the EC_POINT object).
  715. * \return 1 on success and 0 if an error occurred.
  716. */
  717. int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub);
  718. unsigned EC_KEY_get_enc_flags(const EC_KEY *key);
  719. void EC_KEY_set_enc_flags(EC_KEY *eckey, unsigned int flags);
  720. point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key);
  721. void EC_KEY_set_conv_form(EC_KEY *eckey, point_conversion_form_t cform);
  722. #define EC_KEY_get_ex_new_index(l, p, newf, dupf, freef) \
  723. CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_EC_KEY, l, p, newf, dupf, freef)
  724. int EC_KEY_set_ex_data(EC_KEY *key, int idx, void *arg);
  725. void *EC_KEY_get_ex_data(const EC_KEY *key, int idx);
  726. /* wrapper functions for the underlying EC_GROUP object */
  727. void EC_KEY_set_asn1_flag(EC_KEY *eckey, int asn1_flag);
  728. /** Creates a table of pre-computed multiples of the generator to
  729. * accelerate further EC_KEY operations.
  730. * \param key EC_KEY object
  731. * \param ctx BN_CTX object (optional)
  732. * \return 1 on success and 0 if an error occurred.
  733. */
  734. int EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx);
  735. /** Creates a new ec private (and optional a new public) key.
  736. * \param key EC_KEY object
  737. * \return 1 on success and 0 if an error occurred.
  738. */
  739. int EC_KEY_generate_key(EC_KEY *key);
  740. /** Verifies that a private and/or public key is valid.
  741. * \param key the EC_KEY object
  742. * \return 1 on success and 0 otherwise.
  743. */
  744. int EC_KEY_check_key(const EC_KEY *key);
  745. /** Indicates if an EC_KEY can be used for signing.
  746. * \param eckey the EC_KEY object
  747. * \return 1 if can can sign and 0 otherwise.
  748. */
  749. int EC_KEY_can_sign(const EC_KEY *eckey);
  750. /** Sets a public key from affine coordinates performing
  751. * necessary NIST PKV tests.
  752. * \param key the EC_KEY object
  753. * \param x public key x coordinate
  754. * \param y public key y coordinate
  755. * \return 1 on success and 0 otherwise.
  756. */
  757. int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x,
  758. BIGNUM *y);
  759. /** Encodes an EC_KEY public key to an allocated octet string
  760. * \param key key to encode
  761. * \param form point conversion form
  762. * \param pbuf returns pointer to allocated buffer
  763. * \param ctx BN_CTX object (optional)
  764. * \return the length of the encoded octet string or 0 if an error occurred
  765. */
  766. size_t EC_KEY_key2buf(const EC_KEY *key, point_conversion_form_t form,
  767. unsigned char **pbuf, BN_CTX *ctx);
  768. /** Decodes a EC_KEY public key from a octet string
  769. * \param key key to decode
  770. * \param buf memory buffer with the encoded ec point
  771. * \param len length of the encoded ec point
  772. * \param ctx BN_CTX object (optional)
  773. * \return 1 on success and 0 if an error occurred
  774. */
  775. int EC_KEY_oct2key(EC_KEY *key, const unsigned char *buf, size_t len,
  776. BN_CTX *ctx);
  777. /** Decodes an EC_KEY private key from an octet string
  778. * \param key key to decode
  779. * \param buf memory buffer with the encoded private key
  780. * \param len length of the encoded key
  781. * \return 1 on success and 0 if an error occurred
  782. */
  783. int EC_KEY_oct2priv(EC_KEY *key, const unsigned char *buf, size_t len);
  784. /** Encodes a EC_KEY private key to an octet string
  785. * \param key key to encode
  786. * \param buf memory buffer for the result. If NULL the function returns
  787. * required buffer size.
  788. * \param len length of the memory buffer
  789. * \return the length of the encoded octet string or 0 if an error occurred
  790. */
  791. size_t EC_KEY_priv2oct(const EC_KEY *key, unsigned char *buf, size_t len);
  792. /** Encodes an EC_KEY private key to an allocated octet string
  793. * \param eckey key to encode
  794. * \param pbuf returns pointer to allocated buffer
  795. * \return the length of the encoded octet string or 0 if an error occurred
  796. */
  797. size_t EC_KEY_priv2buf(const EC_KEY *eckey, unsigned char **pbuf);
  798. /********************************************************************/
  799. /* de- and encoding functions for SEC1 ECPrivateKey */
  800. /********************************************************************/
  801. /** Decodes a private key from a memory buffer.
  802. * \param key a pointer to a EC_KEY object which should be used (or NULL)
  803. * \param in pointer to memory with the DER encoded private key
  804. * \param len length of the DER encoded private key
  805. * \return the decoded private key or NULL if an error occurred.
  806. */
  807. EC_KEY *d2i_ECPrivateKey(EC_KEY **key, const unsigned char **in, long len);
  808. /** Encodes a private key object and stores the result in a buffer.
  809. * \param key the EC_KEY object to encode
  810. * \param out the buffer for the result (if NULL the function returns number
  811. * of bytes needed).
  812. * \return 1 on success and 0 if an error occurred.
  813. */
  814. int i2d_ECPrivateKey(EC_KEY *key, unsigned char **out);
  815. /********************************************************************/
  816. /* de- and encoding functions for EC parameters */
  817. /********************************************************************/
  818. /** Decodes ec parameter from a memory buffer.
  819. * \param key a pointer to a EC_KEY object which should be used (or NULL)
  820. * \param in pointer to memory with the DER encoded ec parameters
  821. * \param len length of the DER encoded ec parameters
  822. * \return a EC_KEY object with the decoded parameters or NULL if an error
  823. * occurred.
  824. */
  825. EC_KEY *d2i_ECParameters(EC_KEY **key, const unsigned char **in, long len);
  826. /** Encodes ec parameter and stores the result in a buffer.
  827. * \param key the EC_KEY object with ec parameters to encode
  828. * \param out the buffer for the result (if NULL the function returns number
  829. * of bytes needed).
  830. * \return 1 on success and 0 if an error occurred.
  831. */
  832. int i2d_ECParameters(EC_KEY *key, unsigned char **out);
  833. /********************************************************************/
  834. /* de- and encoding functions for EC public key */
  835. /* (octet string, not DER -- hence 'o2i' and 'i2o') */
  836. /********************************************************************/
  837. /** Decodes a ec public key from a octet string.
  838. * \param key a pointer to a EC_KEY object which should be used
  839. * \param in memory buffer with the encoded public key
  840. * \param len length of the encoded public key
  841. * \return EC_KEY object with decoded public key or NULL if an error
  842. * occurred.
  843. */
  844. EC_KEY *o2i_ECPublicKey(EC_KEY **key, const unsigned char **in, long len);
  845. /** Encodes a ec public key in an octet string.
  846. * \param key the EC_KEY object with the public key
  847. * \param out the buffer for the result (if NULL the function returns number
  848. * of bytes needed).
  849. * \return 1 on success and 0 if an error occurred
  850. */
  851. int i2o_ECPublicKey(const EC_KEY *key, unsigned char **out);
  852. /** Prints out the ec parameters on human readable form.
  853. * \param bp BIO object to which the information is printed
  854. * \param key EC_KEY object
  855. * \return 1 on success and 0 if an error occurred
  856. */
  857. int ECParameters_print(BIO *bp, const EC_KEY *key);
  858. /** Prints out the contents of a EC_KEY object
  859. * \param bp BIO object to which the information is printed
  860. * \param key EC_KEY object
  861. * \param off line offset
  862. * \return 1 on success and 0 if an error occurred
  863. */
  864. int EC_KEY_print(BIO *bp, const EC_KEY *key, int off);
  865. # ifndef OPENSSL_NO_STDIO
  866. /** Prints out the ec parameters on human readable form.
  867. * \param fp file descriptor to which the information is printed
  868. * \param key EC_KEY object
  869. * \return 1 on success and 0 if an error occurred
  870. */
  871. int ECParameters_print_fp(FILE *fp, const EC_KEY *key);
  872. /** Prints out the contents of a EC_KEY object
  873. * \param fp file descriptor to which the information is printed
  874. * \param key EC_KEY object
  875. * \param off line offset
  876. * \return 1 on success and 0 if an error occurred
  877. */
  878. int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off);
  879. # endif
  880. const EC_KEY_METHOD *EC_KEY_OpenSSL(void);
  881. const EC_KEY_METHOD *EC_KEY_get_default_method(void);
  882. void EC_KEY_set_default_method(const EC_KEY_METHOD *meth);
  883. const EC_KEY_METHOD *EC_KEY_get_method(const EC_KEY *key);
  884. int EC_KEY_set_method(EC_KEY *key, const EC_KEY_METHOD *meth);
  885. EC_KEY *EC_KEY_new_method(ENGINE *engine);
  886. int ECDH_KDF_X9_62(unsigned char *out, size_t outlen,
  887. const unsigned char *Z, size_t Zlen,
  888. const unsigned char *sinfo, size_t sinfolen,
  889. const EVP_MD *md);
  890. int ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,
  891. const EC_KEY *ecdh,
  892. void *(*KDF) (const void *in, size_t inlen,
  893. void *out, size_t *outlen));
  894. typedef struct ECDSA_SIG_st ECDSA_SIG;
  895. /** Allocates and initialize a ECDSA_SIG structure
  896. * \return pointer to a ECDSA_SIG structure or NULL if an error occurred
  897. */
  898. ECDSA_SIG *ECDSA_SIG_new(void);
  899. /** frees a ECDSA_SIG structure
  900. * \param sig pointer to the ECDSA_SIG structure
  901. */
  902. void ECDSA_SIG_free(ECDSA_SIG *sig);
  903. /** DER encode content of ECDSA_SIG object (note: this function modifies *pp
  904. * (*pp += length of the DER encoded signature)).
  905. * \param sig pointer to the ECDSA_SIG object
  906. * \param pp pointer to a unsigned char pointer for the output or NULL
  907. * \return the length of the DER encoded ECDSA_SIG object or 0
  908. */
  909. int i2d_ECDSA_SIG(const ECDSA_SIG *sig, unsigned char **pp);
  910. /** Decodes a DER encoded ECDSA signature (note: this function changes *pp
  911. * (*pp += len)).
  912. * \param sig pointer to ECDSA_SIG pointer (may be NULL)
  913. * \param pp memory buffer with the DER encoded signature
  914. * \param len length of the buffer
  915. * \return pointer to the decoded ECDSA_SIG structure (or NULL)
  916. */
  917. ECDSA_SIG *d2i_ECDSA_SIG(ECDSA_SIG **sig, const unsigned char **pp, long len);
  918. /** Accessor for r and s fields of ECDSA_SIG
  919. * \param sig pointer to ECDSA_SIG pointer
  920. * \param pr pointer to BIGNUM pointer for r (may be NULL)
  921. * \param ps pointer to BIGNUM pointer for s (may be NULL)
  922. */
  923. void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps);
  924. /** Setter for r and s fields of ECDSA_SIG
  925. * \param sig pointer to ECDSA_SIG pointer
  926. * \param r pointer to BIGNUM for r (may be NULL)
  927. * \param s pointer to BIGNUM for s (may be NULL)
  928. */
  929. int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s);
  930. /** Computes the ECDSA signature of the given hash value using
  931. * the supplied private key and returns the created signature.
  932. * \param dgst pointer to the hash value
  933. * \param dgst_len length of the hash value
  934. * \param eckey EC_KEY object containing a private EC key
  935. * \return pointer to a ECDSA_SIG structure or NULL if an error occurred
  936. */
  937. ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst, int dgst_len,
  938. EC_KEY *eckey);
  939. /** Computes ECDSA signature of a given hash value using the supplied
  940. * private key (note: sig must point to ECDSA_size(eckey) bytes of memory).
  941. * \param dgst pointer to the hash value to sign
  942. * \param dgstlen length of the hash value
  943. * \param kinv BIGNUM with a pre-computed inverse k (optional)
  944. * \param rp BIGNUM with a pre-computed rp value (optional),
  945. * see ECDSA_sign_setup
  946. * \param eckey EC_KEY object containing a private EC key
  947. * \return pointer to a ECDSA_SIG structure or NULL if an error occurred
  948. */
  949. ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dgstlen,
  950. const BIGNUM *kinv, const BIGNUM *rp,
  951. EC_KEY *eckey);
  952. /** Verifies that the supplied signature is a valid ECDSA
  953. * signature of the supplied hash value using the supplied public key.
  954. * \param dgst pointer to the hash value
  955. * \param dgst_len length of the hash value
  956. * \param sig ECDSA_SIG structure
  957. * \param eckey EC_KEY object containing a public EC key
  958. * \return 1 if the signature is valid, 0 if the signature is invalid
  959. * and -1 on error
  960. */
  961. int ECDSA_do_verify(const unsigned char *dgst, int dgst_len,
  962. const ECDSA_SIG *sig, EC_KEY *eckey);
  963. /** Precompute parts of the signing operation
  964. * \param eckey EC_KEY object containing a private EC key
  965. * \param ctx BN_CTX object (optional)
  966. * \param kinv BIGNUM pointer for the inverse of k
  967. * \param rp BIGNUM pointer for x coordinate of k * generator
  968. * \return 1 on success and 0 otherwise
  969. */
  970. int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv, BIGNUM **rp);
  971. /** Computes ECDSA signature of a given hash value using the supplied
  972. * private key (note: sig must point to ECDSA_size(eckey) bytes of memory).
  973. * \param type this parameter is ignored
  974. * \param dgst pointer to the hash value to sign
  975. * \param dgstlen length of the hash value
  976. * \param sig memory for the DER encoded created signature
  977. * \param siglen pointer to the length of the returned signature
  978. * \param eckey EC_KEY object containing a private EC key
  979. * \return 1 on success and 0 otherwise
  980. */
  981. int ECDSA_sign(int type, const unsigned char *dgst, int dgstlen,
  982. unsigned char *sig, unsigned int *siglen, EC_KEY *eckey);
  983. /** Computes ECDSA signature of a given hash value using the supplied
  984. * private key (note: sig must point to ECDSA_size(eckey) bytes of memory).
  985. * \param type this parameter is ignored
  986. * \param dgst pointer to the hash value to sign
  987. * \param dgstlen length of the hash value
  988. * \param sig buffer to hold the DER encoded signature
  989. * \param siglen pointer to the length of the returned signature
  990. * \param kinv BIGNUM with a pre-computed inverse k (optional)
  991. * \param rp BIGNUM with a pre-computed rp value (optional),
  992. * see ECDSA_sign_setup
  993. * \param eckey EC_KEY object containing a private EC key
  994. * \return 1 on success and 0 otherwise
  995. */
  996. int ECDSA_sign_ex(int type, const unsigned char *dgst, int dgstlen,
  997. unsigned char *sig, unsigned int *siglen,
  998. const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey);
  999. /** Verifies that the given signature is valid ECDSA signature
  1000. * of the supplied hash value using the specified public key.
  1001. * \param type this parameter is ignored
  1002. * \param dgst pointer to the hash value
  1003. * \param dgstlen length of the hash value
  1004. * \param sig pointer to the DER encoded signature
  1005. * \param siglen length of the DER encoded signature
  1006. * \param eckey EC_KEY object containing a public EC key
  1007. * \return 1 if the signature is valid, 0 if the signature is invalid
  1008. * and -1 on error
  1009. */
  1010. int ECDSA_verify(int type, const unsigned char *dgst, int dgstlen,
  1011. const unsigned char *sig, int siglen, EC_KEY *eckey);
  1012. /** Returns the maximum length of the DER encoded signature
  1013. * \param eckey EC_KEY object
  1014. * \return numbers of bytes required for the DER encoded signature
  1015. */
  1016. int ECDSA_size(const EC_KEY *eckey);
  1017. /********************************************************************/
  1018. /* EC_KEY_METHOD constructors, destructors, writers and accessors */
  1019. /********************************************************************/
  1020. EC_KEY_METHOD *EC_KEY_METHOD_new(const EC_KEY_METHOD *meth);
  1021. void EC_KEY_METHOD_free(EC_KEY_METHOD *meth);
  1022. void EC_KEY_METHOD_set_init(EC_KEY_METHOD *meth,
  1023. int (*init)(EC_KEY *key),
  1024. void (*finish)(EC_KEY *key),
  1025. int (*copy)(EC_KEY *dest, const EC_KEY *src),
  1026. int (*set_group)(EC_KEY *key, const EC_GROUP *grp),
  1027. int (*set_private)(EC_KEY *key,
  1028. const BIGNUM *priv_key),
  1029. int (*set_public)(EC_KEY *key,
  1030. const EC_POINT *pub_key));
  1031. void EC_KEY_METHOD_set_keygen(EC_KEY_METHOD *meth,
  1032. int (*keygen)(EC_KEY *key));
  1033. void EC_KEY_METHOD_set_compute_key(EC_KEY_METHOD *meth,
  1034. int (*ckey)(unsigned char **psec,
  1035. size_t *pseclen,
  1036. const EC_POINT *pub_key,
  1037. const EC_KEY *ecdh));
  1038. void EC_KEY_METHOD_set_sign(EC_KEY_METHOD *meth,
  1039. int (*sign)(int type, const unsigned char *dgst,
  1040. int dlen, unsigned char *sig,
  1041. unsigned int *siglen,
  1042. const BIGNUM *kinv, const BIGNUM *r,
  1043. EC_KEY *eckey),
  1044. int (*sign_setup)(EC_KEY *eckey, BN_CTX *ctx_in,
  1045. BIGNUM **kinvp, BIGNUM **rp),
  1046. ECDSA_SIG *(*sign_sig)(const unsigned char *dgst,
  1047. int dgst_len,
  1048. const BIGNUM *in_kinv,
  1049. const BIGNUM *in_r,
  1050. EC_KEY *eckey));
  1051. void EC_KEY_METHOD_set_verify(EC_KEY_METHOD *meth,
  1052. int (*verify)(int type, const unsigned
  1053. char *dgst, int dgst_len,
  1054. const unsigned char *sigbuf,
  1055. int sig_len, EC_KEY *eckey),
  1056. int (*verify_sig)(const unsigned char *dgst,
  1057. int dgst_len,
  1058. const ECDSA_SIG *sig,
  1059. EC_KEY *eckey));
  1060. void EC_KEY_METHOD_get_init(const EC_KEY_METHOD *meth,
  1061. int (**pinit)(EC_KEY *key),
  1062. void (**pfinish)(EC_KEY *key),
  1063. int (**pcopy)(EC_KEY *dest, const EC_KEY *src),
  1064. int (**pset_group)(EC_KEY *key,
  1065. const EC_GROUP *grp),
  1066. int (**pset_private)(EC_KEY *key,
  1067. const BIGNUM *priv_key),
  1068. int (**pset_public)(EC_KEY *key,
  1069. const EC_POINT *pub_key));
  1070. void EC_KEY_METHOD_get_keygen(const EC_KEY_METHOD *meth,
  1071. int (**pkeygen)(EC_KEY *key));
  1072. void EC_KEY_METHOD_get_compute_key(const EC_KEY_METHOD *meth,
  1073. int (**pck)(unsigned char **psec,
  1074. size_t *pseclen,
  1075. const EC_POINT *pub_key,
  1076. const EC_KEY *ecdh));
  1077. void EC_KEY_METHOD_get_sign(const EC_KEY_METHOD *meth,
  1078. int (**psign)(int type, const unsigned char *dgst,
  1079. int dlen, unsigned char *sig,
  1080. unsigned int *siglen,
  1081. const BIGNUM *kinv, const BIGNUM *r,
  1082. EC_KEY *eckey),
  1083. int (**psign_setup)(EC_KEY *eckey, BN_CTX *ctx_in,
  1084. BIGNUM **kinvp, BIGNUM **rp),
  1085. ECDSA_SIG *(**psign_sig)(const unsigned char *dgst,
  1086. int dgst_len,
  1087. const BIGNUM *in_kinv,
  1088. const BIGNUM *in_r,
  1089. EC_KEY *eckey));
  1090. void EC_KEY_METHOD_get_verify(const EC_KEY_METHOD *meth,
  1091. int (**pverify)(int type, const unsigned
  1092. char *dgst, int dgst_len,
  1093. const unsigned char *sigbuf,
  1094. int sig_len, EC_KEY *eckey),
  1095. int (**pverify_sig)(const unsigned char *dgst,
  1096. int dgst_len,
  1097. const ECDSA_SIG *sig,
  1098. EC_KEY *eckey));
  1099. # define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x)
  1100. # ifndef __cplusplus
  1101. # if defined(__SUNPRO_C)
  1102. # if __SUNPRO_C >= 0x520
  1103. # pragma error_messages (default,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE)
  1104. # endif
  1105. # endif
  1106. # endif
  1107. # define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid) \
  1108. EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
  1109. EVP_PKEY_OP_PARAMGEN|EVP_PKEY_OP_KEYGEN, \
  1110. EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL)
  1111. # define EVP_PKEY_CTX_set_ec_param_enc(ctx, flag) \
  1112. EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
  1113. EVP_PKEY_OP_PARAMGEN|EVP_PKEY_OP_KEYGEN, \
  1114. EVP_PKEY_CTRL_EC_PARAM_ENC, flag, NULL)
  1115. # define EVP_PKEY_CTX_set_ecdh_cofactor_mode(ctx, flag) \
  1116. EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
  1117. EVP_PKEY_OP_DERIVE, \
  1118. EVP_PKEY_CTRL_EC_ECDH_COFACTOR, flag, NULL)
  1119. # define EVP_PKEY_CTX_get_ecdh_cofactor_mode(ctx) \
  1120. EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
  1121. EVP_PKEY_OP_DERIVE, \
  1122. EVP_PKEY_CTRL_EC_ECDH_COFACTOR, -2, NULL)
  1123. # define EVP_PKEY_CTX_set_ecdh_kdf_type(ctx, kdf) \
  1124. EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
  1125. EVP_PKEY_OP_DERIVE, \
  1126. EVP_PKEY_CTRL_EC_KDF_TYPE, kdf, NULL)
  1127. # define EVP_PKEY_CTX_get_ecdh_kdf_type(ctx) \
  1128. EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
  1129. EVP_PKEY_OP_DERIVE, \
  1130. EVP_PKEY_CTRL_EC_KDF_TYPE, -2, NULL)
  1131. # define EVP_PKEY_CTX_set_ecdh_kdf_md(ctx, md) \
  1132. EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
  1133. EVP_PKEY_OP_DERIVE, \
  1134. EVP_PKEY_CTRL_EC_KDF_MD, 0, (void *)md)
  1135. # define EVP_PKEY_CTX_get_ecdh_kdf_md(ctx, pmd) \
  1136. EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
  1137. EVP_PKEY_OP_DERIVE, \
  1138. EVP_PKEY_CTRL_GET_EC_KDF_MD, 0, (void *)pmd)
  1139. # define EVP_PKEY_CTX_set_ecdh_kdf_outlen(ctx, len) \
  1140. EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
  1141. EVP_PKEY_OP_DERIVE, \
  1142. EVP_PKEY_CTRL_EC_KDF_OUTLEN, len, NULL)
  1143. # define EVP_PKEY_CTX_get_ecdh_kdf_outlen(ctx, plen) \
  1144. EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
  1145. EVP_PKEY_OP_DERIVE, \
  1146. EVP_PKEY_CTRL_GET_EC_KDF_OUTLEN, 0, (void *)plen)
  1147. # define EVP_PKEY_CTX_set0_ecdh_kdf_ukm(ctx, p, plen) \
  1148. EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
  1149. EVP_PKEY_OP_DERIVE, \
  1150. EVP_PKEY_CTRL_EC_KDF_UKM, plen, (void *)p)
  1151. # define EVP_PKEY_CTX_get0_ecdh_kdf_ukm(ctx, p) \
  1152. EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
  1153. EVP_PKEY_OP_DERIVE, \
  1154. EVP_PKEY_CTRL_GET_EC_KDF_UKM, 0, (void *)p)
  1155. # define EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID (EVP_PKEY_ALG_CTRL + 1)
  1156. # define EVP_PKEY_CTRL_EC_PARAM_ENC (EVP_PKEY_ALG_CTRL + 2)
  1157. # define EVP_PKEY_CTRL_EC_ECDH_COFACTOR (EVP_PKEY_ALG_CTRL + 3)
  1158. # define EVP_PKEY_CTRL_EC_KDF_TYPE (EVP_PKEY_ALG_CTRL + 4)
  1159. # define EVP_PKEY_CTRL_EC_KDF_MD (EVP_PKEY_ALG_CTRL + 5)
  1160. # define EVP_PKEY_CTRL_GET_EC_KDF_MD (EVP_PKEY_ALG_CTRL + 6)
  1161. # define EVP_PKEY_CTRL_EC_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 7)
  1162. # define EVP_PKEY_CTRL_GET_EC_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 8)
  1163. # define EVP_PKEY_CTRL_EC_KDF_UKM (EVP_PKEY_ALG_CTRL + 9)
  1164. # define EVP_PKEY_CTRL_GET_EC_KDF_UKM (EVP_PKEY_ALG_CTRL + 10)
  1165. /* KDF types */
  1166. # define EVP_PKEY_ECDH_KDF_NONE 1
  1167. # define EVP_PKEY_ECDH_KDF_X9_62 2
  1168. /* BEGIN ERROR CODES */
  1169. /*
  1170. * The following lines are auto generated by the script mkerr.pl. Any changes
  1171. * made after this point may be overwritten when the script is next run.
  1172. */
  1173. int ERR_load_EC_strings(void);
  1174. /* Error codes for the EC functions. */
  1175. /* Function codes. */
  1176. # define EC_F_BN_TO_FELEM 224
  1177. # define EC_F_D2I_ECPARAMETERS 144
  1178. # define EC_F_D2I_ECPKPARAMETERS 145
  1179. # define EC_F_D2I_ECPRIVATEKEY 146
  1180. # define EC_F_DO_EC_KEY_PRINT 221
  1181. # define EC_F_ECDH_CMS_DECRYPT 238
  1182. # define EC_F_ECDH_CMS_SET_SHARED_INFO 239
  1183. # define EC_F_ECDH_COMPUTE_KEY 246
  1184. # define EC_F_ECDH_SIMPLE_COMPUTE_KEY 257
  1185. # define EC_F_ECDSA_DO_SIGN_EX 251
  1186. # define EC_F_ECDSA_DO_VERIFY 252
  1187. # define EC_F_ECDSA_SIGN_EX 254
  1188. # define EC_F_ECDSA_SIGN_SETUP 248
  1189. # define EC_F_ECDSA_SIG_NEW 265
  1190. # define EC_F_ECDSA_VERIFY 253
  1191. # define EC_F_ECKEY_PARAM2TYPE 223
  1192. # define EC_F_ECKEY_PARAM_DECODE 212
  1193. # define EC_F_ECKEY_PRIV_DECODE 213
  1194. # define EC_F_ECKEY_PRIV_ENCODE 214
  1195. # define EC_F_ECKEY_PUB_DECODE 215
  1196. # define EC_F_ECKEY_PUB_ENCODE 216
  1197. # define EC_F_ECKEY_TYPE2PARAM 220
  1198. # define EC_F_ECPARAMETERS_PRINT 147
  1199. # define EC_F_ECPARAMETERS_PRINT_FP 148
  1200. # define EC_F_ECPKPARAMETERS_PRINT 149
  1201. # define EC_F_ECPKPARAMETERS_PRINT_FP 150
  1202. # define EC_F_ECP_NISTZ256_GET_AFFINE 240
  1203. # define EC_F_ECP_NISTZ256_MULT_PRECOMPUTE 243
  1204. # define EC_F_ECP_NISTZ256_POINTS_MUL 241
  1205. # define EC_F_ECP_NISTZ256_PRE_COMP_NEW 244
  1206. # define EC_F_ECP_NISTZ256_WINDOWED_MUL 242
  1207. # define EC_F_ECX_KEY_OP 266
  1208. # define EC_F_ECX_PRIV_ENCODE 267
  1209. # define EC_F_ECX_PUB_ENCODE 268
  1210. # define EC_F_EC_ASN1_GROUP2CURVE 153
  1211. # define EC_F_EC_ASN1_GROUP2FIELDID 154
  1212. # define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY 208
  1213. # define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT 159
  1214. # define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE 195
  1215. # define EC_F_EC_GF2M_SIMPLE_OCT2POINT 160
  1216. # define EC_F_EC_GF2M_SIMPLE_POINT2OCT 161
  1217. # define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 162
  1218. # define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 163
  1219. # define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES 164
  1220. # define EC_F_EC_GFP_MONT_FIELD_DECODE 133
  1221. # define EC_F_EC_GFP_MONT_FIELD_ENCODE 134
  1222. # define EC_F_EC_GFP_MONT_FIELD_MUL 131
  1223. # define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE 209
  1224. # define EC_F_EC_GFP_MONT_FIELD_SQR 132
  1225. # define EC_F_EC_GFP_MONT_GROUP_SET_CURVE 189
  1226. # define EC_F_EC_GFP_NISTP224_GROUP_SET_CURVE 225
  1227. # define EC_F_EC_GFP_NISTP224_POINTS_MUL 228
  1228. # define EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES 226
  1229. # define EC_F_EC_GFP_NISTP256_GROUP_SET_CURVE 230
  1230. # define EC_F_EC_GFP_NISTP256_POINTS_MUL 231
  1231. # define EC_F_EC_GFP_NISTP256_POINT_GET_AFFINE_COORDINATES 232
  1232. # define EC_F_EC_GFP_NISTP521_GROUP_SET_CURVE 233
  1233. # define EC_F_EC_GFP_NISTP521_POINTS_MUL 234
  1234. # define EC_F_EC_GFP_NISTP521_POINT_GET_AFFINE_COORDINATES 235
  1235. # define EC_F_EC_GFP_NIST_FIELD_MUL 200
  1236. # define EC_F_EC_GFP_NIST_FIELD_SQR 201
  1237. # define EC_F_EC_GFP_NIST_GROUP_SET_CURVE 202
  1238. # define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT 165
  1239. # define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE 166
  1240. # define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE 102
  1241. # define EC_F_EC_GFP_SIMPLE_OCT2POINT 103
  1242. # define EC_F_EC_GFP_SIMPLE_POINT2OCT 104
  1243. # define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE 137
  1244. # define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES 167
  1245. # define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES 168
  1246. # define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES 169
  1247. # define EC_F_EC_GROUP_CHECK 170
  1248. # define EC_F_EC_GROUP_CHECK_DISCRIMINANT 171
  1249. # define EC_F_EC_GROUP_COPY 106
  1250. # define EC_F_EC_GROUP_GET_CURVE_GF2M 172
  1251. # define EC_F_EC_GROUP_GET_CURVE_GFP 130
  1252. # define EC_F_EC_GROUP_GET_DEGREE 173
  1253. # define EC_F_EC_GROUP_GET_ECPARAMETERS 261
  1254. # define EC_F_EC_GROUP_GET_ECPKPARAMETERS 262
  1255. # define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS 193
  1256. # define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS 194
  1257. # define EC_F_EC_GROUP_NEW 108
  1258. # define EC_F_EC_GROUP_NEW_BY_CURVE_NAME 174
  1259. # define EC_F_EC_GROUP_NEW_FROM_DATA 175
  1260. # define EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS 263
  1261. # define EC_F_EC_GROUP_NEW_FROM_ECPKPARAMETERS 264
  1262. # define EC_F_EC_GROUP_SET_CURVE_GF2M 176
  1263. # define EC_F_EC_GROUP_SET_CURVE_GFP 109
  1264. # define EC_F_EC_GROUP_SET_GENERATOR 111
  1265. # define EC_F_EC_KEY_CHECK_KEY 177
  1266. # define EC_F_EC_KEY_COPY 178
  1267. # define EC_F_EC_KEY_GENERATE_KEY 179
  1268. # define EC_F_EC_KEY_NEW 182
  1269. # define EC_F_EC_KEY_NEW_METHOD 245
  1270. # define EC_F_EC_KEY_OCT2PRIV 255
  1271. # define EC_F_EC_KEY_PRINT 180
  1272. # define EC_F_EC_KEY_PRINT_FP 181
  1273. # define EC_F_EC_KEY_PRIV2OCT 256
  1274. # define EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES 229
  1275. # define EC_F_EC_KEY_SIMPLE_CHECK_KEY 258
  1276. # define EC_F_EC_KEY_SIMPLE_OCT2PRIV 259
  1277. # define EC_F_EC_KEY_SIMPLE_PRIV2OCT 260
  1278. # define EC_F_EC_POINTS_MAKE_AFFINE 136
  1279. # define EC_F_EC_POINT_ADD 112
  1280. # define EC_F_EC_POINT_CMP 113
  1281. # define EC_F_EC_POINT_COPY 114
  1282. # define EC_F_EC_POINT_DBL 115
  1283. # define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M 183
  1284. # define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP 116
  1285. # define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP 117
  1286. # define EC_F_EC_POINT_INVERT 210
  1287. # define EC_F_EC_POINT_IS_AT_INFINITY 118
  1288. # define EC_F_EC_POINT_IS_ON_CURVE 119
  1289. # define EC_F_EC_POINT_MAKE_AFFINE 120
  1290. # define EC_F_EC_POINT_NEW 121
  1291. # define EC_F_EC_POINT_OCT2POINT 122
  1292. # define EC_F_EC_POINT_POINT2OCT 123
  1293. # define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M 185
  1294. # define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP 124
  1295. # define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M 186
  1296. # define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP 125
  1297. # define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP 126
  1298. # define EC_F_EC_POINT_SET_TO_INFINITY 127
  1299. # define EC_F_EC_PRE_COMP_NEW 196
  1300. # define EC_F_EC_WNAF_MUL 187
  1301. # define EC_F_EC_WNAF_PRECOMPUTE_MULT 188
  1302. # define EC_F_I2D_ECPARAMETERS 190
  1303. # define EC_F_I2D_ECPKPARAMETERS 191
  1304. # define EC_F_I2D_ECPRIVATEKEY 192
  1305. # define EC_F_I2O_ECPUBLICKEY 151
  1306. # define EC_F_NISTP224_PRE_COMP_NEW 227
  1307. # define EC_F_NISTP256_PRE_COMP_NEW 236
  1308. # define EC_F_NISTP521_PRE_COMP_NEW 237
  1309. # define EC_F_O2I_ECPUBLICKEY 152
  1310. # define EC_F_OLD_EC_PRIV_DECODE 222
  1311. # define EC_F_OSSL_ECDH_COMPUTE_KEY 247
  1312. # define EC_F_OSSL_ECDSA_SIGN_SIG 249
  1313. # define EC_F_OSSL_ECDSA_VERIFY_SIG 250
  1314. # define EC_F_PKEY_ECX_DERIVE 269
  1315. # define EC_F_PKEY_EC_CTRL 197
  1316. # define EC_F_PKEY_EC_CTRL_STR 198
  1317. # define EC_F_PKEY_EC_DERIVE 217
  1318. # define EC_F_PKEY_EC_KEYGEN 199
  1319. # define EC_F_PKEY_EC_PARAMGEN 219
  1320. # define EC_F_PKEY_EC_SIGN 218
  1321. /* Reason codes. */
  1322. # define EC_R_ASN1_ERROR 115
  1323. # define EC_R_BAD_SIGNATURE 156
  1324. # define EC_R_BIGNUM_OUT_OF_RANGE 144
  1325. # define EC_R_BUFFER_TOO_SMALL 100
  1326. # define EC_R_COORDINATES_OUT_OF_RANGE 146
  1327. # define EC_R_CURVE_DOES_NOT_SUPPORT_ECDH 160
  1328. # define EC_R_CURVE_DOES_NOT_SUPPORT_SIGNING 159
  1329. # define EC_R_D2I_ECPKPARAMETERS_FAILURE 117
  1330. # define EC_R_DECODE_ERROR 142
  1331. # define EC_R_DISCRIMINANT_IS_ZERO 118
  1332. # define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 119
  1333. # define EC_R_FIELD_TOO_LARGE 143
  1334. # define EC_R_GF2M_NOT_SUPPORTED 147
  1335. # define EC_R_GROUP2PKPARAMETERS_FAILURE 120
  1336. # define EC_R_I2D_ECPKPARAMETERS_FAILURE 121
  1337. # define EC_R_INCOMPATIBLE_OBJECTS 101
  1338. # define EC_R_INVALID_ARGUMENT 112
  1339. # define EC_R_INVALID_COMPRESSED_POINT 110
  1340. # define EC_R_INVALID_COMPRESSION_BIT 109
  1341. # define EC_R_INVALID_CURVE 141
  1342. # define EC_R_INVALID_DIGEST 151
  1343. # define EC_R_INVALID_DIGEST_TYPE 138
  1344. # define EC_R_INVALID_ENCODING 102
  1345. # define EC_R_INVALID_FIELD 103
  1346. # define EC_R_INVALID_FORM 104
  1347. # define EC_R_INVALID_GROUP_ORDER 122
  1348. # define EC_R_INVALID_KEY 116
  1349. # define EC_R_INVALID_OUTPUT_LENGTH 161
  1350. # define EC_R_INVALID_PEER_KEY 133
  1351. # define EC_R_INVALID_PENTANOMIAL_BASIS 132
  1352. # define EC_R_INVALID_PRIVATE_KEY 123
  1353. # define EC_R_INVALID_TRINOMIAL_BASIS 137
  1354. # define EC_R_KDF_PARAMETER_ERROR 148
  1355. # define EC_R_KEYS_NOT_SET 140
  1356. # define EC_R_MISSING_PARAMETERS 124
  1357. # define EC_R_MISSING_PRIVATE_KEY 125
  1358. # define EC_R_NEED_NEW_SETUP_VALUES 157
  1359. # define EC_R_NOT_A_NIST_PRIME 135
  1360. # define EC_R_NOT_IMPLEMENTED 126
  1361. # define EC_R_NOT_INITIALIZED 111
  1362. # define EC_R_NO_PARAMETERS_SET 139
  1363. # define EC_R_NO_PRIVATE_VALUE 154
  1364. # define EC_R_OPERATION_NOT_SUPPORTED 152
  1365. # define EC_R_PASSED_NULL_PARAMETER 134
  1366. # define EC_R_PEER_KEY_ERROR 149
  1367. # define EC_R_PKPARAMETERS2GROUP_FAILURE 127
  1368. # define EC_R_POINT_ARITHMETIC_FAILURE 155
  1369. # define EC_R_POINT_AT_INFINITY 106
  1370. # define EC_R_POINT_IS_NOT_ON_CURVE 107
  1371. # define EC_R_RANDOM_NUMBER_GENERATION_FAILED 158
  1372. # define EC_R_SHARED_INFO_ERROR 150
  1373. # define EC_R_SLOT_FULL 108
  1374. # define EC_R_UNDEFINED_GENERATOR 113
  1375. # define EC_R_UNDEFINED_ORDER 128
  1376. # define EC_R_UNKNOWN_GROUP 129
  1377. # define EC_R_UNKNOWN_ORDER 114
  1378. # define EC_R_UNSUPPORTED_FIELD 131
  1379. # define EC_R_WRONG_CURVE_PARAMETERS 145
  1380. # define EC_R_WRONG_ORDER 130
  1381. # ifdef __cplusplus
  1382. }
  1383. # endif
  1384. # endif
  1385. #endif