ec.h 45 KB

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