botan_sys/
x509.rs

1use crate::ffi_types::*;
2
3use crate::pubkey::{botan_privkey_t, botan_pubkey_t};
4use crate::rng::botan_rng_t;
5
6pub enum botan_x509_cert_struct {}
7pub type botan_x509_cert_t = *mut botan_x509_cert_struct;
8
9pub enum botan_x509_crl_struct {}
10pub type botan_x509_crl_t = *mut botan_x509_crl_struct;
11
12#[repr(u32)]
13#[allow(clippy::upper_case_acronyms)]
14pub enum X509KeyConstraints {
15    NO_CONSTRAINTS = 0,
16    DIGITAL_SIGNATURE = 32768,
17    NON_REPUDIATION = 16384,
18    KEY_ENCIPHERMENT = 8192,
19    DATA_ENCIPHERMENT = 4096,
20    KEY_AGREEMENT = 2048,
21    KEY_CERT_SIGN = 1024,
22    CRL_SIGN = 512,
23    ENCIPHER_ONLY = 256,
24    DECIPHER_ONLY = 128,
25}
26
27extern "C" {
28    pub fn botan_x509_cert_load(
29        cert_obj: *mut botan_x509_cert_t,
30        cert: *const u8,
31        cert_len: usize,
32    ) -> c_int;
33    pub fn botan_x509_cert_dup(cert_obj: *mut botan_x509_cert_t, cert: botan_x509_cert_t) -> c_int;
34    pub fn botan_x509_cert_load_file(
35        cert_obj: *mut botan_x509_cert_t,
36        filename: *const c_char,
37    ) -> c_int;
38    pub fn botan_x509_cert_destroy(cert: botan_x509_cert_t) -> c_int;
39    pub fn botan_x509_cert_gen_selfsigned(
40        cert: *mut botan_x509_cert_t,
41        key: botan_privkey_t,
42        rng: botan_rng_t,
43        common_name: *const c_char,
44        org_name: *const c_char,
45    ) -> c_int;
46    pub fn botan_x509_cert_get_time_starts(
47        cert: botan_x509_cert_t,
48        out: *mut c_char,
49        out_len: *mut usize,
50    ) -> c_int;
51    pub fn botan_x509_cert_get_time_expires(
52        cert: botan_x509_cert_t,
53        out: *mut c_char,
54        out_len: *mut usize,
55    ) -> c_int;
56    pub fn botan_x509_cert_not_before(cert: botan_x509_cert_t, timestamp: *mut u64) -> c_int;
57    pub fn botan_x509_cert_not_after(cert: botan_x509_cert_t, timestamp: *mut u64) -> c_int;
58    pub fn botan_x509_cert_get_fingerprint(
59        cert: botan_x509_cert_t,
60        hash: *const c_char,
61        out: *mut u8,
62        out_len: *mut usize,
63    ) -> c_int;
64    pub fn botan_x509_cert_get_serial_number(
65        cert: botan_x509_cert_t,
66        out: *mut u8,
67        out_len: *mut usize,
68    ) -> c_int;
69    pub fn botan_x509_cert_get_authority_key_id(
70        cert: botan_x509_cert_t,
71        out: *mut u8,
72        out_len: *mut usize,
73    ) -> c_int;
74    pub fn botan_x509_cert_get_subject_key_id(
75        cert: botan_x509_cert_t,
76        out: *mut u8,
77        out_len: *mut usize,
78    ) -> c_int;
79    pub fn botan_x509_cert_get_public_key_bits(
80        cert: botan_x509_cert_t,
81        out: *mut u8,
82        out_len: *mut usize,
83    ) -> c_int;
84    pub fn botan_x509_cert_get_public_key(
85        cert: botan_x509_cert_t,
86        key: *mut botan_pubkey_t,
87    ) -> c_int;
88    pub fn botan_x509_cert_get_issuer_dn(
89        cert: botan_x509_cert_t,
90        key: *const c_char,
91        index: usize,
92        out: *mut u8,
93        out_len: *mut usize,
94    ) -> c_int;
95    pub fn botan_x509_cert_get_subject_dn(
96        cert: botan_x509_cert_t,
97        key: *const c_char,
98        index: usize,
99        out: *mut u8,
100        out_len: *mut usize,
101    ) -> c_int;
102    pub fn botan_x509_cert_to_string(
103        cert: botan_x509_cert_t,
104        out: *mut c_char,
105        out_len: *mut usize,
106    ) -> c_int;
107
108    pub fn botan_x509_cert_allowed_usage(cert: botan_x509_cert_t, key_usage: c_uint) -> c_int;
109    pub fn botan_x509_cert_hostname_match(
110        cert: botan_x509_cert_t,
111        hostname: *const c_char,
112    ) -> c_int;
113
114    pub fn botan_x509_cert_verify(
115        validation_result: *mut c_int,
116        ee_cert: botan_x509_cert_t,
117        intermediates: *const botan_x509_cert_t,
118        intermediates_len: usize,
119        trusted: *const botan_x509_cert_t,
120        trusted_len: usize,
121        trusted_path: *const c_char,
122        required_key_strength: usize,
123        hostname: *const c_char,
124        reference_time: u64,
125    ) -> c_int;
126
127    pub fn botan_x509_cert_validation_status(code: c_int) -> *const c_char;
128
129    #[cfg(feature = "botan3")]
130    pub fn botan_x509_cert_view_public_key_bits(
131        cert: botan_x509_cert_t,
132        view_ctx: botan_view_ctx,
133        view_fn: botan_view_bin_fn,
134    ) -> c_int;
135
136    #[cfg(feature = "botan3")]
137    pub fn botan_x509_cert_view_as_string(
138        cert: botan_x509_cert_t,
139        view_ctx: botan_view_ctx,
140        view_fn: botan_view_str_fn,
141    ) -> c_int;
142
143    pub fn botan_x509_crl_load_file(crl: *mut botan_x509_crl_t, file_path: *const c_char) -> c_int;
144
145    pub fn botan_x509_crl_load(
146        crl: *mut botan_x509_crl_t,
147        data: *const u8,
148        data_len: usize,
149    ) -> c_int;
150
151    pub fn botan_x509_crl_destroy(crl: botan_x509_crl_t) -> c_int;
152
153    pub fn botan_x509_is_revoked(crl: botan_x509_crl_t, cert: botan_x509_cert_t) -> c_int;
154
155    // TODO: botan_x509_cert_verify_with_crl
156
157}