ec.h 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090
  1. /* crypto/ec/ec.h */
  2. /*
  3. * Originally written by Bodo Moeller for the OpenSSL project.
  4. */
  5. /**
  6. * \file crypto/ec/ec.h Include file for the OpenSSL EC functions
  7. * \author Originally written by Bodo Moeller for the OpenSSL project
  8. */
  9. /* ====================================================================
  10. * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved.
  11. *
  12. * Redistribution and use in source and binary forms, with or without
  13. * modification, are permitted provided that the following conditions
  14. * are met:
  15. *
  16. * 1. Redistributions of source code must retain the above copyright
  17. * notice, this list of conditions and the following disclaimer.
  18. *
  19. * 2. Redistributions in binary form must reproduce the above copyright
  20. * notice, this list of conditions and the following disclaimer in
  21. * the documentation and/or other materials provided with the
  22. * distribution.
  23. *
  24. * 3. All advertising materials mentioning features or use of this
  25. * software must display the following acknowledgment:
  26. * "This product includes software developed by the OpenSSL Project
  27. * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
  28. *
  29. * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
  30. * endorse or promote products derived from this software without
  31. * prior written permission. For written permission, please contact
  32. * openssl-core@openssl.org.
  33. *
  34. * 5. Products derived from this software may not be called "OpenSSL"
  35. * nor may "OpenSSL" appear in their names without prior written
  36. * permission of the OpenSSL Project.
  37. *
  38. * 6. Redistributions of any form whatsoever must retain the following
  39. * acknowledgment:
  40. * "This product includes software developed by the OpenSSL Project
  41. * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
  42. *
  43. * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
  44. * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  45. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  46. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
  47. * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  48. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  49. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  50. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  51. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  52. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  53. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  54. * OF THE POSSIBILITY OF SUCH DAMAGE.
  55. * ====================================================================
  56. *
  57. * This product includes cryptographic software written by Eric Young
  58. * (eay@cryptsoft.com). This product includes software written by Tim
  59. * Hudson (tjh@cryptsoft.com).
  60. *
  61. */
  62. /* ====================================================================
  63. * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
  64. *
  65. * Portions of the attached software ("Contribution") are developed by
  66. * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
  67. *
  68. * The Contribution is licensed pursuant to the OpenSSL open source
  69. * license provided above.
  70. *
  71. * The elliptic curve binary polynomial software is originally written by
  72. * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories.
  73. *
  74. */
  75. #ifndef HEADER_EC_H
  76. #define HEADER_EC_H
  77. #include <openssl/opensslconf.h>
  78. #ifdef OPENSSL_NO_EC
  79. #error EC is disabled.
  80. #endif
  81. #include <openssl/asn1.h>
  82. #include <openssl/symhacks.h>
  83. #ifndef OPENSSL_NO_DEPRECATED
  84. #include <openssl/bn.h>
  85. #endif
  86. #ifdef __cplusplus
  87. extern "C" {
  88. #elif defined(__SUNPRO_C)
  89. # if __SUNPRO_C >= 0x520
  90. # pragma error_messages (off,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE)
  91. # endif
  92. #endif
  93. /** Enum for the point conversion form as defined in X9.62 (ECDSA)
  94. * for the encoding of a elliptic curve point (x,y) */
  95. typedef enum {
  96. /** the point is encoded as z||x, where the octet z specifies
  97. * which solution of the quadratic equation y is */
  98. POINT_CONVERSION_COMPRESSED = 2,
  99. /** the point is encoded as z||x||y, where z is the octet 0x02 */
  100. POINT_CONVERSION_UNCOMPRESSED = 4,
  101. /** the point is encoded as z||x||y, where the octet z specifies
  102. * which solution of the quadratic equation y is */
  103. POINT_CONVERSION_HYBRID = 6
  104. } point_conversion_form_t;
  105. typedef struct ec_method_st EC_METHOD;
  106. typedef struct ec_group_st
  107. /*
  108. EC_METHOD *meth;
  109. -- field definition
  110. -- curve coefficients
  111. -- optional generator with associated information (order, cofactor)
  112. -- optional extra data (precomputed table for fast computation of multiples of generator)
  113. -- ASN1 stuff
  114. */
  115. EC_GROUP;
  116. typedef struct ec_point_st EC_POINT;
  117. /********************************************************************/
  118. /* EC_METHODs for curves over GF(p) */
  119. /********************************************************************/
  120. /** Returns the basic GFp ec methods which provides the basis for the
  121. * optimized methods.
  122. * \return EC_METHOD object
  123. */
  124. const EC_METHOD *EC_GFp_simple_method(void);
  125. /** Returns GFp methods using montgomery multiplication.
  126. * \return EC_METHOD object
  127. */
  128. const EC_METHOD *EC_GFp_mont_method(void);
  129. /** Returns GFp methods using optimized methods for NIST recommended curves
  130. * \return EC_METHOD object
  131. */
  132. const EC_METHOD *EC_GFp_nist_method(void);
  133. /********************************************************************/
  134. /* EC_METHOD for curves over GF(2^m) */
  135. /********************************************************************/
  136. /** Returns the basic GF2m ec method
  137. * \return EC_METHOD object
  138. */
  139. const EC_METHOD *EC_GF2m_simple_method(void);
  140. /********************************************************************/
  141. /* EC_GROUP functions */
  142. /********************************************************************/
  143. /** Creates a new EC_GROUP object
  144. * \param meth EC_METHOD to use
  145. * \return newly created EC_GROUP object or NULL in case of an error.
  146. */
  147. EC_GROUP *EC_GROUP_new(const EC_METHOD *meth);
  148. /** Frees a EC_GROUP object
  149. * \param group EC_GROUP object to be freed.
  150. */
  151. void EC_GROUP_free(EC_GROUP *group);
  152. /** Clears and frees a EC_GROUP object
  153. * \param group EC_GROUP object to be cleared and freed.
  154. */
  155. void EC_GROUP_clear_free(EC_GROUP *group);
  156. /** Copies EC_GROUP objects. Note: both EC_GROUPs must use the same EC_METHOD.
  157. * \param dst destination EC_GROUP object
  158. * \param src source EC_GROUP object
  159. * \return 1 on success and 0 if an error occurred.
  160. */
  161. int EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src);
  162. /** Creates a new EC_GROUP object and copies the copies the content
  163. * form src to the newly created EC_KEY object
  164. * \param src source EC_GROUP object
  165. * \return newly created EC_GROUP object or NULL in case of an error.
  166. */
  167. EC_GROUP *EC_GROUP_dup(const EC_GROUP *src);
  168. /** Returns the EC_METHOD of the EC_GROUP object.
  169. * \param group EC_GROUP object
  170. * \return EC_METHOD used in this EC_GROUP object.
  171. */
  172. const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group);
  173. /** Returns the field type of the EC_METHOD.
  174. * \param meth EC_METHOD object
  175. * \return NID of the underlying field type OID.
  176. */
  177. int EC_METHOD_get_field_type(const EC_METHOD *meth);
  178. /** Sets the generator and it's order/cofactor of a EC_GROUP object.
  179. * \param group EC_GROUP object
  180. * \param generator EC_POINT object with the generator.
  181. * \param order the order of the group generated by the generator.
  182. * \param cofactor the index of the sub-group generated by the generator
  183. * in the group of all points on the elliptic curve.
  184. * \return 1 on success and 0 if an error occured
  185. */
  186. int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor);
  187. /** Returns the generator of a EC_GROUP object.
  188. * \param group EC_GROUP object
  189. * \return the currently used generator (possibly NULL).
  190. */
  191. const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group);
  192. /** Gets the order of a EC_GROUP
  193. * \param group EC_GROUP object
  194. * \param order BIGNUM to which the order is copied
  195. * \param ctx BN_CTX object (optional)
  196. * \return 1 on success and 0 if an error occured
  197. */
  198. int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx);
  199. /** Gets the cofactor of a EC_GROUP
  200. * \param group EC_GROUP object
  201. * \param cofactor BIGNUM to which the cofactor is copied
  202. * \param ctx BN_CTX object (optional)
  203. * \return 1 on success and 0 if an error occured
  204. */
  205. int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, BN_CTX *ctx);
  206. /** Sets the name of a EC_GROUP object
  207. * \param group EC_GROUP object
  208. * \param nid NID of the curve name OID
  209. */
  210. void EC_GROUP_set_curve_name(EC_GROUP *group, int nid);
  211. /** Returns the curve name of a EC_GROUP object
  212. * \param group EC_GROUP object
  213. * \return NID of the curve name OID or 0 if not set.
  214. */
  215. int EC_GROUP_get_curve_name(const EC_GROUP *group);
  216. void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag);
  217. int EC_GROUP_get_asn1_flag(const EC_GROUP *group);
  218. void EC_GROUP_set_point_conversion_form(EC_GROUP *, point_conversion_form_t);
  219. point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *);
  220. unsigned char *EC_GROUP_get0_seed(const EC_GROUP *);
  221. size_t EC_GROUP_get_seed_len(const EC_GROUP *);
  222. size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len);
  223. /** Sets the parameter of a ec over GFp defined by y^2 = x^3 + a*x + b
  224. * \param group EC_GROUP object
  225. * \param p BIGNUM with the prime number
  226. * \param a BIGNUM with parameter a of the equation
  227. * \param b BIGNUM with parameter b of the equation
  228. * \param ctx BN_CTX object (optional)
  229. * \return 1 on success and 0 if an error occured
  230. */
  231. int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
  232. /** Gets the parameter of the ec over GFp defined by y^2 = x^3 + a*x + b
  233. * \param group EC_GROUP object
  234. * \param p BIGNUM for the prime number
  235. * \param a BIGNUM for parameter a of the equation
  236. * \param b BIGNUM for parameter b of the equation
  237. * \param ctx BN_CTX object (optional)
  238. * \return 1 on success and 0 if an error occured
  239. */
  240. int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
  241. /** Sets the parameter of a ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b
  242. * \param group EC_GROUP object
  243. * \param p BIGNUM with the polynomial defining the underlying field
  244. * \param a BIGNUM with parameter a of the equation
  245. * \param b BIGNUM with parameter b of the equation
  246. * \param ctx BN_CTX object (optional)
  247. * \return 1 on success and 0 if an error occured
  248. */
  249. int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
  250. /** Gets the parameter of the ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b
  251. * \param group EC_GROUP object
  252. * \param p BIGNUM for the polynomial defining the underlying field
  253. * \param a BIGNUM for parameter a of the equation
  254. * \param b BIGNUM for parameter b of the equation
  255. * \param ctx BN_CTX object (optional)
  256. * \return 1 on success and 0 if an error occured
  257. */
  258. int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
  259. /** Returns the number of bits needed to represent a field element
  260. * \param group EC_GROUP object
  261. * \return number of bits needed to represent a field element
  262. */
  263. int EC_GROUP_get_degree(const EC_GROUP *group);
  264. /** Checks whether the parameter in the EC_GROUP define a valid ec group
  265. * \param group EC_GROUP object
  266. * \param ctx BN_CTX object (optional)
  267. * \return 1 if group is a valid ec group and 0 otherwise
  268. */
  269. int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx);
  270. /** Checks whether the discriminant of the elliptic curve is zero or not
  271. * \param group EC_GROUP object
  272. * \param ctx BN_CTX object (optional)
  273. * \return 1 if the discriminant is not zero and 0 otherwise
  274. */
  275. int EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx);
  276. /** Compares two EC_GROUP objects
  277. * \param a first EC_GROUP object
  278. * \param b second EC_GROUP object
  279. * \param ctx BN_CTX object (optional)
  280. * \return 0 if both groups are equal and 1 otherwise
  281. */
  282. int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx);
  283. /* EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*()
  284. * after choosing an appropriate EC_METHOD */
  285. /** Creates a new EC_GROUP object with the specified parameters defined
  286. * over GFp (defined by the equation y^2 = x^3 + a*x + b)
  287. * \param p BIGNUM with the prime number
  288. * \param a BIGNUM with the parameter a of the equation
  289. * \param b BIGNUM with the parameter b of the equation
  290. * \param ctx BN_CTX object (optional)
  291. * \return newly created EC_GROUP object with the specified parameters
  292. */
  293. EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
  294. /** Creates a new EC_GROUP object with the specified parameters defined
  295. * over GF2m (defined by the equation y^2 + x*y = x^3 + a*x^2 + b)
  296. * \param p BIGNUM with the polynomial defining the underlying field
  297. * \param a BIGNUM with the parameter a of the equation
  298. * \param b BIGNUM with the parameter b of the equation
  299. * \param ctx BN_CTX object (optional)
  300. * \return newly created EC_GROUP object with the specified parameters
  301. */
  302. EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
  303. /** Creates a EC_GROUP object with a curve specified by a NID
  304. * \param nid NID of the OID of the curve name
  305. * \return newly created EC_GROUP object with specified curve or NULL
  306. * if an error occurred
  307. */
  308. EC_GROUP *EC_GROUP_new_by_curve_name(int nid);
  309. /********************************************************************/
  310. /* handling of internal curves */
  311. /********************************************************************/
  312. typedef struct {
  313. int nid;
  314. const char *comment;
  315. } EC_builtin_curve;
  316. /* EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number
  317. * of all available curves or zero if a error occurred.
  318. * In case r ist not zero nitems EC_builtin_curve structures
  319. * are filled with the data of the first nitems internal groups */
  320. size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems);
  321. /********************************************************************/
  322. /* EC_POINT functions */
  323. /********************************************************************/
  324. /** Creates a new EC_POINT object for the specified EC_GROUP
  325. * \param group EC_GROUP the underlying EC_GROUP object
  326. * \return newly created EC_POINT object or NULL if an error occurred
  327. */
  328. EC_POINT *EC_POINT_new(const EC_GROUP *group);
  329. /** Frees a EC_POINT object
  330. * \param point EC_POINT object to be freed
  331. */
  332. void EC_POINT_free(EC_POINT *point);
  333. /** Clears and frees a EC_POINT object
  334. * \param point EC_POINT object to be cleared and freed
  335. */
  336. void EC_POINT_clear_free(EC_POINT *point);
  337. /** Copies EC_POINT object
  338. * \param dst destination EC_POINT object
  339. * \param src source EC_POINT object
  340. * \return 1 on success and 0 if an error occured
  341. */
  342. int EC_POINT_copy(EC_POINT *dst, const EC_POINT *src);
  343. /** Creates a new EC_POINT object and copies the content of the supplied
  344. * EC_POINT
  345. * \param src source EC_POINT object
  346. * \param group underlying the EC_GROUP object
  347. * \return newly created EC_POINT object or NULL if an error occurred
  348. */
  349. EC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group);
  350. /** Returns the EC_METHOD used in EC_POINT object
  351. * \param point EC_POINT object
  352. * \return the EC_METHOD used
  353. */
  354. const EC_METHOD *EC_POINT_method_of(const EC_POINT *point);
  355. /** Sets a point to infinity (neutral element)
  356. * \param group underlying EC_GROUP object
  357. * \param point EC_POINT to set to infinity
  358. * \return 1 on success and 0 if an error occured
  359. */
  360. int EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point);
  361. /** Sets the jacobian projective coordinates of a EC_POINT over GFp
  362. * \param group underlying EC_GROUP object
  363. * \param p EC_POINT object
  364. * \param x BIGNUM with the x-coordinate
  365. * \param y BIGNUM with the y-coordinate
  366. * \param z BIGNUM with the z-coordinate
  367. * \param ctx BN_CTX object (optional)
  368. * \return 1 on success and 0 if an error occured
  369. */
  370. int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
  371. const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *ctx);
  372. /** Gets the jacobian projective coordinates of a EC_POINT over GFp
  373. * \param group underlying EC_GROUP object
  374. * \param p EC_POINT object
  375. * \param x BIGNUM for the x-coordinate
  376. * \param y BIGNUM for the y-coordinate
  377. * \param z BIGNUM for the z-coordinate
  378. * \param ctx BN_CTX object (optional)
  379. * \return 1 on success and 0 if an error occured
  380. */
  381. int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group,
  382. const EC_POINT *p, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx);
  383. /** Sets the affine coordinates of a EC_POINT over GFp
  384. * \param group underlying EC_GROUP object
  385. * \param p EC_POINT object
  386. * \param x BIGNUM with the x-coordinate
  387. * \param y BIGNUM with the y-coordinate
  388. * \param ctx BN_CTX object (optional)
  389. * \return 1 on success and 0 if an error occured
  390. */
  391. int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
  392. const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx);
  393. /** Gets the affine coordinates of a EC_POINT over GFp
  394. * \param group underlying EC_GROUP object
  395. * \param p EC_POINT object
  396. * \param x BIGNUM for the x-coordinate
  397. * \param y BIGNUM for the y-coordinate
  398. * \param ctx BN_CTX object (optional)
  399. * \return 1 on success and 0 if an error occured
  400. */
  401. int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,
  402. const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx);
  403. /** Sets the x9.62 compressed coordinates of a EC_POINT over GFp
  404. * \param group underlying EC_GROUP object
  405. * \param p EC_POINT object
  406. * \param x BIGNUM with x-coordinate
  407. * \param y_bit integer with the y-Bit (either 0 or 1)
  408. * \param ctx BN_CTX object (optional)
  409. * \return 1 on success and 0 if an error occured
  410. */
  411. int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
  412. const BIGNUM *x, int y_bit, BN_CTX *ctx);
  413. /** Sets the affine coordinates of a EC_POINT over GF2m
  414. * \param group underlying EC_GROUP object
  415. * \param p EC_POINT object
  416. * \param x BIGNUM with the x-coordinate
  417. * \param y BIGNUM with the y-coordinate
  418. * \param ctx BN_CTX object (optional)
  419. * \return 1 on success and 0 if an error occured
  420. */
  421. int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p,
  422. const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx);
  423. /** Gets the affine coordinates of a EC_POINT over GF2m
  424. * \param group underlying EC_GROUP object
  425. * \param p EC_POINT object
  426. * \param x BIGNUM for the x-coordinate
  427. * \param y BIGNUM for the y-coordinate
  428. * \param ctx BN_CTX object (optional)
  429. * \return 1 on success and 0 if an error occured
  430. */
  431. int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group,
  432. const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx);
  433. /** Sets the x9.62 compressed coordinates of a EC_POINT over GF2m
  434. * \param group underlying EC_GROUP object
  435. * \param p EC_POINT object
  436. * \param x BIGNUM with x-coordinate
  437. * \param y_bit integer with the y-Bit (either 0 or 1)
  438. * \param ctx BN_CTX object (optional)
  439. * \return 1 on success and 0 if an error occured
  440. */
  441. int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p,
  442. const BIGNUM *x, int y_bit, BN_CTX *ctx);
  443. /** Encodes a EC_POINT object to a octet string
  444. * \param group underlying EC_GROUP object
  445. * \param p EC_POINT object
  446. * \param form point conversion form
  447. * \param buf memory buffer for the result. If NULL the function returns
  448. * required buffer size.
  449. * \param len length of the memory buffer
  450. * \param ctx BN_CTX object (optional)
  451. * \return the length of the encoded octet string or 0 if an error occurred
  452. */
  453. size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p,
  454. point_conversion_form_t form,
  455. unsigned char *buf, size_t len, BN_CTX *ctx);
  456. /** Decodes a EC_POINT from a octet string
  457. * \param group underlying EC_GROUP object
  458. * \param p EC_POINT object
  459. * \param buf memory buffer with the encoded ec point
  460. * \param len length of the encoded ec point
  461. * \param ctx BN_CTX object (optional)
  462. * \return 1 on success and 0 if an error occured
  463. */
  464. int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p,
  465. const unsigned char *buf, size_t len, BN_CTX *ctx);
  466. /* other interfaces to point2oct/oct2point: */
  467. BIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *,
  468. point_conversion_form_t form, BIGNUM *, BN_CTX *);
  469. EC_POINT *EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *,
  470. EC_POINT *, BN_CTX *);
  471. char *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *,
  472. point_conversion_form_t form, BN_CTX *);
  473. EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *,
  474. EC_POINT *, BN_CTX *);
  475. /********************************************************************/
  476. /* functions for doing EC_POINT arithmetic */
  477. /********************************************************************/
  478. /** Computes the sum of two EC_POINT
  479. * \param group underlying EC_GROUP object
  480. * \param r EC_POINT object for the result (r = a + b)
  481. * \param a EC_POINT object with the first summand
  482. * \param b EC_POINT object with the second summand
  483. * \param ctx BN_CTX object (optional)
  484. * \return 1 on success and 0 if an error occured
  485. */
  486. int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx);
  487. /** Computes the double of a EC_POINT
  488. * \param group underlying EC_GROUP object
  489. * \param r EC_POINT object for the result (r = 2 * a)
  490. * \param a EC_POINT object
  491. * \param ctx BN_CTX object (optional)
  492. * \return 1 on success and 0 if an error occured
  493. */
  494. int EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx);
  495. /** Computes the inverse of a EC_POINT
  496. * \param group underlying EC_GROUP object
  497. * \param a EC_POINT object to be inverted (it's used for the result as well)
  498. * \param ctx BN_CTX object (optional)
  499. * \return 1 on success and 0 if an error occured
  500. */
  501. int EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx);
  502. /** Checks whether the point is the neutral element of the group
  503. * \param group the underlying EC_GROUP object
  504. * \param p EC_POINT object
  505. * \return 1 if the point is the neutral element and 0 otherwise
  506. */
  507. int EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *p);
  508. /** Checks whether the point is on the curve
  509. * \param group underlying EC_GROUP object
  510. * \param point EC_POINT object to check
  511. * \param ctx BN_CTX object (optional)
  512. * \return 1 if point if on the curve and 0 otherwise
  513. */
  514. int EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx);
  515. /** Compares two EC_POINTs
  516. * \param group underlying EC_GROUP object
  517. * \param a first EC_POINT object
  518. * \param b second EC_POINT object
  519. * \param ctx BN_CTX object (optional)
  520. * \return 0 if both points are equal and a value != 0 otherwise
  521. */
  522. int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx);
  523. int EC_POINT_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *);
  524. int EC_POINTs_make_affine(const EC_GROUP *, size_t num, EC_POINT *[], BN_CTX *);
  525. /** Computes r = generator * n sum_{i=0}^num p[i] * m[i]
  526. * \param group underlying EC_GROUP object
  527. * \param r EC_POINT object for the result
  528. * \param n BIGNUM with the multiplier for the group generator (optional)
  529. * \param num number futher summands
  530. * \param p array of size num of EC_POINT objects
  531. * \param m array of size num of BIGNUM objects
  532. * \param ctx BN_CTX object (optional)
  533. * \return 1 on success and 0 if an error occured
  534. */
  535. int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, size_t num, const EC_POINT *p[], const BIGNUM *m[], BN_CTX *ctx);
  536. /** Computes r = generator * n + q * m
  537. * \param group underlying EC_GROUP object
  538. * \param r EC_POINT object for the result
  539. * \param n BIGNUM with the multiplier for the group generator (optional)
  540. * \param q EC_POINT object with the first factor of the second summand
  541. * \param m BIGNUM with the second factor of the second summand
  542. * \param ctx BN_CTX object (optional)
  543. * \return 1 on success and 0 if an error occured
  544. */
  545. int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx);
  546. /** Stores multiples of generator for faster point multiplication
  547. * \param group EC_GROUP object
  548. * \param ctx BN_CTX object (optional)
  549. * \return 1 on success and 0 if an error occured
  550. */
  551. int EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx);
  552. /** Reports whether a precomputation has been done
  553. * \param group EC_GROUP object
  554. * \return 1 if a pre-computation has been done and 0 otherwise
  555. */
  556. int EC_GROUP_have_precompute_mult(const EC_GROUP *group);
  557. /********************************************************************/
  558. /* ASN1 stuff */
  559. /********************************************************************/
  560. /* EC_GROUP_get_basis_type() returns the NID of the basis type
  561. * used to represent the field elements */
  562. int EC_GROUP_get_basis_type(const EC_GROUP *);
  563. int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k);
  564. int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1,
  565. unsigned int *k2, unsigned int *k3);
  566. #define OPENSSL_EC_NAMED_CURVE 0x001
  567. typedef struct ecpk_parameters_st ECPKPARAMETERS;
  568. EC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len);
  569. int i2d_ECPKParameters(const EC_GROUP *, unsigned char **out);
  570. #define d2i_ECPKParameters_bio(bp,x) ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x)
  571. #define i2d_ECPKParameters_bio(bp,x) ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x)
  572. #define d2i_ECPKParameters_fp(fp,x) (EC_GROUP *)ASN1_d2i_fp(NULL, \
  573. (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x))
  574. #define i2d_ECPKParameters_fp(fp,x) ASN1_i2d_fp(i2d_ECPKParameters,(fp), \
  575. (unsigned char *)(x))
  576. #ifndef OPENSSL_NO_BIO
  577. int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off);
  578. #endif
  579. #ifndef OPENSSL_NO_FP_API
  580. int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off);
  581. #endif
  582. /********************************************************************/
  583. /* EC_KEY functions */
  584. /********************************************************************/
  585. typedef struct ec_key_st EC_KEY;
  586. /* some values for the encoding_flag */
  587. #define EC_PKEY_NO_PARAMETERS 0x001
  588. #define EC_PKEY_NO_PUBKEY 0x002
  589. /** Creates a new EC_KEY object.
  590. * \return EC_KEY object or NULL if an error occurred.
  591. */
  592. EC_KEY *EC_KEY_new(void);
  593. /** Creates a new EC_KEY object using a named curve as underlying
  594. * EC_GROUP object.
  595. * \param nid NID of the named curve.
  596. * \return EC_KEY object or NULL if an error occurred.
  597. */
  598. EC_KEY *EC_KEY_new_by_curve_name(int nid);
  599. /** Frees a EC_KEY object.
  600. * \param key EC_KEY object to be freed.
  601. */
  602. void EC_KEY_free(EC_KEY *key);
  603. /** Copies a EC_KEY object.
  604. * \param dst destination EC_KEY object
  605. * \param src src EC_KEY object
  606. * \return dst or NULL if an error occurred.
  607. */
  608. EC_KEY *EC_KEY_copy(EC_KEY *dst, const EC_KEY *src);
  609. /** Creates a new EC_KEY object and copies the content from src to it.
  610. * \param src the source EC_KEY object
  611. * \return newly created EC_KEY object or NULL if an error occurred.
  612. */
  613. EC_KEY *EC_KEY_dup(const EC_KEY *src);
  614. /** Increases the internal reference count of a EC_KEY object.
  615. * \param key EC_KEY object
  616. * \return 1 on success and 0 if an error occurred.
  617. */
  618. int EC_KEY_up_ref(EC_KEY *key);
  619. /** Returns the EC_GROUP object of a EC_KEY object
  620. * \param key EC_KEY object
  621. * \return the EC_GROUP object (possibly NULL).
  622. */
  623. const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key);
  624. /** Sets the EC_GROUP of a EC_KEY object.
  625. * \param key EC_KEY object
  626. * \param group EC_GROUP to use in the EC_KEY object (note: the EC_KEY
  627. * object will use an own copy of the EC_GROUP).
  628. * \return 1 on success and 0 if an error occurred.
  629. */
  630. int EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group);
  631. /** Returns the private key of a EC_KEY object.
  632. * \param key EC_KEY object
  633. * \return a BIGNUM with the private key (possibly NULL).
  634. */
  635. const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key);
  636. /** Sets the private key of a EC_KEY object.
  637. * \param key EC_KEY object
  638. * \param prv BIGNUM with the private key (note: the EC_KEY object
  639. * will use an own copy of the BIGNUM).
  640. * \return 1 on success and 0 if an error occurred.
  641. */
  642. int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv);
  643. /** Returns the public key of a EC_KEY object.
  644. * \param key the EC_KEY object
  645. * \return a EC_POINT object with the public key (possibly NULL)
  646. */
  647. const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key);
  648. /** Sets the public key of a EC_KEY object.
  649. * \param key EC_KEY object
  650. * \param pub EC_POINT object with the public key (note: the EC_KEY object
  651. * will use an own copy of the EC_POINT object).
  652. * \return 1 on success and 0 if an error occurred.
  653. */
  654. int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub);
  655. unsigned EC_KEY_get_enc_flags(const EC_KEY *key);
  656. void EC_KEY_set_enc_flags(EC_KEY *, unsigned int);
  657. point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *);
  658. void EC_KEY_set_conv_form(EC_KEY *, point_conversion_form_t);
  659. /* functions to set/get method specific data */
  660. void *EC_KEY_get_key_method_data(EC_KEY *,
  661. void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *));
  662. void EC_KEY_insert_key_method_data(EC_KEY *, void *data,
  663. void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *));
  664. /* wrapper functions for the underlying EC_GROUP object */
  665. void EC_KEY_set_asn1_flag(EC_KEY *, int);
  666. /** Creates a table of pre-computed multiples of the generator to
  667. * accelerate further EC_KEY operations.
  668. * \param key EC_KEY object
  669. * \param ctx BN_CTX object (optional)
  670. * \return 1 on success and 0 if an error occurred.
  671. */
  672. int EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx);
  673. /** Creates a new ec private (and optional a new public) key.
  674. * \param key EC_KEY object
  675. * \return 1 on success and 0 if an error occurred.
  676. */
  677. int EC_KEY_generate_key(EC_KEY *key);
  678. /** Verifies that a private and/or public key is valid.
  679. * \param key the EC_KEY object
  680. * \return 1 on success and 0 otherwise.
  681. */
  682. int EC_KEY_check_key(const EC_KEY *key);
  683. /********************************************************************/
  684. /* de- and encoding functions for SEC1 ECPrivateKey */
  685. /********************************************************************/
  686. /** Decodes a private key from a memory buffer.
  687. * \param key a pointer to a EC_KEY object which should be used (or NULL)
  688. * \param in pointer to memory with the DER encoded private key
  689. * \param len length of the DER encoded private key
  690. * \return the decoded private key or NULL if an error occurred.
  691. */
  692. EC_KEY *d2i_ECPrivateKey(EC_KEY **key, const unsigned char **in, long len);
  693. /** Encodes a private key object and stores the result in a buffer.
  694. * \param key the EC_KEY object to encode
  695. * \param out the buffer for the result (if NULL the function returns number
  696. * of bytes needed).
  697. * \return 1 on success and 0 if an error occurred.
  698. */
  699. int i2d_ECPrivateKey(EC_KEY *key, unsigned char **out);
  700. /********************************************************************/
  701. /* de- and encoding functions for EC parameters */
  702. /********************************************************************/
  703. /** Decodes ec parameter from a memory buffer.
  704. * \param key a pointer to a EC_KEY object which should be used (or NULL)
  705. * \param in pointer to memory with the DER encoded ec parameters
  706. * \param len length of the DER encoded ec parameters
  707. * \return a EC_KEY object with the decoded parameters or NULL if an error
  708. * occurred.
  709. */
  710. EC_KEY *d2i_ECParameters(EC_KEY **key, const unsigned char **in, long len);
  711. /** Encodes ec parameter and stores the result in a buffer.
  712. * \param key the EC_KEY object with ec paramters to encode
  713. * \param out the buffer for the result (if NULL the function returns number
  714. * of bytes needed).
  715. * \return 1 on success and 0 if an error occurred.
  716. */
  717. int i2d_ECParameters(EC_KEY *key, unsigned char **out);
  718. /********************************************************************/
  719. /* de- and encoding functions for EC public key */
  720. /* (octet string, not DER -- hence 'o2i' and 'i2o') */
  721. /********************************************************************/
  722. /** Decodes a ec public key from a octet string.
  723. * \param key a pointer to a EC_KEY object which should be used
  724. * \param in memory buffer with the encoded public key
  725. * \param len length of the encoded public key
  726. * \return EC_KEY object with decoded public key or NULL if an error
  727. * occurred.
  728. */
  729. EC_KEY *o2i_ECPublicKey(EC_KEY **key, const unsigned char **in, long len);
  730. /** Encodes a ec public key in an octet string.
  731. * \param key the EC_KEY object with the public key
  732. * \param out the buffer for the result (if NULL the function returns number
  733. * of bytes needed).
  734. * \return 1 on success and 0 if an error occurred
  735. */
  736. int i2o_ECPublicKey(EC_KEY *key, unsigned char **out);
  737. #ifndef OPENSSL_NO_BIO
  738. /** Prints out the ec parameters on human readable form.
  739. * \param bp BIO object to which the information is printed
  740. * \param key EC_KEY object
  741. * \return 1 on success and 0 if an error occurred
  742. */
  743. int ECParameters_print(BIO *bp, const EC_KEY *key);
  744. /** Prints out the contents of a EC_KEY object
  745. * \param bp BIO object to which the information is printed
  746. * \param key EC_KEY object
  747. * \param off line offset
  748. * \return 1 on success and 0 if an error occurred
  749. */
  750. int EC_KEY_print(BIO *bp, const EC_KEY *key, int off);
  751. #endif
  752. #ifndef OPENSSL_NO_FP_API
  753. /** Prints out the ec parameters on human readable form.
  754. * \param fp file descriptor to which the information is printed
  755. * \param key EC_KEY object
  756. * \return 1 on success and 0 if an error occurred
  757. */
  758. int ECParameters_print_fp(FILE *fp, const EC_KEY *key);
  759. /** Prints out the contents of a EC_KEY object
  760. * \param fp file descriptor to which the information is printed
  761. * \param key EC_KEY object
  762. * \param off line offset
  763. * \return 1 on success and 0 if an error occurred
  764. */
  765. int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off);
  766. #endif
  767. #define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x)
  768. #ifndef __cplusplus
  769. #if defined(__SUNPRO_C)
  770. # if __SUNPRO_C >= 0x520
  771. # pragma error_messages (default,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE)
  772. # endif
  773. # endif
  774. #endif
  775. #define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid) \
  776. EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, EVP_PKEY_OP_PARAMGEN, \
  777. EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL)
  778. #define EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID (EVP_PKEY_ALG_CTRL + 1)
  779. /* BEGIN ERROR CODES */
  780. /* The following lines are auto generated by the script mkerr.pl. Any changes
  781. * made after this point may be overwritten when the script is next run.
  782. */
  783. void ERR_load_EC_strings(void);
  784. /* Error codes for the EC functions. */
  785. /* Function codes. */
  786. #define EC_F_COMPUTE_WNAF 143
  787. #define EC_F_D2I_ECPARAMETERS 144
  788. #define EC_F_D2I_ECPKPARAMETERS 145
  789. #define EC_F_D2I_ECPRIVATEKEY 146
  790. #define EC_F_ECKEY_PARAM2TYPE 196
  791. #define EC_F_ECKEY_PARAM_DECODE 212
  792. #define EC_F_ECKEY_PRIV_DECODE 213
  793. #define EC_F_ECKEY_PRIV_ENCODE 214
  794. #define EC_F_ECKEY_PUB_DECODE 215
  795. #define EC_F_ECKEY_PUB_ENCODE 216
  796. #define EC_F_ECKEY_TYPE2PARAM 220
  797. #define EC_F_ECPARAMETERS_PRINT 147
  798. #define EC_F_ECPARAMETERS_PRINT_FP 148
  799. #define EC_F_ECPKPARAMETERS_PRINT 149
  800. #define EC_F_ECPKPARAMETERS_PRINT_FP 150
  801. #define EC_F_ECP_NIST_MOD_192 203
  802. #define EC_F_ECP_NIST_MOD_224 204
  803. #define EC_F_ECP_NIST_MOD_256 205
  804. #define EC_F_ECP_NIST_MOD_521 206
  805. #define EC_F_EC_ASN1_GROUP2CURVE 153
  806. #define EC_F_EC_ASN1_GROUP2FIELDID 154
  807. #define EC_F_EC_ASN1_GROUP2PARAMETERS 155
  808. #define EC_F_EC_ASN1_GROUP2PKPARAMETERS 156
  809. #define EC_F_EC_ASN1_PARAMETERS2GROUP 157
  810. #define EC_F_EC_ASN1_PKPARAMETERS2GROUP 158
  811. #define EC_F_EC_EX_DATA_SET_DATA 211
  812. #define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY 208
  813. #define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT 159
  814. #define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE 195
  815. #define EC_F_EC_GF2M_SIMPLE_OCT2POINT 160
  816. #define EC_F_EC_GF2M_SIMPLE_POINT2OCT 161
  817. #define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 162
  818. #define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 163
  819. #define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES 164
  820. #define EC_F_EC_GFP_MONT_FIELD_DECODE 133
  821. #define EC_F_EC_GFP_MONT_FIELD_ENCODE 134
  822. #define EC_F_EC_GFP_MONT_FIELD_MUL 131
  823. #define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE 209
  824. #define EC_F_EC_GFP_MONT_FIELD_SQR 132
  825. #define EC_F_EC_GFP_MONT_GROUP_SET_CURVE 189
  826. #define EC_F_EC_GFP_MONT_GROUP_SET_CURVE_GFP 135
  827. #define EC_F_EC_GFP_NIST_FIELD_MUL 200
  828. #define EC_F_EC_GFP_NIST_FIELD_SQR 201
  829. #define EC_F_EC_GFP_NIST_GROUP_SET_CURVE 202
  830. #define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT 165
  831. #define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE 166
  832. #define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE_GFP 100
  833. #define EC_F_EC_GFP_SIMPLE_GROUP_SET_GENERATOR 101
  834. #define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE 102
  835. #define EC_F_EC_GFP_SIMPLE_OCT2POINT 103
  836. #define EC_F_EC_GFP_SIMPLE_POINT2OCT 104
  837. #define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE 137
  838. #define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES 167
  839. #define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP 105
  840. #define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES 168
  841. #define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES_GFP 128
  842. #define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES 169
  843. #define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP 129
  844. #define EC_F_EC_GROUP_CHECK 170
  845. #define EC_F_EC_GROUP_CHECK_DISCRIMINANT 171
  846. #define EC_F_EC_GROUP_COPY 106
  847. #define EC_F_EC_GROUP_GET0_GENERATOR 139
  848. #define EC_F_EC_GROUP_GET_COFACTOR 140
  849. #define EC_F_EC_GROUP_GET_CURVE_GF2M 172
  850. #define EC_F_EC_GROUP_GET_CURVE_GFP 130
  851. #define EC_F_EC_GROUP_GET_DEGREE 173
  852. #define EC_F_EC_GROUP_GET_ORDER 141
  853. #define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS 193
  854. #define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS 194
  855. #define EC_F_EC_GROUP_NEW 108
  856. #define EC_F_EC_GROUP_NEW_BY_CURVE_NAME 174
  857. #define EC_F_EC_GROUP_NEW_FROM_DATA 175
  858. #define EC_F_EC_GROUP_PRECOMPUTE_MULT 142
  859. #define EC_F_EC_GROUP_SET_CURVE_GF2M 176
  860. #define EC_F_EC_GROUP_SET_CURVE_GFP 109
  861. #define EC_F_EC_GROUP_SET_EXTRA_DATA 110
  862. #define EC_F_EC_GROUP_SET_GENERATOR 111
  863. #define EC_F_EC_KEY_CHECK_KEY 177
  864. #define EC_F_EC_KEY_COPY 178
  865. #define EC_F_EC_KEY_GENERATE_KEY 179
  866. #define EC_F_EC_KEY_NEW 182
  867. #define EC_F_EC_KEY_PRINT 180
  868. #define EC_F_EC_KEY_PRINT_FP 181
  869. #define EC_F_EC_POINTS_MAKE_AFFINE 136
  870. #define EC_F_EC_POINTS_MUL 138
  871. #define EC_F_EC_POINT_ADD 112
  872. #define EC_F_EC_POINT_CMP 113
  873. #define EC_F_EC_POINT_COPY 114
  874. #define EC_F_EC_POINT_DBL 115
  875. #define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M 183
  876. #define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP 116
  877. #define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP 117
  878. #define EC_F_EC_POINT_INVERT 210
  879. #define EC_F_EC_POINT_IS_AT_INFINITY 118
  880. #define EC_F_EC_POINT_IS_ON_CURVE 119
  881. #define EC_F_EC_POINT_MAKE_AFFINE 120
  882. #define EC_F_EC_POINT_MUL 184
  883. #define EC_F_EC_POINT_NEW 121
  884. #define EC_F_EC_POINT_OCT2POINT 122
  885. #define EC_F_EC_POINT_POINT2OCT 123
  886. #define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M 185
  887. #define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP 124
  888. #define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M 186
  889. #define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP 125
  890. #define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP 126
  891. #define EC_F_EC_POINT_SET_TO_INFINITY 127
  892. #define EC_F_EC_PRE_COMP_DUP 207
  893. #define EC_F_EC_WNAF_MUL 187
  894. #define EC_F_EC_WNAF_PRECOMPUTE_MULT 188
  895. #define EC_F_I2D_ECPARAMETERS 190
  896. #define EC_F_I2D_ECPKPARAMETERS 191
  897. #define EC_F_I2D_ECPRIVATEKEY 192
  898. #define EC_F_I2O_ECPUBLICKEY 151
  899. #define EC_F_O2I_ECPUBLICKEY 152
  900. #define EC_F_PKEY_EC_CTRL 197
  901. #define EC_F_PKEY_EC_CTRL_STR 198
  902. #define EC_F_PKEY_EC_DERIVE 217
  903. #define EC_F_PKEY_EC_KEYGEN 199
  904. #define EC_F_PKEY_EC_PARAMGEN 219
  905. #define EC_F_PKEY_EC_SIGN 218
  906. /* Reason codes. */
  907. #define EC_R_ASN1_ERROR 115
  908. #define EC_R_ASN1_UNKNOWN_FIELD 116
  909. #define EC_R_BUFFER_TOO_SMALL 100
  910. #define EC_R_D2I_ECPKPARAMETERS_FAILURE 117
  911. #define EC_R_DECODE_ERROR 137
  912. #define EC_R_DISCRIMINANT_IS_ZERO 118
  913. #define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 119
  914. #define EC_R_GROUP2PKPARAMETERS_FAILURE 120
  915. #define EC_R_I2D_ECPKPARAMETERS_FAILURE 121
  916. #define EC_R_INCOMPATIBLE_OBJECTS 101
  917. #define EC_R_INVALID_ARGUMENT 112
  918. #define EC_R_INVALID_COMPRESSED_POINT 110
  919. #define EC_R_INVALID_COMPRESSION_BIT 109
  920. #define EC_R_INVALID_CURVE 132
  921. #define EC_R_INVALID_DIGEST_TYPE 138
  922. #define EC_R_INVALID_ENCODING 102
  923. #define EC_R_INVALID_FIELD 103
  924. #define EC_R_INVALID_FORM 104
  925. #define EC_R_INVALID_GROUP_ORDER 122
  926. #define EC_R_INVALID_PRIVATE_KEY 123
  927. #define EC_R_KEYS_NOT_SET 140
  928. #define EC_R_MISSING_PARAMETERS 124
  929. #define EC_R_MISSING_PRIVATE_KEY 125
  930. #define EC_R_NOT_A_NIST_PRIME 135
  931. #define EC_R_NOT_A_SUPPORTED_NIST_PRIME 136
  932. #define EC_R_NOT_IMPLEMENTED 126
  933. #define EC_R_NOT_INITIALIZED 111
  934. #define EC_R_NO_FIELD_MOD 133
  935. #define EC_R_NO_PARAMETERS_SET 139
  936. #define EC_R_PASSED_NULL_PARAMETER 134
  937. #define EC_R_PKPARAMETERS2GROUP_FAILURE 127
  938. #define EC_R_POINT_AT_INFINITY 106
  939. #define EC_R_POINT_IS_NOT_ON_CURVE 107
  940. #define EC_R_SLOT_FULL 108
  941. #define EC_R_UNDEFINED_GENERATOR 113
  942. #define EC_R_UNDEFINED_ORDER 128
  943. #define EC_R_UNKNOWN_GROUP 129
  944. #define EC_R_UNKNOWN_ORDER 114
  945. #define EC_R_UNSUPPORTED_FIELD 131
  946. #define EC_R_WRONG_ORDER 130
  947. #ifdef __cplusplus
  948. }
  949. #endif
  950. #endif