@annadata/capacitor-mqtt-quic 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/ios/include/nghttp3/nghttp3.h +3295 -0
  2. package/ios/include/nghttp3/version.h +46 -0
  3. package/ios/include/ngtcp2/ngtcp2.h +6254 -0
  4. package/ios/include/ngtcp2/ngtcp2_crypto.h +1037 -0
  5. package/ios/include/ngtcp2/ngtcp2_crypto_quictls.h +147 -0
  6. package/ios/include/ngtcp2/version.h +51 -0
  7. package/ios/include/openssl/aes.h +111 -0
  8. package/ios/include/openssl/asn1.h +1131 -0
  9. package/ios/include/openssl/asn1_mac.h +10 -0
  10. package/ios/include/openssl/asn1err.h +140 -0
  11. package/ios/include/openssl/asn1t.h +946 -0
  12. package/ios/include/openssl/async.h +96 -0
  13. package/ios/include/openssl/asyncerr.h +29 -0
  14. package/ios/include/openssl/bio.h +887 -0
  15. package/ios/include/openssl/bioerr.h +65 -0
  16. package/ios/include/openssl/blowfish.h +78 -0
  17. package/ios/include/openssl/bn.h +584 -0
  18. package/ios/include/openssl/bnerr.h +47 -0
  19. package/ios/include/openssl/buffer.h +62 -0
  20. package/ios/include/openssl/buffererr.h +25 -0
  21. package/ios/include/openssl/camellia.h +117 -0
  22. package/ios/include/openssl/cast.h +71 -0
  23. package/ios/include/openssl/cmac.h +52 -0
  24. package/ios/include/openssl/cmp.h +597 -0
  25. package/ios/include/openssl/cmp_util.h +56 -0
  26. package/ios/include/openssl/cmperr.h +116 -0
  27. package/ios/include/openssl/cms.h +493 -0
  28. package/ios/include/openssl/cmserr.h +124 -0
  29. package/ios/include/openssl/comp.h +59 -0
  30. package/ios/include/openssl/comperr.h +31 -0
  31. package/ios/include/openssl/conf.h +214 -0
  32. package/ios/include/openssl/conf_api.h +46 -0
  33. package/ios/include/openssl/conferr.h +52 -0
  34. package/ios/include/openssl/configuration.h +149 -0
  35. package/ios/include/openssl/conftypes.h +44 -0
  36. package/ios/include/openssl/core.h +233 -0
  37. package/ios/include/openssl/core_dispatch.h +960 -0
  38. package/ios/include/openssl/core_names.h +561 -0
  39. package/ios/include/openssl/core_object.h +41 -0
  40. package/ios/include/openssl/crmf.h +227 -0
  41. package/ios/include/openssl/crmferr.h +50 -0
  42. package/ios/include/openssl/crypto.h +558 -0
  43. package/ios/include/openssl/cryptoerr.h +55 -0
  44. package/ios/include/openssl/cryptoerr_legacy.h +1466 -0
  45. package/ios/include/openssl/ct.h +573 -0
  46. package/ios/include/openssl/cterr.h +45 -0
  47. package/ios/include/openssl/decoder.h +133 -0
  48. package/ios/include/openssl/decodererr.h +28 -0
  49. package/ios/include/openssl/des.h +211 -0
  50. package/ios/include/openssl/dh.h +335 -0
  51. package/ios/include/openssl/dherr.h +58 -0
  52. package/ios/include/openssl/dsa.h +280 -0
  53. package/ios/include/openssl/dsaerr.h +44 -0
  54. package/ios/include/openssl/dtls1.h +57 -0
  55. package/ios/include/openssl/e_os2.h +308 -0
  56. package/ios/include/openssl/ebcdic.h +39 -0
  57. package/ios/include/openssl/ec.h +1572 -0
  58. package/ios/include/openssl/ecdh.h +10 -0
  59. package/ios/include/openssl/ecdsa.h +10 -0
  60. package/ios/include/openssl/ecerr.h +104 -0
  61. package/ios/include/openssl/encoder.h +124 -0
  62. package/ios/include/openssl/encodererr.h +28 -0
  63. package/ios/include/openssl/engine.h +833 -0
  64. package/ios/include/openssl/engineerr.h +63 -0
  65. package/ios/include/openssl/err.h +504 -0
  66. package/ios/include/openssl/ess.h +128 -0
  67. package/ios/include/openssl/esserr.h +32 -0
  68. package/ios/include/openssl/evp.h +2175 -0
  69. package/ios/include/openssl/evperr.h +134 -0
  70. package/ios/include/openssl/fips_names.h +77 -0
  71. package/ios/include/openssl/fipskey.h +36 -0
  72. package/ios/include/openssl/hmac.h +62 -0
  73. package/ios/include/openssl/http.h +109 -0
  74. package/ios/include/openssl/httperr.h +55 -0
  75. package/ios/include/openssl/idea.h +82 -0
  76. package/ios/include/openssl/kdf.h +138 -0
  77. package/ios/include/openssl/kdferr.h +16 -0
  78. package/ios/include/openssl/lhash.h +331 -0
  79. package/ios/include/openssl/macros.h +325 -0
  80. package/ios/include/openssl/md2.h +56 -0
  81. package/ios/include/openssl/md4.h +63 -0
  82. package/ios/include/openssl/md5.h +62 -0
  83. package/ios/include/openssl/mdc2.h +55 -0
  84. package/ios/include/openssl/modes.h +219 -0
  85. package/ios/include/openssl/obj_mac.h +5481 -0
  86. package/ios/include/openssl/objects.h +183 -0
  87. package/ios/include/openssl/objectserr.h +28 -0
  88. package/ios/include/openssl/ocsp.h +483 -0
  89. package/ios/include/openssl/ocsperr.h +53 -0
  90. package/ios/include/openssl/opensslconf.h +17 -0
  91. package/ios/include/openssl/opensslv.h +114 -0
  92. package/ios/include/openssl/ossl_typ.h +16 -0
  93. package/ios/include/openssl/param_build.h +63 -0
  94. package/ios/include/openssl/params.h +160 -0
  95. package/ios/include/openssl/pem.h +541 -0
  96. package/ios/include/openssl/pem2.h +19 -0
  97. package/ios/include/openssl/pemerr.h +58 -0
  98. package/ios/include/openssl/pkcs12.h +353 -0
  99. package/ios/include/openssl/pkcs12err.h +45 -0
  100. package/ios/include/openssl/pkcs7.h +430 -0
  101. package/ios/include/openssl/pkcs7err.h +63 -0
  102. package/ios/include/openssl/prov_ssl.h +34 -0
  103. package/ios/include/openssl/proverr.h +149 -0
  104. package/ios/include/openssl/provider.h +60 -0
  105. package/ios/include/openssl/quic.h +19 -0
  106. package/ios/include/openssl/rand.h +125 -0
  107. package/ios/include/openssl/randerr.h +69 -0
  108. package/ios/include/openssl/rc2.h +68 -0
  109. package/ios/include/openssl/rc4.h +47 -0
  110. package/ios/include/openssl/rc5.h +79 -0
  111. package/ios/include/openssl/ripemd.h +59 -0
  112. package/ios/include/openssl/rsa.h +610 -0
  113. package/ios/include/openssl/rsaerr.h +107 -0
  114. package/ios/include/openssl/safestack.h +297 -0
  115. package/ios/include/openssl/seed.h +113 -0
  116. package/ios/include/openssl/self_test.h +94 -0
  117. package/ios/include/openssl/sha.h +138 -0
  118. package/ios/include/openssl/srp.h +285 -0
  119. package/ios/include/openssl/srtp.h +56 -0
  120. package/ios/include/openssl/ssl.h +2671 -0
  121. package/ios/include/openssl/ssl2.h +30 -0
  122. package/ios/include/openssl/ssl3.h +347 -0
  123. package/ios/include/openssl/sslerr.h +348 -0
  124. package/ios/include/openssl/sslerr_legacy.h +468 -0
  125. package/ios/include/openssl/stack.h +90 -0
  126. package/ios/include/openssl/store.h +369 -0
  127. package/ios/include/openssl/storeerr.h +49 -0
  128. package/ios/include/openssl/symhacks.h +39 -0
  129. package/ios/include/openssl/tls1.h +1186 -0
  130. package/ios/include/openssl/trace.h +312 -0
  131. package/ios/include/openssl/ts.h +505 -0
  132. package/ios/include/openssl/tserr.h +67 -0
  133. package/ios/include/openssl/txt_db.h +63 -0
  134. package/ios/include/openssl/types.h +239 -0
  135. package/ios/include/openssl/ui.h +407 -0
  136. package/ios/include/openssl/uierr.h +38 -0
  137. package/ios/include/openssl/whrlpool.h +62 -0
  138. package/ios/include/openssl/x509.h +1279 -0
  139. package/ios/include/openssl/x509_vfy.h +894 -0
  140. package/ios/include/openssl/x509err.h +69 -0
  141. package/ios/include/openssl/x509v3.h +1453 -0
  142. package/ios/include/openssl/x509v3err.h +93 -0
  143. package/ios/libs/libcrypto.a +0 -0
  144. package/ios/libs/libnghttp3.a +0 -0
  145. package/ios/libs/libngtcp2.a +0 -0
  146. package/ios/libs/libngtcp2_crypto_quictls.a +0 -0
  147. package/ios/libs/libssl.a +0 -0
  148. package/package.json +2 -2
