ec.h 44 KB

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