1use crate::ffi_types::*;
2
3use crate::pubkey::{botan_privkey_t, botan_pubkey_t};
4use crate::rng::botan_rng_t;
5
6pub enum botan_pk_op_encrypt_struct {}
7pub type botan_pk_op_encrypt_t = *mut botan_pk_op_encrypt_struct;
8
9pub enum botan_pk_op_decrypt_struct {}
10pub type botan_pk_op_decrypt_t = *mut botan_pk_op_decrypt_struct;
11
12pub enum botan_pk_op_sign_struct {}
13pub type botan_pk_op_sign_t = *mut botan_pk_op_sign_struct;
14
15pub enum botan_pk_op_verify_struct {}
16pub type botan_pk_op_verify_t = *mut botan_pk_op_verify_struct;
17
18pub enum botan_pk_op_ka_struct {}
19pub type botan_pk_op_ka_t = *mut botan_pk_op_ka_struct;
20
21pub enum botan_pk_op_kem_encrypt_struct {}
22pub type botan_pk_op_kem_encrypt_t = *mut botan_pk_op_kem_encrypt_struct;
23
24pub enum botan_pk_op_kem_decrypt_struct {}
25pub type botan_pk_op_kem_decrypt_t = *mut botan_pk_op_kem_decrypt_struct;
26
27extern "C" {
28 pub fn botan_pk_op_encrypt_create(
29 op: *mut botan_pk_op_encrypt_t,
30 key: botan_pubkey_t,
31 padding: *const c_char,
32 flags: u32,
33 ) -> c_int;
34 pub fn botan_pk_op_encrypt_destroy(op: botan_pk_op_encrypt_t) -> c_int;
35
36 pub fn botan_pk_op_encrypt_output_length(
37 op: botan_pk_op_encrypt_t,
38 inlen: usize,
39 outlen: *mut usize,
40 ) -> c_int;
41
42 pub fn botan_pk_op_encrypt(
43 op: botan_pk_op_encrypt_t,
44 rng: botan_rng_t,
45 out: *mut u8,
46 out_len: *mut usize,
47 plaintext: *const u8,
48 plaintext_len: usize,
49 ) -> c_int;
50
51 pub fn botan_pk_op_decrypt_create(
52 op: *mut botan_pk_op_decrypt_t,
53 key: botan_privkey_t,
54 padding: *const c_char,
55 flags: u32,
56 ) -> c_int;
57 pub fn botan_pk_op_decrypt_output_length(
58 op: botan_pk_op_decrypt_t,
59 inlen: usize,
60 outlen: *mut usize,
61 ) -> c_int;
62 pub fn botan_pk_op_decrypt_destroy(op: botan_pk_op_decrypt_t) -> c_int;
63 pub fn botan_pk_op_decrypt(
64 op: botan_pk_op_decrypt_t,
65 out: *mut u8,
66 out_len: *mut usize,
67 ciphertext: *const u8,
68 ciphertext_len: usize,
69 ) -> c_int;
70
71 pub fn botan_pk_op_sign_create(
72 op: *mut botan_pk_op_sign_t,
73 key: botan_privkey_t,
74 hash_and_padding: *const c_char,
75 flags: u32,
76 ) -> c_int;
77 pub fn botan_pk_op_sign_output_length(op: botan_pk_op_sign_t, siglen: *mut usize) -> c_int;
78 pub fn botan_pk_op_sign_destroy(op: botan_pk_op_sign_t) -> c_int;
79 pub fn botan_pk_op_sign_update(op: botan_pk_op_sign_t, in_: *const u8, in_len: usize) -> c_int;
80 pub fn botan_pk_op_sign_finish(
81 op: botan_pk_op_sign_t,
82 rng: botan_rng_t,
83 sig: *mut u8,
84 sig_len: *mut usize,
85 ) -> c_int;
86
87 pub fn botan_pk_op_verify_create(
88 op: *mut botan_pk_op_verify_t,
89 key: botan_pubkey_t,
90 hash_and_padding: *const c_char,
91 flags: u32,
92 ) -> c_int;
93 pub fn botan_pk_op_verify_destroy(op: botan_pk_op_verify_t) -> c_int;
94 pub fn botan_pk_op_verify_update(
95 op: botan_pk_op_verify_t,
96 in_: *const u8,
97 in_len: usize,
98 ) -> c_int;
99 pub fn botan_pk_op_verify_finish(
100 op: botan_pk_op_verify_t,
101 sig: *const u8,
102 sig_len: usize,
103 ) -> c_int;
104
105 pub fn botan_pk_op_key_agreement_create(
106 op: *mut botan_pk_op_ka_t,
107 key: botan_privkey_t,
108 kdf: *const c_char,
109 flags: u32,
110 ) -> c_int;
111 pub fn botan_pk_op_key_agreement_destroy(op: botan_pk_op_ka_t) -> c_int;
112 pub fn botan_pk_op_key_agreement_size(op: botan_pk_op_ka_t, agreed_len: *mut usize) -> c_int;
113 pub fn botan_pk_op_key_agreement_export_public(
114 key: botan_privkey_t,
115 out: *mut u8,
116 out_len: *mut usize,
117 ) -> c_int;
118
119 pub fn botan_pk_op_key_agreement(
120 op: botan_pk_op_ka_t,
121 out: *mut u8,
122 out_len: *mut usize,
123 other_key: *const u8,
124 other_key_len: usize,
125 salt: *const u8,
126 salt_len: usize,
127 ) -> c_int;
128 pub fn botan_pkcs_hash_id(
129 hash_name: *const c_char,
130 pkcs_id: *mut u8,
131 pkcs_id_len: *mut usize,
132 ) -> c_int;
133
134 #[cfg(botan_ffi_20230403)]
135 pub fn botan_pk_op_key_agreement_view_public(
136 key: botan_privkey_t,
137 view_ctx: botan_view_ctx,
138 view_fn: botan_view_bin_fn,
139 ) -> c_int;
140
141 #[cfg(botan_ffi_20230403)]
142 pub fn botan_pk_op_kem_encrypt_create(
143 op: *mut botan_pk_op_kem_encrypt_t,
144 key: botan_pubkey_t,
145 kdf: *const c_char,
146 ) -> c_int;
147
148 #[cfg(botan_ffi_20230403)]
149 pub fn botan_pk_op_kem_encrypt_destroy(op: botan_pk_op_kem_encrypt_t) -> c_int;
150
151 #[cfg(botan_ffi_20230403)]
152 pub fn botan_pk_op_kem_encrypt_shared_key_length(
153 op: botan_pk_op_kem_encrypt_t,
154 desired_shared_key_length: usize,
155 output_shared_key_length: *mut usize,
156 ) -> c_int;
157
158 #[cfg(botan_ffi_20230403)]
159 pub fn botan_pk_op_kem_encrypt_encapsulated_key_length(
160 op: botan_pk_op_kem_encrypt_t,
161 output_encapsulated_key_length: *mut usize,
162 ) -> c_int;
163
164 #[cfg(botan_ffi_20230403)]
165 pub fn botan_pk_op_kem_encrypt_create_shared_key(
166 op: botan_pk_op_kem_encrypt_t,
167 rng: botan_rng_t,
168 salt: *const u8,
169 salt_len: usize,
170 desired_shared_key_len: usize,
171 shared_key: *mut u8,
172 shared_key_len: *mut usize,
173 encapsulated_key: *mut u8,
174 encapsulated_key_len: *mut usize,
175 ) -> c_int;
176
177 #[cfg(botan_ffi_20230403)]
178 pub fn botan_pk_op_kem_decrypt_destroy(op: botan_pk_op_kem_decrypt_t) -> c_int;
179
180 #[cfg(botan_ffi_20230403)]
181 pub fn botan_pk_op_kem_decrypt_create(
182 op: *mut botan_pk_op_kem_decrypt_t,
183 key: botan_privkey_t,
184 kdf: *const c_char,
185 ) -> c_int;
186
187 #[cfg(botan_ffi_20230403)]
188 pub fn botan_pk_op_kem_decrypt_shared_key_length(
189 op: botan_pk_op_kem_decrypt_t,
190 desired_shared_key_length: usize,
191 output_shared_key_length: *mut usize,
192 ) -> c_int;
193
194 #[cfg(botan_ffi_20230403)]
195 pub fn botan_pk_op_kem_decrypt_shared_key(
196 op: botan_pk_op_kem_decrypt_t,
197 salt: *const u8,
198 salt_len: usize,
199 encapsulated_key: *const u8,
200 encapsulated_key_len: usize,
201 desired_shared_key_len: usize,
202 shared_key: *mut u8,
203 shared_key_len: *mut usize,
204 ) -> c_int;
205}