1 | use super::super::*; |
2 | use libc::*; |
3 | |
4 | cfg_if! { |
5 | if #[cfg(ossl300)] { |
6 | extern "C" { |
7 | pub fn EVP_MD_get_block_size(md: *const EVP_MD) -> c_int; |
8 | pub fn EVP_MD_get_size(md: *const EVP_MD) -> c_int; |
9 | pub fn EVP_MD_get_type(md: *const EVP_MD) -> c_int; |
10 | |
11 | pub fn EVP_MD_CTX_get0_md(ctx: *const EVP_MD_CTX) -> *const EVP_MD; |
12 | |
13 | pub fn EVP_CIPHER_get_key_length(cipher: *const EVP_CIPHER) -> c_int; |
14 | pub fn EVP_CIPHER_get_block_size(cipher: *const EVP_CIPHER) -> c_int; |
15 | pub fn EVP_CIPHER_get_iv_length(cipher: *const EVP_CIPHER) -> c_int; |
16 | pub fn EVP_CIPHER_get_nid(cipher: *const EVP_CIPHER) -> c_int; |
17 | pub fn EVP_CIPHER_fetch( |
18 | ctx: *mut OSSL_LIB_CTX, |
19 | algorithm: *const c_char, |
20 | properties: *const c_char, |
21 | ) -> *mut EVP_CIPHER; |
22 | pub fn EVP_CIPHER_free(cipher: *mut EVP_CIPHER); |
23 | |
24 | pub fn EVP_CIPHER_CTX_get0_cipher(ctx: *const EVP_CIPHER_CTX) -> *const EVP_CIPHER; |
25 | pub fn EVP_CIPHER_CTX_get_block_size(ctx: *const EVP_CIPHER_CTX) -> c_int; |
26 | pub fn EVP_CIPHER_CTX_get_key_length(ctx: *const EVP_CIPHER_CTX) -> c_int; |
27 | pub fn EVP_CIPHER_CTX_get_iv_length(ctx: *const EVP_CIPHER_CTX) -> c_int; |
28 | pub fn EVP_CIPHER_CTX_get_tag_length(ctx: *const EVP_CIPHER_CTX) -> c_int; |
29 | pub fn EVP_CIPHER_CTX_get_num(ctx: *const EVP_CIPHER_CTX) -> c_int; |
30 | } |
31 | } else { |
32 | extern "C" { |
33 | pub fn EVP_MD_block_size(md: *const EVP_MD) -> c_int; |
34 | pub fn EVP_MD_size(md: *const EVP_MD) -> c_int; |
35 | pub fn EVP_MD_type(md: *const EVP_MD) -> c_int; |
36 | |
37 | pub fn EVP_MD_CTX_md(ctx: *const EVP_MD_CTX) -> *const EVP_MD; |
38 | |
39 | pub fn EVP_CIPHER_key_length(cipher: *const EVP_CIPHER) -> c_int; |
40 | pub fn EVP_CIPHER_block_size(cipher: *const EVP_CIPHER) -> c_int; |
41 | pub fn EVP_CIPHER_iv_length(cipher: *const EVP_CIPHER) -> c_int; |
42 | pub fn EVP_CIPHER_nid(cipher: *const EVP_CIPHER) -> c_int; |
43 | |
44 | pub fn EVP_CIPHER_CTX_cipher(ctx: *const EVP_CIPHER_CTX) -> *const EVP_CIPHER; |
45 | pub fn EVP_CIPHER_CTX_block_size(ctx: *const EVP_CIPHER_CTX) -> c_int; |
46 | pub fn EVP_CIPHER_CTX_key_length(ctx: *const EVP_CIPHER_CTX) -> c_int; |
47 | pub fn EVP_CIPHER_CTX_iv_length(ctx: *const EVP_CIPHER_CTX) -> c_int; |
48 | #[cfg (ossl110)] |
49 | pub fn EVP_CIPHER_CTX_num(ctx: *const EVP_CIPHER_CTX) -> c_int; |
50 | } |
51 | } |
52 | } |
53 | |
54 | cfg_if! { |
55 | if #[cfg(any(ossl110, libressl382))] { |
56 | extern "C" { |
57 | pub fn EVP_MD_CTX_new() -> *mut EVP_MD_CTX; |
58 | pub fn EVP_MD_CTX_free(ctx: *mut EVP_MD_CTX); |
59 | } |
60 | } else { |
61 | extern "C" { |
62 | pub fn EVP_MD_CTX_create() -> *mut EVP_MD_CTX; |
63 | pub fn EVP_MD_CTX_destroy(ctx: *mut EVP_MD_CTX); |
64 | } |
65 | } |
66 | } |
67 | |
68 | cfg_if! { |
69 | if #[cfg(ossl300)] { |
70 | extern "C" { |
71 | pub fn EVP_default_properties_is_fips_enabled(libctx: *mut OSSL_LIB_CTX) -> c_int; |
72 | pub fn EVP_default_properties_enable_fips(libctx: *mut OSSL_LIB_CTX, enable: c_int) -> c_int; |
73 | } |
74 | } |
75 | } |
76 | |
77 | unsafeextern "C" { |
78 | pub unsafefn EVP_DigestInit_ex(ctx: *mut EVP_MD_CTX, typ: *const EVP_MD, imple: *mut ENGINE) |
79 | -> c_int; |
80 | pub unsafefn EVP_DigestUpdate(ctx: *mut EVP_MD_CTX, data: *const c_void, n: size_t) -> c_int; |
81 | pub unsafefn EVP_DigestFinal_ex(ctx: *mut EVP_MD_CTX, res: *mut u8, n: *mut u32) -> c_int; |
82 | #[cfg (ossl300)] |
83 | pub unsafefn EVP_Q_digest( |
84 | libctx: *mut OSSL_LIB_CTX, |
85 | name: *const c_char, |
86 | propq: *const c_char, |
87 | data: *const c_void, |
88 | count: size_t, |
89 | md: *mut c_uchar, |
90 | size: *mut size_t, |
91 | ) -> c_int; |
92 | pub unsafefn EVP_DigestInit(ctx: *mut EVP_MD_CTX, typ: *const EVP_MD) -> c_int; |
93 | pub unsafefn EVP_DigestFinal(ctx: *mut EVP_MD_CTX, res: *mut u8, n: *mut u32) -> c_int; |
94 | #[cfg (ossl111)] |
95 | pub unsafefn EVP_DigestFinalXOF(ctx: *mut EVP_MD_CTX, res: *mut u8, len: usize) -> c_int; |
96 | #[cfg (ossl330)] |
97 | pub fn EVP_DigestSqueeze(ctx: *mut EVP_MD_CTX, res: *mut u8, len: usize) -> c_int; |
98 | |
99 | #[cfg (ossl300)] |
100 | pub unsafefn EVP_MD_fetch( |
101 | ctx: *mut OSSL_LIB_CTX, |
102 | algorithm: *const c_char, |
103 | properties: *const c_char, |
104 | ) -> *mut EVP_MD; |
105 | |
106 | #[cfg (ossl300)] |
107 | pub unsafefn EVP_MD_free(md: *mut EVP_MD); |
108 | |
109 | pub unsafefn EVP_BytesToKey( |
110 | typ: *const EVP_CIPHER, |
111 | md: *const EVP_MD, |
112 | salt: *const u8, |
113 | data: *const u8, |
114 | datalen: c_int, |
115 | count: c_int, |
116 | key: *mut u8, |
117 | iv: *mut u8, |
118 | ) -> c_int; |
119 | |
120 | pub unsafefn EVP_CipherInit( |
121 | ctx: *mut EVP_CIPHER_CTX, |
122 | evp: *const EVP_CIPHER, |
123 | key: *const u8, |
124 | iv: *const u8, |
125 | mode: c_int, |
126 | ) -> c_int; |
127 | pub unsafefn EVP_CipherInit_ex( |
128 | ctx: *mut EVP_CIPHER_CTX, |
129 | type_: *const EVP_CIPHER, |
130 | impl_: *mut ENGINE, |
131 | key: *const c_uchar, |
132 | iv: *const c_uchar, |
133 | enc: c_int, |
134 | ) -> c_int; |
135 | pub unsafefn EVP_CipherUpdate( |
136 | ctx: *mut EVP_CIPHER_CTX, |
137 | outbuf: *mut u8, |
138 | outlen: *mut c_int, |
139 | inbuf: *const u8, |
140 | inlen: c_int, |
141 | ) -> c_int; |
142 | pub unsafefn EVP_CipherFinal(ctx: *mut EVP_CIPHER_CTX, res: *mut u8, len: *mut c_int) -> c_int; |
143 | |
144 | pub unsafefn EVP_DigestSignInit( |
145 | ctx: *mut EVP_MD_CTX, |
146 | pctx: *mut *mut EVP_PKEY_CTX, |
147 | type_: *const EVP_MD, |
148 | e: *mut ENGINE, |
149 | pkey: *mut EVP_PKEY, |
150 | ) -> c_int; |
151 | |
152 | #[cfg (ossl300)] |
153 | pub unsafefn EVP_DigestSignUpdate(ctx: *mut EVP_MD_CTX, data: *const c_void, dsize: size_t) -> c_int; |
154 | pub unsafefn EVP_DigestSignFinal( |
155 | ctx: *mut EVP_MD_CTX, |
156 | sig: *mut c_uchar, |
157 | siglen: *mut size_t, |
158 | ) -> c_int; |
159 | pub unsafefn EVP_DigestVerifyInit( |
160 | ctx: *mut EVP_MD_CTX, |
161 | pctx: *mut *mut EVP_PKEY_CTX, |
162 | type_: *const EVP_MD, |
163 | e: *mut ENGINE, |
164 | pkey: *mut EVP_PKEY, |
165 | ) -> c_int; |
166 | #[cfg (ossl300)] |
167 | pub unsafefn EVP_DigestVerifyUpdate( |
168 | ctx: *mut EVP_MD_CTX, |
169 | data: *const c_void, |
170 | dsize: size_t, |
171 | ) -> c_int; |
172 | pub unsafefn EVP_SealInit( |
173 | ctx: *mut EVP_CIPHER_CTX, |
174 | type_: *const EVP_CIPHER, |
175 | ek: *mut *mut c_uchar, |
176 | ekl: *mut c_int, |
177 | iv: *mut c_uchar, |
178 | pubk: *mut *mut EVP_PKEY, |
179 | npubk: c_int, |
180 | ) -> c_int; |
181 | pub unsafefn EVP_SealFinal(ctx: *mut EVP_CIPHER_CTX, out: *mut c_uchar, outl: *mut c_int) -> c_int; |
182 | pub unsafefn EVP_EncryptInit_ex( |
183 | ctx: *mut EVP_CIPHER_CTX, |
184 | cipher: *const EVP_CIPHER, |
185 | impl_: *mut ENGINE, |
186 | key: *const c_uchar, |
187 | iv: *const c_uchar, |
188 | ) -> c_int; |
189 | pub unsafefn EVP_EncryptUpdate( |
190 | ctx: *mut EVP_CIPHER_CTX, |
191 | out: *mut c_uchar, |
192 | outl: *mut c_int, |
193 | in_: *const u8, |
194 | inl: c_int, |
195 | ) -> c_int; |
196 | pub unsafefn EVP_EncryptFinal_ex( |
197 | ctx: *mut EVP_CIPHER_CTX, |
198 | out: *mut c_uchar, |
199 | outl: *mut c_int, |
200 | ) -> c_int; |
201 | pub unsafefn EVP_OpenInit( |
202 | ctx: *mut EVP_CIPHER_CTX, |
203 | type_: *const EVP_CIPHER, |
204 | ek: *const c_uchar, |
205 | ekl: c_int, |
206 | iv: *const c_uchar, |
207 | priv_: *mut EVP_PKEY, |
208 | ) -> c_int; |
209 | pub unsafefn EVP_OpenFinal(ctx: *mut EVP_CIPHER_CTX, out: *mut c_uchar, outl: *mut c_int) -> c_int; |
210 | pub unsafefn EVP_DecryptInit_ex( |
211 | ctx: *mut EVP_CIPHER_CTX, |
212 | cipher: *const EVP_CIPHER, |
213 | impl_: *mut ENGINE, |
214 | key: *const c_uchar, |
215 | iv: *const c_uchar, |
216 | ) -> c_int; |
217 | pub unsafefn EVP_DecryptUpdate( |
218 | ctx: *mut EVP_CIPHER_CTX, |
219 | out: *mut c_uchar, |
220 | outl: *mut c_int, |
221 | in_: *const u8, |
222 | inl: c_int, |
223 | ) -> c_int; |
224 | pub unsafefn EVP_DecryptFinal_ex( |
225 | ctx: *mut EVP_CIPHER_CTX, |
226 | outm: *mut c_uchar, |
227 | outl: *mut c_int, |
228 | ) -> c_int; |
229 | } |
230 | cfg_if! { |
231 | if #[cfg(ossl300)] { |
232 | extern "C" { |
233 | pub fn EVP_PKEY_get_size(pkey: *const EVP_PKEY) -> c_int; |
234 | } |
235 | } else { |
236 | const_ptr_api! { |
237 | extern "C" { |
238 | pub fn EVP_PKEY_size(pkey: #[const_ptr_if(any(ossl111b, libressl280))] EVP_PKEY) -> c_int; |
239 | } |
240 | } |
241 | } |
242 | } |
243 | cfg_if! { |
244 | if #[cfg(any(ossl111, libressl370))] { |
245 | extern "C" { |
246 | pub fn EVP_DigestSign( |
247 | ctx: *mut EVP_MD_CTX, |
248 | sigret: *mut c_uchar, |
249 | siglen: *mut size_t, |
250 | tbs: *const c_uchar, |
251 | tbslen: size_t |
252 | ) -> c_int; |
253 | |
254 | pub fn EVP_DigestVerify( |
255 | ctx: *mut EVP_MD_CTX, |
256 | sigret: *const c_uchar, |
257 | siglen: size_t, |
258 | tbs: *const c_uchar, |
259 | tbslen: size_t |
260 | ) -> c_int; |
261 | } |
262 | } |
263 | } |
264 | const_ptr_api! { |
265 | extern "C" { |
266 | pub fn EVP_DigestVerifyFinal( |
267 | ctx: *mut EVP_MD_CTX, |
268 | sigret: #[const_ptr_if(any(ossl102, libressl280))] c_uchar, |
269 | siglen: size_t, |
270 | ) -> c_int; |
271 | } |
272 | } |
273 | |
274 | unsafeextern "C" { |
275 | pub unsafefn EVP_CIPHER_CTX_new() -> *mut EVP_CIPHER_CTX; |
276 | pub unsafefn EVP_CIPHER_CTX_free(ctx: *mut EVP_CIPHER_CTX); |
277 | pub unsafefn EVP_CIPHER_CTX_copy(dst: *mut EVP_CIPHER_CTX, src: *const EVP_CIPHER_CTX) -> c_int; |
278 | |
279 | pub unsafefn EVP_MD_CTX_copy_ex(dst: *mut EVP_MD_CTX, src: *const EVP_MD_CTX) -> c_int; |
280 | #[cfg (ossl111)] |
281 | pub unsafefn EVP_MD_CTX_reset(ctx: *mut EVP_MD_CTX) -> c_int; |
282 | pub unsafefn EVP_CIPHER_CTX_set_key_length(ctx: *mut EVP_CIPHER_CTX, keylen: c_int) -> c_int; |
283 | pub unsafefn EVP_CIPHER_CTX_set_padding(ctx: *mut EVP_CIPHER_CTX, padding: c_int) -> c_int; |
284 | pub unsafefn EVP_CIPHER_CTX_ctrl( |
285 | ctx: *mut EVP_CIPHER_CTX, |
286 | type_: c_int, |
287 | arg: c_int, |
288 | ptr: *mut c_void, |
289 | ) -> c_int; |
290 | pub unsafefn EVP_CIPHER_CTX_rand_key(ctx: *mut EVP_CIPHER_CTX, key: *mut c_uchar) -> c_int; |
291 | pub unsafefn EVP_CIPHER_CTX_set_flags(ctx: *mut EVP_CIPHER_CTX, flags: c_int); |
292 | |
293 | pub unsafefn EVP_md_null() -> *const EVP_MD; |
294 | pub unsafefn EVP_md5() -> *const EVP_MD; |
295 | pub unsafefn EVP_sha1() -> *const EVP_MD; |
296 | pub unsafefn EVP_sha224() -> *const EVP_MD; |
297 | pub unsafefn EVP_sha256() -> *const EVP_MD; |
298 | pub unsafefn EVP_sha384() -> *const EVP_MD; |
299 | pub unsafefn EVP_sha512() -> *const EVP_MD; |
300 | #[cfg (any(ossl111, libressl380))] |
301 | pub unsafefn EVP_sha3_224() -> *const EVP_MD; |
302 | #[cfg (any(ossl111, libressl380))] |
303 | pub unsafefn EVP_sha3_256() -> *const EVP_MD; |
304 | #[cfg (any(ossl111, libressl380))] |
305 | pub unsafefn EVP_sha3_384() -> *const EVP_MD; |
306 | #[cfg (any(ossl111, libressl380))] |
307 | pub unsafefn EVP_sha3_512() -> *const EVP_MD; |
308 | #[cfg (ossl111)] |
309 | pub unsafefn EVP_shake128() -> *const EVP_MD; |
310 | #[cfg (ossl111)] |
311 | pub unsafefn EVP_shake256() -> *const EVP_MD; |
312 | pub unsafefn EVP_ripemd160() -> *const EVP_MD; |
313 | #[cfg (all(any(ossl111, libressl291), not(osslconf = "OPENSSL_NO_SM3" )))] |
314 | pub unsafefn EVP_sm3() -> *const EVP_MD; |
315 | pub unsafefn EVP_des_ecb() -> *const EVP_CIPHER; |
316 | pub unsafefn EVP_des_ede3() -> *const EVP_CIPHER; |
317 | pub unsafefn EVP_des_ede3_cbc() -> *const EVP_CIPHER; |
318 | pub unsafefn EVP_des_ede3_ecb() -> *const EVP_CIPHER; |
319 | pub unsafefn EVP_des_ede3_cfb64() -> *const EVP_CIPHER; |
320 | pub unsafefn EVP_des_ede3_cfb8() -> *const EVP_CIPHER; |
321 | pub unsafefn EVP_des_ede3_ofb() -> *const EVP_CIPHER; |
322 | pub unsafefn EVP_des_cbc() -> *const EVP_CIPHER; |
323 | #[cfg (not(osslconf = "OPENSSL_NO_RC4" ))] |
324 | pub unsafefn EVP_rc4() -> *const EVP_CIPHER; |
325 | pub unsafefn EVP_bf_ecb() -> *const EVP_CIPHER; |
326 | pub unsafefn EVP_bf_cbc() -> *const EVP_CIPHER; |
327 | pub unsafefn EVP_bf_cfb64() -> *const EVP_CIPHER; |
328 | pub unsafefn EVP_bf_ofb() -> *const EVP_CIPHER; |
329 | pub unsafefn EVP_aes_128_ecb() -> *const EVP_CIPHER; |
330 | pub unsafefn EVP_aes_128_cbc() -> *const EVP_CIPHER; |
331 | pub unsafefn EVP_aes_128_cfb1() -> *const EVP_CIPHER; |
332 | pub unsafefn EVP_aes_128_cfb8() -> *const EVP_CIPHER; |
333 | pub unsafefn EVP_aes_128_cfb128() -> *const EVP_CIPHER; |
334 | pub unsafefn EVP_aes_128_ctr() -> *const EVP_CIPHER; |
335 | pub unsafefn EVP_aes_128_ccm() -> *const EVP_CIPHER; |
336 | pub unsafefn EVP_aes_128_gcm() -> *const EVP_CIPHER; |
337 | pub unsafefn EVP_aes_128_xts() -> *const EVP_CIPHER; |
338 | pub unsafefn EVP_aes_128_ofb() -> *const EVP_CIPHER; |
339 | #[cfg (ossl110)] |
340 | pub unsafefn EVP_aes_128_ocb() -> *const EVP_CIPHER; |
341 | #[cfg (ossl102)] |
342 | pub unsafefn EVP_aes_128_wrap() -> *const EVP_CIPHER; |
343 | #[cfg (ossl110)] |
344 | pub unsafefn EVP_aes_128_wrap_pad() -> *const EVP_CIPHER; |
345 | pub unsafefn EVP_aes_192_ecb() -> *const EVP_CIPHER; |
346 | pub unsafefn EVP_aes_192_cbc() -> *const EVP_CIPHER; |
347 | pub unsafefn EVP_aes_192_cfb1() -> *const EVP_CIPHER; |
348 | pub unsafefn EVP_aes_192_cfb8() -> *const EVP_CIPHER; |
349 | pub unsafefn EVP_aes_192_cfb128() -> *const EVP_CIPHER; |
350 | pub unsafefn EVP_aes_192_ctr() -> *const EVP_CIPHER; |
351 | pub unsafefn EVP_aes_192_ccm() -> *const EVP_CIPHER; |
352 | pub unsafefn EVP_aes_192_gcm() -> *const EVP_CIPHER; |
353 | pub unsafefn EVP_aes_192_ofb() -> *const EVP_CIPHER; |
354 | #[cfg (ossl110)] |
355 | pub unsafefn EVP_aes_192_ocb() -> *const EVP_CIPHER; |
356 | #[cfg (ossl102)] |
357 | pub unsafefn EVP_aes_192_wrap() -> *const EVP_CIPHER; |
358 | #[cfg (ossl110)] |
359 | pub unsafefn EVP_aes_192_wrap_pad() -> *const EVP_CIPHER; |
360 | pub unsafefn EVP_aes_256_ecb() -> *const EVP_CIPHER; |
361 | pub unsafefn EVP_aes_256_cbc() -> *const EVP_CIPHER; |
362 | pub unsafefn EVP_aes_256_cfb1() -> *const EVP_CIPHER; |
363 | pub unsafefn EVP_aes_256_cfb8() -> *const EVP_CIPHER; |
364 | pub unsafefn EVP_aes_256_cfb128() -> *const EVP_CIPHER; |
365 | pub unsafefn EVP_aes_256_ctr() -> *const EVP_CIPHER; |
366 | pub unsafefn EVP_aes_256_ccm() -> *const EVP_CIPHER; |
367 | pub unsafefn EVP_aes_256_gcm() -> *const EVP_CIPHER; |
368 | pub unsafefn EVP_aes_256_xts() -> *const EVP_CIPHER; |
369 | pub unsafefn EVP_aes_256_ofb() -> *const EVP_CIPHER; |
370 | #[cfg (ossl110)] |
371 | pub unsafefn EVP_aes_256_ocb() -> *const EVP_CIPHER; |
372 | #[cfg (ossl102)] |
373 | pub unsafefn EVP_aes_256_wrap() -> *const EVP_CIPHER; |
374 | #[cfg (ossl110)] |
375 | pub unsafefn EVP_aes_256_wrap_pad() -> *const EVP_CIPHER; |
376 | #[cfg (all(any(ossl110, libressl310), not(osslconf = "OPENSSL_NO_CHACHA" )))] |
377 | pub unsafefn EVP_chacha20() -> *const EVP_CIPHER; |
378 | #[cfg (all(any(ossl110, libressl360), not(osslconf = "OPENSSL_NO_CHACHA" )))] |
379 | pub unsafefn EVP_chacha20_poly1305() -> *const EVP_CIPHER; |
380 | #[cfg (not(osslconf = "OPENSSL_NO_SEED" ))] |
381 | pub unsafefn EVP_seed_cbc() -> *const EVP_CIPHER; |
382 | #[cfg (not(osslconf = "OPENSSL_NO_SEED" ))] |
383 | pub unsafefn EVP_seed_cfb128() -> *const EVP_CIPHER; |
384 | #[cfg (not(osslconf = "OPENSSL_NO_SEED" ))] |
385 | pub unsafefn EVP_seed_ecb() -> *const EVP_CIPHER; |
386 | #[cfg (not(osslconf = "OPENSSL_NO_SEED" ))] |
387 | pub unsafefn EVP_seed_ofb() -> *const EVP_CIPHER; |
388 | |
389 | #[cfg (all(any(ossl111, libressl291), not(osslconf = "OPENSSL_NO_SM4" )))] |
390 | pub unsafefn EVP_sm4_ecb() -> *const EVP_CIPHER; |
391 | #[cfg (all(any(ossl111, libressl291), not(osslconf = "OPENSSL_NO_SM4" )))] |
392 | pub unsafefn EVP_sm4_cbc() -> *const EVP_CIPHER; |
393 | #[cfg (all(any(ossl111, libressl291), not(osslconf = "OPENSSL_NO_SM4" )))] |
394 | pub unsafefn EVP_sm4_cfb128() -> *const EVP_CIPHER; |
395 | #[cfg (all(any(ossl111, libressl291), not(osslconf = "OPENSSL_NO_SM4" )))] |
396 | pub unsafefn EVP_sm4_ofb() -> *const EVP_CIPHER; |
397 | #[cfg (all(any(ossl111, libressl291), not(osslconf = "OPENSSL_NO_SM4" )))] |
398 | pub unsafefn EVP_sm4_ctr() -> *const EVP_CIPHER; |
399 | |
400 | #[cfg (not(osslconf = "OPENSSL_NO_CAMELLIA" ))] |
401 | pub unsafefn EVP_camellia_128_cfb128() -> *const EVP_CIPHER; |
402 | #[cfg (not(osslconf = "OPENSSL_NO_CAMELLIA" ))] |
403 | pub unsafefn EVP_camellia_128_ecb() -> *const EVP_CIPHER; |
404 | #[cfg (not(osslconf = "OPENSSL_NO_CAMELLIA" ))] |
405 | pub unsafefn EVP_camellia_128_cbc() -> *const EVP_CIPHER; |
406 | #[cfg (not(osslconf = "OPENSSL_NO_CAMELLIA" ))] |
407 | pub unsafefn EVP_camellia_128_ofb() -> *const EVP_CIPHER; |
408 | #[cfg (not(osslconf = "OPENSSL_NO_CAMELLIA" ))] |
409 | pub unsafefn EVP_camellia_192_cfb128() -> *const EVP_CIPHER; |
410 | #[cfg (not(osslconf = "OPENSSL_NO_CAMELLIA" ))] |
411 | pub unsafefn EVP_camellia_192_ecb() -> *const EVP_CIPHER; |
412 | #[cfg (not(osslconf = "OPENSSL_NO_CAMELLIA" ))] |
413 | pub unsafefn EVP_camellia_192_cbc() -> *const EVP_CIPHER; |
414 | #[cfg (not(osslconf = "OPENSSL_NO_CAMELLIA" ))] |
415 | pub unsafefn EVP_camellia_192_ofb() -> *const EVP_CIPHER; |
416 | #[cfg (not(osslconf = "OPENSSL_NO_CAMELLIA" ))] |
417 | pub unsafefn EVP_camellia_256_cfb128() -> *const EVP_CIPHER; |
418 | #[cfg (not(osslconf = "OPENSSL_NO_CAMELLIA" ))] |
419 | pub unsafefn EVP_camellia_256_ecb() -> *const EVP_CIPHER; |
420 | #[cfg (not(osslconf = "OPENSSL_NO_CAMELLIA" ))] |
421 | pub unsafefn EVP_camellia_256_cbc() -> *const EVP_CIPHER; |
422 | #[cfg (not(osslconf = "OPENSSL_NO_CAMELLIA" ))] |
423 | pub unsafefn EVP_camellia_256_ofb() -> *const EVP_CIPHER; |
424 | |
425 | #[cfg (not(osslconf = "OPENSSL_NO_CAST" ))] |
426 | pub unsafefn EVP_cast5_cfb64() -> *const EVP_CIPHER; |
427 | #[cfg (not(osslconf = "OPENSSL_NO_CAST" ))] |
428 | pub unsafefn EVP_cast5_ecb() -> *const EVP_CIPHER; |
429 | #[cfg (not(osslconf = "OPENSSL_NO_CAST" ))] |
430 | pub unsafefn EVP_cast5_cbc() -> *const EVP_CIPHER; |
431 | #[cfg (not(osslconf = "OPENSSL_NO_CAST" ))] |
432 | pub unsafefn EVP_cast5_ofb() -> *const EVP_CIPHER; |
433 | |
434 | #[cfg (not(osslconf = "OPENSSL_NO_IDEA" ))] |
435 | pub fn EVP_idea_cfb64() -> *const EVP_CIPHER; |
436 | #[cfg (not(osslconf = "OPENSSL_NO_IDEA" ))] |
437 | pub fn EVP_idea_ecb() -> *const EVP_CIPHER; |
438 | #[cfg (not(osslconf = "OPENSSL_NO_IDEA" ))] |
439 | pub fn EVP_idea_cbc() -> *const EVP_CIPHER; |
440 | #[cfg (not(osslconf = "OPENSSL_NO_IDEA" ))] |
441 | pub fn EVP_idea_ofb() -> *const EVP_CIPHER; |
442 | |
443 | #[cfg (not(osslconf = "OPENSSL_NO_RC2" ))] |
444 | pub unsafefn EVP_rc2_cbc() -> *const EVP_CIPHER; |
445 | #[cfg (not(osslconf = "OPENSSL_NO_RC2" ))] |
446 | pub unsafefn EVP_rc2_40_cbc() -> *const EVP_CIPHER; |
447 | |
448 | #[cfg (not(ossl110))] |
449 | pub fn OPENSSL_add_all_algorithms_noconf(); |
450 | |
451 | pub unsafefn EVP_get_digestbyname(name: *const c_char) -> *const EVP_MD; |
452 | pub unsafefn EVP_get_cipherbyname(name: *const c_char) -> *const EVP_CIPHER; |
453 | } |
454 | |
455 | cfg_if! { |
456 | if #[cfg(ossl300)] { |
457 | extern "C" { |
458 | pub fn EVP_PKEY_get_id(pkey: *const EVP_PKEY) -> c_int; |
459 | pub fn EVP_PKEY_get_bits(key: *const EVP_PKEY) -> c_int; |
460 | pub fn EVP_PKEY_get_security_bits(key: *const EVP_PKEY) -> c_int; |
461 | } |
462 | } else { |
463 | extern "C" { |
464 | pub fn EVP_PKEY_id(pkey: *const EVP_PKEY) -> c_int; |
465 | } |
466 | const_ptr_api! { |
467 | extern "C" { |
468 | pub fn EVP_PKEY_bits(key: #[const_ptr_if(any(ossl110, libressl280))] EVP_PKEY) -> c_int; |
469 | #[cfg(any(ossl110, libressl360))] |
470 | pub fn EVP_PKEY_security_bits(pkey: #[const_ptr_if(any(ossl110, libressl280))] EVP_PKEY) -> c_int; |
471 | } |
472 | } |
473 | } |
474 | } |
475 | unsafeextern "C" { |
476 | pub unsafefn EVP_PKEY_assign(pkey: *mut EVP_PKEY, typ: c_int, key: *mut c_void) -> c_int; |
477 | |
478 | pub unsafefn EVP_PKEY_set1_RSA(k: *mut EVP_PKEY, r: *mut RSA) -> c_int; |
479 | pub unsafefn EVP_PKEY_get1_RSA(k: *mut EVP_PKEY) -> *mut RSA; |
480 | pub unsafefn EVP_PKEY_set1_DSA(k: *mut EVP_PKEY, k: *mut DSA) -> c_int; |
481 | pub unsafefn EVP_PKEY_get1_DSA(k: *mut EVP_PKEY) -> *mut DSA; |
482 | pub unsafefn EVP_PKEY_set1_DH(k: *mut EVP_PKEY, k: *mut DH) -> c_int; |
483 | pub unsafefn EVP_PKEY_get1_DH(k: *mut EVP_PKEY) -> *mut DH; |
484 | pub unsafefn EVP_PKEY_set1_EC_KEY(k: *mut EVP_PKEY, k: *mut EC_KEY) -> c_int; |
485 | pub unsafefn EVP_PKEY_get1_EC_KEY(k: *mut EVP_PKEY) -> *mut EC_KEY; |
486 | |
487 | pub unsafefn EVP_PKEY_new() -> *mut EVP_PKEY; |
488 | pub unsafefn EVP_PKEY_free(k: *mut EVP_PKEY); |
489 | #[cfg (any(ossl110, libressl270))] |
490 | pub unsafefn EVP_PKEY_up_ref(pkey: *mut EVP_PKEY) -> c_int; |
491 | |
492 | pub unsafefn d2i_AutoPrivateKey( |
493 | a: *mut *mut EVP_PKEY, |
494 | pp: *mut *const c_uchar, |
495 | length: c_long, |
496 | ) -> *mut EVP_PKEY; |
497 | |
498 | pub unsafefn EVP_PKEY_cmp(a: *const EVP_PKEY, b: *const EVP_PKEY) -> c_int; |
499 | |
500 | pub unsafefn EVP_PKEY_copy_parameters(to: *mut EVP_PKEY, from: *const EVP_PKEY) -> c_int; |
501 | |
502 | pub unsafefn PKCS5_PBKDF2_HMAC_SHA1( |
503 | pass: *const c_char, |
504 | passlen: c_int, |
505 | salt: *const u8, |
506 | saltlen: c_int, |
507 | iter: c_int, |
508 | keylen: c_int, |
509 | out: *mut u8, |
510 | ) -> c_int; |
511 | pub unsafefn PKCS5_PBKDF2_HMAC( |
512 | pass: *const c_char, |
513 | passlen: c_int, |
514 | salt: *const c_uchar, |
515 | saltlen: c_int, |
516 | iter: c_int, |
517 | digest: *const EVP_MD, |
518 | keylen: c_int, |
519 | out: *mut u8, |
520 | ) -> c_int; |
521 | |
522 | #[cfg (ossl110)] |
523 | pub unsafefn EVP_PBE_scrypt( |
524 | pass: *const c_char, |
525 | passlen: size_t, |
526 | salt: *const c_uchar, |
527 | saltlen: size_t, |
528 | N: u64, |
529 | r: u64, |
530 | p: u64, |
531 | maxmem: u64, |
532 | key: *mut c_uchar, |
533 | keylen: size_t, |
534 | ) -> c_int; |
535 | |
536 | pub unsafefn EVP_PKEY_CTX_new(k: *mut EVP_PKEY, e: *mut ENGINE) -> *mut EVP_PKEY_CTX; |
537 | pub unsafefn EVP_PKEY_CTX_new_id(id: c_int, e: *mut ENGINE) -> *mut EVP_PKEY_CTX; |
538 | pub unsafefn EVP_PKEY_CTX_free(ctx: *mut EVP_PKEY_CTX); |
539 | |
540 | pub unsafefn EVP_PKEY_CTX_ctrl( |
541 | ctx: *mut EVP_PKEY_CTX, |
542 | keytype: c_int, |
543 | optype: c_int, |
544 | cmd: c_int, |
545 | p1: c_int, |
546 | p2: *mut c_void, |
547 | ) -> c_int; |
548 | |
549 | #[cfg (ossl300)] |
550 | pub unsafefn EVP_PKEY_CTX_set_signature_md(ctx: *mut EVP_PKEY_CTX, md: *const EVP_MD) -> c_int; |
551 | |
552 | #[cfg (ossl300)] |
553 | pub unsafefn EVP_PKEY_CTX_set_params(ctx: *mut EVP_PKEY_CTX, params: *const OSSL_PARAM) -> c_int; |
554 | |
555 | #[cfg (ossl300)] |
556 | pub unsafefn EVP_PKEY_CTX_get_params(ctx: *mut EVP_PKEY_CTX, params: *mut OSSL_PARAM) -> c_int; |
557 | |
558 | pub unsafefn EVP_PKEY_new_mac_key( |
559 | type_: c_int, |
560 | e: *mut ENGINE, |
561 | key: *const c_uchar, |
562 | keylen: c_int, |
563 | ) -> *mut EVP_PKEY; |
564 | |
565 | pub unsafefn EVP_PKEY_derive_init(ctx: *mut EVP_PKEY_CTX) -> c_int; |
566 | pub unsafefn EVP_PKEY_derive_set_peer(ctx: *mut EVP_PKEY_CTX, peer: *mut EVP_PKEY) -> c_int; |
567 | #[cfg (ossl300)] |
568 | pub unsafefn EVP_PKEY_derive_set_peer_ex( |
569 | ctx: *mut EVP_PKEY_CTX, |
570 | peer: *mut EVP_PKEY, |
571 | validate_peer: c_int, |
572 | ) -> c_int; |
573 | pub unsafefn EVP_PKEY_derive(ctx: *mut EVP_PKEY_CTX, key: *mut c_uchar, size: *mut size_t) -> c_int; |
574 | |
575 | #[cfg (ossl300)] |
576 | pub unsafefn EVP_PKEY_Q_keygen( |
577 | libctx: *mut OSSL_LIB_CTX, |
578 | propq: *const c_char, |
579 | type_: *const c_char, |
580 | ... |
581 | ) -> *mut EVP_PKEY; |
582 | pub unsafefn EVP_PKEY_keygen_init(ctx: *mut EVP_PKEY_CTX) -> c_int; |
583 | pub unsafefn EVP_PKEY_keygen(ctx: *mut EVP_PKEY_CTX, key: *mut *mut EVP_PKEY) -> c_int; |
584 | |
585 | pub unsafefn EVP_PKEY_sign_init(ctx: *mut EVP_PKEY_CTX) -> c_int; |
586 | pub unsafefn EVP_PKEY_sign( |
587 | ctx: *mut EVP_PKEY_CTX, |
588 | sig: *mut c_uchar, |
589 | siglen: *mut size_t, |
590 | tbs: *const c_uchar, |
591 | tbslen: size_t, |
592 | ) -> c_int; |
593 | pub unsafefn EVP_PKEY_verify_init(ctx: *mut EVP_PKEY_CTX) -> c_int; |
594 | pub unsafefn EVP_PKEY_verify( |
595 | ctx: *mut EVP_PKEY_CTX, |
596 | sig: *const c_uchar, |
597 | siglen: size_t, |
598 | tbs: *const c_uchar, |
599 | tbslen: size_t, |
600 | ) -> c_int; |
601 | pub unsafefn EVP_PKEY_encrypt_init(ctx: *mut EVP_PKEY_CTX) -> c_int; |
602 | pub unsafefn EVP_PKEY_encrypt( |
603 | ctx: *mut EVP_PKEY_CTX, |
604 | pout: *mut c_uchar, |
605 | poutlen: *mut size_t, |
606 | pin: *const c_uchar, |
607 | pinlen: size_t, |
608 | ) -> c_int; |
609 | pub unsafefn EVP_PKEY_decrypt_init(ctx: *mut EVP_PKEY_CTX) -> c_int; |
610 | pub unsafefn EVP_PKEY_decrypt( |
611 | ctx: *mut EVP_PKEY_CTX, |
612 | pout: *mut c_uchar, |
613 | poutlen: *mut size_t, |
614 | pin: *const c_uchar, |
615 | pinlen: size_t, |
616 | ) -> c_int; |
617 | pub unsafefn EVP_PKEY_verify_recover_init(ctx: *mut EVP_PKEY_CTX) -> c_int; |
618 | pub unsafefn EVP_PKEY_verify_recover( |
619 | ctx: *mut EVP_PKEY_CTX, |
620 | rout: *mut c_uchar, |
621 | routlen: *mut size_t, |
622 | sig: *const c_uchar, |
623 | siglen: size_t, |
624 | ) -> c_int; |
625 | } |
626 | |
627 | const_ptr_api! { |
628 | extern "C" { |
629 | pub fn EVP_PKCS82PKEY(p8: #[const_ptr_if(any(ossl110, libressl280))] PKCS8_PRIV_KEY_INFO) -> *mut EVP_PKEY; |
630 | } |
631 | } |
632 | |
633 | cfg_if! { |
634 | if #[cfg(any(ossl111, libressl370))] { |
635 | extern "C" { |
636 | pub fn EVP_PKEY_get_raw_public_key( |
637 | pkey: *const EVP_PKEY, |
638 | ppub: *mut c_uchar, |
639 | len: *mut size_t, |
640 | ) -> c_int; |
641 | pub fn EVP_PKEY_new_raw_public_key( |
642 | ttype: c_int, |
643 | e: *mut ENGINE, |
644 | key: *const c_uchar, |
645 | keylen: size_t, |
646 | ) -> *mut EVP_PKEY; |
647 | pub fn EVP_PKEY_get_raw_private_key( |
648 | pkey: *const EVP_PKEY, |
649 | ppriv: *mut c_uchar, |
650 | len: *mut size_t, |
651 | ) -> c_int; |
652 | pub fn EVP_PKEY_new_raw_private_key( |
653 | ttype: c_int, |
654 | e: *mut ENGINE, |
655 | key: *const c_uchar, |
656 | keylen: size_t, |
657 | ) -> *mut EVP_PKEY; |
658 | } |
659 | } |
660 | } |
661 | |
662 | unsafeextern "C" { |
663 | pub unsafefn EVP_EncodeBlock(dst: *mut c_uchar, src: *const c_uchar, src_len: c_int) -> c_int; |
664 | pub unsafefn EVP_DecodeBlock(dst: *mut c_uchar, src: *const c_uchar, src_len: c_int) -> c_int; |
665 | } |
666 | |