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
135#[cfg(feature = "botan3")]
136extern "C" {
137 pub fn botan_pk_op_key_agreement_view_public(
138 key: botan_privkey_t,
139 view_ctx: botan_view_ctx,
140 view_fn: botan_view_bin_fn,
141 ) -> c_int;
142
143 pub fn botan_pk_op_kem_encrypt_create(
144 op: *mut botan_pk_op_kem_encrypt_t,
145 key: botan_pubkey_t,
146 kdf: *const c_char,
147 ) -> c_int;
148
149 pub fn botan_pk_op_kem_encrypt_destroy(op: botan_pk_op_kem_encrypt_t) -> c_int;
150
151 pub fn botan_pk_op_kem_encrypt_shared_key_length(
152 op: botan_pk_op_kem_encrypt_t,
153 desired_shared_key_length: usize,
154 output_shared_key_length: *mut usize,
155 ) -> c_int;
156
157 pub fn botan_pk_op_kem_encrypt_encapsulated_key_length(
158 op: botan_pk_op_kem_encrypt_t,
159 output_encapsulated_key_length: *mut usize,
160 ) -> c_int;
161
162 pub fn botan_pk_op_kem_encrypt_create_shared_key(
163 op: botan_pk_op_kem_encrypt_t,
164 rng: botan_rng_t,
165 salt: *const u8,
166 salt_len: usize,
167 desired_shared_key_len: usize,
168 shared_key: *mut u8,
169 shared_key_len: *mut usize,
170 encapsulated_key: *mut u8,
171 encapsulated_key_len: *mut usize,
172 ) -> c_int;
173
174 pub fn botan_pk_op_kem_decrypt_destroy(op: botan_pk_op_kem_decrypt_t) -> c_int;
175
176 pub fn botan_pk_op_kem_decrypt_create(
177 op: *mut botan_pk_op_kem_decrypt_t,
178 key: botan_privkey_t,
179 kdf: *const c_char,
180 ) -> c_int;
181
182 pub fn botan_pk_op_kem_decrypt_shared_key_length(
183 op: botan_pk_op_kem_decrypt_t,
184 desired_shared_key_length: usize,
185 output_shared_key_length: *mut usize,
186 ) -> c_int;
187
188 pub fn botan_pk_op_kem_decrypt_shared_key(
189 op: botan_pk_op_kem_decrypt_t,
190 salt: *const u8,
191 salt_len: usize,
192 encapsulated_key: *const u8,
193 encapsulated_key_len: usize,
194 desired_shared_key_len: usize,
195 shared_key: *mut u8,
196 shared_key_len: *mut usize,
197 ) -> c_int;
198}