1 use libc::*;
2 use *;
3 
4 pub const EVP_MAX_MD_SIZE: c_uint = 64;
5 
6 pub const PKCS5_SALT_LEN: c_int = 8;
7 pub const PKCS12_DEFAULT_ITER: c_int = 2048;
8 
9 pub const EVP_PKEY_RSA: c_int = NID_rsaEncryption;
10 pub const EVP_PKEY_DSA: c_int = NID_dsa;
11 pub const EVP_PKEY_DH: c_int = NID_dhKeyAgreement;
12 pub const EVP_PKEY_EC: c_int = NID_X9_62_id_ecPublicKey;
13 #[cfg(ossl111)]
14 pub const EVP_PKEY_X25519: c_int = NID_X25519;
15 #[cfg(ossl111)]
16 pub const EVP_PKEY_ED25519: c_int = NID_ED25519;
17 #[cfg(ossl111)]
18 pub const EVP_PKEY_X448: c_int = NID_X448;
19 #[cfg(ossl111)]
20 pub const EVP_PKEY_ED448: c_int = NID_ED448;
21 pub const EVP_PKEY_HMAC: c_int = NID_hmac;
22 pub const EVP_PKEY_CMAC: c_int = NID_cmac;
23 
24 pub const EVP_CTRL_GCM_SET_IVLEN: c_int = 0x9;
25 pub const EVP_CTRL_GCM_GET_TAG: c_int = 0x10;
26 pub const EVP_CTRL_GCM_SET_TAG: c_int = 0x11;
27 
EVP_get_digestbynid(type_: c_int) -> *const EVP_MD28 pub unsafe fn EVP_get_digestbynid(type_: c_int) -> *const EVP_MD {
29     EVP_get_digestbyname(OBJ_nid2sn(type_))
30 }
31 
32 cfg_if! {
33     if #[cfg(ossl300)] {
34         extern "C" {
35             pub fn EVP_MD_get_size(md: *const EVP_MD) -> c_int;
36             pub fn EVP_MD_get_type(md: *const EVP_MD) -> c_int;
37 
38             pub fn EVP_CIPHER_get_key_length(cipher: *const EVP_CIPHER) -> c_int;
39             pub fn EVP_CIPHER_get_block_size(cipher: *const EVP_CIPHER) -> c_int;
40             pub fn EVP_CIPHER_get_iv_length(cipher: *const EVP_CIPHER) -> c_int;
41             pub fn EVP_CIPHER_get_nid(cipher: *const EVP_CIPHER) -> c_int;
42         }
43 
44         #[inline]
45         pub unsafe fn EVP_MD_size(md: *const EVP_MD) -> c_int {
46             EVP_MD_get_size(md)
47         }
48 
49         #[inline]
50         pub unsafe fn EVP_MD_type(md: *const EVP_MD) -> c_int {
51             EVP_MD_get_type(md)
52         }
53 
54         #[inline]
55         pub unsafe fn EVP_CIPHER_key_length(cipher: *const EVP_CIPHER) -> c_int {
56             EVP_CIPHER_get_key_length(cipher)
57         }
58 
59         #[inline]
60         pub unsafe fn EVP_CIPHER_block_size(cipher: *const EVP_CIPHER) -> c_int {
61             EVP_CIPHER_get_block_size(cipher)
62         }
63 
64         #[inline]
65         pub unsafe fn EVP_CIPHER_iv_length(cipher: *const EVP_CIPHER) -> c_int {
66             EVP_CIPHER_get_iv_length(cipher)
67         }
68 
69         #[inline]
70         pub unsafe fn EVP_CIPHER_nid(cipher: *const EVP_CIPHER) -> c_int {
71             EVP_CIPHER_get_nid(cipher)
72         }
73     } else {
74         extern "C" {
75             pub fn EVP_MD_size(md: *const EVP_MD) -> c_int;
76             pub fn EVP_MD_type(md: *const EVP_MD) -> c_int;
77 
78             pub fn EVP_CIPHER_key_length(cipher: *const EVP_CIPHER) -> c_int;
79             pub fn EVP_CIPHER_block_size(cipher: *const EVP_CIPHER) -> c_int;
80             pub fn EVP_CIPHER_iv_length(cipher: *const EVP_CIPHER) -> c_int;
81             pub fn EVP_CIPHER_nid(cipher: *const EVP_CIPHER) -> c_int;
82         }
83     }
84 }
85 extern "C" {}
86 
87 cfg_if! {
88     if #[cfg(ossl110)] {
89         extern "C" {
90             pub fn EVP_MD_CTX_new() -> *mut EVP_MD_CTX;
91             pub fn EVP_MD_CTX_free(ctx: *mut EVP_MD_CTX);
92         }
93     } else {
94         extern "C" {
95             pub fn EVP_MD_CTX_create() -> *mut EVP_MD_CTX;
96             pub fn EVP_MD_CTX_destroy(ctx: *mut EVP_MD_CTX);
97         }
98     }
99 }
100 
101 extern "C" {
EVP_DigestInit_ex(ctx: *mut EVP_MD_CTX, typ: *const EVP_MD, imple: *mut ENGINE) -> c_int102     pub fn EVP_DigestInit_ex(ctx: *mut EVP_MD_CTX, typ: *const EVP_MD, imple: *mut ENGINE)
103         -> c_int;
EVP_DigestUpdate(ctx: *mut EVP_MD_CTX, data: *const c_void, n: size_t) -> c_int104     pub fn EVP_DigestUpdate(ctx: *mut EVP_MD_CTX, data: *const c_void, n: size_t) -> c_int;
EVP_DigestFinal_ex(ctx: *mut EVP_MD_CTX, res: *mut u8, n: *mut u32) -> c_int105     pub fn EVP_DigestFinal_ex(ctx: *mut EVP_MD_CTX, res: *mut u8, n: *mut u32) -> c_int;
106     #[cfg(ossl300)]
EVP_Q_digest( libctx: *mut OSSL_LIB_CTX, name: *const c_char, propq: *const c_char, data: *const c_void, count: size_t, md: *mut c_uchar, size: *mut c_uint, ) -> c_int107     pub fn EVP_Q_digest(
108         libctx: *mut OSSL_LIB_CTX,
109         name: *const c_char,
110         propq: *const c_char,
111         data: *const c_void,
112         count: size_t,
113         md: *mut c_uchar,
114         size: *mut c_uint,
115     ) -> c_int;
EVP_DigestInit(ctx: *mut EVP_MD_CTX, typ: *const EVP_MD) -> c_int116     pub fn EVP_DigestInit(ctx: *mut EVP_MD_CTX, typ: *const EVP_MD) -> c_int;
EVP_DigestFinal(ctx: *mut EVP_MD_CTX, res: *mut u8, n: *mut u32) -> c_int117     pub fn EVP_DigestFinal(ctx: *mut EVP_MD_CTX, res: *mut u8, n: *mut u32) -> c_int;
118     #[cfg(ossl111)]
EVP_DigestFinalXOF(ctx: *mut EVP_MD_CTX, res: *mut u8, len: usize) -> c_int119     pub fn EVP_DigestFinalXOF(ctx: *mut EVP_MD_CTX, res: *mut u8, len: usize) -> c_int;
120 
EVP_BytesToKey( typ: *const EVP_CIPHER, md: *const EVP_MD, salt: *const u8, data: *const u8, datalen: c_int, count: c_int, key: *mut u8, iv: *mut u8, ) -> c_int121     pub fn EVP_BytesToKey(
122         typ: *const EVP_CIPHER,
123         md: *const EVP_MD,
124         salt: *const u8,
125         data: *const u8,
126         datalen: c_int,
127         count: c_int,
128         key: *mut u8,
129         iv: *mut u8,
130     ) -> c_int;
131 
EVP_CipherInit( ctx: *mut EVP_CIPHER_CTX, evp: *const EVP_CIPHER, key: *const u8, iv: *const u8, mode: c_int, ) -> c_int132     pub fn EVP_CipherInit(
133         ctx: *mut EVP_CIPHER_CTX,
134         evp: *const EVP_CIPHER,
135         key: *const u8,
136         iv: *const u8,
137         mode: c_int,
138     ) -> c_int;
EVP_CipherInit_ex( ctx: *mut EVP_CIPHER_CTX, type_: *const EVP_CIPHER, impl_: *mut ENGINE, key: *const c_uchar, iv: *const c_uchar, enc: c_int, ) -> c_int139     pub fn EVP_CipherInit_ex(
140         ctx: *mut EVP_CIPHER_CTX,
141         type_: *const EVP_CIPHER,
142         impl_: *mut ENGINE,
143         key: *const c_uchar,
144         iv: *const c_uchar,
145         enc: c_int,
146     ) -> c_int;
EVP_CipherUpdate( ctx: *mut EVP_CIPHER_CTX, outbuf: *mut u8, outlen: *mut c_int, inbuf: *const u8, inlen: c_int, ) -> c_int147     pub fn EVP_CipherUpdate(
148         ctx: *mut EVP_CIPHER_CTX,
149         outbuf: *mut u8,
150         outlen: *mut c_int,
151         inbuf: *const u8,
152         inlen: c_int,
153     ) -> c_int;
EVP_CipherFinal(ctx: *mut EVP_CIPHER_CTX, res: *mut u8, len: *mut c_int) -> c_int154     pub fn EVP_CipherFinal(ctx: *mut EVP_CIPHER_CTX, res: *mut u8, len: *mut c_int) -> c_int;
155 
EVP_DigestSignInit( ctx: *mut EVP_MD_CTX, pctx: *mut *mut EVP_PKEY_CTX, type_: *const EVP_MD, e: *mut ENGINE, pkey: *mut EVP_PKEY, ) -> c_int156     pub fn EVP_DigestSignInit(
157         ctx: *mut EVP_MD_CTX,
158         pctx: *mut *mut EVP_PKEY_CTX,
159         type_: *const EVP_MD,
160         e: *mut ENGINE,
161         pkey: *mut EVP_PKEY,
162     ) -> c_int;
EVP_DigestSignFinal( ctx: *mut EVP_MD_CTX, sig: *mut c_uchar, siglen: *mut size_t, ) -> c_int163     pub fn EVP_DigestSignFinal(
164         ctx: *mut EVP_MD_CTX,
165         sig: *mut c_uchar,
166         siglen: *mut size_t,
167     ) -> c_int;
EVP_DigestVerifyInit( ctx: *mut EVP_MD_CTX, pctx: *mut *mut EVP_PKEY_CTX, type_: *const EVP_MD, e: *mut ENGINE, pkey: *mut EVP_PKEY, ) -> c_int168     pub fn EVP_DigestVerifyInit(
169         ctx: *mut EVP_MD_CTX,
170         pctx: *mut *mut EVP_PKEY_CTX,
171         type_: *const EVP_MD,
172         e: *mut ENGINE,
173         pkey: *mut EVP_PKEY,
174     ) -> c_int;
EVP_SealInit( ctx: *mut EVP_CIPHER_CTX, type_: *const EVP_CIPHER, ek: *mut *mut c_uchar, ekl: *mut c_int, iv: *mut c_uchar, pubk: *mut *mut EVP_PKEY, npubk: c_int, ) -> c_int175     pub fn EVP_SealInit(
176         ctx: *mut EVP_CIPHER_CTX,
177         type_: *const EVP_CIPHER,
178         ek: *mut *mut c_uchar,
179         ekl: *mut c_int,
180         iv: *mut c_uchar,
181         pubk: *mut *mut EVP_PKEY,
182         npubk: c_int,
183     ) -> c_int;
EVP_SealFinal(ctx: *mut EVP_CIPHER_CTX, out: *mut c_uchar, outl: *mut c_int) -> c_int184     pub fn EVP_SealFinal(ctx: *mut EVP_CIPHER_CTX, out: *mut c_uchar, outl: *mut c_int) -> c_int;
EVP_EncryptInit_ex( ctx: *mut EVP_CIPHER_CTX, cipher: *const EVP_CIPHER, impl_: *mut ENGINE, key: *const c_uchar, iv: *const c_uchar, ) -> c_int185     pub fn EVP_EncryptInit_ex(
186         ctx: *mut EVP_CIPHER_CTX,
187         cipher: *const EVP_CIPHER,
188         impl_: *mut ENGINE,
189         key: *const c_uchar,
190         iv: *const c_uchar,
191     ) -> c_int;
EVP_EncryptUpdate( ctx: *mut EVP_CIPHER_CTX, out: *mut c_uchar, outl: *mut c_int, in_: *const u8, inl: c_int, ) -> c_int192     pub fn EVP_EncryptUpdate(
193         ctx: *mut EVP_CIPHER_CTX,
194         out: *mut c_uchar,
195         outl: *mut c_int,
196         in_: *const u8,
197         inl: c_int,
198     ) -> c_int;
EVP_EncryptFinal_ex( ctx: *mut EVP_CIPHER_CTX, out: *mut c_uchar, outl: *mut c_int, ) -> c_int199     pub fn EVP_EncryptFinal_ex(
200         ctx: *mut EVP_CIPHER_CTX,
201         out: *mut c_uchar,
202         outl: *mut c_int,
203     ) -> c_int;
EVP_OpenInit( ctx: *mut EVP_CIPHER_CTX, type_: *const EVP_CIPHER, ek: *const c_uchar, ekl: c_int, iv: *const c_uchar, priv_: *mut EVP_PKEY, ) -> c_int204     pub fn EVP_OpenInit(
205         ctx: *mut EVP_CIPHER_CTX,
206         type_: *const EVP_CIPHER,
207         ek: *const c_uchar,
208         ekl: c_int,
209         iv: *const c_uchar,
210         priv_: *mut EVP_PKEY,
211     ) -> c_int;
EVP_OpenFinal(ctx: *mut EVP_CIPHER_CTX, out: *mut c_uchar, outl: *mut c_int) -> c_int212     pub fn EVP_OpenFinal(ctx: *mut EVP_CIPHER_CTX, out: *mut c_uchar, outl: *mut c_int) -> c_int;
EVP_DecryptInit_ex( ctx: *mut EVP_CIPHER_CTX, cipher: *const EVP_CIPHER, impl_: *mut ENGINE, key: *const c_uchar, iv: *const c_uchar, ) -> c_int213     pub fn EVP_DecryptInit_ex(
214         ctx: *mut EVP_CIPHER_CTX,
215         cipher: *const EVP_CIPHER,
216         impl_: *mut ENGINE,
217         key: *const c_uchar,
218         iv: *const c_uchar,
219     ) -> c_int;
EVP_DecryptUpdate( ctx: *mut EVP_CIPHER_CTX, out: *mut c_uchar, outl: *mut c_int, in_: *const u8, inl: c_int, ) -> c_int220     pub fn EVP_DecryptUpdate(
221         ctx: *mut EVP_CIPHER_CTX,
222         out: *mut c_uchar,
223         outl: *mut c_int,
224         in_: *const u8,
225         inl: c_int,
226     ) -> c_int;
EVP_DecryptFinal_ex( ctx: *mut EVP_CIPHER_CTX, outm: *mut c_uchar, outl: *mut c_int, ) -> c_int227     pub fn EVP_DecryptFinal_ex(
228         ctx: *mut EVP_CIPHER_CTX,
229         outm: *mut c_uchar,
230         outl: *mut c_int,
231     ) -> c_int;
232 }
233 cfg_if! {
234     if #[cfg(ossl300)] {
235         extern "C" {
236             pub fn EVP_PKEY_get_size(pkey: *const EVP_PKEY) -> c_int;
237         }
238 
239         #[inline]
240         pub unsafe fn EVP_PKEY_size(pkey: *const EVP_PKEY) -> c_int {
241             EVP_PKEY_get_size(pkey)
242         }
243     } else {
244         const_ptr_api! {
245             extern "C" {
246                 pub fn EVP_PKEY_size(pkey: #[const_ptr_if(any(ossl111b, libressl280))] EVP_PKEY) -> c_int;
247             }
248         }
249     }
250 }
251 cfg_if! {
252     if #[cfg(ossl111)] {
253         extern "C" {
254             pub fn EVP_DigestSign(
255                 ctx: *mut EVP_MD_CTX,
256                 sigret: *mut c_uchar,
257                 siglen: *mut size_t,
258                 tbs: *const c_uchar,
259                 tbslen: size_t
260             ) -> c_int;
261 
262             pub fn EVP_DigestVerify(
263                 ctx: *mut EVP_MD_CTX,
264                 sigret: *const c_uchar,
265                 siglen: size_t,
266                 tbs: *const c_uchar,
267                 tbslen: size_t
268             ) -> c_int;
269         }
270     }
271 }
272 const_ptr_api! {
273     extern "C" {
274         pub fn EVP_DigestVerifyFinal(
275             ctx: *mut EVP_MD_CTX,
276             sigret: #[const_ptr_if(any(ossl102, libressl280))] c_uchar,
277             siglen: size_t,
278         ) -> c_int;
279     }
280 }
281 
282 extern "C" {
EVP_CIPHER_CTX_new() -> *mut EVP_CIPHER_CTX283     pub fn EVP_CIPHER_CTX_new() -> *mut EVP_CIPHER_CTX;
EVP_CIPHER_CTX_free(ctx: *mut EVP_CIPHER_CTX)284     pub fn EVP_CIPHER_CTX_free(ctx: *mut EVP_CIPHER_CTX);
EVP_MD_CTX_copy_ex(dst: *mut EVP_MD_CTX, src: *const EVP_MD_CTX) -> c_int285     pub fn EVP_MD_CTX_copy_ex(dst: *mut EVP_MD_CTX, src: *const EVP_MD_CTX) -> c_int;
EVP_CIPHER_CTX_set_key_length(ctx: *mut EVP_CIPHER_CTX, keylen: c_int) -> c_int286     pub fn EVP_CIPHER_CTX_set_key_length(ctx: *mut EVP_CIPHER_CTX, keylen: c_int) -> c_int;
EVP_CIPHER_CTX_set_padding(ctx: *mut EVP_CIPHER_CTX, padding: c_int) -> c_int287     pub fn EVP_CIPHER_CTX_set_padding(ctx: *mut EVP_CIPHER_CTX, padding: c_int) -> c_int;
EVP_CIPHER_CTX_ctrl( ctx: *mut EVP_CIPHER_CTX, type_: c_int, arg: c_int, ptr: *mut c_void, ) -> c_int288     pub fn EVP_CIPHER_CTX_ctrl(
289         ctx: *mut EVP_CIPHER_CTX,
290         type_: c_int,
291         arg: c_int,
292         ptr: *mut c_void,
293     ) -> c_int;
294 
EVP_md_null() -> *const EVP_MD295     pub fn EVP_md_null() -> *const EVP_MD;
EVP_md5() -> *const EVP_MD296     pub fn EVP_md5() -> *const EVP_MD;
EVP_sha1() -> *const EVP_MD297     pub fn EVP_sha1() -> *const EVP_MD;
EVP_sha224() -> *const EVP_MD298     pub fn EVP_sha224() -> *const EVP_MD;
EVP_sha256() -> *const EVP_MD299     pub fn EVP_sha256() -> *const EVP_MD;
EVP_sha384() -> *const EVP_MD300     pub fn EVP_sha384() -> *const EVP_MD;
EVP_sha512() -> *const EVP_MD301     pub fn EVP_sha512() -> *const EVP_MD;
302     #[cfg(ossl111)]
EVP_sha3_224() -> *const EVP_MD303     pub fn EVP_sha3_224() -> *const EVP_MD;
304     #[cfg(ossl111)]
EVP_sha3_256() -> *const EVP_MD305     pub fn EVP_sha3_256() -> *const EVP_MD;
306     #[cfg(ossl111)]
EVP_sha3_384() -> *const EVP_MD307     pub fn EVP_sha3_384() -> *const EVP_MD;
308     #[cfg(ossl111)]
EVP_sha3_512() -> *const EVP_MD309     pub fn EVP_sha3_512() -> *const EVP_MD;
310     #[cfg(ossl111)]
EVP_shake128() -> *const EVP_MD311     pub fn EVP_shake128() -> *const EVP_MD;
312     #[cfg(ossl111)]
EVP_shake256() -> *const EVP_MD313     pub fn EVP_shake256() -> *const EVP_MD;
EVP_ripemd160() -> *const EVP_MD314     pub fn EVP_ripemd160() -> *const EVP_MD;
315     #[cfg(all(any(ossl111, libressl291), not(osslconf = "OPENSSL_NO_SM3")))]
EVP_sm3() -> *const EVP_MD316     pub fn EVP_sm3() -> *const EVP_MD;
EVP_des_ecb() -> *const EVP_CIPHER317     pub fn EVP_des_ecb() -> *const EVP_CIPHER;
EVP_des_ede3() -> *const EVP_CIPHER318     pub fn EVP_des_ede3() -> *const EVP_CIPHER;
EVP_des_ede3_cbc() -> *const EVP_CIPHER319     pub fn EVP_des_ede3_cbc() -> *const EVP_CIPHER;
EVP_des_ede3_cfb64() -> *const EVP_CIPHER320     pub fn EVP_des_ede3_cfb64() -> *const EVP_CIPHER;
EVP_des_cbc() -> *const EVP_CIPHER321     pub fn EVP_des_cbc() -> *const EVP_CIPHER;
EVP_rc4() -> *const EVP_CIPHER322     pub fn EVP_rc4() -> *const EVP_CIPHER;
EVP_bf_ecb() -> *const EVP_CIPHER323     pub fn EVP_bf_ecb() -> *const EVP_CIPHER;
EVP_bf_cbc() -> *const EVP_CIPHER324     pub fn EVP_bf_cbc() -> *const EVP_CIPHER;
EVP_bf_cfb64() -> *const EVP_CIPHER325     pub fn EVP_bf_cfb64() -> *const EVP_CIPHER;
EVP_bf_ofb() -> *const EVP_CIPHER326     pub fn EVP_bf_ofb() -> *const EVP_CIPHER;
EVP_aes_128_ecb() -> *const EVP_CIPHER327     pub fn EVP_aes_128_ecb() -> *const EVP_CIPHER;
EVP_aes_128_cbc() -> *const EVP_CIPHER328     pub fn EVP_aes_128_cbc() -> *const EVP_CIPHER;
EVP_aes_128_cfb1() -> *const EVP_CIPHER329     pub fn EVP_aes_128_cfb1() -> *const EVP_CIPHER;
EVP_aes_128_cfb8() -> *const EVP_CIPHER330     pub fn EVP_aes_128_cfb8() -> *const EVP_CIPHER;
EVP_aes_128_cfb128() -> *const EVP_CIPHER331     pub fn EVP_aes_128_cfb128() -> *const EVP_CIPHER;
EVP_aes_128_ctr() -> *const EVP_CIPHER332     pub fn EVP_aes_128_ctr() -> *const EVP_CIPHER;
EVP_aes_128_ccm() -> *const EVP_CIPHER333     pub fn EVP_aes_128_ccm() -> *const EVP_CIPHER;
EVP_aes_128_gcm() -> *const EVP_CIPHER334     pub fn EVP_aes_128_gcm() -> *const EVP_CIPHER;
EVP_aes_128_xts() -> *const EVP_CIPHER335     pub fn EVP_aes_128_xts() -> *const EVP_CIPHER;
EVP_aes_128_ofb() -> *const EVP_CIPHER336     pub fn EVP_aes_128_ofb() -> *const EVP_CIPHER;
337     #[cfg(ossl110)]
EVP_aes_128_ocb() -> *const EVP_CIPHER338     pub fn EVP_aes_128_ocb() -> *const EVP_CIPHER;
EVP_aes_192_ecb() -> *const EVP_CIPHER339     pub fn EVP_aes_192_ecb() -> *const EVP_CIPHER;
EVP_aes_192_cbc() -> *const EVP_CIPHER340     pub fn EVP_aes_192_cbc() -> *const EVP_CIPHER;
EVP_aes_192_cfb1() -> *const EVP_CIPHER341     pub fn EVP_aes_192_cfb1() -> *const EVP_CIPHER;
EVP_aes_192_cfb8() -> *const EVP_CIPHER342     pub fn EVP_aes_192_cfb8() -> *const EVP_CIPHER;
EVP_aes_192_cfb128() -> *const EVP_CIPHER343     pub fn EVP_aes_192_cfb128() -> *const EVP_CIPHER;
EVP_aes_192_ctr() -> *const EVP_CIPHER344     pub fn EVP_aes_192_ctr() -> *const EVP_CIPHER;
EVP_aes_192_ccm() -> *const EVP_CIPHER345     pub fn EVP_aes_192_ccm() -> *const EVP_CIPHER;
EVP_aes_192_gcm() -> *const EVP_CIPHER346     pub fn EVP_aes_192_gcm() -> *const EVP_CIPHER;
EVP_aes_192_ofb() -> *const EVP_CIPHER347     pub fn EVP_aes_192_ofb() -> *const EVP_CIPHER;
348     #[cfg(ossl110)]
EVP_aes_192_ocb() -> *const EVP_CIPHER349     pub fn EVP_aes_192_ocb() -> *const EVP_CIPHER;
EVP_aes_256_ecb() -> *const EVP_CIPHER350     pub fn EVP_aes_256_ecb() -> *const EVP_CIPHER;
EVP_aes_256_cbc() -> *const EVP_CIPHER351     pub fn EVP_aes_256_cbc() -> *const EVP_CIPHER;
EVP_aes_256_cfb1() -> *const EVP_CIPHER352     pub fn EVP_aes_256_cfb1() -> *const EVP_CIPHER;
EVP_aes_256_cfb8() -> *const EVP_CIPHER353     pub fn EVP_aes_256_cfb8() -> *const EVP_CIPHER;
EVP_aes_256_cfb128() -> *const EVP_CIPHER354     pub fn EVP_aes_256_cfb128() -> *const EVP_CIPHER;
EVP_aes_256_ctr() -> *const EVP_CIPHER355     pub fn EVP_aes_256_ctr() -> *const EVP_CIPHER;
EVP_aes_256_ccm() -> *const EVP_CIPHER356     pub fn EVP_aes_256_ccm() -> *const EVP_CIPHER;
EVP_aes_256_gcm() -> *const EVP_CIPHER357     pub fn EVP_aes_256_gcm() -> *const EVP_CIPHER;
EVP_aes_256_xts() -> *const EVP_CIPHER358     pub fn EVP_aes_256_xts() -> *const EVP_CIPHER;
EVP_aes_256_ofb() -> *const EVP_CIPHER359     pub fn EVP_aes_256_ofb() -> *const EVP_CIPHER;
360     #[cfg(ossl110)]
EVP_aes_256_ocb() -> *const EVP_CIPHER361     pub fn EVP_aes_256_ocb() -> *const EVP_CIPHER;
362     #[cfg(ossl110)]
EVP_chacha20() -> *const ::EVP_CIPHER363     pub fn EVP_chacha20() -> *const ::EVP_CIPHER;
364     #[cfg(ossl110)]
EVP_chacha20_poly1305() -> *const ::EVP_CIPHER365     pub fn EVP_chacha20_poly1305() -> *const ::EVP_CIPHER;
366 
367     #[cfg(not(ossl110))]
OPENSSL_add_all_algorithms_noconf()368     pub fn OPENSSL_add_all_algorithms_noconf();
369 
EVP_get_digestbyname(name: *const c_char) -> *const EVP_MD370     pub fn EVP_get_digestbyname(name: *const c_char) -> *const EVP_MD;
EVP_get_cipherbyname(name: *const c_char) -> *const EVP_CIPHER371     pub fn EVP_get_cipherbyname(name: *const c_char) -> *const EVP_CIPHER;
372 }
373 
374 cfg_if! {
375     if #[cfg(ossl300)] {
376         extern "C" {
377             pub fn EVP_PKEY_get_id(pkey: *const EVP_PKEY) -> c_int;
378             pub fn EVP_PKEY_get_bits(key: *const EVP_PKEY) -> c_int;
379         }
380 
381         #[inline]
382         pub unsafe fn EVP_PKEY_id(pkey: *const EVP_PKEY) -> c_int {
383             EVP_PKEY_get_id(pkey)
384         }
385 
386         #[inline]
387         pub unsafe fn EVP_PKEY_bits(pkey: *const EVP_PKEY) -> c_int {
388             EVP_PKEY_get_bits(pkey)
389         }
390     } else {
391         extern "C" {
392             pub fn EVP_PKEY_id(pkey: *const EVP_PKEY) -> c_int;
393         }
394         const_ptr_api! {
395             extern "C" {
396                 pub fn EVP_PKEY_bits(key: #[const_ptr_if(any(ossl110, libressl280))] EVP_PKEY) -> c_int;
397             }
398         }
399     }
400 }
401 extern "C" {
EVP_PKEY_assign(pkey: *mut EVP_PKEY, typ: c_int, key: *mut c_void) -> c_int402     pub fn EVP_PKEY_assign(pkey: *mut EVP_PKEY, typ: c_int, key: *mut c_void) -> c_int;
403 
EVP_PKEY_set1_RSA(k: *mut EVP_PKEY, r: *mut RSA) -> c_int404     pub fn EVP_PKEY_set1_RSA(k: *mut EVP_PKEY, r: *mut RSA) -> c_int;
EVP_PKEY_get1_RSA(k: *mut EVP_PKEY) -> *mut RSA405     pub fn EVP_PKEY_get1_RSA(k: *mut EVP_PKEY) -> *mut RSA;
EVP_PKEY_get1_DSA(k: *mut EVP_PKEY) -> *mut DSA406     pub fn EVP_PKEY_get1_DSA(k: *mut EVP_PKEY) -> *mut DSA;
EVP_PKEY_get1_DH(k: *mut EVP_PKEY) -> *mut DH407     pub fn EVP_PKEY_get1_DH(k: *mut EVP_PKEY) -> *mut DH;
EVP_PKEY_get1_EC_KEY(k: *mut EVP_PKEY) -> *mut EC_KEY408     pub fn EVP_PKEY_get1_EC_KEY(k: *mut EVP_PKEY) -> *mut EC_KEY;
409 
EVP_PKEY_new() -> *mut EVP_PKEY410     pub fn EVP_PKEY_new() -> *mut EVP_PKEY;
EVP_PKEY_free(k: *mut EVP_PKEY)411     pub fn EVP_PKEY_free(k: *mut EVP_PKEY);
412     #[cfg(any(ossl110, libressl270))]
EVP_PKEY_up_ref(pkey: *mut EVP_PKEY) -> c_int413     pub fn EVP_PKEY_up_ref(pkey: *mut EVP_PKEY) -> c_int;
414 
d2i_AutoPrivateKey( a: *mut *mut EVP_PKEY, pp: *mut *const c_uchar, length: c_long, ) -> *mut EVP_PKEY415     pub fn d2i_AutoPrivateKey(
416         a: *mut *mut EVP_PKEY,
417         pp: *mut *const c_uchar,
418         length: c_long,
419     ) -> *mut EVP_PKEY;
420 
EVP_PKEY_cmp(a: *const EVP_PKEY, b: *const EVP_PKEY) -> c_int421     pub fn EVP_PKEY_cmp(a: *const EVP_PKEY, b: *const EVP_PKEY) -> c_int;
422 
EVP_PKEY_copy_parameters(to: *mut EVP_PKEY, from: *const EVP_PKEY) -> c_int423     pub fn EVP_PKEY_copy_parameters(to: *mut EVP_PKEY, from: *const EVP_PKEY) -> c_int;
424 
PKCS5_PBKDF2_HMAC_SHA1( pass: *const c_char, passlen: c_int, salt: *const u8, saltlen: c_int, iter: c_int, keylen: c_int, out: *mut u8, ) -> c_int425     pub fn PKCS5_PBKDF2_HMAC_SHA1(
426         pass: *const c_char,
427         passlen: c_int,
428         salt: *const u8,
429         saltlen: c_int,
430         iter: c_int,
431         keylen: c_int,
432         out: *mut u8,
433     ) -> c_int;
PKCS5_PBKDF2_HMAC( pass: *const c_char, passlen: c_int, salt: *const c_uchar, saltlen: c_int, iter: c_int, digest: *const EVP_MD, keylen: c_int, out: *mut u8, ) -> c_int434     pub fn PKCS5_PBKDF2_HMAC(
435         pass: *const c_char,
436         passlen: c_int,
437         salt: *const c_uchar,
438         saltlen: c_int,
439         iter: c_int,
440         digest: *const EVP_MD,
441         keylen: c_int,
442         out: *mut u8,
443     ) -> c_int;
444 
445     #[cfg(ossl110)]
EVP_PBE_scrypt( pass: *const c_char, passlen: size_t, salt: *const c_uchar, saltlen: size_t, N: u64, r: u64, p: u64, maxmem: u64, key: *mut c_uchar, keylen: size_t, ) -> c_int446     pub fn EVP_PBE_scrypt(
447         pass: *const c_char,
448         passlen: size_t,
449         salt: *const c_uchar,
450         saltlen: size_t,
451         N: u64,
452         r: u64,
453         p: u64,
454         maxmem: u64,
455         key: *mut c_uchar,
456         keylen: size_t,
457     ) -> c_int;
458 }
459 
460 pub const EVP_PKEY_OP_KEYGEN: c_int = 1 << 2;
461 cfg_if! {
462     if #[cfg(ossl300)] {
463         pub const EVP_PKEY_OP_SIGN: c_int = 1 << 4;
464         pub const EVP_PKEY_OP_VERIFY: c_int = 1 << 5;
465         pub const EVP_PKEY_OP_VERIFYRECOVER: c_int = 1 << 6;
466         pub const EVP_PKEY_OP_SIGNCTX: c_int = 1 << 7;
467         pub const EVP_PKEY_OP_VERIFYCTX: c_int = 1 << 8;
468         pub const EVP_PKEY_OP_ENCRYPT: c_int = 1 << 9;
469         pub const EVP_PKEY_OP_DECRYPT: c_int = 1 << 10;
470     } else {
471         pub const EVP_PKEY_OP_SIGN: c_int = 1 << 3;
472         pub const EVP_PKEY_OP_VERIFY: c_int = 1 << 4;
473         pub const EVP_PKEY_OP_VERIFYRECOVER: c_int = 1 << 5;
474         pub const EVP_PKEY_OP_SIGNCTX: c_int = 1 << 6;
475         pub const EVP_PKEY_OP_VERIFYCTX: c_int = 1 << 7;
476         pub const EVP_PKEY_OP_ENCRYPT: c_int = 1 << 8;
477         pub const EVP_PKEY_OP_DECRYPT: c_int = 1 << 9;
478     }
479 }
480 
481 pub const EVP_PKEY_OP_TYPE_SIG: c_int = EVP_PKEY_OP_SIGN
482     | EVP_PKEY_OP_VERIFY
483     | EVP_PKEY_OP_VERIFYRECOVER
484     | EVP_PKEY_OP_SIGNCTX
485     | EVP_PKEY_OP_VERIFYCTX;
486 
487 pub const EVP_PKEY_OP_TYPE_CRYPT: c_int = EVP_PKEY_OP_ENCRYPT | EVP_PKEY_OP_DECRYPT;
488 
489 pub const EVP_PKEY_CTRL_SET_MAC_KEY: c_int = 6;
490 
491 pub const EVP_PKEY_CTRL_CIPHER: c_int = 12;
492 
493 pub const EVP_PKEY_ALG_CTRL: c_int = 0x1000;
494 
495 extern "C" {
EVP_PKEY_CTX_new(k: *mut EVP_PKEY, e: *mut ENGINE) -> *mut EVP_PKEY_CTX496     pub fn EVP_PKEY_CTX_new(k: *mut EVP_PKEY, e: *mut ENGINE) -> *mut EVP_PKEY_CTX;
EVP_PKEY_CTX_new_id(id: c_int, e: *mut ENGINE) -> *mut EVP_PKEY_CTX497     pub fn EVP_PKEY_CTX_new_id(id: c_int, e: *mut ENGINE) -> *mut EVP_PKEY_CTX;
EVP_PKEY_CTX_free(ctx: *mut EVP_PKEY_CTX)498     pub fn EVP_PKEY_CTX_free(ctx: *mut EVP_PKEY_CTX);
499 
EVP_PKEY_CTX_ctrl( ctx: *mut EVP_PKEY_CTX, keytype: c_int, optype: c_int, cmd: c_int, p1: c_int, p2: *mut c_void, ) -> c_int500     pub fn EVP_PKEY_CTX_ctrl(
501         ctx: *mut EVP_PKEY_CTX,
502         keytype: c_int,
503         optype: c_int,
504         cmd: c_int,
505         p1: c_int,
506         p2: *mut c_void,
507     ) -> c_int;
508 
EVP_PKEY_new_mac_key( type_: c_int, e: *mut ENGINE, key: *const c_uchar, keylen: c_int, ) -> *mut EVP_PKEY509     pub fn EVP_PKEY_new_mac_key(
510         type_: c_int,
511         e: *mut ENGINE,
512         key: *const c_uchar,
513         keylen: c_int,
514     ) -> *mut EVP_PKEY;
515 
EVP_PKEY_derive_init(ctx: *mut EVP_PKEY_CTX) -> c_int516     pub fn EVP_PKEY_derive_init(ctx: *mut EVP_PKEY_CTX) -> c_int;
EVP_PKEY_derive_set_peer(ctx: *mut EVP_PKEY_CTX, peer: *mut EVP_PKEY) -> c_int517     pub fn EVP_PKEY_derive_set_peer(ctx: *mut EVP_PKEY_CTX, peer: *mut EVP_PKEY) -> c_int;
EVP_PKEY_derive(ctx: *mut EVP_PKEY_CTX, key: *mut c_uchar, size: *mut size_t) -> c_int518     pub fn EVP_PKEY_derive(ctx: *mut EVP_PKEY_CTX, key: *mut c_uchar, size: *mut size_t) -> c_int;
519 
EVP_PKEY_keygen_init(ctx: *mut EVP_PKEY_CTX) -> c_int520     pub fn EVP_PKEY_keygen_init(ctx: *mut EVP_PKEY_CTX) -> c_int;
EVP_PKEY_keygen(ctx: *mut EVP_PKEY_CTX, key: *mut *mut EVP_PKEY) -> c_int521     pub fn EVP_PKEY_keygen(ctx: *mut EVP_PKEY_CTX, key: *mut *mut EVP_PKEY) -> c_int;
522 
EVP_PKEY_encrypt_init(ctx: *mut EVP_PKEY_CTX) -> c_int523     pub fn EVP_PKEY_encrypt_init(ctx: *mut EVP_PKEY_CTX) -> c_int;
EVP_PKEY_encrypt( ctx: *mut EVP_PKEY_CTX, pout: *mut c_uchar, poutlen: *mut size_t, pin: *const c_uchar, pinlen: size_t, ) -> c_int524     pub fn EVP_PKEY_encrypt(
525         ctx: *mut EVP_PKEY_CTX,
526         pout: *mut c_uchar,
527         poutlen: *mut size_t,
528         pin: *const c_uchar,
529         pinlen: size_t,
530     ) -> c_int;
EVP_PKEY_decrypt_init(ctx: *mut EVP_PKEY_CTX) -> c_int531     pub fn EVP_PKEY_decrypt_init(ctx: *mut EVP_PKEY_CTX) -> c_int;
EVP_PKEY_decrypt( ctx: *mut EVP_PKEY_CTX, pout: *mut c_uchar, poutlen: *mut size_t, pin: *const c_uchar, pinlen: size_t, ) -> c_int532     pub fn EVP_PKEY_decrypt(
533         ctx: *mut EVP_PKEY_CTX,
534         pout: *mut c_uchar,
535         poutlen: *mut size_t,
536         pin: *const c_uchar,
537         pinlen: size_t,
538     ) -> c_int;
539 }
540 
541 const_ptr_api! {
542     extern "C" {
543         pub fn EVP_PKCS82PKEY(p8: #[const_ptr_if(any(ossl110, libressl280))] PKCS8_PRIV_KEY_INFO) -> *mut EVP_PKEY;
544     }
545 }
546 
547 cfg_if! {
548     if #[cfg(any(ossl111))] {
549         extern "C" {
550             pub fn EVP_PKEY_get_raw_public_key(
551                 pkey: *const EVP_PKEY,
552                 ppub: *mut c_uchar,
553                 len: *mut size_t,
554             ) -> c_int;
555             pub fn EVP_PKEY_new_raw_public_key(
556                 ttype: c_int,
557                 e: *mut ENGINE,
558                 key: *const c_uchar,
559                 keylen: size_t,
560             ) -> *mut EVP_PKEY;
561             pub fn EVP_PKEY_get_raw_private_key(
562                 pkey: *const EVP_PKEY,
563                 ppriv: *mut c_uchar,
564                 len: *mut size_t,
565             ) -> c_int;
566             pub fn EVP_PKEY_new_raw_private_key(
567                 ttype: c_int,
568                 e: *mut ENGINE,
569                 key: *const c_uchar,
570                 keylen: size_t,
571             ) -> *mut EVP_PKEY;
572         }
573     }
574 }
575 
576 extern "C" {
EVP_EncodeBlock(dst: *mut c_uchar, src: *const c_uchar, src_len: c_int) -> c_int577     pub fn EVP_EncodeBlock(dst: *mut c_uchar, src: *const c_uchar, src_len: c_int) -> c_int;
EVP_DecodeBlock(dst: *mut c_uchar, src: *const c_uchar, src_len: c_int) -> c_int578     pub fn EVP_DecodeBlock(dst: *mut c_uchar, src: *const c_uchar, src_len: c_int) -> c_int;
579 }
580