ec.h 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159
  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. #ifndef OPENSSL_ECC_MAX_FIELD_BITS
  94. # define OPENSSL_ECC_MAX_FIELD_BITS 661
  95. #endif
  96. /** Enum for the point conversion form as defined in X9.62 (ECDSA)
  97. * for the encoding of a elliptic curve point (x,y) */
  98. typedef enum {
  99. /** the point is encoded as z||x, where the octet z specifies
  100. * which solution of the quadratic equation y is */
  101. POINT_CONVERSION_COMPRESSED = 2,
  102. /** the point is encoded as z||x||y, where z is the octet 0x02 */
  103. POINT_CONVERSION_UNCOMPRESSED = 4,
  104. /** the point is encoded as z||x||y, where the octet z specifies
  105. * which solution of the quadratic equation y is */
  106. POINT_CONVERSION_HYBRID = 6
  107. } point_conversion_form_t;
  108. typedef struct ec_method_st EC_METHOD;
  109. typedef struct ec_group_st
  110. /*
  111. EC_METHOD *meth;
  112. -- field definition
  113. -- curve coefficients
  114. -- optional generator with associated information (order, cofactor)
  115. -- optional extra data (precomputed table for fast computation of multiples of generator)
  116. -- ASN1 stuff
  117. */
  118. EC_GROUP;
  119. typedef struct ec_point_st EC_POINT;
  120. /********************************************************************/
  121. /* EC_METHODs for curves over GF(p) */
  122. /********************************************************************/
  123. /** Returns the basic GFp ec methods which provides the basis for the
  124. * optimized methods.
  125. * \return EC_METHOD object
  126. */
  127. const EC_METHOD *EC_GFp_simple_method(void);
  128. /** Returns GFp methods using montgomery multiplication.
  129. * \return EC_METHOD object
  130. */
  131. const EC_METHOD *EC_GFp_mont_method(void);
  132. /** Returns GFp methods using optimized methods for NIST recommended curves
  133. * \return EC_METHOD object
  134. */
  135. const EC_METHOD *EC_GFp_nist_method(void);
  136. #ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
  137. /** Returns 64-bit optimized methods for nistp224
  138. * \return EC_METHOD object
  139. */
  140. const EC_METHOD *EC_GFp_nistp224_method(void);
  141. /** Returns 64-bit optimized methods for nistp256
  142. * \return EC_METHOD object
  143. */
  144. const EC_METHOD *EC_GFp_nistp256_method(void);
  145. /** Returns 64-bit optimized methods for nistp521
  146. * \return EC_METHOD object
  147. */
  148. const EC_METHOD *EC_GFp_nistp521_method(void);
  149. #endif
  150. #ifndef OPENSSL_NO_EC2M
  151. /********************************************************************/
  152. /* EC_METHOD for curves over GF(2^m) */
  153. /********************************************************************/
  154. /** Returns the basic GF2m ec method
  155. * \return EC_METHOD object
  156. */
  157. const EC_METHOD *EC_GF2m_simple_method(void);
  158. #endif
  159. /********************************************************************/
  160. /* EC_GROUP functions */
  161. /********************************************************************/
  162. /** Creates a new EC_GROUP object
  163. * \param meth EC_METHOD to use
  164. * \return newly created EC_GROUP object or NULL in case of an error.
  165. */
  166. EC_GROUP *EC_GROUP_new(const EC_METHOD *meth);
  167. /** Frees a EC_GROUP object
  168. * \param group EC_GROUP object to be freed.
  169. */
  170. void EC_GROUP_free(EC_GROUP *group);
  171. /** Clears and frees a EC_GROUP object
  172. * \param group EC_GROUP object to be cleared and freed.
  173. */
  174. void EC_GROUP_clear_free(EC_GROUP *group);
  175. /** Copies EC_GROUP objects. Note: both EC_GROUPs must use the same EC_METHOD.
  176. * \param dst destination EC_GROUP object
  177. * \param src source EC_GROUP object
  178. * \return 1 on success and 0 if an error occurred.
  179. */
  180. int EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src);
  181. /** Creates a new EC_GROUP object and copies the copies the content
  182. * form src to the newly created EC_KEY object
  183. * \param src source EC_GROUP object
  184. * \return newly created EC_GROUP object or NULL in case of an error.
  185. */
  186. EC_GROUP *EC_GROUP_dup(const EC_GROUP *src);
  187. /** Returns the EC_METHOD of the EC_GROUP object.
  188. * \param group EC_GROUP object
  189. * \return EC_METHOD used in this EC_GROUP object.
  190. */
  191. const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group);
  192. /** Returns the field type of the EC_METHOD.
  193. * \param meth EC_METHOD object
  194. * \return NID of the underlying field type OID.
  195. */
  196. int EC_METHOD_get_field_type(const EC_METHOD *meth);
  197. /** Sets the generator and it's order/cofactor of a EC_GROUP object.
  198. * \param group EC_GROUP object
  199. * \param generator EC_POINT object with the generator.
  200. * \param order the order of the group generated by the generator.
  201. * \param cofactor the index of the sub-group generated by the generator
  202. * in the group of all points on the elliptic curve.
  203. * \return 1 on success and 0 if an error occured
  204. */
  205. int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor);
  206. /** Returns the generator of a EC_GROUP object.
  207. * \param group EC_GROUP object
  208. * \return the currently used generator (possibly NULL).
  209. */
  210. const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group);
  211. /** Gets the order of a EC_GROUP
  212. * \param group EC_GROUP object
  213. * \param order BIGNUM to which the order is copied
  214. * \param ctx BN_CTX object (optional)
  215. * \return 1 on success and 0 if an error occured
  216. */
  217. int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx);
  218. /** Gets the cofactor of a EC_GROUP
  219. * \param group EC_GROUP object
  220. * \param cofactor BIGNUM to which the cofactor is copied
  221. * \param ctx BN_CTX object (optional)
  222. * \return 1 on success and 0 if an error occured
  223. */
  224. int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, BN_CTX *ctx);
  225. /** Sets the name of a EC_GROUP object
  226. * \param group EC_GROUP object
  227. * \param nid NID of the curve name OID
  228. */
  229. void EC_GROUP_set_curve_name(EC_GROUP *group, int nid);
  230. /** Returns the curve name of a EC_GROUP object
  231. * \param group EC_GROUP object
  232. * \return NID of the curve name OID or 0 if not set.
  233. */
  234. int EC_GROUP_get_curve_name(const EC_GROUP *group);
  235. void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag);
  236. int EC_GROUP_get_asn1_flag(const EC_GROUP *group);
  237. void EC_GROUP_set_point_conversion_form(EC_GROUP *, point_conversion_form_t);
  238. point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *);
  239. unsigned char *EC_GROUP_get0_seed(const EC_GROUP *);
  240. size_t EC_GROUP_get_seed_len(const EC_GROUP *);
  241. size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len);
  242. /** Sets the parameter of a ec over GFp defined by y^2 = x^3 + a*x + b
  243. * \param group EC_GROUP object
  244. * \param p BIGNUM with the prime number
  245. * \param a BIGNUM with parameter a of the equation
  246. * \param b BIGNUM with parameter b of the equation
  247. * \param ctx BN_CTX object (optional)
  248. * \return 1 on success and 0 if an error occured
  249. */
  250. int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
  251. /** Gets the parameter of the ec over GFp defined by y^2 = x^3 + a*x + b
  252. * \param group EC_GROUP object
  253. * \param p BIGNUM for the prime number
  254. * \param a BIGNUM for parameter a of the equation
  255. * \param b BIGNUM for parameter b of the equation
  256. * \param ctx BN_CTX object (optional)
  257. * \return 1 on success and 0 if an error occured
  258. */
  259. int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
  260. #ifndef OPENSSL_NO_EC2M
  261. /** Sets the parameter of a ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b
  262. * \param group EC_GROUP object
  263. * \param p BIGNUM with the polynomial defining the underlying field
  264. * \param a BIGNUM with parameter a of the equation
  265. * \param b BIGNUM with parameter b of the equation
  266. * \param ctx BN_CTX object (optional)
  267. * \return 1 on success and 0 if an error occured
  268. */
  269. int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
  270. /** Gets the parameter of the ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b
  271. * \param group EC_GROUP object
  272. * \param p BIGNUM for the polynomial defining the underlying field
  273. * \param a BIGNUM for parameter a of the equation
  274. * \param b BIGNUM for parameter b of the equation
  275. * \param ctx BN_CTX object (optional)
  276. * \return 1 on success and 0 if an error occured
  277. */
  278. int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
  279. #endif
  280. /** Returns the number of bits needed to represent a field element
  281. * \param group EC_GROUP object
  282. * \return number of bits needed to represent a field element
  283. */
  284. int EC_GROUP_get_degree(const EC_GROUP *group);
  285. /** Checks whether the parameter in the EC_GROUP define a valid ec group
  286. * \param group EC_GROUP object
  287. * \param ctx BN_CTX object (optional)
  288. * \return 1 if group is a valid ec group and 0 otherwise
  289. */
  290. int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx);
  291. /** Checks whether the discriminant of the elliptic curve is zero or not
  292. * \param group EC_GROUP object
  293. * \param ctx BN_CTX object (optional)
  294. * \return 1 if the discriminant is not zero and 0 otherwise
  295. */
  296. int EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx);
  297. /** Compares two EC_GROUP objects
  298. * \param a first EC_GROUP object
  299. * \param b second EC_GROUP object
  300. * \param ctx BN_CTX object (optional)
  301. * \return 0 if both groups are equal and 1 otherwise
  302. */
  303. int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx);
  304. /* EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*()
  305. * after choosing an appropriate EC_METHOD */
  306. /** Creates a new EC_GROUP object with the specified parameters defined
  307. * over GFp (defined by the equation y^2 = x^3 + a*x + b)
  308. * \param p BIGNUM with the prime number
  309. * \param a BIGNUM with the parameter a of the equation
  310. * \param b BIGNUM with the parameter b of the equation
  311. * \param ctx BN_CTX object (optional)
  312. * \return newly created EC_GROUP object with the specified parameters
  313. */
  314. EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
  315. #ifndef OPENSSL_NO_EC2M
  316. /** Creates a new EC_GROUP object with the specified parameters defined
  317. * over GF2m (defined by the equation y^2 + x*y = x^3 + a*x^2 + b)
  318. * \param p BIGNUM with the polynomial defining the underlying field
  319. * \param a BIGNUM with the parameter a of the equation
  320. * \param b BIGNUM with the parameter b of the equation
  321. * \param ctx BN_CTX object (optional)
  322. * \return newly created EC_GROUP object with the specified parameters
  323. */
  324. EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
  325. #endif
  326. /** Creates a EC_GROUP object with a curve specified by a NID
  327. * \param nid NID of the OID of the curve name
  328. * \return newly created EC_GROUP object with specified curve or NULL
  329. * if an error occurred
  330. */
  331. EC_GROUP *EC_GROUP_new_by_curve_name(int nid);
  332. /********************************************************************/
  333. /* handling of internal curves */
  334. /********************************************************************/
  335. typedef struct {
  336. int nid;
  337. const char *comment;
  338. } EC_builtin_curve;
  339. /* EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number
  340. * of all available curves or zero if a error occurred.
  341. * In case r ist not zero nitems EC_builtin_curve structures
  342. * are filled with the data of the first nitems internal groups */
  343. size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems);
  344. /********************************************************************/
  345. /* EC_POINT functions */
  346. /********************************************************************/
  347. /** Creates a new EC_POINT object for the specified EC_GROUP
  348. * \param group EC_GROUP the underlying EC_GROUP object
  349. * \return newly created EC_POINT object or NULL if an error occurred
  350. */
  351. EC_POINT *EC_POINT_new(const EC_GROUP *group);
  352. /** Frees a EC_POINT object
  353. * \param point EC_POINT object to be freed
  354. */
  355. void EC_POINT_free(EC_POINT *point);
  356. /** Clears and frees a EC_POINT object
  357. * \param point EC_POINT object to be cleared and freed
  358. */
  359. void EC_POINT_clear_free(EC_POINT *point);
  360. /** Copies EC_POINT object
  361. * \param dst destination EC_POINT object
  362. * \param src source EC_POINT object
  363. * \return 1 on success and 0 if an error occured
  364. */
  365. int EC_POINT_copy(EC_POINT *dst, const EC_POINT *src);
  366. /** Creates a new EC_POINT object and copies the content of the supplied
  367. * EC_POINT
  368. * \param src source EC_POINT object
  369. * \param group underlying the EC_GROUP object
  370. * \return newly created EC_POINT object or NULL if an error occurred
  371. */
  372. EC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group);
  373. /** Returns the EC_METHOD used in EC_POINT object
  374. * \param point EC_POINT object
  375. * \return the EC_METHOD used
  376. */
  377. const EC_METHOD *EC_POINT_method_of(const EC_POINT *point);
  378. /** Sets a point to infinity (neutral element)
  379. * \param group underlying EC_GROUP object
  380. * \param point EC_POINT to set to infinity
  381. * \return 1 on success and 0 if an error occured
  382. */
  383. int EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point);
  384. /** Sets the jacobian projective coordinates of a EC_POINT over GFp
  385. * \param group underlying EC_GROUP object
  386. * \param p EC_POINT object
  387. * \param x BIGNUM with the x-coordinate
  388. * \param y BIGNUM with the y-coordinate
  389. * \param z BIGNUM with the z-coordinate
  390. * \param ctx BN_CTX object (optional)
  391. * \return 1 on success and 0 if an error occured
  392. */
  393. int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
  394. const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *ctx);
  395. /** Gets the jacobian projective coordinates of a EC_POINT over GFp
  396. * \param group underlying EC_GROUP object
  397. * \param p EC_POINT object
  398. * \param x BIGNUM for the x-coordinate
  399. * \param y BIGNUM for the y-coordinate
  400. * \param z BIGNUM for the z-coordinate
  401. * \param ctx BN_CTX object (optional)
  402. * \return 1 on success and 0 if an error occured
  403. */
  404. int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group,
  405. const EC_POINT *p, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx);
  406. /** Sets the affine coordinates of a EC_POINT over GFp
  407. * \param group underlying EC_GROUP object
  408. * \param p EC_POINT object
  409. * \param x BIGNUM with the x-coordinate
  410. * \param y BIGNUM with the y-coordinate
  411. * \param ctx BN_CTX object (optional)
  412. * \return 1 on success and 0 if an error occured
  413. */
  414. int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
  415. const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx);
  416. /** Gets the affine coordinates of a EC_POINT over GFp
  417. * \param group underlying EC_GROUP object
  418. * \param p EC_POINT object
  419. * \param x BIGNUM for the x-coordinate
  420. * \param y BIGNUM for the y-coordinate
  421. * \param ctx BN_CTX object (optional)
  422. * \return 1 on success and 0 if an error occured
  423. */
  424. int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,
  425. const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx);
  426. /** Sets the x9.62 compressed coordinates of a EC_POINT over GFp
  427. * \param group underlying EC_GROUP object
  428. * \param p EC_POINT object
  429. * \param x BIGNUM with x-coordinate
  430. * \param y_bit integer with the y-Bit (either 0 or 1)
  431. * \param ctx BN_CTX object (optional)
  432. * \return 1 on success and 0 if an error occured
  433. */
  434. int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
  435. const BIGNUM *x, int y_bit, BN_CTX *ctx);
  436. #ifndef OPENSSL_NO_EC2M
  437. /** Sets the affine coordinates of a EC_POINT over GF2m
  438. * \param group underlying EC_GROUP object
  439. * \param p EC_POINT object
  440. * \param x BIGNUM with the x-coordinate
  441. * \param y BIGNUM with the y-coordinate
  442. * \param ctx BN_CTX object (optional)
  443. * \return 1 on success and 0 if an error occured
  444. */
  445. int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p,
  446. const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx);
  447. /** Gets the affine coordinates of a EC_POINT over GF2m
  448. * \param group underlying EC_GROUP object
  449. * \param p EC_POINT object
  450. * \param x BIGNUM for the x-coordinate
  451. * \param y BIGNUM for the y-coordinate
  452. * \param ctx BN_CTX object (optional)
  453. * \return 1 on success and 0 if an error occured
  454. */
  455. int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group,
  456. const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx);
  457. /** Sets the x9.62 compressed coordinates of a EC_POINT over GF2m
  458. * \param group underlying EC_GROUP object
  459. * \param p EC_POINT object
  460. * \param x BIGNUM with x-coordinate
  461. * \param y_bit integer with the y-Bit (either 0 or 1)
  462. * \param ctx BN_CTX object (optional)
  463. * \return 1 on success and 0 if an error occured
  464. */
  465. int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p,
  466. const BIGNUM *x, int y_bit, BN_CTX *ctx);
  467. #endif
  468. /** Encodes a EC_POINT object to a octet string
  469. * \param group underlying EC_GROUP object
  470. * \param p EC_POINT object
  471. * \param form point conversion form
  472. * \param buf memory buffer for the result. If NULL the function returns
  473. * required buffer size.
  474. * \param len length of the memory buffer
  475. * \param ctx BN_CTX object (optional)
  476. * \return the length of the encoded octet string or 0 if an error occurred
  477. */
  478. size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p,
  479. point_conversion_form_t form,
  480. unsigned char *buf, size_t len, BN_CTX *ctx);
  481. /** Decodes a EC_POINT from a octet string
  482. * \param group underlying EC_GROUP object
  483. * \param p EC_POINT object
  484. * \param buf memory buffer with the encoded ec point
  485. * \param len length of the encoded ec point
  486. * \param ctx BN_CTX object (optional)
  487. * \return 1 on success and 0 if an error occured
  488. */
  489. int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p,
  490. const unsigned char *buf, size_t len, BN_CTX *ctx);
  491. /* other interfaces to point2oct/oct2point: */
  492. BIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *,
  493. point_conversion_form_t form, BIGNUM *, BN_CTX *);
  494. EC_POINT *EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *,
  495. EC_POINT *, BN_CTX *);
  496. char *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *,
  497. point_conversion_form_t form, BN_CTX *);
  498. EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *,
  499. EC_POINT *, BN_CTX *);
  500. /********************************************************************/
  501. /* functions for doing EC_POINT arithmetic */
  502. /********************************************************************/
  503. /** Computes the sum of two EC_POINT
  504. * \param group underlying EC_GROUP object
  505. * \param r EC_POINT object for the result (r = a + b)
  506. * \param a EC_POINT object with the first summand
  507. * \param b EC_POINT object with the second summand
  508. * \param ctx BN_CTX object (optional)
  509. * \return 1 on success and 0 if an error occured
  510. */
  511. int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx);
  512. /** Computes the double of a EC_POINT
  513. * \param group underlying EC_GROUP object
  514. * \param r EC_POINT object for the result (r = 2 * a)
  515. * \param a EC_POINT object
  516. * \param ctx BN_CTX object (optional)
  517. * \return 1 on success and 0 if an error occured
  518. */
  519. int EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx);
  520. /** Computes the inverse of a EC_POINT
  521. * \param group underlying EC_GROUP object
  522. * \param a EC_POINT object to be inverted (it's used for the result as well)
  523. * \param ctx BN_CTX object (optional)
  524. * \return 1 on success and 0 if an error occured
  525. */
  526. int EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx);
  527. /** Checks whether the point is the neutral element of the group
  528. * \param group the underlying EC_GROUP object
  529. * \param p EC_POINT object
  530. * \return 1 if the point is the neutral element and 0 otherwise
  531. */
  532. int EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *p);
  533. /** Checks whether the point is on the curve
  534. * \param group underlying EC_GROUP object
  535. * \param point EC_POINT object to check
  536. * \param ctx BN_CTX object (optional)
  537. * \return 1 if point if on the curve and 0 otherwise
  538. */
  539. int EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx);
  540. /** Compares two EC_POINTs
  541. * \param group underlying EC_GROUP object
  542. * \param a first EC_POINT object
  543. * \param b second EC_POINT object
  544. * \param ctx BN_CTX object (optional)
  545. * \return 0 if both points are equal and a value != 0 otherwise
  546. */
  547. int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx);
  548. int EC_POINT_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *);
  549. int EC_POINTs_make_affine(const EC_GROUP *, size_t num, EC_POINT *[], BN_CTX *);
  550. /** Computes r = generator * n sum_{i=0}^num p[i] * m[i]
  551. * \param group underlying EC_GROUP object
  552. * \param r EC_POINT object for the result
  553. * \param n BIGNUM with the multiplier for the group generator (optional)
  554. * \param num number futher summands
  555. * \param p array of size num of EC_POINT objects
  556. * \param m array of size num of BIGNUM objects
  557. * \param ctx BN_CTX object (optional)
  558. * \return 1 on success and 0 if an error occured
  559. */
  560. 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);
  561. /** Computes r = generator * n + q * m
  562. * \param group underlying EC_GROUP object
  563. * \param r EC_POINT object for the result
  564. * \param n BIGNUM with the multiplier for the group generator (optional)
  565. * \param q EC_POINT object with the first factor of the second summand
  566. * \param m BIGNUM with the second factor of the second summand
  567. * \param ctx BN_CTX object (optional)
  568. * \return 1 on success and 0 if an error occured
  569. */
  570. int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx);
  571. /** Stores multiples of generator for faster point multiplication
  572. * \param group EC_GROUP object
  573. * \param ctx BN_CTX object (optional)
  574. * \return 1 on success and 0 if an error occured
  575. */
  576. int EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx);
  577. /** Reports whether a precomputation has been done
  578. * \param group EC_GROUP object
  579. * \return 1 if a pre-computation has been done and 0 otherwise
  580. */
  581. int EC_GROUP_have_precompute_mult(const EC_GROUP *group);
  582. /********************************************************************/
  583. /* ASN1 stuff */
  584. /********************************************************************/
  585. /* EC_GROUP_get_basis_type() returns the NID of the basis type
  586. * used to represent the field elements */
  587. int EC_GROUP_get_basis_type(const EC_GROUP *);
  588. #ifndef OPENSSL_NO_EC2M
  589. int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k);
  590. int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1,
  591. unsigned int *k2, unsigned int *k3);
  592. #endif
  593. #define OPENSSL_EC_NAMED_CURVE 0x001
  594. typedef struct ecpk_parameters_st ECPKPARAMETERS;
  595. EC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len);
  596. int i2d_ECPKParameters(const EC_GROUP *, unsigned char **out);
  597. #define d2i_ECPKParameters_bio(bp,x) ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x)
  598. #define i2d_ECPKParameters_bio(bp,x) ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x)
  599. #define d2i_ECPKParameters_fp(fp,x) (EC_GROUP *)ASN1_d2i_fp(NULL, \
  600. (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x))
  601. #define i2d_ECPKParameters_fp(fp,x) ASN1_i2d_fp(i2d_ECPKParameters,(fp), \
  602. (unsigned char *)(x))
  603. #ifndef OPENSSL_NO_BIO
  604. int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off);
  605. #endif
  606. #ifndef OPENSSL_NO_FP_API
  607. int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off);
  608. #endif
  609. /********************************************************************/
  610. /* EC_KEY functions */
  611. /********************************************************************/
  612. typedef struct ec_key_st EC_KEY;
  613. /* some values for the encoding_flag */
  614. #define EC_PKEY_NO_PARAMETERS 0x001
  615. #define EC_PKEY_NO_PUBKEY 0x002
  616. /* some values for the flags field */
  617. #define EC_FLAG_NON_FIPS_ALLOW 0x1
  618. #define EC_FLAG_FIPS_CHECKED 0x2
  619. /** Creates a new EC_KEY object.
  620. * \return EC_KEY object or NULL if an error occurred.
  621. */
  622. EC_KEY *EC_KEY_new(void);
  623. int EC_KEY_get_flags(const EC_KEY *key);
  624. void EC_KEY_set_flags(EC_KEY *key, int flags);
  625. void EC_KEY_clear_flags(EC_KEY *key, int flags);
  626. /** Creates a new EC_KEY object using a named curve as underlying
  627. * EC_GROUP object.
  628. * \param nid NID of the named curve.
  629. * \return EC_KEY object or NULL if an error occurred.
  630. */
  631. EC_KEY *EC_KEY_new_by_curve_name(int nid);
  632. /** Frees a EC_KEY object.
  633. * \param key EC_KEY object to be freed.
  634. */
  635. void EC_KEY_free(EC_KEY *key);
  636. /** Copies a EC_KEY object.
  637. * \param dst destination EC_KEY object
  638. * \param src src EC_KEY object
  639. * \return dst or NULL if an error occurred.
  640. */
  641. EC_KEY *EC_KEY_copy(EC_KEY *dst, const EC_KEY *src);
  642. /** Creates a new EC_KEY object and copies the content from src to it.
  643. * \param src the source EC_KEY object
  644. * \return newly created EC_KEY object or NULL if an error occurred.
  645. */
  646. EC_KEY *EC_KEY_dup(const EC_KEY *src);
  647. /** Increases the internal reference count of a EC_KEY object.
  648. * \param key EC_KEY object
  649. * \return 1 on success and 0 if an error occurred.
  650. */
  651. int EC_KEY_up_ref(EC_KEY *key);
  652. /** Returns the EC_GROUP object of a EC_KEY object
  653. * \param key EC_KEY object
  654. * \return the EC_GROUP object (possibly NULL).
  655. */
  656. const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key);
  657. /** Sets the EC_GROUP of a EC_KEY object.
  658. * \param key EC_KEY object
  659. * \param group EC_GROUP to use in the EC_KEY object (note: the EC_KEY
  660. * object will use an own copy of the EC_GROUP).
  661. * \return 1 on success and 0 if an error occurred.
  662. */
  663. int EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group);
  664. /** Returns the private key of a EC_KEY object.
  665. * \param key EC_KEY object
  666. * \return a BIGNUM with the private key (possibly NULL).
  667. */
  668. const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key);
  669. /** Sets the private key of a EC_KEY object.
  670. * \param key EC_KEY object
  671. * \param prv BIGNUM with the private key (note: the EC_KEY object
  672. * will use an own copy of the BIGNUM).
  673. * \return 1 on success and 0 if an error occurred.
  674. */
  675. int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv);
  676. /** Returns the public key of a EC_KEY object.
  677. * \param key the EC_KEY object
  678. * \return a EC_POINT object with the public key (possibly NULL)
  679. */
  680. const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key);
  681. /** Sets the public key of a EC_KEY object.
  682. * \param key EC_KEY object
  683. * \param pub EC_POINT object with the public key (note: the EC_KEY object
  684. * will use an own copy of the EC_POINT object).
  685. * \return 1 on success and 0 if an error occurred.
  686. */
  687. int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub);
  688. unsigned EC_KEY_get_enc_flags(const EC_KEY *key);
  689. void EC_KEY_set_enc_flags(EC_KEY *, unsigned int);
  690. point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *);
  691. void EC_KEY_set_conv_form(EC_KEY *, point_conversion_form_t);
  692. /* functions to set/get method specific data */
  693. void *EC_KEY_get_key_method_data(EC_KEY *,
  694. void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *));
  695. void EC_KEY_insert_key_method_data(EC_KEY *, void *data,
  696. void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *));
  697. /* wrapper functions for the underlying EC_GROUP object */
  698. void EC_KEY_set_asn1_flag(EC_KEY *, int);
  699. /** Creates a table of pre-computed multiples of the generator to
  700. * accelerate further EC_KEY operations.
  701. * \param key EC_KEY object
  702. * \param ctx BN_CTX object (optional)
  703. * \return 1 on success and 0 if an error occurred.
  704. */
  705. int EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx);
  706. /** Creates a new ec private (and optional a new public) key.
  707. * \param key EC_KEY object
  708. * \return 1 on success and 0 if an error occurred.
  709. */
  710. int EC_KEY_generate_key(EC_KEY *key);
  711. /** Verifies that a private and/or public key is valid.
  712. * \param key the EC_KEY object
  713. * \return 1 on success and 0 otherwise.
  714. */
  715. int EC_KEY_check_key(const EC_KEY *key);
  716. /** Sets a public key from affine coordindates performing
  717. * neccessary NIST PKV tests.
  718. * \param key the EC_KEY object
  719. * \param x public key x coordinate
  720. * \param y public key y coordinate
  721. * \return 1 on success and 0 otherwise.
  722. */
  723. int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x, BIGNUM *y);
  724. /********************************************************************/
  725. /* de- and encoding functions for SEC1 ECPrivateKey */
  726. /********************************************************************/
  727. /** Decodes a private key from a memory buffer.
  728. * \param key a pointer to a EC_KEY object which should be used (or NULL)
  729. * \param in pointer to memory with the DER encoded private key
  730. * \param len length of the DER encoded private key
  731. * \return the decoded private key or NULL if an error occurred.
  732. */
  733. EC_KEY *d2i_ECPrivateKey(EC_KEY **key, const unsigned char **in, long len);
  734. /** Encodes a private key object and stores the result in a buffer.
  735. * \param key the EC_KEY object to encode
  736. * \param out the buffer for the result (if NULL the function returns number
  737. * of bytes needed).
  738. * \return 1 on success and 0 if an error occurred.
  739. */
  740. int i2d_ECPrivateKey(EC_KEY *key, unsigned char **out);
  741. /********************************************************************/
  742. /* de- and encoding functions for EC parameters */
  743. /********************************************************************/
  744. /** Decodes ec parameter from a memory buffer.
  745. * \param key a pointer to a EC_KEY object which should be used (or NULL)
  746. * \param in pointer to memory with the DER encoded ec parameters
  747. * \param len length of the DER encoded ec parameters
  748. * \return a EC_KEY object with the decoded parameters or NULL if an error
  749. * occurred.
  750. */
  751. EC_KEY *d2i_ECParameters(EC_KEY **key, const unsigned char **in, long len);
  752. /** Encodes ec parameter and stores the result in a buffer.
  753. * \param key the EC_KEY object with ec paramters to encode
  754. * \param out the buffer for the result (if NULL the function returns number
  755. * of bytes needed).
  756. * \return 1 on success and 0 if an error occurred.
  757. */
  758. int i2d_ECParameters(EC_KEY *key, unsigned char **out);
  759. /********************************************************************/
  760. /* de- and encoding functions for EC public key */
  761. /* (octet string, not DER -- hence 'o2i' and 'i2o') */
  762. /********************************************************************/
  763. /** Decodes a ec public key from a octet string.
  764. * \param key a pointer to a EC_KEY object which should be used
  765. * \param in memory buffer with the encoded public key
  766. * \param len length of the encoded public key
  767. * \return EC_KEY object with decoded public key or NULL if an error
  768. * occurred.
  769. */
  770. EC_KEY *o2i_ECPublicKey(EC_KEY **key, const unsigned char **in, long len);
  771. /** Encodes a ec public key in an octet string.
  772. * \param key the EC_KEY object with the public key
  773. * \param out the buffer for the result (if NULL the function returns number
  774. * of bytes needed).
  775. * \return 1 on success and 0 if an error occurred
  776. */
  777. int i2o_ECPublicKey(EC_KEY *key, unsigned char **out);
  778. #ifndef OPENSSL_NO_BIO
  779. /** Prints out the ec parameters on human readable form.
  780. * \param bp BIO object to which the information is printed
  781. * \param key EC_KEY object
  782. * \return 1 on success and 0 if an error occurred
  783. */
  784. int ECParameters_print(BIO *bp, const EC_KEY *key);
  785. /** Prints out the contents of a EC_KEY object
  786. * \param bp BIO object to which the information is printed
  787. * \param key EC_KEY object
  788. * \param off line offset
  789. * \return 1 on success and 0 if an error occurred
  790. */
  791. int EC_KEY_print(BIO *bp, const EC_KEY *key, int off);
  792. #endif
  793. #ifndef OPENSSL_NO_FP_API
  794. /** Prints out the ec parameters on human readable form.
  795. * \param fp file descriptor to which the information is printed
  796. * \param key EC_KEY object
  797. * \return 1 on success and 0 if an error occurred
  798. */
  799. int ECParameters_print_fp(FILE *fp, const EC_KEY *key);
  800. /** Prints out the contents of a EC_KEY object
  801. * \param fp file descriptor to which the information is printed
  802. * \param key EC_KEY object
  803. * \param off line offset
  804. * \return 1 on success and 0 if an error occurred
  805. */
  806. int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off);
  807. #endif
  808. #define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x)
  809. #ifndef __cplusplus
  810. #if defined(__SUNPRO_C)
  811. # if __SUNPRO_C >= 0x520
  812. # pragma error_messages (default,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE)
  813. # endif
  814. # endif
  815. #endif
  816. #define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid) \
  817. EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, EVP_PKEY_OP_PARAMGEN, \
  818. EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL)
  819. #define EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID (EVP_PKEY_ALG_CTRL + 1)
  820. /* BEGIN ERROR CODES */
  821. /* The following lines are auto generated by the script mkerr.pl. Any changes
  822. * made after this point may be overwritten when the script is next run.
  823. */
  824. void ERR_load_EC_strings(void);
  825. /* Error codes for the EC functions. */
  826. /* Function codes. */
  827. #define EC_F_BN_TO_FELEM 224
  828. #define EC_F_COMPUTE_WNAF 143
  829. #define EC_F_D2I_ECPARAMETERS 144
  830. #define EC_F_D2I_ECPKPARAMETERS 145
  831. #define EC_F_D2I_ECPRIVATEKEY 146
  832. #define EC_F_DO_EC_KEY_PRINT 221
  833. #define EC_F_ECKEY_PARAM2TYPE 223
  834. #define EC_F_ECKEY_PARAM_DECODE 212
  835. #define EC_F_ECKEY_PRIV_DECODE 213
  836. #define EC_F_ECKEY_PRIV_ENCODE 214
  837. #define EC_F_ECKEY_PUB_DECODE 215
  838. #define EC_F_ECKEY_PUB_ENCODE 216
  839. #define EC_F_ECKEY_TYPE2PARAM 220
  840. #define EC_F_ECPARAMETERS_PRINT 147
  841. #define EC_F_ECPARAMETERS_PRINT_FP 148
  842. #define EC_F_ECPKPARAMETERS_PRINT 149
  843. #define EC_F_ECPKPARAMETERS_PRINT_FP 150
  844. #define EC_F_ECP_NIST_MOD_192 203
  845. #define EC_F_ECP_NIST_MOD_224 204
  846. #define EC_F_ECP_NIST_MOD_256 205
  847. #define EC_F_ECP_NIST_MOD_521 206
  848. #define EC_F_EC_ASN1_GROUP2CURVE 153
  849. #define EC_F_EC_ASN1_GROUP2FIELDID 154
  850. #define EC_F_EC_ASN1_GROUP2PARAMETERS 155
  851. #define EC_F_EC_ASN1_GROUP2PKPARAMETERS 156
  852. #define EC_F_EC_ASN1_PARAMETERS2GROUP 157
  853. #define EC_F_EC_ASN1_PKPARAMETERS2GROUP 158
  854. #define EC_F_EC_EX_DATA_SET_DATA 211
  855. #define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY 208
  856. #define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT 159
  857. #define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE 195
  858. #define EC_F_EC_GF2M_SIMPLE_OCT2POINT 160
  859. #define EC_F_EC_GF2M_SIMPLE_POINT2OCT 161
  860. #define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 162
  861. #define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 163
  862. #define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES 164
  863. #define EC_F_EC_GFP_MONT_FIELD_DECODE 133
  864. #define EC_F_EC_GFP_MONT_FIELD_ENCODE 134
  865. #define EC_F_EC_GFP_MONT_FIELD_MUL 131
  866. #define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE 209
  867. #define EC_F_EC_GFP_MONT_FIELD_SQR 132
  868. #define EC_F_EC_GFP_MONT_GROUP_SET_CURVE 189
  869. #define EC_F_EC_GFP_MONT_GROUP_SET_CURVE_GFP 135
  870. #define EC_F_EC_GFP_NISTP224_GROUP_SET_CURVE 225
  871. #define EC_F_EC_GFP_NISTP224_POINTS_MUL 228
  872. #define EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES 226
  873. #define EC_F_EC_GFP_NISTP256_GROUP_SET_CURVE 230
  874. #define EC_F_EC_GFP_NISTP256_POINTS_MUL 231
  875. #define EC_F_EC_GFP_NISTP256_POINT_GET_AFFINE_COORDINATES 232
  876. #define EC_F_EC_GFP_NISTP521_GROUP_SET_CURVE 233
  877. #define EC_F_EC_GFP_NISTP521_POINTS_MUL 234
  878. #define EC_F_EC_GFP_NISTP521_POINT_GET_AFFINE_COORDINATES 235
  879. #define EC_F_EC_GFP_NIST_FIELD_MUL 200
  880. #define EC_F_EC_GFP_NIST_FIELD_SQR 201
  881. #define EC_F_EC_GFP_NIST_GROUP_SET_CURVE 202
  882. #define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT 165
  883. #define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE 166
  884. #define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE_GFP 100
  885. #define EC_F_EC_GFP_SIMPLE_GROUP_SET_GENERATOR 101
  886. #define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE 102
  887. #define EC_F_EC_GFP_SIMPLE_OCT2POINT 103
  888. #define EC_F_EC_GFP_SIMPLE_POINT2OCT 104
  889. #define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE 137
  890. #define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES 167
  891. #define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP 105
  892. #define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES 168
  893. #define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES_GFP 128
  894. #define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES 169
  895. #define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP 129
  896. #define EC_F_EC_GROUP_CHECK 170
  897. #define EC_F_EC_GROUP_CHECK_DISCRIMINANT 171
  898. #define EC_F_EC_GROUP_COPY 106
  899. #define EC_F_EC_GROUP_GET0_GENERATOR 139
  900. #define EC_F_EC_GROUP_GET_COFACTOR 140
  901. #define EC_F_EC_GROUP_GET_CURVE_GF2M 172
  902. #define EC_F_EC_GROUP_GET_CURVE_GFP 130
  903. #define EC_F_EC_GROUP_GET_DEGREE 173
  904. #define EC_F_EC_GROUP_GET_ORDER 141
  905. #define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS 193
  906. #define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS 194
  907. #define EC_F_EC_GROUP_NEW 108
  908. #define EC_F_EC_GROUP_NEW_BY_CURVE_NAME 174
  909. #define EC_F_EC_GROUP_NEW_FROM_DATA 175
  910. #define EC_F_EC_GROUP_PRECOMPUTE_MULT 142
  911. #define EC_F_EC_GROUP_SET_CURVE_GF2M 176
  912. #define EC_F_EC_GROUP_SET_CURVE_GFP 109
  913. #define EC_F_EC_GROUP_SET_EXTRA_DATA 110
  914. #define EC_F_EC_GROUP_SET_GENERATOR 111
  915. #define EC_F_EC_KEY_CHECK_KEY 177
  916. #define EC_F_EC_KEY_COPY 178
  917. #define EC_F_EC_KEY_GENERATE_KEY 179
  918. #define EC_F_EC_KEY_NEW 182
  919. #define EC_F_EC_KEY_PRINT 180
  920. #define EC_F_EC_KEY_PRINT_FP 181
  921. #define EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES 229
  922. #define EC_F_EC_POINTS_MAKE_AFFINE 136
  923. #define EC_F_EC_POINT_ADD 112
  924. #define EC_F_EC_POINT_CMP 113
  925. #define EC_F_EC_POINT_COPY 114
  926. #define EC_F_EC_POINT_DBL 115
  927. #define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M 183
  928. #define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP 116
  929. #define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP 117
  930. #define EC_F_EC_POINT_INVERT 210
  931. #define EC_F_EC_POINT_IS_AT_INFINITY 118
  932. #define EC_F_EC_POINT_IS_ON_CURVE 119
  933. #define EC_F_EC_POINT_MAKE_AFFINE 120
  934. #define EC_F_EC_POINT_MUL 184
  935. #define EC_F_EC_POINT_NEW 121
  936. #define EC_F_EC_POINT_OCT2POINT 122
  937. #define EC_F_EC_POINT_POINT2OCT 123
  938. #define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M 185
  939. #define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP 124
  940. #define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M 186
  941. #define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP 125
  942. #define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP 126
  943. #define EC_F_EC_POINT_SET_TO_INFINITY 127
  944. #define EC_F_EC_PRE_COMP_DUP 207
  945. #define EC_F_EC_PRE_COMP_NEW 196
  946. #define EC_F_EC_WNAF_MUL 187
  947. #define EC_F_EC_WNAF_PRECOMPUTE_MULT 188
  948. #define EC_F_I2D_ECPARAMETERS 190
  949. #define EC_F_I2D_ECPKPARAMETERS 191
  950. #define EC_F_I2D_ECPRIVATEKEY 192
  951. #define EC_F_I2O_ECPUBLICKEY 151
  952. #define EC_F_NISTP224_PRE_COMP_NEW 227
  953. #define EC_F_NISTP256_PRE_COMP_NEW 236
  954. #define EC_F_NISTP521_PRE_COMP_NEW 237
  955. #define EC_F_O2I_ECPUBLICKEY 152
  956. #define EC_F_OLD_EC_PRIV_DECODE 222
  957. #define EC_F_PKEY_EC_CTRL 197
  958. #define EC_F_PKEY_EC_CTRL_STR 198
  959. #define EC_F_PKEY_EC_DERIVE 217
  960. #define EC_F_PKEY_EC_KEYGEN 199
  961. #define EC_F_PKEY_EC_PARAMGEN 219
  962. #define EC_F_PKEY_EC_SIGN 218
  963. /* Reason codes. */
  964. #define EC_R_ASN1_ERROR 115
  965. #define EC_R_ASN1_UNKNOWN_FIELD 116
  966. #define EC_R_BIGNUM_OUT_OF_RANGE 144
  967. #define EC_R_BUFFER_TOO_SMALL 100
  968. #define EC_R_COORDINATES_OUT_OF_RANGE 146
  969. #define EC_R_D2I_ECPKPARAMETERS_FAILURE 117
  970. #define EC_R_DECODE_ERROR 142
  971. #define EC_R_DISCRIMINANT_IS_ZERO 118
  972. #define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 119
  973. #define EC_R_FIELD_TOO_LARGE 143
  974. #define EC_R_GF2M_NOT_SUPPORTED 147
  975. #define EC_R_GROUP2PKPARAMETERS_FAILURE 120
  976. #define EC_R_I2D_ECPKPARAMETERS_FAILURE 121
  977. #define EC_R_INCOMPATIBLE_OBJECTS 101
  978. #define EC_R_INVALID_ARGUMENT 112
  979. #define EC_R_INVALID_COMPRESSED_POINT 110
  980. #define EC_R_INVALID_COMPRESSION_BIT 109
  981. #define EC_R_INVALID_CURVE 141
  982. #define EC_R_INVALID_DIGEST_TYPE 138
  983. #define EC_R_INVALID_ENCODING 102
  984. #define EC_R_INVALID_FIELD 103
  985. #define EC_R_INVALID_FORM 104
  986. #define EC_R_INVALID_GROUP_ORDER 122
  987. #define EC_R_INVALID_PENTANOMIAL_BASIS 132
  988. #define EC_R_INVALID_PRIVATE_KEY 123
  989. #define EC_R_INVALID_TRINOMIAL_BASIS 137
  990. #define EC_R_KEYS_NOT_SET 140
  991. #define EC_R_MISSING_PARAMETERS 124
  992. #define EC_R_MISSING_PRIVATE_KEY 125
  993. #define EC_R_NOT_A_NIST_PRIME 135
  994. #define EC_R_NOT_A_SUPPORTED_NIST_PRIME 136
  995. #define EC_R_NOT_IMPLEMENTED 126
  996. #define EC_R_NOT_INITIALIZED 111
  997. #define EC_R_NO_FIELD_MOD 133
  998. #define EC_R_NO_PARAMETERS_SET 139
  999. #define EC_R_PASSED_NULL_PARAMETER 134
  1000. #define EC_R_PKPARAMETERS2GROUP_FAILURE 127
  1001. #define EC_R_POINT_AT_INFINITY 106
  1002. #define EC_R_POINT_IS_NOT_ON_CURVE 107
  1003. #define EC_R_SLOT_FULL 108
  1004. #define EC_R_UNDEFINED_GENERATOR 113
  1005. #define EC_R_UNDEFINED_ORDER 128
  1006. #define EC_R_UNKNOWN_GROUP 129
  1007. #define EC_R_UNKNOWN_ORDER 114
  1008. #define EC_R_UNSUPPORTED_FIELD 131
  1009. #define EC_R_WRONG_CURVE_PARAMETERS 145
  1010. #define EC_R_WRONG_ORDER 130
  1011. #ifdef __cplusplus
  1012. }
  1013. #endif
  1014. #endif