1 | use super::super::*; |
2 | use libc::*; |
3 | |
4 | #[repr (C)] |
5 | #[derive (Copy, Clone)] |
6 | pub enum point_conversion_form_t { |
7 | POINT_CONVERSION_COMPRESSED = 2, |
8 | POINT_CONVERSION_UNCOMPRESSED = 4, |
9 | POINT_CONVERSION_HYBRID = 6, |
10 | } |
11 | |
12 | #[cfg (not(libressl410))] |
13 | pub enum EC_METHOD {} |
14 | pub enum EC_GROUP {} |
15 | pub enum EC_POINT {} |
16 | |
17 | unsafeextern "C" { |
18 | #[cfg (not(osslconf = "OPENSSL_NO_EC2M" ))] |
19 | pub unsafefn EC_GF2m_simple_method() -> *const EC_METHOD; |
20 | |
21 | #[cfg (not(libressl410))] |
22 | pub unsafefn EC_GROUP_new(meth: *const EC_METHOD) -> *mut EC_GROUP; |
23 | |
24 | pub unsafefn EC_GROUP_free(group: *mut EC_GROUP); |
25 | |
26 | pub unsafefn EC_GROUP_get_order( |
27 | group: *const EC_GROUP, |
28 | order: *mut BIGNUM, |
29 | ctx: *mut BN_CTX, |
30 | ) -> c_int; |
31 | |
32 | pub unsafefn EC_GROUP_get_cofactor( |
33 | group: *const EC_GROUP, |
34 | cofactor: *mut BIGNUM, |
35 | ctx: *mut BN_CTX, |
36 | ) -> c_int; |
37 | |
38 | pub unsafefn EC_GROUP_get0_generator(group: *const EC_GROUP) -> *const EC_POINT; |
39 | |
40 | pub unsafefn EC_GROUP_set_generator( |
41 | group: *mut EC_GROUP, |
42 | generator: *const EC_POINT, |
43 | order: *const BIGNUM, |
44 | cofactor: *const BIGNUM, |
45 | ) -> c_int; |
46 | |
47 | pub unsafefn EC_GROUP_get_curve_name(group: *const EC_GROUP) -> c_int; |
48 | |
49 | pub unsafefn EC_GROUP_set_asn1_flag(key: *mut EC_GROUP, flag: c_int); |
50 | |
51 | pub unsafefn EC_GROUP_get_asn1_flag(group: *const EC_GROUP) -> c_int; |
52 | |
53 | pub unsafefn EC_GROUP_get_curve_GFp( |
54 | group: *const EC_GROUP, |
55 | p: *mut BIGNUM, |
56 | a: *mut BIGNUM, |
57 | b: *mut BIGNUM, |
58 | ctx: *mut BN_CTX, |
59 | ) -> c_int; |
60 | |
61 | #[cfg (not(osslconf = "OPENSSL_NO_EC2M" ))] |
62 | pub unsafefn EC_GROUP_get_curve_GF2m( |
63 | group: *const EC_GROUP, |
64 | p: *mut BIGNUM, |
65 | a: *mut BIGNUM, |
66 | b: *mut BIGNUM, |
67 | ctx: *mut BN_CTX, |
68 | ) -> c_int; |
69 | |
70 | pub unsafefn EC_GROUP_get_degree(group: *const EC_GROUP) -> c_int; |
71 | |
72 | #[cfg (ossl110)] |
73 | pub unsafefn EC_GROUP_order_bits(group: *const EC_GROUP) -> c_int; |
74 | |
75 | pub unsafefn EC_GROUP_new_curve_GFp( |
76 | p: *const BIGNUM, |
77 | a: *const BIGNUM, |
78 | b: *const BIGNUM, |
79 | ctx: *mut BN_CTX, |
80 | ) -> *mut EC_GROUP; |
81 | |
82 | #[cfg (not(osslconf = "OPENSSL_NO_EC2M" ))] |
83 | pub unsafefn EC_GROUP_new_curve_GF2m( |
84 | p: *const BIGNUM, |
85 | a: *const BIGNUM, |
86 | b: *const BIGNUM, |
87 | ctx: *mut BN_CTX, |
88 | ) -> *mut EC_GROUP; |
89 | |
90 | pub unsafefn EC_GROUP_new_by_curve_name(nid: c_int) -> *mut EC_GROUP; |
91 | |
92 | pub unsafefn EC_POINT_is_at_infinity(group: *const EC_GROUP, point: *const EC_POINT) -> c_int; |
93 | |
94 | pub unsafefn EC_POINT_is_on_curve( |
95 | group: *const EC_GROUP, |
96 | point: *const EC_POINT, |
97 | ctx: *mut BN_CTX, |
98 | ) -> c_int; |
99 | |
100 | pub unsafefn EC_POINT_new(group: *const EC_GROUP) -> *mut EC_POINT; |
101 | |
102 | pub unsafefn EC_POINT_free(point: *mut EC_POINT); |
103 | |
104 | pub unsafefn EC_POINT_dup(p: *const EC_POINT, group: *const EC_GROUP) -> *mut EC_POINT; |
105 | |
106 | #[cfg (any(ossl111, boringssl, libressl350, awslc))] |
107 | pub unsafefn EC_POINT_get_affine_coordinates( |
108 | group: *const EC_GROUP, |
109 | p: *const EC_POINT, |
110 | x: *mut BIGNUM, |
111 | y: *mut BIGNUM, |
112 | ctx: *mut BN_CTX, |
113 | ) -> c_int; |
114 | |
115 | pub unsafefn EC_POINT_get_affine_coordinates_GFp( |
116 | group: *const EC_GROUP, |
117 | p: *const EC_POINT, |
118 | x: *mut BIGNUM, |
119 | y: *mut BIGNUM, |
120 | ctx: *mut BN_CTX, |
121 | ) -> c_int; |
122 | |
123 | pub unsafefn EC_POINT_set_affine_coordinates_GFp( |
124 | group: *const EC_GROUP, |
125 | p: *mut EC_POINT, |
126 | x: *const BIGNUM, |
127 | y: *const BIGNUM, |
128 | ctx: *mut BN_CTX, |
129 | ) -> c_int; |
130 | |
131 | #[cfg (not(osslconf = "OPENSSL_NO_EC2M" ))] |
132 | pub unsafefn EC_POINT_get_affine_coordinates_GF2m( |
133 | group: *const EC_GROUP, |
134 | p: *const EC_POINT, |
135 | x: *mut BIGNUM, |
136 | y: *mut BIGNUM, |
137 | ctx: *mut BN_CTX, |
138 | ) -> c_int; |
139 | |
140 | pub unsafefn EC_POINT_point2oct( |
141 | group: *const EC_GROUP, |
142 | p: *const EC_POINT, |
143 | form: point_conversion_form_t, |
144 | buf: *mut c_uchar, |
145 | len: size_t, |
146 | ctx: *mut BN_CTX, |
147 | ) -> size_t; |
148 | |
149 | pub unsafefn EC_POINT_oct2point( |
150 | group: *const EC_GROUP, |
151 | p: *mut EC_POINT, |
152 | buf: *const c_uchar, |
153 | len: size_t, |
154 | ctx: *mut BN_CTX, |
155 | ) -> c_int; |
156 | |
157 | pub unsafefn EC_POINT_point2hex( |
158 | group: *const EC_GROUP, |
159 | p: *const EC_POINT, |
160 | form: point_conversion_form_t, |
161 | ctx: *mut BN_CTX, |
162 | ) -> *mut c_char; |
163 | |
164 | pub unsafefn EC_POINT_hex2point( |
165 | group: *const EC_GROUP, |
166 | s: *const c_char, |
167 | p: *mut EC_POINT, |
168 | ctx: *mut BN_CTX, |
169 | ) -> *mut EC_POINT; |
170 | |
171 | pub unsafefn EC_POINT_add( |
172 | group: *const EC_GROUP, |
173 | r: *mut EC_POINT, |
174 | a: *const EC_POINT, |
175 | b: *const EC_POINT, |
176 | ctx: *mut BN_CTX, |
177 | ) -> c_int; |
178 | |
179 | pub unsafefn EC_POINT_invert(group: *const EC_GROUP, r: *mut EC_POINT, ctx: *mut BN_CTX) -> c_int; |
180 | |
181 | pub unsafefn EC_POINT_cmp( |
182 | group: *const EC_GROUP, |
183 | a: *const EC_POINT, |
184 | b: *const EC_POINT, |
185 | ctx: *mut BN_CTX, |
186 | ) -> c_int; |
187 | |
188 | pub unsafefn EC_POINT_mul( |
189 | group: *const EC_GROUP, |
190 | r: *mut EC_POINT, |
191 | n: *const BIGNUM, |
192 | q: *const EC_POINT, |
193 | m: *const BIGNUM, |
194 | ctx: *mut BN_CTX, |
195 | ) -> c_int; |
196 | |
197 | pub unsafefn EC_KEY_new() -> *mut EC_KEY; |
198 | |
199 | pub unsafefn EC_KEY_new_by_curve_name(nid: c_int) -> *mut EC_KEY; |
200 | |
201 | pub unsafefn EC_KEY_free(key: *mut EC_KEY); |
202 | |
203 | pub unsafefn EC_KEY_dup(key: *const EC_KEY) -> *mut EC_KEY; |
204 | |
205 | pub unsafefn EC_KEY_up_ref(key: *mut EC_KEY) -> c_int; |
206 | |
207 | pub unsafefn EC_KEY_get0_group(key: *const EC_KEY) -> *const EC_GROUP; |
208 | |
209 | pub unsafefn EC_KEY_set_group(key: *mut EC_KEY, group: *const EC_GROUP) -> c_int; |
210 | |
211 | pub unsafefn EC_KEY_get0_private_key(key: *const EC_KEY) -> *const BIGNUM; |
212 | |
213 | pub unsafefn EC_KEY_set_private_key(key: *mut EC_KEY, key: *const BIGNUM) -> c_int; |
214 | |
215 | pub unsafefn EC_KEY_get0_public_key(key: *const EC_KEY) -> *const EC_POINT; |
216 | |
217 | pub unsafefn EC_KEY_set_public_key(key: *mut EC_KEY, key: *const EC_POINT) -> c_int; |
218 | |
219 | pub unsafefn EC_KEY_generate_key(key: *mut EC_KEY) -> c_int; |
220 | |
221 | pub unsafefn EC_KEY_check_key(key: *const EC_KEY) -> c_int; |
222 | |
223 | pub unsafefn EC_KEY_set_public_key_affine_coordinates( |
224 | key: *mut EC_KEY, |
225 | x: *mut BIGNUM, |
226 | y: *mut BIGNUM, |
227 | ) -> c_int; |
228 | } |
229 | |
230 | cfg_if! { |
231 | if #[cfg(any(ossl110, libressl280))] { |
232 | pub enum ECDSA_SIG {} |
233 | } else { |
234 | #[repr (C)] |
235 | pub struct ECDSA_SIG { |
236 | pub r: *mut BIGNUM, |
237 | pub s: *mut BIGNUM, |
238 | } |
239 | } |
240 | } |
241 | |
242 | unsafeextern "C" { |
243 | pub unsafefn ECDSA_SIG_new() -> *mut ECDSA_SIG; |
244 | |
245 | pub unsafefn ECDSA_SIG_free(sig: *mut ECDSA_SIG); |
246 | |
247 | #[cfg (any(ossl110, libressl273))] |
248 | pub unsafefn ECDSA_SIG_get0(sig: *const ECDSA_SIG, pr: *mut *const BIGNUM, ps: *mut *const BIGNUM); |
249 | |
250 | #[cfg (any(ossl110, libressl273))] |
251 | pub unsafefn ECDSA_SIG_set0(sig: *mut ECDSA_SIG, pr: *mut BIGNUM, ps: *mut BIGNUM) -> c_int; |
252 | |
253 | pub unsafefn ECDSA_do_sign( |
254 | dgst: *const c_uchar, |
255 | dgst_len: c_int, |
256 | eckey: *mut EC_KEY, |
257 | ) -> *mut ECDSA_SIG; |
258 | |
259 | pub unsafefn ECDSA_do_verify( |
260 | dgst: *const c_uchar, |
261 | dgst_len: c_int, |
262 | sig: *const ECDSA_SIG, |
263 | eckey: *mut EC_KEY, |
264 | ) -> c_int; |
265 | |
266 | pub unsafefn d2i_ECDSA_SIG( |
267 | sig: *mut *mut ECDSA_SIG, |
268 | inp: *mut *const c_uchar, |
269 | length: c_long, |
270 | ) -> *mut ECDSA_SIG; |
271 | |
272 | pub unsafefn i2d_ECDSA_SIG(sig: *const ECDSA_SIG, out: *mut *mut c_uchar) -> c_int; |
273 | } |
274 | |