]>
Commit | Line | Data |
---|---|---|
35b73a1f | 1 | /* |
fecb3aae | 2 | * Copyright 2002-2022 The OpenSSL Project Authors. All Rights Reserved. |
aa8f3d76 | 3 | * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved |
6cc5e19d | 4 | * |
48f4ad77 | 5 | * Licensed under the Apache License 2.0 (the "License"). You may not use |
21dcbebc RS |
6 | * this file except in compliance with the License. You can obtain a copy |
7 | * in the file LICENSE in the source distribution or at | |
8 | * https://www.openssl.org/source/license.html | |
6cc5e19d | 9 | */ |
21dcbebc | 10 | |
ae4186b0 DMSP |
11 | #ifndef OPENSSL_EC_H |
12 | # define OPENSSL_EC_H | |
d86167ec DMSP |
13 | # pragma once |
14 | ||
15 | # include <openssl/macros.h> | |
936c2b9e | 16 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
d86167ec DMSP |
17 | # define HEADER_EC_H |
18 | # endif | |
6cc5e19d | 19 | |
0f113f3e | 20 | # include <openssl/opensslconf.h> |
565b3399 RL |
21 | # include <openssl/types.h> |
22 | ||
1d8f18dc DDO |
23 | # include <string.h> |
24 | ||
565b3399 RL |
25 | # ifdef __cplusplus |
26 | extern "C" { | |
27 | # endif | |
28 | ||
29 | /* Values for EVP_PKEY_CTX_set_ec_param_enc() */ | |
30 | # define OPENSSL_EC_EXPLICIT_CURVE 0x000 | |
31 | # define OPENSSL_EC_NAMED_CURVE 0x001 | |
32 | ||
33 | int EVP_PKEY_CTX_set_ec_paramgen_curve_nid(EVP_PKEY_CTX *ctx, int nid); | |
34 | int EVP_PKEY_CTX_set_ec_param_enc(EVP_PKEY_CTX *ctx, int param_enc); | |
35 | int EVP_PKEY_CTX_set_ecdh_cofactor_mode(EVP_PKEY_CTX *ctx, int cofactor_mode); | |
36 | int EVP_PKEY_CTX_get_ecdh_cofactor_mode(EVP_PKEY_CTX *ctx); | |
37 | ||
38 | int EVP_PKEY_CTX_set_ecdh_kdf_type(EVP_PKEY_CTX *ctx, int kdf); | |
39 | int EVP_PKEY_CTX_get_ecdh_kdf_type(EVP_PKEY_CTX *ctx); | |
40 | ||
41 | int EVP_PKEY_CTX_set_ecdh_kdf_md(EVP_PKEY_CTX *ctx, const EVP_MD *md); | |
42 | int EVP_PKEY_CTX_get_ecdh_kdf_md(EVP_PKEY_CTX *ctx, const EVP_MD **md); | |
43 | ||
44 | int EVP_PKEY_CTX_set_ecdh_kdf_outlen(EVP_PKEY_CTX *ctx, int len); | |
45 | int EVP_PKEY_CTX_get_ecdh_kdf_outlen(EVP_PKEY_CTX *ctx, int *len); | |
46 | ||
47 | int EVP_PKEY_CTX_set0_ecdh_kdf_ukm(EVP_PKEY_CTX *ctx, unsigned char *ukm, | |
48 | int len); | |
76e48c9d TM |
49 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
50 | OSSL_DEPRECATEDIN_3_0 | |
565b3399 | 51 | int EVP_PKEY_CTX_get0_ecdh_kdf_ukm(EVP_PKEY_CTX *ctx, unsigned char **ukm); |
76e48c9d | 52 | # endif |
565b3399 RL |
53 | |
54 | # define EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID (EVP_PKEY_ALG_CTRL + 1) | |
55 | # define EVP_PKEY_CTRL_EC_PARAM_ENC (EVP_PKEY_ALG_CTRL + 2) | |
56 | # define EVP_PKEY_CTRL_EC_ECDH_COFACTOR (EVP_PKEY_ALG_CTRL + 3) | |
57 | # define EVP_PKEY_CTRL_EC_KDF_TYPE (EVP_PKEY_ALG_CTRL + 4) | |
58 | # define EVP_PKEY_CTRL_EC_KDF_MD (EVP_PKEY_ALG_CTRL + 5) | |
59 | # define EVP_PKEY_CTRL_GET_EC_KDF_MD (EVP_PKEY_ALG_CTRL + 6) | |
60 | # define EVP_PKEY_CTRL_EC_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 7) | |
61 | # define EVP_PKEY_CTRL_GET_EC_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 8) | |
62 | # define EVP_PKEY_CTRL_EC_KDF_UKM (EVP_PKEY_ALG_CTRL + 9) | |
63 | # define EVP_PKEY_CTRL_GET_EC_KDF_UKM (EVP_PKEY_ALG_CTRL + 10) | |
64 | ||
65 | /* KDF types */ | |
66 | # define EVP_PKEY_ECDH_KDF_NONE 1 | |
67 | # define EVP_PKEY_ECDH_KDF_X9_63 2 | |
68 | /* | |
69 | * The old name for EVP_PKEY_ECDH_KDF_X9_63 | |
70 | * The ECDH KDF specification has been mistakenly attributed to ANSI X9.62, | |
71 | * it is actually specified in ANSI X9.63. | |
72 | * This identifier is retained for backwards compatibility | |
73 | */ | |
74 | # define EVP_PKEY_ECDH_KDF_X9_62 EVP_PKEY_ECDH_KDF_X9_63 | |
87c9c659 | 75 | |
ba12070f NL |
76 | /** Enum for the point conversion form as defined in X9.62 (ECDSA) |
77 | * for the encoding of a elliptic curve point (x,y) */ | |
3a12ce01 | 78 | typedef enum { |
0f113f3e | 79 | /** the point is encoded as z||x, where the octet z specifies |
ba12070f | 80 | * which solution of the quadratic equation y is */ |
0f113f3e | 81 | POINT_CONVERSION_COMPRESSED = 2, |
91d2728b | 82 | /** the point is encoded as z||x||y, where z is the octet 0x04 */ |
0f113f3e MC |
83 | POINT_CONVERSION_UNCOMPRESSED = 4, |
84 | /** the point is encoded as z||x||y, where the octet z specifies | |
85 | * which solution of the quadratic equation y is */ | |
86 | POINT_CONVERSION_HYBRID = 6 | |
3a12ce01 BM |
87 | } point_conversion_form_t; |
88 | ||
f9253152 DDO |
89 | const char *OSSL_EC_curve_nid2name(int nid); |
90 | ||
3d34bedf MC |
91 | # ifndef OPENSSL_NO_EC |
92 | # include <openssl/asn1.h> | |
93 | # include <openssl/symhacks.h> | |
94 | # ifndef OPENSSL_NO_DEPRECATED_1_1_0 | |
95 | # include <openssl/bn.h> | |
96 | # endif | |
97 | # include <openssl/ecerr.h> | |
98 | ||
99 | # ifndef OPENSSL_ECC_MAX_FIELD_BITS | |
100 | # define OPENSSL_ECC_MAX_FIELD_BITS 661 | |
101 | # endif | |
102 | ||
c0f39ded | 103 | # include <openssl/params.h> |
23ccae80 | 104 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
3a12ce01 | 105 | typedef struct ec_method_st EC_METHOD; |
23ccae80 | 106 | # endif |
60b350a3 | 107 | typedef struct ec_group_st EC_GROUP; |
3a12ce01 | 108 | typedef struct ec_point_st EC_POINT; |
60b350a3 RS |
109 | typedef struct ecpk_parameters_st ECPKPARAMETERS; |
110 | typedef struct ec_parameters_st ECPARAMETERS; | |
3a12ce01 | 111 | |
ba12070f | 112 | /********************************************************************/ |
0f113f3e | 113 | /* EC_METHODs for curves over GF(p) */ |
ba12070f NL |
114 | /********************************************************************/ |
115 | ||
5b5eea4b | 116 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
ba12070f | 117 | /** Returns the basic GFp ec methods which provides the basis for the |
0f113f3e | 118 | * optimized methods. |
ba12070f | 119 | * \return EC_METHOD object |
3a12ce01 | 120 | */ |
5b5eea4b | 121 | OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_simple_method(void); |
ba12070f NL |
122 | |
123 | /** Returns GFp methods using montgomery multiplication. | |
124 | * \return EC_METHOD object | |
125 | */ | |
5b5eea4b | 126 | OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_mont_method(void); |
ba12070f NL |
127 | |
128 | /** Returns GFp methods using optimized methods for NIST recommended curves | |
129 | * \return EC_METHOD object | |
130 | */ | |
5b5eea4b | 131 | OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_nist_method(void); |
3a12ce01 | 132 | |
5b5eea4b | 133 | # ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 |
04daec86 BM |
134 | /** Returns 64-bit optimized methods for nistp224 |
135 | * \return EC_METHOD object | |
136 | */ | |
5b5eea4b | 137 | OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_nistp224_method(void); |
3e00b4c9 BM |
138 | |
139 | /** Returns 64-bit optimized methods for nistp256 | |
140 | * \return EC_METHOD object | |
141 | */ | |
5b5eea4b | 142 | OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_nistp256_method(void); |
3e00b4c9 BM |
143 | |
144 | /** Returns 64-bit optimized methods for nistp521 | |
145 | * \return EC_METHOD object | |
146 | */ | |
5b5eea4b SL |
147 | OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_nistp521_method(void); |
148 | # endif /* OPENSSL_NO_EC_NISTP_64_GCC_128 */ | |
ba12070f | 149 | |
5b5eea4b | 150 | # ifndef OPENSSL_NO_EC2M |
0f113f3e | 151 | /********************************************************************/ |
ba12070f NL |
152 | /* EC_METHOD for curves over GF(2^m) */ |
153 | /********************************************************************/ | |
154 | ||
0f113f3e | 155 | /** Returns the basic GF2m ec method |
ba12070f | 156 | * \return EC_METHOD object |
7793f30e | 157 | */ |
5b5eea4b | 158 | OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GF2m_simple_method(void); |
7793f30e | 159 | |
5b5eea4b | 160 | # endif |
3a12ce01 | 161 | |
ba12070f NL |
162 | /********************************************************************/ |
163 | /* EC_GROUP functions */ | |
164 | /********************************************************************/ | |
165 | ||
a9612d6c MC |
166 | /** |
167 | * Creates a new EC_GROUP object | |
a9612d6c | 168 | * \param meth EC_METHOD to use |
ba12070f NL |
169 | * \return newly created EC_GROUP object or NULL in case of an error. |
170 | */ | |
5b5eea4b SL |
171 | OSSL_DEPRECATEDIN_3_0 EC_GROUP *EC_GROUP_new(const EC_METHOD *meth); |
172 | ||
173 | /** Clears and frees a EC_GROUP object | |
174 | * \param group EC_GROUP object to be cleared and freed. | |
175 | */ | |
176 | OSSL_DEPRECATEDIN_3_0 void EC_GROUP_clear_free(EC_GROUP *group); | |
177 | ||
178 | /** Returns the EC_METHOD of the EC_GROUP object. | |
179 | * \param group EC_GROUP object | |
180 | * \return EC_METHOD used in this EC_GROUP object. | |
181 | */ | |
182 | OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group); | |
183 | ||
184 | /** Returns the field type of the EC_METHOD. | |
185 | * \param meth EC_METHOD object | |
186 | * \return NID of the underlying field type OID. | |
187 | */ | |
188 | OSSL_DEPRECATEDIN_3_0 int EC_METHOD_get_field_type(const EC_METHOD *meth); | |
189 | # endif /* OPENSSL_NO_DEPRECATED_3_0 */ | |
ba12070f NL |
190 | |
191 | /** Frees a EC_GROUP object | |
192 | * \param group EC_GROUP object to be freed. | |
193 | */ | |
194 | void EC_GROUP_free(EC_GROUP *group); | |
195 | ||
ba12070f NL |
196 | /** Copies EC_GROUP objects. Note: both EC_GROUPs must use the same EC_METHOD. |
197 | * \param dst destination EC_GROUP object | |
198 | * \param src source EC_GROUP object | |
199 | * \return 1 on success and 0 if an error occurred. | |
200 | */ | |
201 | int EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src); | |
202 | ||
9fdcc21f | 203 | /** Creates a new EC_GROUP object and copies the content |
ba12070f NL |
204 | * form src to the newly created EC_KEY object |
205 | * \param src source EC_GROUP object | |
206 | * \return newly created EC_GROUP object or NULL in case of an error. | |
207 | */ | |
208 | EC_GROUP *EC_GROUP_dup(const EC_GROUP *src); | |
209 | ||
68756b12 | 210 | /** Sets the generator and its order/cofactor of a EC_GROUP object. |
0f113f3e | 211 | * \param group EC_GROUP object |
ba12070f NL |
212 | * \param generator EC_POINT object with the generator. |
213 | * \param order the order of the group generated by the generator. | |
214 | * \param cofactor the index of the sub-group generated by the generator | |
215 | * in the group of all points on the elliptic curve. | |
478b50cf | 216 | * \return 1 on success and 0 if an error occurred |
ba12070f | 217 | */ |
0f113f3e MC |
218 | int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, |
219 | const BIGNUM *order, const BIGNUM *cofactor); | |
ba12070f NL |
220 | |
221 | /** Returns the generator of a EC_GROUP object. | |
222 | * \param group EC_GROUP object | |
223 | * \return the currently used generator (possibly NULL). | |
224 | */ | |
225 | const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group); | |
226 | ||
f54be179 AP |
227 | /** Returns the montgomery data for order(Generator) |
228 | * \param group EC_GROUP object | |
14f46560 | 229 | * \return the currently used montgomery data (possibly NULL). |
f54be179 AP |
230 | */ |
231 | BN_MONT_CTX *EC_GROUP_get_mont_data(const EC_GROUP *group); | |
232 | ||
ba12070f NL |
233 | /** Gets the order of a EC_GROUP |
234 | * \param group EC_GROUP object | |
235 | * \param order BIGNUM to which the order is copied | |
a773b52a | 236 | * \param ctx unused |
478b50cf | 237 | * \return 1 on success and 0 if an error occurred |
ba12070f NL |
238 | */ |
239 | int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx); | |
48fe4d62 | 240 | |
be2e334f DSH |
241 | /** Gets the order of an EC_GROUP |
242 | * \param group EC_GROUP object | |
243 | * \return the group order | |
244 | */ | |
be2e334f DSH |
245 | const BIGNUM *EC_GROUP_get0_order(const EC_GROUP *group); |
246 | ||
8483a003 | 247 | /** Gets the number of bits of the order of an EC_GROUP |
be2e334f DSH |
248 | * \param group EC_GROUP object |
249 | * \return number of bits of group order. | |
250 | */ | |
be2e334f DSH |
251 | int EC_GROUP_order_bits(const EC_GROUP *group); |
252 | ||
ba12070f NL |
253 | /** Gets the cofactor of a EC_GROUP |
254 | * \param group EC_GROUP object | |
255 | * \param cofactor BIGNUM to which the cofactor is copied | |
a773b52a | 256 | * \param ctx unused |
478b50cf | 257 | * \return 1 on success and 0 if an error occurred |
ba12070f | 258 | */ |
0f113f3e MC |
259 | int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, |
260 | BN_CTX *ctx); | |
b6db386f | 261 | |
be2e334f DSH |
262 | /** Gets the cofactor of an EC_GROUP |
263 | * \param group EC_GROUP object | |
264 | * \return the group cofactor | |
265 | */ | |
be2e334f DSH |
266 | const BIGNUM *EC_GROUP_get0_cofactor(const EC_GROUP *group); |
267 | ||
ba12070f NL |
268 | /** Sets the name of a EC_GROUP object |
269 | * \param group EC_GROUP object | |
270 | * \param nid NID of the curve name OID | |
271 | */ | |
272 | void EC_GROUP_set_curve_name(EC_GROUP *group, int nid); | |
b6db386f | 273 | |
ba12070f NL |
274 | /** Returns the curve name of a EC_GROUP object |
275 | * \param group EC_GROUP object | |
276 | * \return NID of the curve name OID or 0 if not set. | |
277 | */ | |
278 | int EC_GROUP_get_curve_name(const EC_GROUP *group); | |
945e15a2 | 279 | |
fa1f0306 DA |
280 | /** Gets the field of an EC_GROUP |
281 | * \param group EC_GROUP object | |
282 | * \return the group field | |
283 | */ | |
284 | const BIGNUM *EC_GROUP_get0_field(const EC_GROUP *group); | |
285 | ||
23ccae80 BB |
286 | /** Returns the field type of the EC_GROUP. |
287 | * \param group EC_GROUP object | |
288 | * \return NID of the underlying field type OID. | |
289 | */ | |
290 | int EC_GROUP_get_field_type(const EC_GROUP *group); | |
291 | ||
ba12070f NL |
292 | void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag); |
293 | int EC_GROUP_get_asn1_flag(const EC_GROUP *group); | |
5f3d6f70 | 294 | |
0f113f3e MC |
295 | void EC_GROUP_set_point_conversion_form(EC_GROUP *group, |
296 | point_conversion_form_t form); | |
5f3d6f70 BM |
297 | point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *); |
298 | ||
9945b460 | 299 | unsigned char *EC_GROUP_get0_seed(const EC_GROUP *x); |
5f3d6f70 BM |
300 | size_t EC_GROUP_get_seed_len(const EC_GROUP *); |
301 | size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len); | |
48fe4d62 | 302 | |
af9fb19a | 303 | /** Sets the parameters of an ec curve defined by y^2 = x^3 + a*x + b (for GFp) |
8e3cced7 | 304 | * or y^2 + x*y = x^3 + a*x^2 + b (for GF2m) |
ba12070f | 305 | * \param group EC_GROUP object |
8e3cced7 MC |
306 | * \param p BIGNUM with the prime number (GFp) or the polynomial |
307 | * defining the underlying field (GF2m) | |
308 | * \param a BIGNUM with parameter a of the equation | |
309 | * \param b BIGNUM with parameter b of the equation | |
310 | * \param ctx BN_CTX object (optional) | |
311 | * \return 1 on success and 0 if an error occurred | |
312 | */ | |
313 | int EC_GROUP_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, | |
314 | const BIGNUM *b, BN_CTX *ctx); | |
315 | ||
316 | /** Gets the parameters of the ec curve defined by y^2 = x^3 + a*x + b (for GFp) | |
317 | * or y^2 + x*y = x^3 + a*x^2 + b (for GF2m) | |
318 | * \param group EC_GROUP object | |
319 | * \param p BIGNUM with the prime number (GFp) or the polynomial | |
320 | * defining the underlying field (GF2m) | |
321 | * \param a BIGNUM for parameter a of the equation | |
322 | * \param b BIGNUM for parameter b of the equation | |
323 | * \param ctx BN_CTX object (optional) | |
324 | * \return 1 on success and 0 if an error occurred | |
325 | */ | |
326 | int EC_GROUP_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, | |
327 | BN_CTX *ctx); | |
328 | ||
5b5eea4b | 329 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
8e3cced7 MC |
330 | /** Sets the parameters of an ec curve. Synonym for EC_GROUP_set_curve |
331 | * \param group EC_GROUP object | |
332 | * \param p BIGNUM with the prime number (GFp) or the polynomial | |
333 | * defining the underlying field (GF2m) | |
ba12070f NL |
334 | * \param a BIGNUM with parameter a of the equation |
335 | * \param b BIGNUM with parameter b of the equation | |
336 | * \param ctx BN_CTX object (optional) | |
478b50cf | 337 | * \return 1 on success and 0 if an error occurred |
ba12070f | 338 | */ |
5b5eea4b SL |
339 | OSSL_DEPRECATEDIN_3_0 int EC_GROUP_set_curve_GFp(EC_GROUP *group, |
340 | const BIGNUM *p, | |
341 | const BIGNUM *a, | |
342 | const BIGNUM *b, | |
343 | BN_CTX *ctx); | |
ba12070f | 344 | |
8e3cced7 | 345 | /** Gets the parameters of an ec curve. Synonym for EC_GROUP_get_curve |
ba12070f | 346 | * \param group EC_GROUP object |
8e3cced7 MC |
347 | * \param p BIGNUM with the prime number (GFp) or the polynomial |
348 | * defining the underlying field (GF2m) | |
ba12070f NL |
349 | * \param a BIGNUM for parameter a of the equation |
350 | * \param b BIGNUM for parameter b of the equation | |
351 | * \param ctx BN_CTX object (optional) | |
478b50cf | 352 | * \return 1 on success and 0 if an error occurred |
ba12070f | 353 | */ |
5b5eea4b SL |
354 | OSSL_DEPRECATEDIN_3_0 int EC_GROUP_get_curve_GFp(const EC_GROUP *group, |
355 | BIGNUM *p, | |
356 | BIGNUM *a, BIGNUM *b, | |
357 | BN_CTX *ctx); | |
ba12070f | 358 | |
5b5eea4b | 359 | # ifndef OPENSSL_NO_EC2M |
8e3cced7 | 360 | /** Sets the parameter of an ec curve. Synonym for EC_GROUP_set_curve |
ba12070f | 361 | * \param group EC_GROUP object |
8e3cced7 MC |
362 | * \param p BIGNUM with the prime number (GFp) or the polynomial |
363 | * defining the underlying field (GF2m) | |
ba12070f NL |
364 | * \param a BIGNUM with parameter a of the equation |
365 | * \param b BIGNUM with parameter b of the equation | |
366 | * \param ctx BN_CTX object (optional) | |
478b50cf | 367 | * \return 1 on success and 0 if an error occurred |
ba12070f | 368 | */ |
5b5eea4b SL |
369 | OSSL_DEPRECATEDIN_3_0 int EC_GROUP_set_curve_GF2m(EC_GROUP *group, |
370 | const BIGNUM *p, | |
371 | const BIGNUM *a, | |
372 | const BIGNUM *b, | |
373 | BN_CTX *ctx); | |
ba12070f | 374 | |
8e3cced7 | 375 | /** Gets the parameters of an ec curve. Synonym for EC_GROUP_get_curve |
ba12070f | 376 | * \param group EC_GROUP object |
8e3cced7 MC |
377 | * \param p BIGNUM with the prime number (GFp) or the polynomial |
378 | * defining the underlying field (GF2m) | |
ba12070f NL |
379 | * \param a BIGNUM for parameter a of the equation |
380 | * \param b BIGNUM for parameter b of the equation | |
381 | * \param ctx BN_CTX object (optional) | |
478b50cf | 382 | * \return 1 on success and 0 if an error occurred |
ba12070f | 383 | */ |
5b5eea4b SL |
384 | OSSL_DEPRECATEDIN_3_0 int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, |
385 | BIGNUM *p, | |
386 | BIGNUM *a, BIGNUM *b, | |
387 | BN_CTX *ctx); | |
388 | # endif /* OPENSSL_NO_EC2M */ | |
389 | # endif /* OPENSSL_NO_DEPRECATED_3_0 */ | |
390 | ||
0f113f3e | 391 | /** Returns the number of bits needed to represent a field element |
ba12070f NL |
392 | * \param group EC_GROUP object |
393 | * \return number of bits needed to represent a field element | |
394 | */ | |
395 | int EC_GROUP_get_degree(const EC_GROUP *group); | |
3a12ce01 | 396 | |
ba12070f NL |
397 | /** Checks whether the parameter in the EC_GROUP define a valid ec group |
398 | * \param group EC_GROUP object | |
399 | * \param ctx BN_CTX object (optional) | |
400 | * \return 1 if group is a valid ec group and 0 otherwise | |
401 | */ | |
af28dd6c | 402 | int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx); |
945e15a2 | 403 | |
ba12070f NL |
404 | /** Checks whether the discriminant of the elliptic curve is zero or not |
405 | * \param group EC_GROUP object | |
406 | * \param ctx BN_CTX object (optional) | |
407 | * \return 1 if the discriminant is not zero and 0 otherwise | |
408 | */ | |
409 | int EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx); | |
410 | ||
411 | /** Compares two EC_GROUP objects | |
412 | * \param a first EC_GROUP object | |
413 | * \param b second EC_GROUP object | |
414 | * \param ctx BN_CTX object (optional) | |
14f46560 | 415 | * \return 0 if the groups are equal, 1 if not, or -1 on error |
ba12070f NL |
416 | */ |
417 | int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx); | |
ada0e717 | 418 | |
0f113f3e MC |
419 | /* |
420 | * EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*() after | |
421 | * choosing an appropriate EC_METHOD | |
422 | */ | |
945e15a2 | 423 | |
ba12070f NL |
424 | /** Creates a new EC_GROUP object with the specified parameters defined |
425 | * over GFp (defined by the equation y^2 = x^3 + a*x + b) | |
426 | * \param p BIGNUM with the prime number | |
427 | * \param a BIGNUM with the parameter a of the equation | |
428 | * \param b BIGNUM with the parameter b of the equation | |
429 | * \param ctx BN_CTX object (optional) | |
430 | * \return newly created EC_GROUP object with the specified parameters | |
431 | */ | |
0f113f3e MC |
432 | EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, |
433 | const BIGNUM *b, BN_CTX *ctx); | |
ee8db22e | 434 | # ifndef OPENSSL_NO_EC2M |
ba12070f NL |
435 | /** Creates a new EC_GROUP object with the specified parameters defined |
436 | * over GF2m (defined by the equation y^2 + x*y = x^3 + a*x^2 + b) | |
437 | * \param p BIGNUM with the polynomial defining the underlying field | |
438 | * \param a BIGNUM with the parameter a of the equation | |
439 | * \param b BIGNUM with the parameter b of the equation | |
440 | * \param ctx BN_CTX object (optional) | |
441 | * \return newly created EC_GROUP object with the specified parameters | |
442 | */ | |
0f113f3e MC |
443 | EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, |
444 | const BIGNUM *b, BN_CTX *ctx); | |
ee8db22e | 445 | # endif |
60b350a3 | 446 | |
c0f39ded SL |
447 | /** |
448 | * Creates a EC_GROUP object with a curve specified by parameters. | |
449 | * The parameters may be explicit or a named curve, | |
450 | * \param params A list of parameters describing the group. | |
451 | * \param libctx The associated library context or NULL for the default | |
452 | * context | |
453 | * \param propq A property query string | |
454 | * \return newly created EC_GROUP object with specified parameters or NULL | |
455 | * if an error occurred | |
456 | */ | |
457 | EC_GROUP *EC_GROUP_new_from_params(const OSSL_PARAM params[], | |
b4250010 | 458 | OSSL_LIB_CTX *libctx, const char *propq); |
c0f39ded | 459 | |
a9612d6c MC |
460 | /** |
461 | * Creates a EC_GROUP object with a curve specified by a NID | |
462 | * \param libctx The associated library context or NULL for the default | |
463 | * context | |
2da8d4eb | 464 | * \param propq A property query string |
a9612d6c MC |
465 | * \param nid NID of the OID of the curve name |
466 | * \return newly created EC_GROUP object with specified curve or NULL | |
467 | * if an error occurred | |
468 | */ | |
b4250010 | 469 | EC_GROUP *EC_GROUP_new_by_curve_name_ex(OSSL_LIB_CTX *libctx, const char *propq, |
d8652be0 | 470 | int nid); |
a9612d6c MC |
471 | |
472 | /** | |
473 | * Creates a EC_GROUP object with a curve specified by a NID. Same as | |
d8652be0 | 474 | * EC_GROUP_new_by_curve_name_ex but the libctx and propq are always |
2da8d4eb | 475 | * NULL. |
a9612d6c | 476 | * \param nid NID of the OID of the curve name |
ba12070f NL |
477 | * \return newly created EC_GROUP object with specified curve or NULL |
478 | * if an error occurred | |
479 | */ | |
8b15c740 | 480 | EC_GROUP *EC_GROUP_new_by_curve_name(int nid); |
ba12070f | 481 | |
60b350a3 RS |
482 | /** Creates a new EC_GROUP object from an ECPARAMETERS object |
483 | * \param params pointer to the ECPARAMETERS object | |
484 | * \return newly created EC_GROUP object with specified curve or NULL | |
485 | * if an error occurred | |
486 | */ | |
487 | EC_GROUP *EC_GROUP_new_from_ecparameters(const ECPARAMETERS *params); | |
488 | ||
436ad81f | 489 | /** Creates an ECPARAMETERS object for the given EC_GROUP object. |
60b350a3 RS |
490 | * \param group pointer to the EC_GROUP object |
491 | * \param params pointer to an existing ECPARAMETERS object or NULL | |
492 | * \return pointer to the new ECPARAMETERS object or NULL | |
493 | * if an error occurred. | |
494 | */ | |
495 | ECPARAMETERS *EC_GROUP_get_ecparameters(const EC_GROUP *group, | |
496 | ECPARAMETERS *params); | |
497 | ||
498 | /** Creates a new EC_GROUP object from an ECPKPARAMETERS object | |
499 | * \param params pointer to an existing ECPKPARAMETERS object, or NULL | |
500 | * \return newly created EC_GROUP object with specified curve, or NULL | |
501 | * if an error occurred | |
502 | */ | |
503 | EC_GROUP *EC_GROUP_new_from_ecpkparameters(const ECPKPARAMETERS *params); | |
504 | ||
436ad81f | 505 | /** Creates an ECPKPARAMETERS object for the given EC_GROUP object. |
60b350a3 RS |
506 | * \param group pointer to the EC_GROUP object |
507 | * \param params pointer to an existing ECPKPARAMETERS object or NULL | |
508 | * \return pointer to the new ECPKPARAMETERS object or NULL | |
509 | * if an error occurred. | |
510 | */ | |
511 | ECPKPARAMETERS *EC_GROUP_get_ecpkparameters(const EC_GROUP *group, | |
512 | ECPKPARAMETERS *params); | |
513 | ||
ba12070f NL |
514 | /********************************************************************/ |
515 | /* handling of internal curves */ | |
516 | /********************************************************************/ | |
517 | ||
0f113f3e MC |
518 | typedef struct { |
519 | int nid; | |
520 | const char *comment; | |
521 | } EC_builtin_curve; | |
ba12070f | 522 | |
0f113f3e MC |
523 | /* |
524 | * EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number of all | |
8483a003 | 525 | * available curves or zero if a error occurred. In case r is not zero, |
0f113f3e MC |
526 | * nitems EC_builtin_curve structures are filled with the data of the first |
527 | * nitems internal groups | |
528 | */ | |
65b1d31d | 529 | size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems); |
7eb18f12 | 530 | |
64095ce9 DSH |
531 | const char *EC_curve_nid2nist(int nid); |
532 | int EC_curve_nist2nid(const char *name); | |
a9612d6c MC |
533 | int EC_GROUP_check_named_curve(const EC_GROUP *group, int nist_only, |
534 | BN_CTX *ctx); | |
7e31164a | 535 | |
ba12070f NL |
536 | /********************************************************************/ |
537 | /* EC_POINT functions */ | |
538 | /********************************************************************/ | |
539 | ||
540 | /** Creates a new EC_POINT object for the specified EC_GROUP | |
541 | * \param group EC_GROUP the underlying EC_GROUP object | |
542 | * \return newly created EC_POINT object or NULL if an error occurred | |
543 | */ | |
544 | EC_POINT *EC_POINT_new(const EC_GROUP *group); | |
545 | ||
546 | /** Frees a EC_POINT object | |
547 | * \param point EC_POINT object to be freed | |
548 | */ | |
549 | void EC_POINT_free(EC_POINT *point); | |
550 | ||
551 | /** Clears and frees a EC_POINT object | |
552 | * \param point EC_POINT object to be cleared and freed | |
553 | */ | |
554 | void EC_POINT_clear_free(EC_POINT *point); | |
555 | ||
556 | /** Copies EC_POINT object | |
557 | * \param dst destination EC_POINT object | |
558 | * \param src source EC_POINT object | |
478b50cf | 559 | * \return 1 on success and 0 if an error occurred |
ba12070f NL |
560 | */ |
561 | int EC_POINT_copy(EC_POINT *dst, const EC_POINT *src); | |
945e15a2 | 562 | |
ba12070f NL |
563 | /** Creates a new EC_POINT object and copies the content of the supplied |
564 | * EC_POINT | |
565 | * \param src source EC_POINT object | |
566 | * \param group underlying the EC_GROUP object | |
0f113f3e | 567 | * \return newly created EC_POINT object or NULL if an error occurred |
ba12070f NL |
568 | */ |
569 | EC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group); | |
0f113f3e | 570 | |
ba12070f NL |
571 | /** Sets a point to infinity (neutral element) |
572 | * \param group underlying EC_GROUP object | |
573 | * \param point EC_POINT to set to infinity | |
478b50cf | 574 | * \return 1 on success and 0 if an error occurred |
ba12070f NL |
575 | */ |
576 | int EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point); | |
577 | ||
5b5eea4b SL |
578 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
579 | /** Returns the EC_METHOD used in EC_POINT object | |
580 | * \param point EC_POINT object | |
581 | * \return the EC_METHOD used | |
582 | */ | |
583 | OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_POINT_method_of(const EC_POINT *point); | |
584 | ||
ba12070f NL |
585 | /** Sets the jacobian projective coordinates of a EC_POINT over GFp |
586 | * \param group underlying EC_GROUP object | |
587 | * \param p EC_POINT object | |
588 | * \param x BIGNUM with the x-coordinate | |
589 | * \param y BIGNUM with the y-coordinate | |
590 | * \param z BIGNUM with the z-coordinate | |
591 | * \param ctx BN_CTX object (optional) | |
478b50cf | 592 | * \return 1 on success and 0 if an error occurred |
ba12070f | 593 | */ |
5b5eea4b SL |
594 | OSSL_DEPRECATEDIN_3_0 int EC_POINT_set_Jprojective_coordinates_GFp |
595 | (const EC_GROUP *group, EC_POINT *p, | |
596 | const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, | |
597 | BN_CTX *ctx); | |
ba12070f NL |
598 | |
599 | /** Gets the jacobian projective coordinates of a EC_POINT over GFp | |
600 | * \param group underlying EC_GROUP object | |
601 | * \param p EC_POINT object | |
602 | * \param x BIGNUM for the x-coordinate | |
603 | * \param y BIGNUM for the y-coordinate | |
604 | * \param z BIGNUM for the z-coordinate | |
605 | * \param ctx BN_CTX object (optional) | |
478b50cf | 606 | * \return 1 on success and 0 if an error occurred |
ba12070f | 607 | */ |
5b5eea4b SL |
608 | OSSL_DEPRECATEDIN_3_0 int EC_POINT_get_Jprojective_coordinates_GFp |
609 | (const EC_GROUP *group, const EC_POINT *p, | |
610 | BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx); | |
611 | # endif /* OPENSSL_NO_DEPRECATED_3_0 */ | |
ba12070f | 612 | |
8e3cced7 MC |
613 | /** Sets the affine coordinates of an EC_POINT |
614 | * \param group underlying EC_GROUP object | |
615 | * \param p EC_POINT object | |
616 | * \param x BIGNUM with the x-coordinate | |
617 | * \param y BIGNUM with the y-coordinate | |
618 | * \param ctx BN_CTX object (optional) | |
619 | * \return 1 on success and 0 if an error occurred | |
620 | */ | |
621 | int EC_POINT_set_affine_coordinates(const EC_GROUP *group, EC_POINT *p, | |
622 | const BIGNUM *x, const BIGNUM *y, | |
623 | BN_CTX *ctx); | |
624 | ||
625 | /** Gets the affine coordinates of an EC_POINT. | |
626 | * \param group underlying EC_GROUP object | |
627 | * \param p EC_POINT object | |
628 | * \param x BIGNUM for the x-coordinate | |
629 | * \param y BIGNUM for the y-coordinate | |
630 | * \param ctx BN_CTX object (optional) | |
631 | * \return 1 on success and 0 if an error occurred | |
632 | */ | |
633 | int EC_POINT_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *p, | |
634 | BIGNUM *x, BIGNUM *y, BN_CTX *ctx); | |
635 | ||
5b5eea4b | 636 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
8e3cced7 MC |
637 | /** Sets the affine coordinates of an EC_POINT. A synonym of |
638 | * EC_POINT_set_affine_coordinates | |
ba12070f NL |
639 | * \param group underlying EC_GROUP object |
640 | * \param p EC_POINT object | |
641 | * \param x BIGNUM with the x-coordinate | |
642 | * \param y BIGNUM with the y-coordinate | |
643 | * \param ctx BN_CTX object (optional) | |
478b50cf | 644 | * \return 1 on success and 0 if an error occurred |
ba12070f | 645 | */ |
5b5eea4b SL |
646 | OSSL_DEPRECATEDIN_3_0 int EC_POINT_set_affine_coordinates_GFp |
647 | (const EC_GROUP *group, EC_POINT *p, | |
648 | const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx); | |
ba12070f | 649 | |
8e3cced7 MC |
650 | /** Gets the affine coordinates of an EC_POINT. A synonym of |
651 | * EC_POINT_get_affine_coordinates | |
ba12070f NL |
652 | * \param group underlying EC_GROUP object |
653 | * \param p EC_POINT object | |
654 | * \param x BIGNUM for the x-coordinate | |
655 | * \param y BIGNUM for the y-coordinate | |
656 | * \param ctx BN_CTX object (optional) | |
478b50cf | 657 | * \return 1 on success and 0 if an error occurred |
ba12070f | 658 | */ |
5b5eea4b SL |
659 | OSSL_DEPRECATEDIN_3_0 int EC_POINT_get_affine_coordinates_GFp |
660 | (const EC_GROUP *group, const EC_POINT *p, | |
661 | BIGNUM *x, BIGNUM *y, BN_CTX *ctx); | |
662 | # endif /* OPENSSL_NO_DEPRECATED_3_0 */ | |
ba12070f | 663 | |
8e3cced7 MC |
664 | /** Sets the x9.62 compressed coordinates of a EC_POINT |
665 | * \param group underlying EC_GROUP object | |
666 | * \param p EC_POINT object | |
667 | * \param x BIGNUM with x-coordinate | |
668 | * \param y_bit integer with the y-Bit (either 0 or 1) | |
669 | * \param ctx BN_CTX object (optional) | |
670 | * \return 1 on success and 0 if an error occurred | |
671 | */ | |
672 | int EC_POINT_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *p, | |
673 | const BIGNUM *x, int y_bit, | |
674 | BN_CTX *ctx); | |
675 | ||
5b5eea4b | 676 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
8e3cced7 MC |
677 | /** Sets the x9.62 compressed coordinates of a EC_POINT. A synonym of |
678 | * EC_POINT_set_compressed_coordinates | |
ba12070f NL |
679 | * \param group underlying EC_GROUP object |
680 | * \param p EC_POINT object | |
681 | * \param x BIGNUM with x-coordinate | |
682 | * \param y_bit integer with the y-Bit (either 0 or 1) | |
683 | * \param ctx BN_CTX object (optional) | |
478b50cf | 684 | * \return 1 on success and 0 if an error occurred |
ba12070f | 685 | */ |
5b5eea4b SL |
686 | OSSL_DEPRECATEDIN_3_0 int EC_POINT_set_compressed_coordinates_GFp |
687 | (const EC_GROUP *group, EC_POINT *p, | |
688 | const BIGNUM *x, int y_bit, BN_CTX *ctx); | |
689 | # ifndef OPENSSL_NO_EC2M | |
8e3cced7 MC |
690 | /** Sets the affine coordinates of an EC_POINT. A synonym of |
691 | * EC_POINT_set_affine_coordinates | |
ba12070f NL |
692 | * \param group underlying EC_GROUP object |
693 | * \param p EC_POINT object | |
694 | * \param x BIGNUM with the x-coordinate | |
695 | * \param y BIGNUM with the y-coordinate | |
696 | * \param ctx BN_CTX object (optional) | |
478b50cf | 697 | * \return 1 on success and 0 if an error occurred |
ba12070f | 698 | */ |
5b5eea4b SL |
699 | OSSL_DEPRECATEDIN_3_0 int EC_POINT_set_affine_coordinates_GF2m |
700 | (const EC_GROUP *group, EC_POINT *p, | |
701 | const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx); | |
ba12070f | 702 | |
8e3cced7 MC |
703 | /** Gets the affine coordinates of an EC_POINT. A synonym of |
704 | * EC_POINT_get_affine_coordinates | |
ba12070f NL |
705 | * \param group underlying EC_GROUP object |
706 | * \param p EC_POINT object | |
707 | * \param x BIGNUM for the x-coordinate | |
708 | * \param y BIGNUM for the y-coordinate | |
709 | * \param ctx BN_CTX object (optional) | |
478b50cf | 710 | * \return 1 on success and 0 if an error occurred |
ba12070f | 711 | */ |
5b5eea4b SL |
712 | OSSL_DEPRECATEDIN_3_0 int EC_POINT_get_affine_coordinates_GF2m |
713 | (const EC_GROUP *group, const EC_POINT *p, | |
714 | BIGNUM *x, BIGNUM *y, BN_CTX *ctx); | |
ba12070f | 715 | |
8e3cced7 MC |
716 | /** Sets the x9.62 compressed coordinates of a EC_POINT. A synonym of |
717 | * EC_POINT_set_compressed_coordinates | |
ba12070f NL |
718 | * \param group underlying EC_GROUP object |
719 | * \param p EC_POINT object | |
720 | * \param x BIGNUM with x-coordinate | |
721 | * \param y_bit integer with the y-Bit (either 0 or 1) | |
722 | * \param ctx BN_CTX object (optional) | |
478b50cf | 723 | * \return 1 on success and 0 if an error occurred |
ba12070f | 724 | */ |
5b5eea4b SL |
725 | OSSL_DEPRECATEDIN_3_0 int EC_POINT_set_compressed_coordinates_GF2m |
726 | (const EC_GROUP *group, EC_POINT *p, | |
727 | const BIGNUM *x, int y_bit, BN_CTX *ctx); | |
728 | # endif | |
729 | # endif /* OPENSSL_NO_DEPRECATED_3_0 */ | |
730 | ||
ba12070f NL |
731 | /** Encodes a EC_POINT object to a octet string |
732 | * \param group underlying EC_GROUP object | |
733 | * \param p EC_POINT object | |
734 | * \param form point conversion form | |
735 | * \param buf memory buffer for the result. If NULL the function returns | |
736 | * required buffer size. | |
737 | * \param len length of the memory buffer | |
738 | * \param ctx BN_CTX object (optional) | |
739 | * \return the length of the encoded octet string or 0 if an error occurred | |
740 | */ | |
741 | size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p, | |
0f113f3e MC |
742 | point_conversion_form_t form, |
743 | unsigned char *buf, size_t len, BN_CTX *ctx); | |
ba12070f NL |
744 | |
745 | /** Decodes a EC_POINT from a octet string | |
746 | * \param group underlying EC_GROUP object | |
747 | * \param p EC_POINT object | |
748 | * \param buf memory buffer with the encoded ec point | |
749 | * \param len length of the encoded ec point | |
750 | * \param ctx BN_CTX object (optional) | |
478b50cf | 751 | * \return 1 on success and 0 if an error occurred |
ba12070f NL |
752 | */ |
753 | int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p, | |
0f113f3e | 754 | const unsigned char *buf, size_t len, BN_CTX *ctx); |
7d7db13e | 755 | |
981bd8a2 DSH |
756 | /** Encodes an EC_POINT object to an allocated octet string |
757 | * \param group underlying EC_GROUP object | |
758 | * \param point EC_POINT object | |
759 | * \param form point conversion form | |
760 | * \param pbuf returns pointer to allocated buffer | |
981bd8a2 DSH |
761 | * \param ctx BN_CTX object (optional) |
762 | * \return the length of the encoded octet string or 0 if an error occurred | |
763 | */ | |
981bd8a2 DSH |
764 | size_t EC_POINT_point2buf(const EC_GROUP *group, const EC_POINT *point, |
765 | point_conversion_form_t form, | |
766 | unsigned char **pbuf, BN_CTX *ctx); | |
767 | ||
6cbe6382 | 768 | /* other interfaces to point2oct/oct2point: */ |
c1131e6a SL |
769 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
770 | OSSL_DEPRECATEDIN_3_0 BIGNUM *EC_POINT_point2bn(const EC_GROUP *, | |
771 | const EC_POINT *, | |
772 | point_conversion_form_t form, | |
773 | BIGNUM *, BN_CTX *); | |
774 | OSSL_DEPRECATEDIN_3_0 EC_POINT *EC_POINT_bn2point(const EC_GROUP *, | |
775 | const BIGNUM *, | |
776 | EC_POINT *, BN_CTX *); | |
777 | # endif /* OPENSSL_NO_DEPRECATED_3_0 */ | |
778 | ||
6cbe6382 | 779 | char *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *, |
0f113f3e | 780 | point_conversion_form_t form, BN_CTX *); |
6cbe6382 | 781 | EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *, |
0f113f3e | 782 | EC_POINT *, BN_CTX *); |
3a12ce01 | 783 | |
ba12070f NL |
784 | /********************************************************************/ |
785 | /* functions for doing EC_POINT arithmetic */ | |
786 | /********************************************************************/ | |
787 | ||
0f113f3e | 788 | /** Computes the sum of two EC_POINT |
ba12070f NL |
789 | * \param group underlying EC_GROUP object |
790 | * \param r EC_POINT object for the result (r = a + b) | |
791 | * \param a EC_POINT object with the first summand | |
792 | * \param b EC_POINT object with the second summand | |
793 | * \param ctx BN_CTX object (optional) | |
478b50cf | 794 | * \return 1 on success and 0 if an error occurred |
ba12070f | 795 | */ |
0f113f3e MC |
796 | int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, |
797 | const EC_POINT *b, BN_CTX *ctx); | |
ba12070f NL |
798 | |
799 | /** Computes the double of a EC_POINT | |
800 | * \param group underlying EC_GROUP object | |
801 | * \param r EC_POINT object for the result (r = 2 * a) | |
0f113f3e | 802 | * \param a EC_POINT object |
ba12070f | 803 | * \param ctx BN_CTX object (optional) |
478b50cf | 804 | * \return 1 on success and 0 if an error occurred |
ba12070f | 805 | */ |
0f113f3e MC |
806 | int EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, |
807 | BN_CTX *ctx); | |
ba12070f NL |
808 | |
809 | /** Computes the inverse of a EC_POINT | |
810 | * \param group underlying EC_GROUP object | |
811 | * \param a EC_POINT object to be inverted (it's used for the result as well) | |
812 | * \param ctx BN_CTX object (optional) | |
478b50cf | 813 | * \return 1 on success and 0 if an error occurred |
ba12070f NL |
814 | */ |
815 | int EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx); | |
816 | ||
817 | /** Checks whether the point is the neutral element of the group | |
818 | * \param group the underlying EC_GROUP object | |
819 | * \param p EC_POINT object | |
820 | * \return 1 if the point is the neutral element and 0 otherwise | |
821 | */ | |
822 | int EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *p); | |
823 | ||
0f113f3e | 824 | /** Checks whether the point is on the curve |
ba12070f NL |
825 | * \param group underlying EC_GROUP object |
826 | * \param point EC_POINT object to check | |
827 | * \param ctx BN_CTX object (optional) | |
14f46560 | 828 | * \return 1 if the point is on the curve, 0 if not, or -1 on error |
ba12070f | 829 | */ |
0f113f3e MC |
830 | int EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, |
831 | BN_CTX *ctx); | |
ba12070f | 832 | |
0f113f3e | 833 | /** Compares two EC_POINTs |
ba12070f NL |
834 | * \param group underlying EC_GROUP object |
835 | * \param a first EC_POINT object | |
836 | * \param b second EC_POINT object | |
837 | * \param ctx BN_CTX object (optional) | |
14f46560 | 838 | * \return 1 if the points are not equal, 0 if they are, or -1 on error |
ba12070f | 839 | */ |
0f113f3e MC |
840 | int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, |
841 | BN_CTX *ctx); | |
fb171e53 | 842 | |
5b5eea4b SL |
843 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
844 | OSSL_DEPRECATEDIN_3_0 int EC_POINT_make_affine(const EC_GROUP *group, | |
845 | EC_POINT *point, BN_CTX *ctx); | |
846 | OSSL_DEPRECATEDIN_3_0 int EC_POINTs_make_affine(const EC_GROUP *group, size_t num, | |
847 | EC_POINT *points[], BN_CTX *ctx); | |
fb171e53 | 848 | |
14f46560 | 849 | /** Computes r = generator * n + sum_{i=0}^{num-1} p[i] * m[i] |
ba12070f NL |
850 | * \param group underlying EC_GROUP object |
851 | * \param r EC_POINT object for the result | |
852 | * \param n BIGNUM with the multiplier for the group generator (optional) | |
8483a003 | 853 | * \param num number further summands |
ba12070f NL |
854 | * \param p array of size num of EC_POINT objects |
855 | * \param m array of size num of BIGNUM objects | |
856 | * \param ctx BN_CTX object (optional) | |
478b50cf | 857 | * \return 1 on success and 0 if an error occurred |
ba12070f | 858 | */ |
5b5eea4b SL |
859 | OSSL_DEPRECATEDIN_3_0 int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, |
860 | const BIGNUM *n, size_t num, | |
861 | const EC_POINT *p[], const BIGNUM *m[], | |
862 | BN_CTX *ctx); | |
863 | # endif /* OPENSSL_NO_DEPRECATED_3_0 */ | |
ba12070f NL |
864 | |
865 | /** Computes r = generator * n + q * m | |
866 | * \param group underlying EC_GROUP object | |
867 | * \param r EC_POINT object for the result | |
868 | * \param n BIGNUM with the multiplier for the group generator (optional) | |
869 | * \param q EC_POINT object with the first factor of the second summand | |
870 | * \param m BIGNUM with the second factor of the second summand | |
871 | * \param ctx BN_CTX object (optional) | |
478b50cf | 872 | * \return 1 on success and 0 if an error occurred |
ba12070f | 873 | */ |
0f113f3e MC |
874 | int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, |
875 | const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx); | |
3a12ce01 | 876 | |
5b5eea4b | 877 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
ba12070f NL |
878 | /** Stores multiples of generator for faster point multiplication |
879 | * \param group EC_GROUP object | |
880 | * \param ctx BN_CTX object (optional) | |
478b50cf | 881 | * \return 1 on success and 0 if an error occurred |
ba12070f | 882 | */ |
5b5eea4b | 883 | OSSL_DEPRECATEDIN_3_0 int EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx); |
6cc5e19d | 884 | |
ba12070f NL |
885 | /** Reports whether a precomputation has been done |
886 | * \param group EC_GROUP object | |
887 | * \return 1 if a pre-computation has been done and 0 otherwise | |
888 | */ | |
5b5eea4b SL |
889 | OSSL_DEPRECATEDIN_3_0 int EC_GROUP_have_precompute_mult(const EC_GROUP *group); |
890 | # endif /* OPENSSL_NO_DEPRECATED_3_0 */ | |
6cc5e19d | 891 | |
ba12070f NL |
892 | /********************************************************************/ |
893 | /* ASN1 stuff */ | |
894 | /********************************************************************/ | |
8aefe253 | 895 | |
60b350a3 | 896 | DECLARE_ASN1_ITEM(ECPKPARAMETERS) |
9ba6f347 | 897 | DECLARE_ASN1_ALLOC_FUNCTIONS(ECPKPARAMETERS) |
60b350a3 | 898 | DECLARE_ASN1_ITEM(ECPARAMETERS) |
9ba6f347 | 899 | DECLARE_ASN1_ALLOC_FUNCTIONS(ECPARAMETERS) |
60b350a3 | 900 | |
0f113f3e MC |
901 | /* |
902 | * EC_GROUP_get_basis_type() returns the NID of the basis type used to | |
903 | * represent the field elements | |
904 | */ | |
34f1f2a8 | 905 | int EC_GROUP_get_basis_type(const EC_GROUP *); |
ee8db22e | 906 | # ifndef OPENSSL_NO_EC2M |
34f1f2a8 | 907 | int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k); |
0f113f3e MC |
908 | int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1, |
909 | unsigned int *k2, unsigned int *k3); | |
ee8db22e | 910 | # endif |
8aefe253 | 911 | |
6343829a | 912 | EC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len); |
458c2917 BM |
913 | int i2d_ECPKParameters(const EC_GROUP *, unsigned char **out); |
914 | ||
ee8db22e P |
915 | # define d2i_ECPKParameters_bio(bp,x) \ |
916 | ASN1_d2i_bio_of(EC_GROUP, NULL, d2i_ECPKParameters, bp, x) | |
917 | # define i2d_ECPKParameters_bio(bp,x) \ | |
918 | ASN1_i2d_bio_of(EC_GROUP, i2d_ECPKParameters, bp, x) | |
919 | # define d2i_ECPKParameters_fp(fp,x) \ | |
cca8a4ce NT |
920 | (EC_GROUP *)ASN1_d2i_fp(NULL, (d2i_of_void *)d2i_ECPKParameters, (fp), \ |
921 | (void **)(x)) | |
ee8db22e | 922 | # define i2d_ECPKParameters_fp(fp,x) \ |
cca8a4ce | 923 | ASN1_i2d_fp((i2d_of_void *)i2d_ECPKParameters, (fp), (void *)(x)) |
5f3d6f70 | 924 | |
5b5eea4b SL |
925 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
926 | OSSL_DEPRECATEDIN_3_0 int ECPKParameters_print(BIO *bp, const EC_GROUP *x, | |
927 | int off); | |
928 | # ifndef OPENSSL_NO_STDIO | |
929 | OSSL_DEPRECATEDIN_3_0 int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, | |
930 | int off); | |
931 | # endif | |
932 | # endif /* OPENSSL_NO_DEPRECATED_3_0 */ | |
ba12070f NL |
933 | |
934 | /********************************************************************/ | |
935 | /* EC_KEY functions */ | |
936 | /********************************************************************/ | |
937 | ||
14a7cfb3 | 938 | /* some values for the encoding_flag */ |
ee8db22e P |
939 | # define EC_PKEY_NO_PARAMETERS 0x001 |
940 | # define EC_PKEY_NO_PUBKEY 0x002 | |
14a7cfb3 | 941 | |
cac4fb58 | 942 | /* some values for the flags field */ |
5b5eea4b SL |
943 | # define EC_FLAG_SM2_RANGE 0x0004 |
944 | # define EC_FLAG_COFACTOR_ECDH 0x1000 | |
945 | # define EC_FLAG_CHECK_NAMED_GROUP 0x2000 | |
946 | # define EC_FLAG_CHECK_NAMED_GROUP_NIST 0x4000 | |
947 | # define EC_FLAG_CHECK_NAMED_GROUP_MASK \ | |
948 | (EC_FLAG_CHECK_NAMED_GROUP | EC_FLAG_CHECK_NAMED_GROUP_NIST) | |
949 | ||
950 | /* Deprecated flags - it was using 0x01..0x02 */ | |
951 | # define EC_FLAG_NON_FIPS_ALLOW 0x0000 | |
952 | # define EC_FLAG_FIPS_CHECKED 0x0000 | |
cac4fb58 | 953 | |
5b5eea4b | 954 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
a9612d6c MC |
955 | /** |
956 | * Creates a new EC_KEY object. | |
957 | * \param ctx The library context for to use for this EC_KEY. May be NULL in | |
958 | * which case the default library context is used. | |
959 | * \return EC_KEY object or NULL if an error occurred. | |
960 | */ | |
5b5eea4b | 961 | OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_new_ex(OSSL_LIB_CTX *ctx, const char *propq); |
a9612d6c MC |
962 | |
963 | /** | |
d8652be0 | 964 | * Creates a new EC_KEY object. Same as calling EC_KEY_new_ex with a |
2da8d4eb | 965 | * NULL library context |
ba12070f NL |
966 | * \return EC_KEY object or NULL if an error occurred. |
967 | */ | |
5b5eea4b | 968 | OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_new(void); |
ba12070f | 969 | |
5b5eea4b | 970 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_get_flags(const EC_KEY *key); |
cac4fb58 | 971 | |
5b5eea4b | 972 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_set_flags(EC_KEY *key, int flags); |
cac4fb58 | 973 | |
5b5eea4b | 974 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_clear_flags(EC_KEY *key, int flags); |
cac4fb58 | 975 | |
5b5eea4b | 976 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_decoded_from_explicit_params(const EC_KEY *key); |
fe2f8aec | 977 | |
a9612d6c MC |
978 | /** |
979 | * Creates a new EC_KEY object using a named curve as underlying | |
ba12070f | 980 | * EC_GROUP object. |
2da8d4eb MC |
981 | * \param ctx The library context for to use for this EC_KEY. May be NULL in |
982 | * which case the default library context is used. | |
983 | * \param propq Any property query string | |
984 | * \param nid NID of the named curve. | |
a9612d6c MC |
985 | * \return EC_KEY object or NULL if an error occurred. |
986 | */ | |
5b5eea4b SL |
987 | OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_new_by_curve_name_ex(OSSL_LIB_CTX *ctx, |
988 | const char *propq, | |
989 | int nid); | |
a9612d6c MC |
990 | |
991 | /** | |
992 | * Creates a new EC_KEY object using a named curve as underlying | |
993 | * EC_GROUP object. Same as calling EC_KEY_new_by_curve_name_ex with a NULL | |
2da8d4eb | 994 | * library context and property query string. |
ba12070f | 995 | * \param nid NID of the named curve. |
0f113f3e | 996 | * \return EC_KEY object or NULL if an error occurred. |
ba12070f | 997 | */ |
5b5eea4b | 998 | OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_new_by_curve_name(int nid); |
a9612d6c | 999 | |
ba12070f NL |
1000 | /** Frees a EC_KEY object. |
1001 | * \param key EC_KEY object to be freed. | |
1002 | */ | |
5b5eea4b | 1003 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_free(EC_KEY *key); |
ba12070f NL |
1004 | |
1005 | /** Copies a EC_KEY object. | |
1006 | * \param dst destination EC_KEY object | |
1007 | * \param src src EC_KEY object | |
1008 | * \return dst or NULL if an error occurred. | |
1009 | */ | |
5b5eea4b | 1010 | OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_copy(EC_KEY *dst, const EC_KEY *src); |
ba12070f NL |
1011 | |
1012 | /** Creates a new EC_KEY object and copies the content from src to it. | |
1013 | * \param src the source EC_KEY object | |
1014 | * \return newly created EC_KEY object or NULL if an error occurred. | |
1015 | */ | |
5b5eea4b | 1016 | OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_dup(const EC_KEY *src); |
ba12070f NL |
1017 | |
1018 | /** Increases the internal reference count of a EC_KEY object. | |
1019 | * \param key EC_KEY object | |
1020 | * \return 1 on success and 0 if an error occurred. | |
1021 | */ | |
5b5eea4b | 1022 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_up_ref(EC_KEY *key); |
ba12070f | 1023 | |
d1da335c | 1024 | /** Returns the ENGINE object of a EC_KEY object |
28c0a61b | 1025 | * \param eckey EC_KEY object |
d1da335c RL |
1026 | * \return the ENGINE object (possibly NULL). |
1027 | */ | |
5b5eea4b | 1028 | OSSL_DEPRECATEDIN_3_0 ENGINE *EC_KEY_get0_engine(const EC_KEY *eckey); |
d1da335c | 1029 | |
ba12070f NL |
1030 | /** Returns the EC_GROUP object of a EC_KEY object |
1031 | * \param key EC_KEY object | |
1032 | * \return the EC_GROUP object (possibly NULL). | |
1033 | */ | |
5b5eea4b | 1034 | OSSL_DEPRECATEDIN_3_0 const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key); |
ba12070f NL |
1035 | |
1036 | /** Sets the EC_GROUP of a EC_KEY object. | |
1037 | * \param key EC_KEY object | |
1038 | * \param group EC_GROUP to use in the EC_KEY object (note: the EC_KEY | |
1039 | * object will use an own copy of the EC_GROUP). | |
1040 | * \return 1 on success and 0 if an error occurred. | |
1041 | */ | |
5b5eea4b | 1042 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group); |
ba12070f NL |
1043 | |
1044 | /** Returns the private key of a EC_KEY object. | |
1045 | * \param key EC_KEY object | |
1046 | * \return a BIGNUM with the private key (possibly NULL). | |
1047 | */ | |
5b5eea4b | 1048 | OSSL_DEPRECATEDIN_3_0 const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key); |
ba12070f NL |
1049 | |
1050 | /** Sets the private key of a EC_KEY object. | |
1051 | * \param key EC_KEY object | |
1052 | * \param prv BIGNUM with the private key (note: the EC_KEY object | |
1053 | * will use an own copy of the BIGNUM). | |
1054 | * \return 1 on success and 0 if an error occurred. | |
1055 | */ | |
5b5eea4b | 1056 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv); |
ba12070f NL |
1057 | |
1058 | /** Returns the public key of a EC_KEY object. | |
1059 | * \param key the EC_KEY object | |
1060 | * \return a EC_POINT object with the public key (possibly NULL) | |
1061 | */ | |
5b5eea4b | 1062 | OSSL_DEPRECATEDIN_3_0 const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key); |
ba12070f NL |
1063 | |
1064 | /** Sets the public key of a EC_KEY object. | |
1065 | * \param key EC_KEY object | |
1066 | * \param pub EC_POINT object with the public key (note: the EC_KEY object | |
1067 | * will use an own copy of the EC_POINT object). | |
1068 | * \return 1 on success and 0 if an error occurred. | |
1069 | */ | |
5b5eea4b | 1070 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub); |
ba12070f | 1071 | |
5b5eea4b SL |
1072 | OSSL_DEPRECATEDIN_3_0 unsigned EC_KEY_get_enc_flags(const EC_KEY *key); |
1073 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_set_enc_flags(EC_KEY *eckey, unsigned int flags); | |
1074 | OSSL_DEPRECATEDIN_3_0 point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key); | |
1075 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_set_conv_form(EC_KEY *eckey, | |
1076 | point_conversion_form_t cform); | |
1077 | # endif /*OPENSSL_NO_DEPRECATED_3_0 */ | |
3aef36ff | 1078 | |
f9253152 | 1079 | # define EC_KEY_get_ex_new_index(l, p, newf, dupf, freef) \ |
3aef36ff | 1080 | CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_EC_KEY, l, p, newf, dupf, freef) |
5b5eea4b SL |
1081 | |
1082 | # ifndef OPENSSL_NO_DEPRECATED_3_0 | |
1083 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_ex_data(EC_KEY *key, int idx, void *arg); | |
1084 | OSSL_DEPRECATEDIN_3_0 void *EC_KEY_get_ex_data(const EC_KEY *key, int idx); | |
3aef36ff | 1085 | |
9dd84053 | 1086 | /* wrapper functions for the underlying EC_GROUP object */ |
5b5eea4b | 1087 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_set_asn1_flag(EC_KEY *eckey, int asn1_flag); |
ba12070f | 1088 | |
0f113f3e | 1089 | /** Creates a table of pre-computed multiples of the generator to |
ba12070f NL |
1090 | * accelerate further EC_KEY operations. |
1091 | * \param key EC_KEY object | |
1092 | * \param ctx BN_CTX object (optional) | |
1093 | * \return 1 on success and 0 if an error occurred. | |
1094 | */ | |
5b5eea4b | 1095 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx); |
ba12070f NL |
1096 | |
1097 | /** Creates a new ec private (and optional a new public) key. | |
1098 | * \param key EC_KEY object | |
1099 | * \return 1 on success and 0 if an error occurred. | |
1100 | */ | |
5b5eea4b | 1101 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_generate_key(EC_KEY *key); |
ba12070f NL |
1102 | |
1103 | /** Verifies that a private and/or public key is valid. | |
1104 | * \param key the EC_KEY object | |
1105 | * \return 1 on success and 0 otherwise. | |
1106 | */ | |
5b5eea4b | 1107 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_check_key(const EC_KEY *key); |
ba12070f | 1108 | |
4b0555ec | 1109 | /** Indicates if an EC_KEY can be used for signing. |
f5fd3848 | 1110 | * \param eckey the EC_KEY object |
4b0555ec DSH |
1111 | * \return 1 if can can sign and 0 otherwise. |
1112 | */ | |
5b5eea4b | 1113 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_can_sign(const EC_KEY *eckey); |
4b0555ec | 1114 | |
8483a003 | 1115 | /** Sets a public key from affine coordinates performing |
478b50cf | 1116 | * necessary NIST PKV tests. |
fef1c40b DSH |
1117 | * \param key the EC_KEY object |
1118 | * \param x public key x coordinate | |
1119 | * \param y public key y coordinate | |
1120 | * \return 1 on success and 0 otherwise. | |
1121 | */ | |
5b5eea4b SL |
1122 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, |
1123 | BIGNUM *x, | |
1124 | BIGNUM *y); | |
ba12070f | 1125 | |
981bd8a2 DSH |
1126 | /** Encodes an EC_KEY public key to an allocated octet string |
1127 | * \param key key to encode | |
1128 | * \param form point conversion form | |
1129 | * \param pbuf returns pointer to allocated buffer | |
981bd8a2 DSH |
1130 | * \param ctx BN_CTX object (optional) |
1131 | * \return the length of the encoded octet string or 0 if an error occurred | |
1132 | */ | |
5b5eea4b SL |
1133 | OSSL_DEPRECATEDIN_3_0 size_t EC_KEY_key2buf(const EC_KEY *key, |
1134 | point_conversion_form_t form, | |
1135 | unsigned char **pbuf, BN_CTX *ctx); | |
981bd8a2 DSH |
1136 | |
1137 | /** Decodes a EC_KEY public key from a octet string | |
1138 | * \param key key to decode | |
1139 | * \param buf memory buffer with the encoded ec point | |
1140 | * \param len length of the encoded ec point | |
1141 | * \param ctx BN_CTX object (optional) | |
1142 | * \return 1 on success and 0 if an error occurred | |
1143 | */ | |
1144 | ||
5b5eea4b SL |
1145 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_oct2key(EC_KEY *key, const unsigned char *buf, |
1146 | size_t len, BN_CTX *ctx); | |
981bd8a2 | 1147 | |
cf241395 DSH |
1148 | /** Decodes an EC_KEY private key from an octet string |
1149 | * \param key key to decode | |
1150 | * \param buf memory buffer with the encoded private key | |
1151 | * \param len length of the encoded key | |
1152 | * \return 1 on success and 0 if an error occurred | |
1153 | */ | |
1154 | ||
5b5eea4b SL |
1155 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_oct2priv(EC_KEY *key, const unsigned char *buf, |
1156 | size_t len); | |
cf241395 DSH |
1157 | |
1158 | /** Encodes a EC_KEY private key to an octet string | |
1159 | * \param key key to encode | |
1160 | * \param buf memory buffer for the result. If NULL the function returns | |
1161 | * required buffer size. | |
1162 | * \param len length of the memory buffer | |
1163 | * \return the length of the encoded octet string or 0 if an error occurred | |
1164 | */ | |
1165 | ||
5b5eea4b SL |
1166 | OSSL_DEPRECATEDIN_3_0 size_t EC_KEY_priv2oct(const EC_KEY *key, |
1167 | unsigned char *buf, size_t len); | |
cf241395 | 1168 | |
7fc7d1a7 | 1169 | /** Encodes an EC_KEY private key to an allocated octet string |
f5fd3848 | 1170 | * \param eckey key to encode |
7fc7d1a7 DSH |
1171 | * \param pbuf returns pointer to allocated buffer |
1172 | * \return the length of the encoded octet string or 0 if an error occurred | |
1173 | */ | |
5b5eea4b SL |
1174 | OSSL_DEPRECATEDIN_3_0 size_t EC_KEY_priv2buf(const EC_KEY *eckey, |
1175 | unsigned char **pbuf); | |
cf241395 | 1176 | |
ba12070f NL |
1177 | /********************************************************************/ |
1178 | /* de- and encoding functions for SEC1 ECPrivateKey */ | |
1179 | /********************************************************************/ | |
1180 | ||
1181 | /** Decodes a private key from a memory buffer. | |
1182 | * \param key a pointer to a EC_KEY object which should be used (or NULL) | |
1183 | * \param in pointer to memory with the DER encoded private key | |
1184 | * \param len length of the DER encoded private key | |
1185 | * \return the decoded private key or NULL if an error occurred. | |
1186 | */ | |
5b5eea4b SL |
1187 | OSSL_DEPRECATEDIN_3_0 EC_KEY *d2i_ECPrivateKey(EC_KEY **key, |
1188 | const unsigned char **in, | |
1189 | long len); | |
ba12070f NL |
1190 | |
1191 | /** Encodes a private key object and stores the result in a buffer. | |
1192 | * \param key the EC_KEY object to encode | |
1193 | * \param out the buffer for the result (if NULL the function returns number | |
1194 | * of bytes needed). | |
1195 | * \return 1 on success and 0 if an error occurred. | |
1196 | */ | |
5b5eea4b SL |
1197 | OSSL_DEPRECATEDIN_3_0 int i2d_ECPrivateKey(const EC_KEY *key, |
1198 | unsigned char **out); | |
ba12070f | 1199 | |
ba12070f NL |
1200 | /********************************************************************/ |
1201 | /* de- and encoding functions for EC parameters */ | |
1202 | /********************************************************************/ | |
1203 | ||
1204 | /** Decodes ec parameter from a memory buffer. | |
1205 | * \param key a pointer to a EC_KEY object which should be used (or NULL) | |
1206 | * \param in pointer to memory with the DER encoded ec parameters | |
1207 | * \param len length of the DER encoded ec parameters | |
1208 | * \return a EC_KEY object with the decoded parameters or NULL if an error | |
1209 | * occurred. | |
1210 | */ | |
5b5eea4b SL |
1211 | OSSL_DEPRECATEDIN_3_0 EC_KEY *d2i_ECParameters(EC_KEY **key, |
1212 | const unsigned char **in, | |
1213 | long len); | |
ba12070f NL |
1214 | |
1215 | /** Encodes ec parameter and stores the result in a buffer. | |
1afd7fa9 | 1216 | * \param key the EC_KEY object with ec parameters to encode |
ba12070f NL |
1217 | * \param out the buffer for the result (if NULL the function returns number |
1218 | * of bytes needed). | |
1219 | * \return 1 on success and 0 if an error occurred. | |
1220 | */ | |
5b5eea4b SL |
1221 | OSSL_DEPRECATEDIN_3_0 int i2d_ECParameters(const EC_KEY *key, |
1222 | unsigned char **out); | |
ba12070f | 1223 | |
ba12070f NL |
1224 | /********************************************************************/ |
1225 | /* de- and encoding functions for EC public key */ | |
1226 | /* (octet string, not DER -- hence 'o2i' and 'i2o') */ | |
1227 | /********************************************************************/ | |
1228 | ||
af9fb19a | 1229 | /** Decodes an ec public key from a octet string. |
ba12070f NL |
1230 | * \param key a pointer to a EC_KEY object which should be used |
1231 | * \param in memory buffer with the encoded public key | |
1232 | * \param len length of the encoded public key | |
1233 | * \return EC_KEY object with decoded public key or NULL if an error | |
1234 | * occurred. | |
1235 | */ | |
5b5eea4b SL |
1236 | OSSL_DEPRECATEDIN_3_0 EC_KEY *o2i_ECPublicKey(EC_KEY **key, |
1237 | const unsigned char **in, long len); | |
ba12070f | 1238 | |
af9fb19a | 1239 | /** Encodes an ec public key in an octet string. |
ba12070f NL |
1240 | * \param key the EC_KEY object with the public key |
1241 | * \param out the buffer for the result (if NULL the function returns number | |
1242 | * of bytes needed). | |
1243 | * \return 1 on success and 0 if an error occurred | |
1244 | */ | |
5b5eea4b | 1245 | OSSL_DEPRECATEDIN_3_0 int i2o_ECPublicKey(const EC_KEY *key, unsigned char **out); |
14a7cfb3 | 1246 | |
ba12070f NL |
1247 | /** Prints out the ec parameters on human readable form. |
1248 | * \param bp BIO object to which the information is printed | |
1249 | * \param key EC_KEY object | |
1250 | * \return 1 on success and 0 if an error occurred | |
1251 | */ | |
5b5eea4b | 1252 | OSSL_DEPRECATEDIN_3_0 int ECParameters_print(BIO *bp, const EC_KEY *key); |
ba12070f NL |
1253 | |
1254 | /** Prints out the contents of a EC_KEY object | |
1255 | * \param bp BIO object to which the information is printed | |
1256 | * \param key EC_KEY object | |
0f113f3e | 1257 | * \param off line offset |
ba12070f NL |
1258 | * \return 1 on success and 0 if an error occurred |
1259 | */ | |
5b5eea4b | 1260 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_print(BIO *bp, const EC_KEY *key, int off); |
ba12070f | 1261 | |
5b5eea4b | 1262 | # ifndef OPENSSL_NO_STDIO |
ba12070f NL |
1263 | /** Prints out the ec parameters on human readable form. |
1264 | * \param fp file descriptor to which the information is printed | |
1265 | * \param key EC_KEY object | |
1266 | * \return 1 on success and 0 if an error occurred | |
1267 | */ | |
5b5eea4b | 1268 | OSSL_DEPRECATEDIN_3_0 int ECParameters_print_fp(FILE *fp, const EC_KEY *key); |
ba12070f NL |
1269 | |
1270 | /** Prints out the contents of a EC_KEY object | |
1271 | * \param fp file descriptor to which the information is printed | |
1272 | * \param key EC_KEY object | |
0f113f3e | 1273 | * \param off line offset |
ba12070f NL |
1274 | * \return 1 on success and 0 if an error occurred |
1275 | */ | |
5b5eea4b SL |
1276 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off); |
1277 | # endif /* OPENSSL_NO_STDIO */ | |
0bee0e62 | 1278 | |
5b5eea4b SL |
1279 | OSSL_DEPRECATEDIN_3_0 const EC_KEY_METHOD *EC_KEY_OpenSSL(void); |
1280 | OSSL_DEPRECATEDIN_3_0 const EC_KEY_METHOD *EC_KEY_get_default_method(void); | |
1281 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_set_default_method(const EC_KEY_METHOD *meth); | |
1282 | OSSL_DEPRECATEDIN_3_0 const EC_KEY_METHOD *EC_KEY_get_method(const EC_KEY *key); | |
1283 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_method(EC_KEY *key, const EC_KEY_METHOD *meth); | |
1284 | OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_new_method(ENGINE *engine); | |
28572b57 | 1285 | |
ffd89124 AS |
1286 | /** The old name for ecdh_KDF_X9_63 |
1287 | * The ECDH KDF specification has been mistakingly attributed to ANSI X9.62, | |
1288 | * it is actually specified in ANSI X9.63. | |
1289 | * This identifier is retained for backwards compatibility | |
1290 | */ | |
5b5eea4b SL |
1291 | OSSL_DEPRECATEDIN_3_0 int ECDH_KDF_X9_62(unsigned char *out, size_t outlen, |
1292 | const unsigned char *Z, size_t Zlen, | |
1293 | const unsigned char *sinfo, | |
1294 | size_t sinfolen, const EVP_MD *md); | |
1295 | ||
1296 | OSSL_DEPRECATEDIN_3_0 int ECDH_compute_key(void *out, size_t outlen, | |
1297 | const EC_POINT *pub_key, | |
1298 | const EC_KEY *ecdh, | |
1299 | void *(*KDF)(const void *in, | |
1300 | size_t inlen, void *out, | |
1301 | size_t *outlen)); | |
1302 | # endif /* OPENSSL_NO_DEPRECATED_3_0 */ | |
a22a7e70 | 1303 | |
714b2abb DSH |
1304 | typedef struct ECDSA_SIG_st ECDSA_SIG; |
1305 | ||
ef5b2ba6 DSH |
1306 | /** Allocates and initialize a ECDSA_SIG structure |
1307 | * \return pointer to a ECDSA_SIG structure or NULL if an error occurred | |
1308 | */ | |
1309 | ECDSA_SIG *ECDSA_SIG_new(void); | |
1310 | ||
1311 | /** frees a ECDSA_SIG structure | |
1312 | * \param sig pointer to the ECDSA_SIG structure | |
1313 | */ | |
1314 | void ECDSA_SIG_free(ECDSA_SIG *sig); | |
1315 | ||
9fdcc21f | 1316 | /** i2d_ECDSA_SIG encodes content of ECDSA_SIG (note: this function modifies *pp |
ef5b2ba6 DSH |
1317 | * (*pp += length of the DER encoded signature)). |
1318 | * \param sig pointer to the ECDSA_SIG object | |
1319 | * \param pp pointer to a unsigned char pointer for the output or NULL | |
bbda7997 MC |
1320 | * \return the length of the DER encoded ECDSA_SIG object or a negative value |
1321 | * on error | |
ef5b2ba6 | 1322 | */ |
9fdcc21f | 1323 | DECLARE_ASN1_ENCODE_FUNCTIONS_only(ECDSA_SIG, ECDSA_SIG) |
ef5b2ba6 | 1324 | |
9fdcc21f | 1325 | /** d2i_ECDSA_SIG decodes an ECDSA signature (note: this function modifies *pp |
ef5b2ba6 DSH |
1326 | * (*pp += len)). |
1327 | * \param sig pointer to ECDSA_SIG pointer (may be NULL) | |
1328 | * \param pp memory buffer with the DER encoded signature | |
1329 | * \param len length of the buffer | |
1330 | * \return pointer to the decoded ECDSA_SIG structure (or NULL) | |
1331 | */ | |
ef5b2ba6 | 1332 | |
7236e3c8 | 1333 | /** Accessor for r and s fields of ECDSA_SIG |
0396401d | 1334 | * \param sig pointer to ECDSA_SIG structure |
7236e3c8 DSH |
1335 | * \param pr pointer to BIGNUM pointer for r (may be NULL) |
1336 | * \param ps pointer to BIGNUM pointer for s (may be NULL) | |
1337 | */ | |
9267c11b | 1338 | void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps); |
7236e3c8 | 1339 | |
0396401d DMSP |
1340 | /** Accessor for r field of ECDSA_SIG |
1341 | * \param sig pointer to ECDSA_SIG structure | |
1342 | */ | |
1343 | const BIGNUM *ECDSA_SIG_get0_r(const ECDSA_SIG *sig); | |
1344 | ||
1345 | /** Accessor for s field of ECDSA_SIG | |
1346 | * \param sig pointer to ECDSA_SIG structure | |
1347 | */ | |
1348 | const BIGNUM *ECDSA_SIG_get0_s(const ECDSA_SIG *sig); | |
1349 | ||
6a571a18 | 1350 | /** Setter for r and s fields of ECDSA_SIG |
0396401d | 1351 | * \param sig pointer to ECDSA_SIG structure |
9aaf5048 TM |
1352 | * \param r pointer to BIGNUM for r |
1353 | * \param s pointer to BIGNUM for s | |
6a571a18 | 1354 | */ |
1d454d58 | 1355 | int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s); |
6a571a18 | 1356 | |
5b5eea4b | 1357 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
180eec16 DSH |
1358 | /** Computes the ECDSA signature of the given hash value using |
1359 | * the supplied private key and returns the created signature. | |
1360 | * \param dgst pointer to the hash value | |
1361 | * \param dgst_len length of the hash value | |
1362 | * \param eckey EC_KEY object containing a private EC key | |
1363 | * \return pointer to a ECDSA_SIG structure or NULL if an error occurred | |
1364 | */ | |
5b5eea4b SL |
1365 | OSSL_DEPRECATEDIN_3_0 ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst, |
1366 | int dgst_len, EC_KEY *eckey); | |
180eec16 DSH |
1367 | |
1368 | /** Computes ECDSA signature of a given hash value using the supplied | |
1369 | * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). | |
1370 | * \param dgst pointer to the hash value to sign | |
1371 | * \param dgstlen length of the hash value | |
1372 | * \param kinv BIGNUM with a pre-computed inverse k (optional) | |
8483a003 | 1373 | * \param rp BIGNUM with a pre-computed rp value (optional), |
180eec16 DSH |
1374 | * see ECDSA_sign_setup |
1375 | * \param eckey EC_KEY object containing a private EC key | |
1376 | * \return pointer to a ECDSA_SIG structure or NULL if an error occurred | |
1377 | */ | |
5b5eea4b SL |
1378 | OSSL_DEPRECATEDIN_3_0 ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, |
1379 | int dgstlen, const BIGNUM *kinv, | |
1380 | const BIGNUM *rp, EC_KEY *eckey); | |
180eec16 DSH |
1381 | |
1382 | /** Verifies that the supplied signature is a valid ECDSA | |
1383 | * signature of the supplied hash value using the supplied public key. | |
1384 | * \param dgst pointer to the hash value | |
1385 | * \param dgst_len length of the hash value | |
1386 | * \param sig ECDSA_SIG structure | |
1387 | * \param eckey EC_KEY object containing a public EC key | |
1388 | * \return 1 if the signature is valid, 0 if the signature is invalid | |
1389 | * and -1 on error | |
1390 | */ | |
5b5eea4b SL |
1391 | OSSL_DEPRECATEDIN_3_0 int ECDSA_do_verify(const unsigned char *dgst, int dgst_len, |
1392 | const ECDSA_SIG *sig, EC_KEY *eckey); | |
180eec16 | 1393 | |
bd3602eb DSH |
1394 | /** Precompute parts of the signing operation |
1395 | * \param eckey EC_KEY object containing a private EC key | |
1396 | * \param ctx BN_CTX object (optional) | |
1397 | * \param kinv BIGNUM pointer for the inverse of k | |
1398 | * \param rp BIGNUM pointer for x coordinate of k * generator | |
1399 | * \return 1 on success and 0 otherwise | |
1400 | */ | |
5b5eea4b SL |
1401 | OSSL_DEPRECATEDIN_3_0 int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, |
1402 | BIGNUM **kinv, BIGNUM **rp); | |
bd3602eb DSH |
1403 | |
1404 | /** Computes ECDSA signature of a given hash value using the supplied | |
1405 | * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). | |
1406 | * \param type this parameter is ignored | |
1407 | * \param dgst pointer to the hash value to sign | |
1408 | * \param dgstlen length of the hash value | |
1409 | * \param sig memory for the DER encoded created signature | |
1410 | * \param siglen pointer to the length of the returned signature | |
1411 | * \param eckey EC_KEY object containing a private EC key | |
1412 | * \return 1 on success and 0 otherwise | |
1413 | */ | |
5b5eea4b SL |
1414 | OSSL_DEPRECATEDIN_3_0 int ECDSA_sign(int type, const unsigned char *dgst, |
1415 | int dgstlen, unsigned char *sig, | |
1416 | unsigned int *siglen, EC_KEY *eckey); | |
bd3602eb DSH |
1417 | |
1418 | /** Computes ECDSA signature of a given hash value using the supplied | |
1419 | * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). | |
1420 | * \param type this parameter is ignored | |
1421 | * \param dgst pointer to the hash value to sign | |
1422 | * \param dgstlen length of the hash value | |
1423 | * \param sig buffer to hold the DER encoded signature | |
1424 | * \param siglen pointer to the length of the returned signature | |
1425 | * \param kinv BIGNUM with a pre-computed inverse k (optional) | |
8483a003 | 1426 | * \param rp BIGNUM with a pre-computed rp value (optional), |
bd3602eb DSH |
1427 | * see ECDSA_sign_setup |
1428 | * \param eckey EC_KEY object containing a private EC key | |
1429 | * \return 1 on success and 0 otherwise | |
1430 | */ | |
5b5eea4b SL |
1431 | OSSL_DEPRECATEDIN_3_0 int ECDSA_sign_ex(int type, const unsigned char *dgst, |
1432 | int dgstlen, unsigned char *sig, | |
1433 | unsigned int *siglen, const BIGNUM *kinv, | |
1434 | const BIGNUM *rp, EC_KEY *eckey); | |
bd3602eb DSH |
1435 | |
1436 | /** Verifies that the given signature is valid ECDSA signature | |
1437 | * of the supplied hash value using the specified public key. | |
1438 | * \param type this parameter is ignored | |
1439 | * \param dgst pointer to the hash value | |
1440 | * \param dgstlen length of the hash value | |
1441 | * \param sig pointer to the DER encoded signature | |
1442 | * \param siglen length of the DER encoded signature | |
1443 | * \param eckey EC_KEY object containing a public EC key | |
1444 | * \return 1 if the signature is valid, 0 if the signature is invalid | |
1445 | * and -1 on error | |
1446 | */ | |
5b5eea4b SL |
1447 | OSSL_DEPRECATEDIN_3_0 int ECDSA_verify(int type, const unsigned char *dgst, |
1448 | int dgstlen, const unsigned char *sig, | |
1449 | int siglen, EC_KEY *eckey); | |
7236e3c8 | 1450 | |
cf517a6d DSH |
1451 | /** Returns the maximum length of the DER encoded signature |
1452 | * \param eckey EC_KEY object | |
1453 | * \return numbers of bytes required for the DER encoded signature | |
1454 | */ | |
5b5eea4b | 1455 | OSSL_DEPRECATEDIN_3_0 int ECDSA_size(const EC_KEY *eckey); |
cf517a6d | 1456 | |
7bb75a5d DSH |
1457 | /********************************************************************/ |
1458 | /* EC_KEY_METHOD constructors, destructors, writers and accessors */ | |
1459 | /********************************************************************/ | |
1460 | ||
5b5eea4b SL |
1461 | OSSL_DEPRECATEDIN_3_0 EC_KEY_METHOD *EC_KEY_METHOD_new(const EC_KEY_METHOD *meth); |
1462 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_free(EC_KEY_METHOD *meth); | |
1463 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_set_init | |
1464 | (EC_KEY_METHOD *meth, | |
1465 | int (*init)(EC_KEY *key), | |
1466 | void (*finish)(EC_KEY *key), | |
1467 | int (*copy)(EC_KEY *dest, const EC_KEY *src), | |
1468 | int (*set_group)(EC_KEY *key, const EC_GROUP *grp), | |
1469 | int (*set_private)(EC_KEY *key, const BIGNUM *priv_key), | |
1470 | int (*set_public)(EC_KEY *key, const EC_POINT *pub_key)); | |
1471 | ||
1472 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_set_keygen(EC_KEY_METHOD *meth, | |
1473 | int (*keygen)(EC_KEY *key)); | |
1474 | ||
1475 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_set_compute_key | |
1476 | (EC_KEY_METHOD *meth, | |
1477 | int (*ckey)(unsigned char **psec, size_t *pseclen, | |
1478 | const EC_POINT *pub_key, const EC_KEY *ecdh)); | |
1479 | ||
1480 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_set_sign | |
1481 | (EC_KEY_METHOD *meth, | |
1482 | int (*sign)(int type, const unsigned char *dgst, | |
1483 | int dlen, unsigned char *sig, | |
1484 | unsigned int *siglen, | |
1485 | const BIGNUM *kinv, const BIGNUM *r, | |
1486 | EC_KEY *eckey), | |
1487 | int (*sign_setup)(EC_KEY *eckey, BN_CTX *ctx_in, | |
1488 | BIGNUM **kinvp, BIGNUM **rp), | |
1489 | ECDSA_SIG *(*sign_sig)(const unsigned char *dgst, | |
1490 | int dgst_len, | |
1491 | const BIGNUM *in_kinv, | |
1492 | const BIGNUM *in_r, | |
1493 | EC_KEY *eckey)); | |
1494 | ||
1495 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_set_verify | |
1496 | (EC_KEY_METHOD *meth, | |
1497 | int (*verify)(int type, const unsigned | |
1498 | char *dgst, int dgst_len, | |
1499 | const unsigned char *sigbuf, | |
1500 | int sig_len, EC_KEY *eckey), | |
1501 | int (*verify_sig)(const unsigned char *dgst, | |
1502 | int dgst_len, const ECDSA_SIG *sig, | |
1503 | EC_KEY *eckey)); | |
1504 | ||
1505 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_get_init | |
1506 | (const EC_KEY_METHOD *meth, | |
1507 | int (**pinit)(EC_KEY *key), | |
1508 | void (**pfinish)(EC_KEY *key), | |
1509 | int (**pcopy)(EC_KEY *dest, const EC_KEY *src), | |
1510 | int (**pset_group)(EC_KEY *key, const EC_GROUP *grp), | |
1511 | int (**pset_private)(EC_KEY *key, const BIGNUM *priv_key), | |
1512 | int (**pset_public)(EC_KEY *key, const EC_POINT *pub_key)); | |
1513 | ||
1514 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_get_keygen | |
1515 | (const EC_KEY_METHOD *meth, int (**pkeygen)(EC_KEY *key)); | |
1516 | ||
1517 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_get_compute_key | |
1518 | (const EC_KEY_METHOD *meth, | |
1519 | int (**pck)(unsigned char **psec, | |
1520 | size_t *pseclen, | |
1521 | const EC_POINT *pub_key, | |
1522 | const EC_KEY *ecdh)); | |
1523 | ||
1524 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_get_sign | |
1525 | (const EC_KEY_METHOD *meth, | |
1526 | int (**psign)(int type, const unsigned char *dgst, | |
1527 | int dlen, unsigned char *sig, | |
1528 | unsigned int *siglen, | |
1529 | const BIGNUM *kinv, const BIGNUM *r, | |
1530 | EC_KEY *eckey), | |
1531 | int (**psign_setup)(EC_KEY *eckey, BN_CTX *ctx_in, | |
1532 | BIGNUM **kinvp, BIGNUM **rp), | |
1533 | ECDSA_SIG *(**psign_sig)(const unsigned char *dgst, | |
1534 | int dgst_len, | |
1535 | const BIGNUM *in_kinv, | |
1536 | const BIGNUM *in_r, | |
1537 | EC_KEY *eckey)); | |
1538 | ||
1539 | OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_get_verify | |
1540 | (const EC_KEY_METHOD *meth, | |
1541 | int (**pverify)(int type, const unsigned | |
1542 | char *dgst, int dgst_len, | |
1543 | const unsigned char *sigbuf, | |
1544 | int sig_len, EC_KEY *eckey), | |
1545 | int (**pverify_sig)(const unsigned char *dgst, | |
579422c8 | 1546 | int dgst_len, |
5b5eea4b SL |
1547 | const ECDSA_SIG *sig, |
1548 | EC_KEY *eckey)); | |
1549 | # endif /* OPENSSL_NO_DEPRECATED_3_0 */ | |
579422c8 | 1550 | |
f9253152 DDO |
1551 | # define EVP_EC_gen(curve) \ |
1552 | EVP_PKEY_Q_keygen(NULL, NULL, "EC", (char *)(strstr(curve, ""))) | |
1d8f18dc | 1553 | /* strstr is used to enable type checking for the variadic string arg */ |
579422c8 | 1554 | # define ECParameters_dup(x) ASN1_dup_of(EC_KEY, i2d_ECParameters, \ |
5b5eea4b | 1555 | d2i_ECParameters, x) |
458c2917 | 1556 | |
ee8db22e P |
1557 | # ifndef __cplusplus |
1558 | # if defined(__SUNPRO_C) | |
1559 | # if __SUNPRO_C >= 0x520 | |
1560 | # pragma error_messages (default,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE) | |
1561 | # endif | |
0f113f3e | 1562 | # endif |
ad0db060 | 1563 | # endif |
ad0db060 | 1564 | |
565b3399 RL |
1565 | # endif |
1566 | # ifdef __cplusplus | |
65e81670 | 1567 | } |
3c27208f | 1568 | # endif |
5acaa495 | 1569 | #endif |