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