1 use libc::*;
2
3 use *;
4
5 pub const BIO_TYPE_NONE: c_int = 0;
6
7 pub const BIO_CTRL_EOF: c_int = 2;
8 pub const BIO_CTRL_INFO: c_int = 3;
9 pub const BIO_CTRL_FLUSH: c_int = 11;
10 pub const BIO_C_SET_BUF_MEM_EOF_RETURN: c_int = 130;
11
12 extern "C" {
13 pub fn BIO_set_flags(b: *mut BIO, flags: c_int);
14 pub fn BIO_clear_flags(b: *mut BIO, flags: c_int);
15 }
16
AES_set_encrypt_key(userKey: *const c_uchar, bits: c_int, key: *mut AES_KEY) -> c_int17 pub unsafe fn BIO_set_retry_read(b: *mut BIO) {
18 BIO_set_flags(b, BIO_FLAGS_READ | BIO_FLAGS_SHOULD_RETRY)
19 }
AES_ige_encrypt( in_: *const c_uchar, out: *mut c_uchar, length: size_t, key: *const AES_KEY, ivec: *mut c_uchar, enc: c_int, )20
21 pub unsafe fn BIO_set_retry_write(b: *mut BIO) {
22 BIO_set_flags(b, BIO_FLAGS_WRITE | BIO_FLAGS_SHOULD_RETRY)
23 }
24
25 pub unsafe fn BIO_clear_retry_flags(b: *mut BIO) {
26 BIO_clear_flags(b, BIO_FLAGS_RWS | BIO_FLAGS_SHOULD_RETRY)
27 }
28
AES_wrap_key( key: *mut AES_KEY, iv: *const c_uchar, out: *mut c_uchar, in_: *const c_uchar, inlen: c_uint, ) -> c_int29 pub const BIO_FLAGS_READ: c_int = 0x01;
30 pub const BIO_FLAGS_WRITE: c_int = 0x02;
31 pub const BIO_FLAGS_IO_SPECIAL: c_int = 0x04;
32 pub const BIO_FLAGS_RWS: c_int = BIO_FLAGS_READ | BIO_FLAGS_WRITE | BIO_FLAGS_IO_SPECIAL;
33 pub const BIO_FLAGS_SHOULD_RETRY: c_int = 0x08;
34
35 pub type bio_info_cb =
36 Option<unsafe extern "C" fn(*mut BIO, c_int, *const c_char, c_int, c_long, c_long)>;
AES_unwrap_key( key: *mut AES_KEY, iv: *const c_uchar, out: *mut c_uchar, in_: *const c_uchar, inlen: c_uint, ) -> c_int37
38 cfg_if! {
39 if #[cfg(any(ossl110, libressl280))] {
40 pub enum BIO_METHOD {}
41 } else {
42 #[repr(C)]
43 pub struct BIO_METHOD {
44 pub type_: c_int,
45 pub name: *const c_char,
46 pub bwrite: Option<unsafe extern "C" fn(*mut ::BIO, *const c_char, c_int) -> c_int>,
47 pub bread: Option<unsafe extern "C" fn(*mut ::BIO, *mut c_char, c_int) -> c_int>,
48 pub bputs: Option<unsafe extern "C" fn(*mut ::BIO, *const c_char) -> c_int>,
49 pub bgets: Option<unsafe extern "C" fn(*mut ::BIO, *mut c_char, c_int) -> c_int>,
50 pub ctrl: Option<unsafe extern "C" fn(*mut ::BIO, c_int, c_long, *mut c_void) -> c_long>,
51 pub create: Option<unsafe extern "C" fn(*mut ::BIO) -> c_int>,
52 pub destroy: Option<unsafe extern "C" fn(*mut ::BIO) -> c_int>,
53 pub callback_ctrl: Option<unsafe extern "C" fn(*mut ::BIO, c_int, ::bio_info_cb) -> c_long>,
54 }
55 }
56 }
57
58 pub unsafe fn BIO_get_mem_data(b: *mut BIO, pp: *mut *mut c_char) -> c_long {
59 BIO_ctrl(b, BIO_CTRL_INFO, 0, pp as *mut c_void)
60 }
61
62 cfg_if! {
63 if #[cfg(any(ossl110, libressl280))] {
64 extern "C" {
65 pub fn BIO_s_file() -> *const BIO_METHOD;
66 pub fn BIO_new(type_: *const BIO_METHOD) -> *mut BIO;
67 }
68 } else {
69 extern "C" {
70 pub fn BIO_s_file() -> *mut BIO_METHOD;
71 pub fn BIO_new(type_: *mut BIO_METHOD) -> *mut BIO;
72 }
73 }
74 }
75 extern "C" {
76 #[cfg(not(osslconf = "OPENSSL_NO_STDIO"))]
77 pub fn BIO_new_fp(stream: *mut FILE, close_flag: c_int) -> *mut BIO;
78 #[cfg(any(ossl110, libressl273))]
79 pub fn BIO_set_data(a: *mut ::BIO, data: *mut c_void);
80 #[cfg(any(ossl110, libressl273))]
81 pub fn BIO_get_data(a: *mut ::BIO) -> *mut c_void;
82 #[cfg(any(ossl110, libressl273))]
83 pub fn BIO_set_init(a: *mut ::BIO, init: c_int);
84 pub fn BIO_write(b: *mut BIO, buf: *const c_void, len: c_int) -> c_int;
85 pub fn BIO_read(b: *mut BIO, buf: *mut c_void, len: c_int) -> c_int;
86 pub fn BIO_ctrl(b: *mut BIO, cmd: c_int, larg: c_long, parg: *mut c_void) -> c_long;
87 pub fn BIO_free_all(b: *mut BIO);
88 }
89
90 cfg_if! {
91 if #[cfg(any(ossl110, libressl280))] {
92 extern "C" {
93 pub fn BIO_s_mem() -> *const BIO_METHOD;
94 }
95 } else {
96 extern "C" {
97 pub fn BIO_s_mem() -> *mut BIO_METHOD;
98 }
99 }
100 }
101 cfg_if! {
102 if #[cfg(any(ossl102, libressl280))] {
103 extern "C" {
104 pub fn BIO_new_mem_buf(buf: *const c_void, len: c_int) -> *mut BIO;
105 }
106 } else {
107 extern "C" {
108 pub fn BIO_new_mem_buf(buf: *mut c_void, len: c_int) -> *mut BIO;
109 }
110 }
111 }
112
113 extern "C" {
114 pub fn BIO_new_socket(sock: c_int, close_flag: c_int) -> *mut BIO;
115
116 #[cfg(any(ossl110, libressl273))]
117 pub fn BIO_meth_new(type_: c_int, name: *const c_char) -> *mut BIO_METHOD;
118 #[cfg(any(ossl110, libressl273))]
119 pub fn BIO_meth_free(biom: *mut BIO_METHOD);
120 // FIXME should wrap in Option
121 #[cfg(any(ossl110, libressl273))]
122 pub fn BIO_meth_set_write(
123 biom: *mut BIO_METHOD,
124 write: unsafe extern "C" fn(*mut BIO, *const c_char, c_int) -> c_int,
125 ) -> c_int;
126 #[cfg(any(ossl110, libressl273))]
127 pub fn BIO_meth_set_read(
128 biom: *mut BIO_METHOD,
129 read: unsafe extern "C" fn(*mut BIO, *mut c_char, c_int) -> c_int,
130 ) -> c_int;
131 #[cfg(any(ossl110, libressl273))]
132 pub fn BIO_meth_set_puts(
133 biom: *mut BIO_METHOD,
134 read: unsafe extern "C" fn(*mut BIO, *const c_char) -> c_int,
135 ) -> c_int;
136 #[cfg(any(ossl110, libressl273))]
137 pub fn BIO_meth_set_ctrl(
138 biom: *mut BIO_METHOD,
139 read: unsafe extern "C" fn(*mut BIO, c_int, c_long, *mut c_void) -> c_long,
140 ) -> c_int;
141 #[cfg(any(ossl110, libressl273))]
142 pub fn BIO_meth_set_create(
143 biom: *mut BIO_METHOD,
144 create: unsafe extern "C" fn(*mut BIO) -> c_int,
145 ) -> c_int;
146 #[cfg(any(ossl110, libressl273))]
147 pub fn BIO_meth_set_destroy(
148 biom: *mut BIO_METHOD,
149 destroy: unsafe extern "C" fn(*mut BIO) -> c_int,
150 ) -> c_int;
151 }
152