ec.h 44 KB

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