1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
use cty::{c_char, c_int};

use pubkey::{botan_privkey_t, botan_pubkey_t};
use rng::botan_rng_t;

pub enum botan_pk_op_encrypt_struct {}
pub type botan_pk_op_encrypt_t = *mut botan_pk_op_encrypt_struct;

pub enum botan_pk_op_decrypt_struct {}
pub type botan_pk_op_decrypt_t = *mut botan_pk_op_decrypt_struct;

pub enum botan_pk_op_sign_struct {}
pub type botan_pk_op_sign_t = *mut botan_pk_op_sign_struct;

pub enum botan_pk_op_verify_struct {}
pub type botan_pk_op_verify_t = *mut botan_pk_op_verify_struct;

pub enum botan_pk_op_ka_struct {}
pub type botan_pk_op_ka_t = *mut botan_pk_op_ka_struct;

extern "C" {
    pub fn botan_pk_op_encrypt_create(
        op: *mut botan_pk_op_encrypt_t,
        key: botan_pubkey_t,
        padding: *const c_char,
        flags: u32,
    ) -> c_int;
    pub fn botan_pk_op_encrypt_destroy(op: botan_pk_op_encrypt_t) -> c_int;

    pub fn botan_pk_op_encrypt_output_length(
        op: botan_pk_op_encrypt_t,
        inlen: usize,
        outlen: *mut usize,
    ) -> c_int;

    pub fn botan_pk_op_encrypt(
        op: botan_pk_op_encrypt_t,
        rng: botan_rng_t,
        out: *mut u8,
        out_len: *mut usize,
        plaintext: *const u8,
        plaintext_len: usize,
    ) -> c_int;

    pub fn botan_pk_op_decrypt_create(
        op: *mut botan_pk_op_decrypt_t,
        key: botan_privkey_t,
        padding: *const c_char,
        flags: u32,
    ) -> c_int;
    pub fn botan_pk_op_decrypt_output_length(
        op: botan_pk_op_decrypt_t,
        inlen: usize,
        outlen: *mut usize,
    ) -> c_int;
    pub fn botan_pk_op_decrypt_destroy(op: botan_pk_op_decrypt_t) -> c_int;
    pub fn botan_pk_op_decrypt(
        op: botan_pk_op_decrypt_t,
        out: *mut u8,
        out_len: *mut usize,
        ciphertext: *const u8,
        ciphertext_len: usize,
    ) -> c_int;

    pub fn botan_pk_op_sign_create(
        op: *mut botan_pk_op_sign_t,
        key: botan_privkey_t,
        hash_and_padding: *const c_char,
        flags: u32,
    ) -> c_int;
    pub fn botan_pk_op_sign_output_length(op: botan_pk_op_sign_t, siglen: *mut usize) -> c_int;
    pub fn botan_pk_op_sign_destroy(op: botan_pk_op_sign_t) -> c_int;
    pub fn botan_pk_op_sign_update(op: botan_pk_op_sign_t, in_: *const u8, in_len: usize) -> c_int;
    pub fn botan_pk_op_sign_finish(
        op: botan_pk_op_sign_t,
        rng: botan_rng_t,
        sig: *mut u8,
        sig_len: *mut usize,
    ) -> c_int;

    pub fn botan_pk_op_verify_create(
        op: *mut botan_pk_op_verify_t,
        key: botan_pubkey_t,
        hash_and_padding: *const c_char,
        flags: u32,
    ) -> c_int;
    pub fn botan_pk_op_verify_destroy(op: botan_pk_op_verify_t) -> c_int;
    pub fn botan_pk_op_verify_update(
        op: botan_pk_op_verify_t,
        in_: *const u8,
        in_len: usize,
    ) -> c_int;
    pub fn botan_pk_op_verify_finish(
        op: botan_pk_op_verify_t,
        sig: *const u8,
        sig_len: usize,
    ) -> c_int;

    pub fn botan_pk_op_key_agreement_create(
        op: *mut botan_pk_op_ka_t,
        key: botan_privkey_t,
        kdf: *const c_char,
        flags: u32,
    ) -> c_int;
    pub fn botan_pk_op_key_agreement_destroy(op: botan_pk_op_ka_t) -> c_int;
    pub fn botan_pk_op_key_agreement_size(op: botan_pk_op_ka_t, agreed_len: *mut usize) -> c_int;
    pub fn botan_pk_op_key_agreement_export_public(
        key: botan_privkey_t,
        out: *mut u8,
        out_len: *mut usize,
    ) -> c_int;
    pub fn botan_pk_op_key_agreement(
        op: botan_pk_op_ka_t,
        out: *mut u8,
        out_len: *mut usize,
        other_key: *const u8,
        other_key_len: usize,
        salt: *const u8,
        salt_len: usize,
    ) -> c_int;
    pub fn botan_pkcs_hash_id(
        hash_name: *const c_char,
        pkcs_id: *mut u8,
        pkcs_id_len: *mut usize,
    ) -> c_int;

}