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 extern "C" {
EVP_MD_size(md: *const EVP_MD) -> c_int33     pub fn EVP_MD_size(md: *const EVP_MD) -> c_int;
EVP_MD_type(md: *const EVP_MD) -> c_int34     pub fn EVP_MD_type(md: *const EVP_MD) -> c_int;
35 
EVP_CIPHER_key_length(cipher: *const EVP_CIPHER) -> c_int36     pub fn EVP_CIPHER_key_length(cipher: *const EVP_CIPHER) -> c_int;
EVP_CIPHER_block_size(cipher: *const EVP_CIPHER) -> c_int37     pub fn EVP_CIPHER_block_size(cipher: *const EVP_CIPHER) -> c_int;
EVP_CIPHER_iv_length(cipher: *const EVP_CIPHER) -> c_int38     pub fn EVP_CIPHER_iv_length(cipher: *const EVP_CIPHER) -> c_int;
39 }
40 
41 cfg_if! {
42     if #[cfg(ossl110)] {
43         extern "C" {
44             pub fn EVP_MD_CTX_new() -> *mut EVP_MD_CTX;
45             pub fn EVP_MD_CTX_free(ctx: *mut EVP_MD_CTX);
46         }
47     } else {
48         extern "C" {
49             pub fn EVP_MD_CTX_create() -> *mut EVP_MD_CTX;
50             pub fn EVP_MD_CTX_destroy(ctx: *mut EVP_MD_CTX);
51         }
52     }
53 }
54 
55 extern "C" {
EVP_DigestInit_ex(ctx: *mut EVP_MD_CTX, typ: *const EVP_MD, imple: *mut ENGINE) -> c_int56     pub fn EVP_DigestInit_ex(ctx: *mut EVP_MD_CTX, typ: *const EVP_MD, imple: *mut ENGINE)
57         -> c_int;
EVP_DigestUpdate(ctx: *mut EVP_MD_CTX, data: *const c_void, n: size_t) -> c_int58     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_int59     pub fn EVP_DigestFinal_ex(ctx: *mut EVP_MD_CTX, res: *mut u8, n: *mut u32) -> c_int;
EVP_DigestInit(ctx: *mut EVP_MD_CTX, typ: *const EVP_MD) -> c_int60     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_int61     pub fn EVP_DigestFinal(ctx: *mut EVP_MD_CTX, res: *mut u8, n: *mut u32) -> c_int;
62     #[cfg(ossl111)]
EVP_DigestFinalXOF(ctx: *mut EVP_MD_CTX, res: *mut u8, len: usize) -> c_int63     pub fn EVP_DigestFinalXOF(ctx: *mut EVP_MD_CTX, res: *mut u8, len: usize) -> c_int;
64 
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_int65     pub fn EVP_BytesToKey(
66         typ: *const EVP_CIPHER,
67         md: *const EVP_MD,
68         salt: *const u8,
69         data: *const u8,
70         datalen: c_int,
71         count: c_int,
72         key: *mut u8,
73         iv: *mut u8,
74     ) -> c_int;
75 
EVP_CipherInit( ctx: *mut EVP_CIPHER_CTX, evp: *const EVP_CIPHER, key: *const u8, iv: *const u8, mode: c_int, ) -> c_int76     pub fn EVP_CipherInit(
77         ctx: *mut EVP_CIPHER_CTX,
78         evp: *const EVP_CIPHER,
79         key: *const u8,
80         iv: *const u8,
81         mode: c_int,
82     ) -> 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_int83     pub fn EVP_CipherInit_ex(
84         ctx: *mut EVP_CIPHER_CTX,
85         type_: *const EVP_CIPHER,
86         impl_: *mut ENGINE,
87         key: *const c_uchar,
88         iv: *const c_uchar,
89         enc: c_int,
90     ) -> c_int;
EVP_CipherUpdate( ctx: *mut EVP_CIPHER_CTX, outbuf: *mut u8, outlen: *mut c_int, inbuf: *const u8, inlen: c_int, ) -> c_int91     pub fn EVP_CipherUpdate(
92         ctx: *mut EVP_CIPHER_CTX,
93         outbuf: *mut u8,
94         outlen: *mut c_int,
95         inbuf: *const u8,
96         inlen: c_int,
97     ) -> c_int;
EVP_CipherFinal(ctx: *mut EVP_CIPHER_CTX, res: *mut u8, len: *mut c_int) -> c_int98     pub fn EVP_CipherFinal(ctx: *mut EVP_CIPHER_CTX, res: *mut u8, len: *mut c_int) -> c_int;
99 
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_int100     pub fn EVP_DigestSignInit(
101         ctx: *mut EVP_MD_CTX,
102         pctx: *mut *mut EVP_PKEY_CTX,
103         type_: *const EVP_MD,
104         e: *mut ENGINE,
105         pkey: *mut EVP_PKEY,
106     ) -> c_int;
EVP_DigestSignFinal( ctx: *mut EVP_MD_CTX, sig: *mut c_uchar, siglen: *mut size_t, ) -> c_int107     pub fn EVP_DigestSignFinal(
108         ctx: *mut EVP_MD_CTX,
109         sig: *mut c_uchar,
110         siglen: *mut size_t,
111     ) -> 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_int112     pub fn EVP_DigestVerifyInit(
113         ctx: *mut EVP_MD_CTX,
114         pctx: *mut *mut EVP_PKEY_CTX,
115         type_: *const EVP_MD,
116         e: *mut ENGINE,
117         pkey: *mut EVP_PKEY,
118     ) -> 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_int119     pub fn EVP_SealInit(
120         ctx: *mut EVP_CIPHER_CTX,
121         type_: *const EVP_CIPHER,
122         ek: *mut *mut c_uchar,
123         ekl: *mut c_int,
124         iv: *mut c_uchar,
125         pubk: *mut *mut EVP_PKEY,
126         npubk: c_int,
127     ) -> c_int;
EVP_SealFinal(ctx: *mut EVP_CIPHER_CTX, out: *mut c_uchar, outl: *mut c_int) -> c_int128     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_int129     pub fn EVP_EncryptInit_ex(
130         ctx: *mut EVP_CIPHER_CTX,
131         cipher: *const EVP_CIPHER,
132         impl_: *mut ENGINE,
133         key: *const c_uchar,
134         iv: *const c_uchar,
135     ) -> c_int;
EVP_EncryptUpdate( ctx: *mut EVP_CIPHER_CTX, out: *mut c_uchar, outl: *mut c_int, in_: *const u8, inl: c_int, ) -> c_int136     pub fn EVP_EncryptUpdate(
137         ctx: *mut EVP_CIPHER_CTX,
138         out: *mut c_uchar,
139         outl: *mut c_int,
140         in_: *const u8,
141         inl: c_int,
142     ) -> c_int;
EVP_EncryptFinal_ex( ctx: *mut EVP_CIPHER_CTX, out: *mut c_uchar, outl: *mut c_int, ) -> c_int143     pub fn EVP_EncryptFinal_ex(
144         ctx: *mut EVP_CIPHER_CTX,
145         out: *mut c_uchar,
146         outl: *mut c_int,
147     ) -> 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_int148     pub fn EVP_OpenInit(
149         ctx: *mut EVP_CIPHER_CTX,
150         type_: *const EVP_CIPHER,
151         ek: *const c_uchar,
152         ekl: c_int,
153         iv: *const c_uchar,
154         priv_: *mut EVP_PKEY,
155     ) -> c_int;
EVP_OpenFinal(ctx: *mut EVP_CIPHER_CTX, out: *mut c_uchar, outl: *mut c_int) -> c_int156     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_int157     pub fn EVP_DecryptInit_ex(
158         ctx: *mut EVP_CIPHER_CTX,
159         cipher: *const EVP_CIPHER,
160         impl_: *mut ENGINE,
161         key: *const c_uchar,
162         iv: *const c_uchar,
163     ) -> c_int;
EVP_DecryptUpdate( ctx: *mut EVP_CIPHER_CTX, out: *mut c_uchar, outl: *mut c_int, in_: *const u8, inl: c_int, ) -> c_int164     pub fn EVP_DecryptUpdate(
165         ctx: *mut EVP_CIPHER_CTX,
166         out: *mut c_uchar,
167         outl: *mut c_int,
168         in_: *const u8,
169         inl: c_int,
170     ) -> c_int;
EVP_DecryptFinal_ex( ctx: *mut EVP_CIPHER_CTX, outm: *mut c_uchar, outl: *mut c_int, ) -> c_int171     pub fn EVP_DecryptFinal_ex(
172         ctx: *mut EVP_CIPHER_CTX,
173         outm: *mut c_uchar,
174         outl: *mut c_int,
175     ) -> c_int;
176 }
177 const_ptr_api! {
178     extern "C" {
179         pub fn EVP_PKEY_size(pkey: #[const_ptr_if(any(ossl111b, libressl280))] EVP_PKEY) -> c_int;
180     }
181 }
182 cfg_if! {
183     if #[cfg(ossl111)] {
184         extern "C" {
185             pub fn EVP_DigestSign(
186                 ctx: *mut EVP_MD_CTX,
187                 sigret: *mut c_uchar,
188                 siglen: *mut size_t,
189                 tbs: *const c_uchar,
190                 tbslen: size_t
191             ) -> c_int;
192 
193             pub fn EVP_DigestVerify(
194                 ctx: *mut EVP_MD_CTX,
195                 sigret: *const c_uchar,
196                 siglen: size_t,
197                 tbs: *const c_uchar,
198                 tbslen: size_t
199             ) -> c_int;
200         }
201     }
202 }
203 const_ptr_api! {
204     extern "C" {
205         pub fn EVP_DigestVerifyFinal(
206             ctx: *mut EVP_MD_CTX,
207             sigret: #[const_ptr_if(any(ossl102, libressl280))] c_uchar,
208             siglen: size_t,
209         ) -> c_int;
210     }
211 }
212 
213 extern "C" {
EVP_CIPHER_CTX_new() -> *mut EVP_CIPHER_CTX214     pub fn EVP_CIPHER_CTX_new() -> *mut EVP_CIPHER_CTX;
EVP_CIPHER_CTX_free(ctx: *mut EVP_CIPHER_CTX)215     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_int216     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_int217     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_int218     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_int219     pub fn EVP_CIPHER_CTX_ctrl(
220         ctx: *mut EVP_CIPHER_CTX,
221         type_: c_int,
222         arg: c_int,
223         ptr: *mut c_void,
224     ) -> c_int;
225 
EVP_md_null() -> *const EVP_MD226     pub fn EVP_md_null() -> *const EVP_MD;
EVP_md5() -> *const EVP_MD227     pub fn EVP_md5() -> *const EVP_MD;
EVP_sha1() -> *const EVP_MD228     pub fn EVP_sha1() -> *const EVP_MD;
EVP_sha224() -> *const EVP_MD229     pub fn EVP_sha224() -> *const EVP_MD;
EVP_sha256() -> *const EVP_MD230     pub fn EVP_sha256() -> *const EVP_MD;
EVP_sha384() -> *const EVP_MD231     pub fn EVP_sha384() -> *const EVP_MD;
EVP_sha512() -> *const EVP_MD232     pub fn EVP_sha512() -> *const EVP_MD;
233     #[cfg(ossl111)]
EVP_sha3_224() -> *const EVP_MD234     pub fn EVP_sha3_224() -> *const EVP_MD;
235     #[cfg(ossl111)]
EVP_sha3_256() -> *const EVP_MD236     pub fn EVP_sha3_256() -> *const EVP_MD;
237     #[cfg(ossl111)]
EVP_sha3_384() -> *const EVP_MD238     pub fn EVP_sha3_384() -> *const EVP_MD;
239     #[cfg(ossl111)]
EVP_sha3_512() -> *const EVP_MD240     pub fn EVP_sha3_512() -> *const EVP_MD;
241     #[cfg(ossl111)]
EVP_shake128() -> *const EVP_MD242     pub fn EVP_shake128() -> *const EVP_MD;
243     #[cfg(ossl111)]
EVP_shake256() -> *const EVP_MD244     pub fn EVP_shake256() -> *const EVP_MD;
EVP_ripemd160() -> *const EVP_MD245     pub fn EVP_ripemd160() -> *const EVP_MD;
EVP_des_ecb() -> *const EVP_CIPHER246     pub fn EVP_des_ecb() -> *const EVP_CIPHER;
EVP_des_ede3() -> *const EVP_CIPHER247     pub fn EVP_des_ede3() -> *const EVP_CIPHER;
EVP_des_ede3_cbc() -> *const EVP_CIPHER248     pub fn EVP_des_ede3_cbc() -> *const EVP_CIPHER;
EVP_des_ede3_cfb64() -> *const EVP_CIPHER249     pub fn EVP_des_ede3_cfb64() -> *const EVP_CIPHER;
EVP_des_cbc() -> *const EVP_CIPHER250     pub fn EVP_des_cbc() -> *const EVP_CIPHER;
EVP_rc4() -> *const EVP_CIPHER251     pub fn EVP_rc4() -> *const EVP_CIPHER;
EVP_bf_ecb() -> *const EVP_CIPHER252     pub fn EVP_bf_ecb() -> *const EVP_CIPHER;
EVP_bf_cbc() -> *const EVP_CIPHER253     pub fn EVP_bf_cbc() -> *const EVP_CIPHER;
EVP_bf_cfb64() -> *const EVP_CIPHER254     pub fn EVP_bf_cfb64() -> *const EVP_CIPHER;
EVP_bf_ofb() -> *const EVP_CIPHER255     pub fn EVP_bf_ofb() -> *const EVP_CIPHER;
EVP_aes_128_ecb() -> *const EVP_CIPHER256     pub fn EVP_aes_128_ecb() -> *const EVP_CIPHER;
EVP_aes_128_cbc() -> *const EVP_CIPHER257     pub fn EVP_aes_128_cbc() -> *const EVP_CIPHER;
EVP_aes_128_cfb1() -> *const EVP_CIPHER258     pub fn EVP_aes_128_cfb1() -> *const EVP_CIPHER;
EVP_aes_128_cfb8() -> *const EVP_CIPHER259     pub fn EVP_aes_128_cfb8() -> *const EVP_CIPHER;
EVP_aes_128_cfb128() -> *const EVP_CIPHER260     pub fn EVP_aes_128_cfb128() -> *const EVP_CIPHER;
EVP_aes_128_ctr() -> *const EVP_CIPHER261     pub fn EVP_aes_128_ctr() -> *const EVP_CIPHER;
EVP_aes_128_ccm() -> *const EVP_CIPHER262     pub fn EVP_aes_128_ccm() -> *const EVP_CIPHER;
EVP_aes_128_gcm() -> *const EVP_CIPHER263     pub fn EVP_aes_128_gcm() -> *const EVP_CIPHER;
EVP_aes_128_xts() -> *const EVP_CIPHER264     pub fn EVP_aes_128_xts() -> *const EVP_CIPHER;
EVP_aes_128_ofb() -> *const EVP_CIPHER265     pub fn EVP_aes_128_ofb() -> *const EVP_CIPHER;
266     #[cfg(ossl110)]
EVP_aes_128_ocb() -> *const EVP_CIPHER267     pub fn EVP_aes_128_ocb() -> *const EVP_CIPHER;
EVP_aes_192_ecb() -> *const EVP_CIPHER268     pub fn EVP_aes_192_ecb() -> *const EVP_CIPHER;
EVP_aes_192_cbc() -> *const EVP_CIPHER269     pub fn EVP_aes_192_cbc() -> *const EVP_CIPHER;
EVP_aes_192_cfb1() -> *const EVP_CIPHER270     pub fn EVP_aes_192_cfb1() -> *const EVP_CIPHER;
EVP_aes_192_cfb8() -> *const EVP_CIPHER271     pub fn EVP_aes_192_cfb8() -> *const EVP_CIPHER;
EVP_aes_192_cfb128() -> *const EVP_CIPHER272     pub fn EVP_aes_192_cfb128() -> *const EVP_CIPHER;
EVP_aes_192_ctr() -> *const EVP_CIPHER273     pub fn EVP_aes_192_ctr() -> *const EVP_CIPHER;
EVP_aes_192_ccm() -> *const EVP_CIPHER274     pub fn EVP_aes_192_ccm() -> *const EVP_CIPHER;
EVP_aes_192_gcm() -> *const EVP_CIPHER275     pub fn EVP_aes_192_gcm() -> *const EVP_CIPHER;
EVP_aes_192_ofb() -> *const EVP_CIPHER276     pub fn EVP_aes_192_ofb() -> *const EVP_CIPHER;
277     #[cfg(ossl110)]
EVP_aes_192_ocb() -> *const EVP_CIPHER278     pub fn EVP_aes_192_ocb() -> *const EVP_CIPHER;
EVP_aes_256_ecb() -> *const EVP_CIPHER279     pub fn EVP_aes_256_ecb() -> *const EVP_CIPHER;
EVP_aes_256_cbc() -> *const EVP_CIPHER280     pub fn EVP_aes_256_cbc() -> *const EVP_CIPHER;
EVP_aes_256_cfb1() -> *const EVP_CIPHER281     pub fn EVP_aes_256_cfb1() -> *const EVP_CIPHER;
EVP_aes_256_cfb8() -> *const EVP_CIPHER282     pub fn EVP_aes_256_cfb8() -> *const EVP_CIPHER;
EVP_aes_256_cfb128() -> *const EVP_CIPHER283     pub fn EVP_aes_256_cfb128() -> *const EVP_CIPHER;
EVP_aes_256_ctr() -> *const EVP_CIPHER284     pub fn EVP_aes_256_ctr() -> *const EVP_CIPHER;
EVP_aes_256_ccm() -> *const EVP_CIPHER285     pub fn EVP_aes_256_ccm() -> *const EVP_CIPHER;
EVP_aes_256_gcm() -> *const EVP_CIPHER286     pub fn EVP_aes_256_gcm() -> *const EVP_CIPHER;
EVP_aes_256_xts() -> *const EVP_CIPHER287     pub fn EVP_aes_256_xts() -> *const EVP_CIPHER;
EVP_aes_256_ofb() -> *const EVP_CIPHER288     pub fn EVP_aes_256_ofb() -> *const EVP_CIPHER;
289     #[cfg(ossl110)]
EVP_aes_256_ocb() -> *const EVP_CIPHER290     pub fn EVP_aes_256_ocb() -> *const EVP_CIPHER;
291     #[cfg(ossl110)]
EVP_chacha20() -> *const ::EVP_CIPHER292     pub fn EVP_chacha20() -> *const ::EVP_CIPHER;
293     #[cfg(ossl110)]
EVP_chacha20_poly1305() -> *const ::EVP_CIPHER294     pub fn EVP_chacha20_poly1305() -> *const ::EVP_CIPHER;
295 
296     #[cfg(not(ossl110))]
OPENSSL_add_all_algorithms_noconf()297     pub fn OPENSSL_add_all_algorithms_noconf();
298 
EVP_get_digestbyname(name: *const c_char) -> *const EVP_MD299     pub fn EVP_get_digestbyname(name: *const c_char) -> *const EVP_MD;
EVP_get_cipherbyname(name: *const c_char) -> *const EVP_CIPHER300     pub fn EVP_get_cipherbyname(name: *const c_char) -> *const EVP_CIPHER;
301 
EVP_PKEY_id(pkey: *const EVP_PKEY) -> c_int302     pub fn EVP_PKEY_id(pkey: *const EVP_PKEY) -> c_int;
303 }
304 const_ptr_api! {
305     extern "C" {
306         pub fn EVP_PKEY_bits(key: #[const_ptr_if(any(ossl110, libressl280))] EVP_PKEY) -> c_int;
307     }
308 }
309 extern "C" {
EVP_PKEY_assign(pkey: *mut EVP_PKEY, typ: c_int, key: *mut c_void) -> c_int310     pub fn EVP_PKEY_assign(pkey: *mut EVP_PKEY, typ: c_int, key: *mut c_void) -> c_int;
311 
EVP_PKEY_set1_RSA(k: *mut EVP_PKEY, r: *mut RSA) -> c_int312     pub fn EVP_PKEY_set1_RSA(k: *mut EVP_PKEY, r: *mut RSA) -> c_int;
EVP_PKEY_get1_RSA(k: *mut EVP_PKEY) -> *mut RSA313     pub fn EVP_PKEY_get1_RSA(k: *mut EVP_PKEY) -> *mut RSA;
EVP_PKEY_get1_DSA(k: *mut EVP_PKEY) -> *mut DSA314     pub fn EVP_PKEY_get1_DSA(k: *mut EVP_PKEY) -> *mut DSA;
EVP_PKEY_get1_DH(k: *mut EVP_PKEY) -> *mut DH315     pub fn EVP_PKEY_get1_DH(k: *mut EVP_PKEY) -> *mut DH;
EVP_PKEY_get1_EC_KEY(k: *mut EVP_PKEY) -> *mut EC_KEY316     pub fn EVP_PKEY_get1_EC_KEY(k: *mut EVP_PKEY) -> *mut EC_KEY;
317 
EVP_PKEY_new() -> *mut EVP_PKEY318     pub fn EVP_PKEY_new() -> *mut EVP_PKEY;
EVP_PKEY_free(k: *mut EVP_PKEY)319     pub fn EVP_PKEY_free(k: *mut EVP_PKEY);
320     #[cfg(any(ossl110, libressl270))]
EVP_PKEY_up_ref(pkey: *mut EVP_PKEY) -> c_int321     pub fn EVP_PKEY_up_ref(pkey: *mut EVP_PKEY) -> c_int;
322 
d2i_AutoPrivateKey( a: *mut *mut EVP_PKEY, pp: *mut *const c_uchar, length: c_long, ) -> *mut EVP_PKEY323     pub fn d2i_AutoPrivateKey(
324         a: *mut *mut EVP_PKEY,
325         pp: *mut *const c_uchar,
326         length: c_long,
327     ) -> *mut EVP_PKEY;
328 
EVP_PKEY_cmp(a: *const EVP_PKEY, b: *const EVP_PKEY) -> c_int329     pub fn EVP_PKEY_cmp(a: *const EVP_PKEY, b: *const EVP_PKEY) -> c_int;
330 
EVP_PKEY_copy_parameters(to: *mut EVP_PKEY, from: *const EVP_PKEY) -> c_int331     pub fn EVP_PKEY_copy_parameters(to: *mut EVP_PKEY, from: *const EVP_PKEY) -> c_int;
332 
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_int333     pub fn PKCS5_PBKDF2_HMAC_SHA1(
334         pass: *const c_char,
335         passlen: c_int,
336         salt: *const u8,
337         saltlen: c_int,
338         iter: c_int,
339         keylen: c_int,
340         out: *mut u8,
341     ) -> 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_int342     pub fn PKCS5_PBKDF2_HMAC(
343         pass: *const c_char,
344         passlen: c_int,
345         salt: *const c_uchar,
346         saltlen: c_int,
347         iter: c_int,
348         digest: *const EVP_MD,
349         keylen: c_int,
350         out: *mut u8,
351     ) -> c_int;
352 
353     #[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_int354     pub fn EVP_PBE_scrypt(
355         pass: *const c_char,
356         passlen: size_t,
357         salt: *const c_uchar,
358         saltlen: size_t,
359         N: u64,
360         r: u64,
361         p: u64,
362         maxmem: u64,
363         key: *mut c_uchar,
364         keylen: size_t,
365     ) -> c_int;
366 }
367 
368 pub const EVP_PKEY_OP_KEYGEN: c_int = 1 << 2;
369 pub const EVP_PKEY_OP_SIGN: c_int = 1 << 3;
370 pub const EVP_PKEY_OP_VERIFY: c_int = 1 << 4;
371 pub const EVP_PKEY_OP_VERIFYRECOVER: c_int = 1 << 5;
372 pub const EVP_PKEY_OP_SIGNCTX: c_int = 1 << 6;
373 pub const EVP_PKEY_OP_VERIFYCTX: c_int = 1 << 7;
374 pub const EVP_PKEY_OP_ENCRYPT: c_int = 1 << 8;
375 pub const EVP_PKEY_OP_DECRYPT: c_int = 1 << 9;
376 
377 pub const EVP_PKEY_OP_TYPE_SIG: c_int = EVP_PKEY_OP_SIGN
378     | EVP_PKEY_OP_VERIFY
379     | EVP_PKEY_OP_VERIFYRECOVER
380     | EVP_PKEY_OP_SIGNCTX
381     | EVP_PKEY_OP_VERIFYCTX;
382 
383 pub const EVP_PKEY_OP_TYPE_CRYPT: c_int = EVP_PKEY_OP_ENCRYPT | EVP_PKEY_OP_DECRYPT;
384 
385 pub const EVP_PKEY_CTRL_SET_MAC_KEY: c_int = 6;
386 
387 pub const EVP_PKEY_CTRL_CIPHER: c_int = 12;
388 
389 pub const EVP_PKEY_ALG_CTRL: c_int = 0x1000;
390 
391 extern "C" {
EVP_PKEY_CTX_new(k: *mut EVP_PKEY, e: *mut ENGINE) -> *mut EVP_PKEY_CTX392     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_CTX393     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)394     pub fn EVP_PKEY_CTX_free(ctx: *mut EVP_PKEY_CTX);
395 
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_int396     pub fn EVP_PKEY_CTX_ctrl(
397         ctx: *mut EVP_PKEY_CTX,
398         keytype: c_int,
399         optype: c_int,
400         cmd: c_int,
401         p1: c_int,
402         p2: *mut c_void,
403     ) -> c_int;
404 
EVP_PKEY_new_mac_key( type_: c_int, e: *mut ENGINE, key: *const c_uchar, keylen: c_int, ) -> *mut EVP_PKEY405     pub fn EVP_PKEY_new_mac_key(
406         type_: c_int,
407         e: *mut ENGINE,
408         key: *const c_uchar,
409         keylen: c_int,
410     ) -> *mut EVP_PKEY;
411 
EVP_PKEY_derive_init(ctx: *mut EVP_PKEY_CTX) -> c_int412     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_int413     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_int414     pub fn EVP_PKEY_derive(ctx: *mut EVP_PKEY_CTX, key: *mut c_uchar, size: *mut size_t) -> c_int;
415 
EVP_PKEY_keygen_init(ctx: *mut EVP_PKEY_CTX) -> c_int416     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_int417     pub fn EVP_PKEY_keygen(ctx: *mut EVP_PKEY_CTX, key: *mut *mut EVP_PKEY) -> c_int;
418 
EVP_PKEY_encrypt_init(ctx: *mut EVP_PKEY_CTX) -> c_int419     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_int420     pub fn EVP_PKEY_encrypt(
421         ctx: *mut EVP_PKEY_CTX,
422         pout: *mut c_uchar,
423         poutlen: *mut size_t,
424         pin: *const c_uchar,
425         pinlen: size_t,
426     ) -> c_int;
EVP_PKEY_decrypt_init(ctx: *mut EVP_PKEY_CTX) -> c_int427     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_int428     pub fn EVP_PKEY_decrypt(
429         ctx: *mut EVP_PKEY_CTX,
430         pout: *mut c_uchar,
431         poutlen: *mut size_t,
432         pin: *const c_uchar,
433         pinlen: size_t,
434     ) -> c_int;
435 }
436 
437 const_ptr_api! {
438     extern "C" {
439         pub fn EVP_PKCS82PKEY(p8: #[const_ptr_if(any(ossl110, libressl280))] PKCS8_PRIV_KEY_INFO) -> *mut EVP_PKEY;
440     }
441 }
442 
443 cfg_if! {
444     if #[cfg(any(ossl111))] {
445         extern "C" {
446             pub fn EVP_PKEY_get_raw_public_key(
447                 pkey: *const EVP_PKEY,
448                 ppub: *mut c_uchar,
449                 len: *mut size_t,
450             ) -> c_int;
451             pub fn EVP_PKEY_new_raw_public_key(
452                 ttype: c_int,
453                 e: *mut ENGINE,
454                 key: *const c_uchar,
455                 keylen: size_t,
456             ) -> *mut EVP_PKEY;
457             pub fn EVP_PKEY_get_raw_private_key(
458                 pkey: *const EVP_PKEY,
459                 ppriv: *mut c_uchar,
460                 len: *mut size_t,
461             ) -> c_int;
462             pub fn EVP_PKEY_new_raw_private_key(
463                 ttype: c_int,
464                 e: *mut ENGINE,
465                 key: *const c_uchar,
466                 keylen: size_t,
467             ) -> *mut EVP_PKEY;
468         }
469     }
470 }
471 
472 extern "C" {
EVP_EncodeBlock(dst: *mut c_uchar, src: *const c_uchar, src_len: c_int) -> c_int473     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_int474     pub fn EVP_DecodeBlock(dst: *mut c_uchar, src: *const c_uchar, src_len: c_int) -> c_int;
475 }
476