@@ -0,0 +1,1572 @@
1
+ /*
2
+ * Copyright 2002-2022 The OpenSSL Project Authors. All Rights Reserved.
3
+ * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
4
+ *
5
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
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
9
+ */
10
+
11
+ #ifndef OPENSSL_EC_H
12
+ # define OPENSSL_EC_H
13
+ # pragma once
14
+
15
+ # include <openssl/macros.h>
16
+ # ifndef OPENSSL_NO_DEPRECATED_3_0
17
+ # define HEADER_EC_H
18
+ # endif
19
+
20
+ # include <openssl/opensslconf.h>
21
+ # include <openssl/types.h>
22
+
23
+ # include <string.h>
24
+
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);
49
+ # ifndef OPENSSL_NO_DEPRECATED_3_0
50
+ OSSL_DEPRECATEDIN_3_0
51
+ int EVP_PKEY_CTX_get0_ecdh_kdf_ukm(EVP_PKEY_CTX *ctx, unsigned char **ukm);
52
+ # endif
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
75
+
76
+ /** Enum for the point conversion form as defined in X9.62 (ECDSA)
77
+ * for the encoding of a elliptic curve point (x,y) */
78
+ typedef enum {
79
+ /** the point is encoded as z||x, where the octet z specifies
80
+ * which solution of the quadratic equation y is */
81
+ POINT_CONVERSION_COMPRESSED = 2,
82
+ /** the point is encoded as z||x||y, where z is the octet 0x04 */
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
87
+ } point_conversion_form_t;
88
+
89
+ const char *OSSL_EC_curve_nid2name(int nid);
90
+
91
+ # ifndef OPENSSL_NO_STDIO
92
+ # include <stdio.h>
93
+ # endif
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
+
106
+ # include <openssl/params.h>
107
+ # ifndef OPENSSL_NO_DEPRECATED_3_0
108
+ typedef struct ec_method_st EC_METHOD;
109
+ # endif
110
+ typedef struct ec_group_st EC_GROUP;
111
+ typedef struct ec_point_st EC_POINT;
112
+ typedef struct ecpk_parameters_st ECPKPARAMETERS;
113
+ typedef struct ec_parameters_st ECPARAMETERS;
114
+
115
+ /********************************************************************/
116
+ /* EC_METHODs for curves over GF(p) */
117
+ /********************************************************************/
118
+
119
+ # ifndef OPENSSL_NO_DEPRECATED_3_0
120
+ /** Returns the basic GFp ec methods which provides the basis for the
121
+ * optimized methods.
122
+ * \return EC_METHOD object
123
+ */
124
+ OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_simple_method(void);
125
+
126
+ /** Returns GFp methods using montgomery multiplication.
127
+ * \return EC_METHOD object
128
+ */
129
+ OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_mont_method(void);
130
+
131
+ /** Returns GFp methods using optimized methods for NIST recommended curves
132
+ * \return EC_METHOD object
133
+ */
134
+ OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_nist_method(void);
135
+
136
+ # ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
137
+ /** Returns 64-bit optimized methods for nistp224
138
+ * \return EC_METHOD object
139
+ */
140
+ OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_nistp224_method(void);
141
+
142
+ /** Returns 64-bit optimized methods for nistp256
143
+ * \return EC_METHOD object
144
+ */
145
+ OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_nistp256_method(void);
146
+
147
+ /** Returns 64-bit optimized methods for nistp521
148
+ * \return EC_METHOD object
149
+ */
150
+ OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_nistp521_method(void);
151
+ # endif /* OPENSSL_NO_EC_NISTP_64_GCC_128 */
152
+
153
+ # ifndef OPENSSL_NO_EC2M
154
+ /********************************************************************/
155
+ /* EC_METHOD for curves over GF(2^m) */
156
+ /********************************************************************/
157
+
158
+ /** Returns the basic GF2m ec method
159
+ * \return EC_METHOD object
160
+ */
161
+ OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GF2m_simple_method(void);
162
+
163
+ # endif
164
+
165
+ /********************************************************************/
166
+ /* EC_GROUP functions */
167
+ /********************************************************************/
168
+
169
+ /**
170
+ * Creates a new EC_GROUP object
171
+ * \param meth EC_METHOD to use
172
+ * \return newly created EC_GROUP object or NULL in case of an error.
173
+ */
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 */
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
+
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
+
206
+ /** Creates a new EC_GROUP object and copies the content
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
+
213
+ /** Sets the generator and its order/cofactor of a EC_GROUP object.
214
+ * \param group EC_GROUP object
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.
219
+ * \return 1 on success and 0 if an error occurred
220
+ */
221
+ int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator,
222
+ const BIGNUM *order, const BIGNUM *cofactor);
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
+
230
+ /** Returns the montgomery data for order(Generator)
231
+ * \param group EC_GROUP object
232
+ * \return the currently used montgomery data (possibly NULL).
233
+ */
234
+ BN_MONT_CTX *EC_GROUP_get_mont_data(const EC_GROUP *group);
235
+
236
+ /** Gets the order of a EC_GROUP
237
+ * \param group EC_GROUP object
238
+ * \param order BIGNUM to which the order is copied
239
+ * \param ctx unused
240
+ * \return 1 on success and 0 if an error occurred
241
+ */
242
+ int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx);
243
+
244
+ /** Gets the order of an EC_GROUP
245
+ * \param group EC_GROUP object
246
+ * \return the group order
247
+ */
248
+ const BIGNUM *EC_GROUP_get0_order(const EC_GROUP *group);
249
+
250
+ /** Gets the number of bits of the order of an EC_GROUP
251
+ * \param group EC_GROUP object
252
+ * \return number of bits of group order.
253
+ */
254
+ int EC_GROUP_order_bits(const EC_GROUP *group);
255
+
256
+ /** Gets the cofactor of a EC_GROUP
257
+ * \param group EC_GROUP object
258
+ * \param cofactor BIGNUM to which the cofactor is copied
259
+ * \param ctx unused
260
+ * \return 1 on success and 0 if an error occurred
261
+ */
262
+ int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor,
263
+ BN_CTX *ctx);
264
+
265
+ /** Gets the cofactor of an EC_GROUP
266
+ * \param group EC_GROUP object
267
+ * \return the group cofactor
268
+ */
269
+ const BIGNUM *EC_GROUP_get0_cofactor(const EC_GROUP *group);
270
+
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);
276
+
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);
282
+
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
+
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
+
295
+ void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag);
296
+ int EC_GROUP_get_asn1_flag(const EC_GROUP *group);
297
+
298
+ void EC_GROUP_set_point_conversion_form(EC_GROUP *group,
299
+ point_conversion_form_t form);
300
+ point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *);
301
+
302
+ unsigned char *EC_GROUP_get0_seed(const EC_GROUP *x);
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);
305
+
306
+ /** Sets the parameters of an ec curve defined by y^2 = x^3 + a*x + b (for GFp)
307
+ * or y^2 + x*y = x^3 + a*x^2 + b (for GF2m)
308
+ * \param group EC_GROUP object
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
+
332
+ # ifndef OPENSSL_NO_DEPRECATED_3_0
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)
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)
340
+ * \return 1 on success and 0 if an error occurred
341
+ */
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);
347
+
348
+ /** Gets the parameters of an ec curve. Synonym for EC_GROUP_get_curve
349
+ * \param group EC_GROUP object
350
+ * \param p BIGNUM with the prime number (GFp) or the polynomial
351
+ * defining the underlying field (GF2m)
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)
355
+ * \return 1 on success and 0 if an error occurred
356
+ */
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);
361
+
362
+ # ifndef OPENSSL_NO_EC2M
363
+ /** Sets the parameter of an ec curve. Synonym for EC_GROUP_set_curve
364
+ * \param group EC_GROUP object
365
+ * \param p BIGNUM with the prime number (GFp) or the polynomial
366
+ * defining the underlying field (GF2m)
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)
370
+ * \return 1 on success and 0 if an error occurred
371
+ */
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);
377
+
378
+ /** Gets the parameters of an ec curve. Synonym for EC_GROUP_get_curve
379
+ * \param group EC_GROUP object
380
+ * \param p BIGNUM with the prime number (GFp) or the polynomial
381
+ * defining the underlying field (GF2m)
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)
385
+ * \return 1 on success and 0 if an error occurred
386
+ */
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
+
394
+ /** Returns the number of bits needed to represent a field element
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);
399
+
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
+ */
405
+ int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx);
406
+
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)
418
+ * \return 0 if the groups are equal, 1 if not, or -1 on error
419
+ */
420
+ int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx);
421
+
422
+ /*
423
+ * EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*() after
424
+ * choosing an appropriate EC_METHOD
425
+ */
426
+
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
+ */
435
+ EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a,
436
+ const BIGNUM *b, BN_CTX *ctx);
437
+ # ifndef OPENSSL_NO_EC2M
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
+ */
446
+ EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a,
447
+ const BIGNUM *b, BN_CTX *ctx);
448
+ # endif
449
+
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[],
461
+ OSSL_LIB_CTX *libctx, const char *propq);
462
+
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
467
+ * \param propq A property query string
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
+ */
472
+ EC_GROUP *EC_GROUP_new_by_curve_name_ex(OSSL_LIB_CTX *libctx, const char *propq,
473
+ int nid);
474
+
475
+ /**
476
+ * Creates a EC_GROUP object with a curve specified by a NID. Same as
477
+ * EC_GROUP_new_by_curve_name_ex but the libctx and propq are always
478
+ * NULL.
479
+ * \param nid NID of the OID of the curve name
480
+ * \return newly created EC_GROUP object with specified curve or NULL
481
+ * if an error occurred
482
+ */
483
+ EC_GROUP *EC_GROUP_new_by_curve_name(int nid);
484
+
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
+
492
+ /** Creates an ECPARAMETERS object for the given EC_GROUP object.
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
+
508
+ /** Creates an ECPKPARAMETERS object for the given EC_GROUP object.
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
+
517
+ /********************************************************************/
518
+ /* handling of internal curves */
519
+ /********************************************************************/
520
+
521
+ typedef struct {
522
+ int nid;
523
+ const char *comment;
524
+ } EC_builtin_curve;
525
+
526
+ /*
527
+ * EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number of all
528
+ * available curves or zero if a error occurred. In case r is not zero,
529
+ * nitems EC_builtin_curve structures are filled with the data of the first
530
+ * nitems internal groups
531
+ */
532
+ size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems);
533
+
534
+ const char *EC_curve_nid2nist(int nid);
535
+ int EC_curve_nist2nid(const char *name);
536
+ int EC_GROUP_check_named_curve(const EC_GROUP *group, int nist_only,
537
+ BN_CTX *ctx);
538
+
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
562
+ * \return 1 on success and 0 if an error occurred
563
+ */
564
+ int EC_POINT_copy(EC_POINT *dst, const EC_POINT *src);
565
+
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
570
+ * \return newly created EC_POINT object or NULL if an error occurred
571
+ */
572
+ EC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group);
573
+
574
+ /** Sets a point to infinity (neutral element)
575
+ * \param group underlying EC_GROUP object
576
+ * \param point EC_POINT to set to infinity
577
+ * \return 1 on success and 0 if an error occurred
578
+ */
579
+ int EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point);
580
+
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
+
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)
595
+ * \return 1 on success and 0 if an error occurred
596
+ */
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);
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)
609
+ * \return 1 on success and 0 if an error occurred
610
+ */
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 */
615
+
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
+
639
+ # ifndef OPENSSL_NO_DEPRECATED_3_0
640
+ /** Sets the affine coordinates of an EC_POINT. A synonym of
641
+ * EC_POINT_set_affine_coordinates
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)
647
+ * \return 1 on success and 0 if an error occurred
648
+ */
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);
652
+
653
+ /** Gets the affine coordinates of an EC_POINT. A synonym of
654
+ * EC_POINT_get_affine_coordinates
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)
660
+ * \return 1 on success and 0 if an error occurred
661
+ */
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 */
666
+
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
+
679
+ # ifndef OPENSSL_NO_DEPRECATED_3_0
680
+ /** Sets the x9.62 compressed coordinates of a EC_POINT. A synonym of
681
+ * EC_POINT_set_compressed_coordinates
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)
687
+ * \return 1 on success and 0 if an error occurred
688
+ */
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
693
+ /** Sets the affine coordinates of an EC_POINT. A synonym of
694
+ * EC_POINT_set_affine_coordinates
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)
700
+ * \return 1 on success and 0 if an error occurred
701
+ */
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);
705
+
706
+ /** Gets the affine coordinates of an EC_POINT. A synonym of
707
+ * EC_POINT_get_affine_coordinates
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)
713
+ * \return 1 on success and 0 if an error occurred
714
+ */
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);
718
+
719
+ /** Sets the x9.62 compressed coordinates of a EC_POINT. A synonym of
720
+ * EC_POINT_set_compressed_coordinates
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)
726
+ * \return 1 on success and 0 if an error occurred
727
+ */
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
+
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,
745
+ point_conversion_form_t form,
746
+ unsigned char *buf, size_t len, BN_CTX *ctx);
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)
754
+ * \return 1 on success and 0 if an error occurred
755
+ */
756
+ int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p,
757
+ const unsigned char *buf, size_t len, BN_CTX *ctx);
758
+
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
764
+ * \param ctx BN_CTX object (optional)
765
+ * \return the length of the encoded octet string or 0 if an error occurred
766
+ */
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
+
771
+ /* other interfaces to point2oct/oct2point: */
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
+
782
+ char *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *,
783
+ point_conversion_form_t form, BN_CTX *);
784
+ EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *,
785
+ EC_POINT *, BN_CTX *);
786
+
787
+ /********************************************************************/
788
+ /* functions for doing EC_POINT arithmetic */
789
+ /********************************************************************/
790
+
791
+ /** Computes the sum of two EC_POINT
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)
797
+ * \return 1 on success and 0 if an error occurred
798
+ */
799
+ int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,
800
+ const EC_POINT *b, BN_CTX *ctx);
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)
805
+ * \param a EC_POINT object
806
+ * \param ctx BN_CTX object (optional)
807
+ * \return 1 on success and 0 if an error occurred
808
+ */
809
+ int EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,
810
+ BN_CTX *ctx);
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)
816
+ * \return 1 on success and 0 if an error occurred
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
+
827
+ /** Checks whether the point is on the curve
828
+ * \param group underlying EC_GROUP object
829
+ * \param point EC_POINT object to check
830
+ * \param ctx BN_CTX object (optional)
831
+ * \return 1 if the point is on the curve, 0 if not, or -1 on error
832
+ */
833
+ int EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point,
834
+ BN_CTX *ctx);
835
+
836
+ /** Compares two EC_POINTs
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)
841
+ * \return 1 if the points are not equal, 0 if they are, or -1 on error
842
+ */
843
+ int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b,
844
+ BN_CTX *ctx);
845
+
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);
851
+
852
+ /** Computes r = generator * n + sum_{i=0}^{num-1} p[i] * m[i]
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)
856
+ * \param num number further summands
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)
860
+ * \return 1 on success and 0 if an error occurred
861
+ */
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 */
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)
875
+ * \return 1 on success and 0 if an error occurred
876
+ */
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);
879
+
880
+ # ifndef OPENSSL_NO_DEPRECATED_3_0
881
+ /** Stores multiples of generator for faster point multiplication
882
+ * \param group EC_GROUP object
883
+ * \param ctx BN_CTX object (optional)
884
+ * \return 1 on success and 0 if an error occurred
885
+ */
886
+ OSSL_DEPRECATEDIN_3_0 int EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx);
887
+
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
+ */
892
+ OSSL_DEPRECATEDIN_3_0 int EC_GROUP_have_precompute_mult(const EC_GROUP *group);
893
+ # endif /* OPENSSL_NO_DEPRECATED_3_0 */
894
+
895
+ /********************************************************************/
896
+ /* ASN1 stuff */
897
+ /********************************************************************/
898
+
899
+ DECLARE_ASN1_ITEM(ECPKPARAMETERS)
900
+ DECLARE_ASN1_ALLOC_FUNCTIONS(ECPKPARAMETERS)
901
+ DECLARE_ASN1_ITEM(ECPARAMETERS)
902
+ DECLARE_ASN1_ALLOC_FUNCTIONS(ECPARAMETERS)
903
+
904
+ /*
905
+ * EC_GROUP_get_basis_type() returns the NID of the basis type used to
906
+ * represent the field elements
907
+ */
908
+ int EC_GROUP_get_basis_type(const EC_GROUP *);
909
+ # ifndef OPENSSL_NO_EC2M
910
+ int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k);
911
+ int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1,
912
+ unsigned int *k2, unsigned int *k3);
913
+ # endif
914
+
915
+ EC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len);
916
+ int i2d_ECPKParameters(const EC_GROUP *, unsigned char **out);
917
+
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) \
923
+ (EC_GROUP *)ASN1_d2i_fp(NULL, (d2i_of_void *)d2i_ECPKParameters, (fp), \
924
+ (void **)(x))
925
+ # define i2d_ECPKParameters_fp(fp,x) \
926
+ ASN1_i2d_fp((i2d_of_void *)i2d_ECPKParameters, (fp), (void *)(x))
927
+
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 */
936
+
937
+ /********************************************************************/
938
+ /* EC_KEY functions */
939
+ /********************************************************************/
940
+
941
+ /* some values for the encoding_flag */
942
+ # define EC_PKEY_NO_PARAMETERS 0x001
943
+ # define EC_PKEY_NO_PUBKEY 0x002
944
+
945
+ /* some values for the flags field */
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
956
+
957
+ # ifndef OPENSSL_NO_DEPRECATED_3_0
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
+ */
964
+ OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_new_ex(OSSL_LIB_CTX *ctx, const char *propq);
965
+
966
+ /**
967
+ * Creates a new EC_KEY object. Same as calling EC_KEY_new_ex with a
968
+ * NULL library context
969
+ * \return EC_KEY object or NULL if an error occurred.
970
+ */
971
+ OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_new(void);
972
+
973
+ OSSL_DEPRECATEDIN_3_0 int EC_KEY_get_flags(const EC_KEY *key);
974
+
975
+ OSSL_DEPRECATEDIN_3_0 void EC_KEY_set_flags(EC_KEY *key, int flags);
976
+
977
+ OSSL_DEPRECATEDIN_3_0 void EC_KEY_clear_flags(EC_KEY *key, int flags);
978
+
979
+ OSSL_DEPRECATEDIN_3_0 int EC_KEY_decoded_from_explicit_params(const EC_KEY *key);
980
+
981
+ /**
982
+ * Creates a new EC_KEY object using a named curve as underlying
983
+ * EC_GROUP object.
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.
988
+ * \return EC_KEY object or NULL if an error occurred.
989
+ */
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);
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
997
+ * library context and property query string.
998
+ * \param nid NID of the named curve.
999
+ * \return EC_KEY object or NULL if an error occurred.
1000
+ */
1001
+ OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_new_by_curve_name(int nid);
1002
+
1003
+ /** Frees a EC_KEY object.
1004
+ * \param key EC_KEY object to be freed.
1005
+ */
1006
+ OSSL_DEPRECATEDIN_3_0 void EC_KEY_free(EC_KEY *key);
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
+ */
1013
+ OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_copy(EC_KEY *dst, const EC_KEY *src);
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
+ */
1019
+ OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_dup(const EC_KEY *src);
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
+ */
1025
+ OSSL_DEPRECATEDIN_3_0 int EC_KEY_up_ref(EC_KEY *key);
1026
+
1027
+ /** Returns the ENGINE object of a EC_KEY object
1028
+ * \param eckey EC_KEY object
1029
+ * \return the ENGINE object (possibly NULL).
1030
+ */
1031
+ OSSL_DEPRECATEDIN_3_0 ENGINE *EC_KEY_get0_engine(const EC_KEY *eckey);
1032
+
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
+ */
1037
+ OSSL_DEPRECATEDIN_3_0 const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key);
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
+ */
1045
+ OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group);
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
+ */
1051
+ OSSL_DEPRECATEDIN_3_0 const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key);
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
+ */
1059
+ OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv);
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
+ */
1065
+ OSSL_DEPRECATEDIN_3_0 const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key);
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
+ */
1073
+ OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub);
1074
+
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 */
1081
+
1082
+ # define EC_KEY_get_ex_new_index(l, p, newf, dupf, freef) \
1083
+ CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_EC_KEY, l, p, newf, dupf, freef)
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);
1088
+
1089
+ /* wrapper functions for the underlying EC_GROUP object */
1090
+ OSSL_DEPRECATEDIN_3_0 void EC_KEY_set_asn1_flag(EC_KEY *eckey, int asn1_flag);
1091
+
1092
+ /** Creates a table of pre-computed multiples of the generator to
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
+ */
1098
+ OSSL_DEPRECATEDIN_3_0 int EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx);
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
+ */
1104
+ OSSL_DEPRECATEDIN_3_0 int EC_KEY_generate_key(EC_KEY *key);
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
+ */
1110
+ OSSL_DEPRECATEDIN_3_0 int EC_KEY_check_key(const EC_KEY *key);
1111
+
1112
+ /** Indicates if an EC_KEY can be used for signing.
1113
+ * \param eckey the EC_KEY object
1114
+ * \return 1 if can can sign and 0 otherwise.
1115
+ */
1116
+ OSSL_DEPRECATEDIN_3_0 int EC_KEY_can_sign(const EC_KEY *eckey);
1117
+
1118
+ /** Sets a public key from affine coordinates performing
1119
+ * necessary NIST PKV tests.
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
+ */
1125
+ OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key,
1126
+ BIGNUM *x,
1127
+ BIGNUM *y);
1128
+
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
1133
+ * \param ctx BN_CTX object (optional)
1134
+ * \return the length of the encoded octet string or 0 if an error occurred
1135
+ */
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);
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
+
1148
+ OSSL_DEPRECATEDIN_3_0 int EC_KEY_oct2key(EC_KEY *key, const unsigned char *buf,
1149
+ size_t len, BN_CTX *ctx);
1150
+
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
+
1158
+ OSSL_DEPRECATEDIN_3_0 int EC_KEY_oct2priv(EC_KEY *key, const unsigned char *buf,
1159
+ size_t len);
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
+
1169
+ OSSL_DEPRECATEDIN_3_0 size_t EC_KEY_priv2oct(const EC_KEY *key,
1170
+ unsigned char *buf, size_t len);
1171
+
1172
+ /** Encodes an EC_KEY private key to an allocated octet string
1173
+ * \param eckey key to encode
1174
+ * \param pbuf returns pointer to allocated buffer
1175
+ * \return the length of the encoded octet string or 0 if an error occurred
1176
+ */
1177
+ OSSL_DEPRECATEDIN_3_0 size_t EC_KEY_priv2buf(const EC_KEY *eckey,
1178
+ unsigned char **pbuf);
1179
+
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
+ */
1190
+ OSSL_DEPRECATEDIN_3_0 EC_KEY *d2i_ECPrivateKey(EC_KEY **key,
1191
+ const unsigned char **in,
1192
+ long len);
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
+ */
1200
+ OSSL_DEPRECATEDIN_3_0 int i2d_ECPrivateKey(const EC_KEY *key,
1201
+ unsigned char **out);
1202
+
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
+ */
1214
+ OSSL_DEPRECATEDIN_3_0 EC_KEY *d2i_ECParameters(EC_KEY **key,
1215
+ const unsigned char **in,
1216
+ long len);
1217
+
1218
+ /** Encodes ec parameter and stores the result in a buffer.
1219
+ * \param key the EC_KEY object with ec parameters to encode
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
+ */
1224
+ OSSL_DEPRECATEDIN_3_0 int i2d_ECParameters(const EC_KEY *key,
1225
+ unsigned char **out);
1226
+
1227
+ /********************************************************************/
1228
+ /* de- and encoding functions for EC public key */
1229
+ /* (octet string, not DER -- hence 'o2i' and 'i2o') */
1230
+ /********************************************************************/
1231
+
1232
+ /** Decodes an ec public key from a octet string.
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
+ */
1239
+ OSSL_DEPRECATEDIN_3_0 EC_KEY *o2i_ECPublicKey(EC_KEY **key,
1240
+ const unsigned char **in, long len);
1241
+
1242
+ /** Encodes an ec public key in an octet string.
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
+ */
1248
+ OSSL_DEPRECATEDIN_3_0 int i2o_ECPublicKey(const EC_KEY *key, unsigned char **out);
1249
+
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
+ */
1255
+ OSSL_DEPRECATEDIN_3_0 int ECParameters_print(BIO *bp, const EC_KEY *key);
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
1260
+ * \param off line offset
1261
+ * \return 1 on success and 0 if an error occurred
1262
+ */
1263
+ OSSL_DEPRECATEDIN_3_0 int EC_KEY_print(BIO *bp, const EC_KEY *key, int off);
1264
+
1265
+ # ifndef OPENSSL_NO_STDIO
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
+ */
1271
+ OSSL_DEPRECATEDIN_3_0 int ECParameters_print_fp(FILE *fp, const EC_KEY *key);
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
1276
+ * \param off line offset
1277
+ * \return 1 on success and 0 if an error occurred
1278
+ */
1279
+ OSSL_DEPRECATEDIN_3_0 int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off);
1280
+ # endif /* OPENSSL_NO_STDIO */
1281
+
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);
1288
+
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
+ */
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 */
1306
+
1307
+ typedef struct ECDSA_SIG_st ECDSA_SIG;
1308
+
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
+
1319
+ /** i2d_ECDSA_SIG encodes content of ECDSA_SIG (note: this function modifies *pp
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
1323
+ * \return the length of the DER encoded ECDSA_SIG object or a negative value
1324
+ * on error
1325
+ */
1326
+ DECLARE_ASN1_ENCODE_FUNCTIONS_only(ECDSA_SIG, ECDSA_SIG)
1327
+
1328
+ /** d2i_ECDSA_SIG decodes an ECDSA signature (note: this function modifies *pp
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
+ */
1335
+
1336
+ /** Accessor for r and s fields of ECDSA_SIG
1337
+ * \param sig pointer to ECDSA_SIG structure
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
+ */
1341
+ void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps);
1342
+
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
+
1353
+ /** Setter for r and s fields of ECDSA_SIG
1354
+ * \param sig pointer to ECDSA_SIG structure
1355
+ * \param r pointer to BIGNUM for r
1356
+ * \param s pointer to BIGNUM for s
1357
+ */
1358
+ int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s);
1359
+
1360
+ # ifndef OPENSSL_NO_DEPRECATED_3_0
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
+ */
1368
+ OSSL_DEPRECATEDIN_3_0 ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst,
1369
+ int dgst_len, EC_KEY *eckey);
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)
1376
+ * \param rp BIGNUM with a pre-computed rp value (optional),
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
+ */
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);
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
+ */
1394
+ OSSL_DEPRECATEDIN_3_0 int ECDSA_do_verify(const unsigned char *dgst, int dgst_len,
1395
+ const ECDSA_SIG *sig, EC_KEY *eckey);
1396
+
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
+ */
1404
+ OSSL_DEPRECATEDIN_3_0 int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx,
1405
+ BIGNUM **kinv, BIGNUM **rp);
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
+ */
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);
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)
1429
+ * \param rp BIGNUM with a pre-computed rp value (optional),
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
+ */
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);
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
+ */
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);
1453
+
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
+ */
1458
+ OSSL_DEPRECATEDIN_3_0 int ECDSA_size(const EC_KEY *eckey);
1459
+
1460
+ /********************************************************************/
1461
+ /* EC_KEY_METHOD constructors, destructors, writers and accessors */
1462
+ /********************************************************************/
1463
+
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,
1549
+ int dgst_len,
1550
+ const ECDSA_SIG *sig,
1551
+ EC_KEY *eckey));
1552
+ # endif /* OPENSSL_NO_DEPRECATED_3_0 */
1553
+
1554
+ # define EVP_EC_gen(curve) \
1555
+ EVP_PKEY_Q_keygen(NULL, NULL, "EC", (char *)(strstr(curve, "")))
1556
+ /* strstr is used to enable type checking for the variadic string arg */
1557
+ # define ECParameters_dup(x) ASN1_dup_of(EC_KEY, i2d_ECParameters, \
1558
+ d2i_ECParameters, x)
1559
+
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
1565
+ # endif
1566
+ # endif
1567
+
1568
+ # endif
1569
+ # ifdef __cplusplus
1570
+ }
1571
+ # endif
1572
+ #endif