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