1 use libc::*;
2 
3 use *;
4 
5 pub const X509_FILETYPE_PEM: c_int = 1;
6 pub const X509_FILETYPE_ASN1: c_int = 2;
7 pub const X509_FILETYPE_DEFAULT: c_int = 3;
8 
9 #[repr(C)]
10 pub struct X509_VAL {
11     pub notBefore: *mut ASN1_TIME,
12     pub notAfter: *mut ASN1_TIME,
13 }
14 
15 pub enum X509_NAME_ENTRY {}
16 
17 stack!(stack_st_X509_NAME);
18 
19 pub enum X509_EXTENSION {}
20 
21 stack!(stack_st_X509_EXTENSION);
22 
23 stack!(stack_st_X509_ATTRIBUTE);
24 
25 cfg_if! {
26     if #[cfg(ossl110)] {
27         pub enum X509_REQ_INFO {}
28     } else {
29         #[repr(C)]
30         pub struct X509_REQ_INFO {
31             pub enc: ASN1_ENCODING,
32             pub version: *mut ::ASN1_INTEGER,
33             pub subject: *mut ::X509_NAME,
34             pubkey: *mut c_void,
35             pub attributes: *mut stack_st_X509_ATTRIBUTE,
36         }
37     }
38 }
39 
40 cfg_if! {
41     if #[cfg(ossl110)] {
42         pub enum X509_CRL {}
43     } else {
44         #[repr(C)]
45         pub struct X509_CRL {
46             pub crl: *mut X509_CRL_INFO,
47             sig_alg: *mut X509_ALGOR,
48             signature: *mut c_void,
49             references: c_int,
50             flags: c_int,
51             akid: *mut c_void,
52             idp: *mut c_void,
53             idp_flags: c_int,
54             idp_reasons: c_int,
55             crl_number: *mut ASN1_INTEGER,
56             base_crl_number: *mut ASN1_INTEGER,
57             sha1_hash: [c_uchar; 20],
58             issuers: *mut c_void,
59             meth: *const c_void,
60             meth_data: *mut c_void,
61         }
62     }
63 }
64 
65 stack!(stack_st_X509_CRL);
66 
67 cfg_if! {
68     if #[cfg(ossl110)] {
69         pub enum X509_CRL_INFO {}
70     } else {
71         #[repr(C)]
72         pub struct X509_CRL_INFO {
73             version: *mut ASN1_INTEGER,
74             sig_alg: *mut X509_ALGOR,
75             pub issuer: *mut X509_NAME,
76             pub lastUpdate: *mut ASN1_TIME,
77             pub nextUpdate: *mut ASN1_TIME,
78             pub revoked: *mut stack_st_X509_REVOKED,
79             extensions: *mut stack_st_X509_EXTENSION,
80             enc: ASN1_ENCODING,
81         }
82     }
83 }
84 
85 cfg_if! {
86     if #[cfg(ossl110)] {
87         pub enum X509_REVOKED {}
88     } else {
89         #[repr(C)]
90         pub struct X509_REVOKED {
91             pub serialNumber: *mut ASN1_INTEGER,
92             pub revocationDate: *mut ASN1_TIME,
93             pub extensions: *mut stack_st_X509_EXTENSION,
94             issuer: *mut stack_st_GENERAL_NAME,
95             reason: c_int,
96             sequence: c_int,
97         }
98     }
99 }
100 
101 stack!(stack_st_X509_REVOKED);
102 
103 cfg_if! {
104     if #[cfg(ossl110)] {
105         pub enum X509_REQ {}
106     } else {
107         #[repr(C)]
108         pub struct X509_REQ {
109             pub req_info: *mut X509_REQ_INFO,
110             sig_alg: *mut c_void,
111             signature: *mut c_void,
112             references: c_int,
113         }
114     }
115 }
116 
117 cfg_if! {
118     if #[cfg(ossl110)] {
119         pub enum X509_CINF {}
120     } else {
121         #[repr(C)]
122         pub struct X509_CINF {
123             version: *mut c_void,
124             serialNumber: *mut c_void,
125             signature: *mut c_void,
126             issuer: *mut c_void,
127             pub validity: *mut X509_VAL,
128             subject: *mut c_void,
129             key: *mut c_void,
130             issuerUID: *mut c_void,
131             subjectUID: *mut c_void,
132             pub extensions: *mut stack_st_X509_EXTENSION,
133             enc: ASN1_ENCODING,
134         }
135     }
136 }
137 
138 stack!(stack_st_X509);
139 
140 cfg_if! {
141     if #[cfg(not(ossl110))] {
142         pub const X509_LU_FAIL: c_int = 0;
143         pub const X509_LU_X509: c_int = 1;
144         pub const X509_LU_CRL: c_int = 2;
145     }
146 }
147 
148 cfg_if! {
149     if #[cfg(any(ossl110, libressl270))] {
150         pub enum X509_OBJECT {}
151     } else {
152         #[repr(C)]
153         pub struct X509_OBJECT {
154             pub type_: c_int,
155             pub data: X509_OBJECT_data,
156         }
157         #[repr(C)]
158         pub union X509_OBJECT_data {
159             pub ptr: *mut c_char,
160             pub x509: *mut X509,
161             pub crl: *mut X509_CRL,
162             pub pkey: *mut EVP_PKEY,
163         }
164     }
165 }
166 
167 stack!(stack_st_X509_OBJECT);
168 
169 pub enum X509_LOOKUP {}
170 
171 stack!(stack_st_X509_LOOKUP);
172 
173 extern "C" {
X509_verify_cert_error_string(n: c_long) -> *const c_char174     pub fn X509_verify_cert_error_string(n: c_long) -> *const c_char;
175 
X509_sign(x: *mut X509, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> c_int176     pub fn X509_sign(x: *mut X509, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> c_int;
177 
X509_digest( x: *const X509, digest: *const EVP_MD, buf: *mut c_uchar, len: *mut c_uint, ) -> c_int178     pub fn X509_digest(
179         x: *const X509,
180         digest: *const EVP_MD,
181         buf: *mut c_uchar,
182         len: *mut c_uint,
183     ) -> c_int;
184 
X509_REQ_sign(x: *mut X509_REQ, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> c_int185     pub fn X509_REQ_sign(x: *mut X509_REQ, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> c_int;
186 
i2d_X509_bio(b: *mut BIO, x: *mut X509) -> c_int187     pub fn i2d_X509_bio(b: *mut BIO, x: *mut X509) -> c_int;
i2d_X509_REQ_bio(b: *mut BIO, x: *mut X509_REQ) -> c_int188     pub fn i2d_X509_REQ_bio(b: *mut BIO, x: *mut X509_REQ) -> c_int;
i2d_PrivateKey_bio(b: *mut BIO, x: *mut EVP_PKEY) -> c_int189     pub fn i2d_PrivateKey_bio(b: *mut BIO, x: *mut EVP_PKEY) -> c_int;
i2d_PUBKEY_bio(b: *mut BIO, x: *mut EVP_PKEY) -> c_int190     pub fn i2d_PUBKEY_bio(b: *mut BIO, x: *mut EVP_PKEY) -> c_int;
191 
i2d_PUBKEY(k: *mut EVP_PKEY, buf: *mut *mut u8) -> c_int192     pub fn i2d_PUBKEY(k: *mut EVP_PKEY, buf: *mut *mut u8) -> c_int;
d2i_PUBKEY(k: *mut *mut EVP_PKEY, buf: *mut *const u8, len: c_long) -> *mut EVP_PKEY193     pub fn d2i_PUBKEY(k: *mut *mut EVP_PKEY, buf: *mut *const u8, len: c_long) -> *mut EVP_PKEY;
d2i_RSA_PUBKEY(k: *mut *mut RSA, buf: *mut *const u8, len: c_long) -> *mut RSA194     pub fn d2i_RSA_PUBKEY(k: *mut *mut RSA, buf: *mut *const u8, len: c_long) -> *mut RSA;
i2d_RSA_PUBKEY(k: *mut RSA, buf: *mut *mut u8) -> c_int195     pub fn i2d_RSA_PUBKEY(k: *mut RSA, buf: *mut *mut u8) -> c_int;
d2i_DSA_PUBKEY(k: *mut *mut DSA, pp: *mut *const c_uchar, length: c_long) -> *mut DSA196     pub fn d2i_DSA_PUBKEY(k: *mut *mut DSA, pp: *mut *const c_uchar, length: c_long) -> *mut DSA;
i2d_DSA_PUBKEY(a: *mut DSA, pp: *mut *mut c_uchar) -> c_int197     pub fn i2d_DSA_PUBKEY(a: *mut DSA, pp: *mut *mut c_uchar) -> c_int;
d2i_EC_PUBKEY( a: *mut *mut EC_KEY, pp: *mut *const c_uchar, length: c_long, ) -> *mut EC_KEY198     pub fn d2i_EC_PUBKEY(
199         a: *mut *mut EC_KEY,
200         pp: *mut *const c_uchar,
201         length: c_long,
202     ) -> *mut EC_KEY;
i2d_EC_PUBKEY(a: *mut EC_KEY, pp: *mut *mut c_uchar) -> c_int203     pub fn i2d_EC_PUBKEY(a: *mut EC_KEY, pp: *mut *mut c_uchar) -> c_int;
i2d_PrivateKey(k: *mut EVP_PKEY, buf: *mut *mut u8) -> c_int204     pub fn i2d_PrivateKey(k: *mut EVP_PKEY, buf: *mut *mut u8) -> c_int;
205 
d2i_ECPrivateKey( k: *mut *mut EC_KEY, pp: *mut *const c_uchar, length: c_long, ) -> *mut EC_KEY206     pub fn d2i_ECPrivateKey(
207         k: *mut *mut EC_KEY,
208         pp: *mut *const c_uchar,
209         length: c_long,
210     ) -> *mut EC_KEY;
i2d_ECPrivateKey(ec_key: *mut EC_KEY, pp: *mut *mut c_uchar) -> c_int211     pub fn i2d_ECPrivateKey(ec_key: *mut EC_KEY, pp: *mut *mut c_uchar) -> c_int;
212 }
213 
214 const_ptr_api! {
215     extern "C" {
216         #[cfg(ossl102)]
217         pub fn X509_ALGOR_get0(
218             paobj: *mut #[const_ptr_if(ossl110)] ASN1_OBJECT,
219             pptype: *mut c_int,
220             ppval: *mut #[const_ptr_if(ossl110)] c_void,
221             alg: #[const_ptr_if(ossl110)] X509_ALGOR,
222         );
223     }
224 }
225 
226 extern "C" {
X509_gmtime_adj(time: *mut ASN1_TIME, adj: c_long) -> *mut ASN1_TIME227     pub fn X509_gmtime_adj(time: *mut ASN1_TIME, adj: c_long) -> *mut ASN1_TIME;
228 
X509_to_X509_REQ(x: *mut X509, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> *mut X509_REQ229     pub fn X509_to_X509_REQ(x: *mut X509, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> *mut X509_REQ;
230 
X509_ALGOR_free(x: *mut X509_ALGOR)231     pub fn X509_ALGOR_free(x: *mut X509_ALGOR);
232 
X509_REVOKED_new() -> *mut X509_REVOKED233     pub fn X509_REVOKED_new() -> *mut X509_REVOKED;
X509_REVOKED_free(x: *mut X509_REVOKED)234     pub fn X509_REVOKED_free(x: *mut X509_REVOKED);
235     #[cfg(any(ossl110, libressl270))]
X509_REVOKED_dup(rev: *mut X509_REVOKED) -> *mut X509_REVOKED236     pub fn X509_REVOKED_dup(rev: *mut X509_REVOKED) -> *mut X509_REVOKED;
d2i_X509_REVOKED( a: *mut *mut X509_REVOKED, pp: *mut *const c_uchar, length: c_long, ) -> *mut X509_REVOKED237     pub fn d2i_X509_REVOKED(
238         a: *mut *mut X509_REVOKED,
239         pp: *mut *const c_uchar,
240         length: c_long,
241     ) -> *mut X509_REVOKED;
i2d_X509_REVOKED(x: *mut X509_REVOKED, buf: *mut *mut u8) -> c_int242     pub fn i2d_X509_REVOKED(x: *mut X509_REVOKED, buf: *mut *mut u8) -> c_int;
X509_CRL_new() -> *mut X509_CRL243     pub fn X509_CRL_new() -> *mut X509_CRL;
X509_CRL_free(x: *mut X509_CRL)244     pub fn X509_CRL_free(x: *mut X509_CRL);
d2i_X509_CRL( a: *mut *mut X509_CRL, pp: *mut *const c_uchar, length: c_long, ) -> *mut X509_CRL245     pub fn d2i_X509_CRL(
246         a: *mut *mut X509_CRL,
247         pp: *mut *const c_uchar,
248         length: c_long,
249     ) -> *mut X509_CRL;
i2d_X509_CRL(x: *mut X509_CRL, buf: *mut *mut u8) -> c_int250     pub fn i2d_X509_CRL(x: *mut X509_CRL, buf: *mut *mut u8) -> c_int;
251 
X509_REQ_new() -> *mut X509_REQ252     pub fn X509_REQ_new() -> *mut X509_REQ;
X509_REQ_free(x: *mut X509_REQ)253     pub fn X509_REQ_free(x: *mut X509_REQ);
d2i_X509_REQ( a: *mut *mut X509_REQ, pp: *mut *const c_uchar, length: c_long, ) -> *mut X509_REQ254     pub fn d2i_X509_REQ(
255         a: *mut *mut X509_REQ,
256         pp: *mut *const c_uchar,
257         length: c_long,
258     ) -> *mut X509_REQ;
i2d_X509_REQ(x: *mut X509_REQ, buf: *mut *mut u8) -> c_int259     pub fn i2d_X509_REQ(x: *mut X509_REQ, buf: *mut *mut u8) -> c_int;
260 }
261 
262 const_ptr_api! {
263     extern "C" {
264         #[cfg(any(ossl102, libressl273))]
265         pub fn X509_get0_signature(
266             psig: *mut #[const_ptr_if(any(ossl110, libressl273))] ASN1_BIT_STRING,
267             palg: *mut #[const_ptr_if(any(ossl110, libressl273))] X509_ALGOR,
268             x: *const X509,
269         );
270     }
271 }
272 extern "C" {
273     #[cfg(ossl102)]
X509_get_signature_nid(x: *const X509) -> c_int274     pub fn X509_get_signature_nid(x: *const X509) -> c_int;
275 
X509_EXTENSION_free(ext: *mut X509_EXTENSION)276     pub fn X509_EXTENSION_free(ext: *mut X509_EXTENSION);
277 
X509_NAME_ENTRY_free(x: *mut X509_NAME_ENTRY)278     pub fn X509_NAME_ENTRY_free(x: *mut X509_NAME_ENTRY);
279 
X509_NAME_new() -> *mut X509_NAME280     pub fn X509_NAME_new() -> *mut X509_NAME;
X509_NAME_free(x: *mut X509_NAME)281     pub fn X509_NAME_free(x: *mut X509_NAME);
282 
X509_new() -> *mut X509283     pub fn X509_new() -> *mut X509;
X509_free(x: *mut X509)284     pub fn X509_free(x: *mut X509);
i2d_X509(x: *mut X509, buf: *mut *mut u8) -> c_int285     pub fn i2d_X509(x: *mut X509, buf: *mut *mut u8) -> c_int;
d2i_X509(a: *mut *mut X509, pp: *mut *const c_uchar, length: c_long) -> *mut X509286     pub fn d2i_X509(a: *mut *mut X509, pp: *mut *const c_uchar, length: c_long) -> *mut X509;
287 
X509_get_pubkey(x: *mut X509) -> *mut EVP_PKEY288     pub fn X509_get_pubkey(x: *mut X509) -> *mut EVP_PKEY;
289 
X509_set_version(x: *mut X509, version: c_long) -> c_int290     pub fn X509_set_version(x: *mut X509, version: c_long) -> c_int;
291     #[cfg(ossl110)]
X509_get_version(x: *const X509) -> c_long292     pub fn X509_get_version(x: *const X509) -> c_long;
X509_set_serialNumber(x: *mut X509, sn: *mut ASN1_INTEGER) -> c_int293     pub fn X509_set_serialNumber(x: *mut X509, sn: *mut ASN1_INTEGER) -> c_int;
X509_get_serialNumber(x: *mut X509) -> *mut ASN1_INTEGER294     pub fn X509_get_serialNumber(x: *mut X509) -> *mut ASN1_INTEGER;
X509_set_issuer_name(x: *mut X509, name: *mut X509_NAME) -> c_int295     pub fn X509_set_issuer_name(x: *mut X509, name: *mut X509_NAME) -> c_int;
296 
X509_subject_name_hash(x: *mut ::X509) -> c_ulong297     pub fn X509_subject_name_hash(x: *mut ::X509) -> c_ulong;
298 }
299 const_ptr_api! {
300     extern "C" {
301         pub fn X509_get_issuer_name(x: #[const_ptr_if(any(ossl110, libressl280))] ::X509) -> *mut ::X509_NAME;
302     }
303 }
304 extern "C" {
X509_set_subject_name(x: *mut X509, name: *mut X509_NAME) -> c_int305     pub fn X509_set_subject_name(x: *mut X509, name: *mut X509_NAME) -> c_int;
306 }
307 const_ptr_api! {
308     extern "C" {
309         pub fn X509_get_subject_name(x: #[const_ptr_if(any(ossl110, libressl280))] ::X509) -> *mut ::X509_NAME;
310     }
311 }
312 cfg_if! {
313     if #[cfg(ossl110)] {
314         extern "C" {
315             pub fn X509_set1_notBefore(x: *mut ::X509, tm: *const ::ASN1_TIME) -> c_int;
316             pub fn X509_set1_notAfter(x: *mut ::X509, tm: *const ::ASN1_TIME) -> c_int;
317         }
318     } else {
319         extern "C" {
320             pub fn X509_set_notBefore(x: *mut ::X509, tm: *const ::ASN1_TIME) -> c_int;
321             pub fn X509_set_notAfter(x: *mut ::X509, tm: *const ::ASN1_TIME) -> c_int;
322         }
323     }
324 }
325 extern "C" {
326     #[cfg(ossl110)]
X509_REQ_get_version(req: *const X509_REQ) -> c_long327     pub fn X509_REQ_get_version(req: *const X509_REQ) -> c_long;
X509_REQ_set_version(req: *mut X509_REQ, version: c_long) -> c_int328     pub fn X509_REQ_set_version(req: *mut X509_REQ, version: c_long) -> c_int;
329     #[cfg(ossl110)]
X509_REQ_get_subject_name(req: *const X509_REQ) -> *mut X509_NAME330     pub fn X509_REQ_get_subject_name(req: *const X509_REQ) -> *mut X509_NAME;
X509_REQ_set_subject_name(req: *mut X509_REQ, name: *mut X509_NAME) -> c_int331     pub fn X509_REQ_set_subject_name(req: *mut X509_REQ, name: *mut X509_NAME) -> c_int;
X509_REQ_set_pubkey(req: *mut X509_REQ, pkey: *mut EVP_PKEY) -> c_int332     pub fn X509_REQ_set_pubkey(req: *mut X509_REQ, pkey: *mut EVP_PKEY) -> c_int;
X509_REQ_get_pubkey(req: *mut X509_REQ) -> *mut EVP_PKEY333     pub fn X509_REQ_get_pubkey(req: *mut X509_REQ) -> *mut EVP_PKEY;
X509_REQ_get_extensions(req: *mut X509_REQ) -> *mut stack_st_X509_EXTENSION334     pub fn X509_REQ_get_extensions(req: *mut X509_REQ) -> *mut stack_st_X509_EXTENSION;
X509_REQ_add_extensions(req: *mut X509_REQ, exts: *mut stack_st_X509_EXTENSION) -> c_int335     pub fn X509_REQ_add_extensions(req: *mut X509_REQ, exts: *mut stack_st_X509_EXTENSION)
336         -> c_int;
X509_set_pubkey(x: *mut X509, pkey: *mut EVP_PKEY) -> c_int337     pub fn X509_set_pubkey(x: *mut X509, pkey: *mut EVP_PKEY) -> c_int;
X509_REQ_verify(req: *mut X509_REQ, pkey: *mut EVP_PKEY) -> c_int338     pub fn X509_REQ_verify(req: *mut X509_REQ, pkey: *mut EVP_PKEY) -> c_int;
339     #[cfg(any(ossl110, libressl273))]
X509_getm_notBefore(x: *const X509) -> *mut ASN1_TIME340     pub fn X509_getm_notBefore(x: *const X509) -> *mut ASN1_TIME;
341     #[cfg(any(ossl110, libressl273))]
X509_getm_notAfter(x: *const X509) -> *mut ASN1_TIME342     pub fn X509_getm_notAfter(x: *const X509) -> *mut ASN1_TIME;
343     #[cfg(any(ossl110, libressl273))]
X509_up_ref(x: *mut X509) -> c_int344     pub fn X509_up_ref(x: *mut X509) -> c_int;
345 
346     #[cfg(any(ossl110, libressl270))]
X509_REVOKED_get0_serialNumber(req: *const X509_REVOKED) -> *const ASN1_INTEGER347     pub fn X509_REVOKED_get0_serialNumber(req: *const X509_REVOKED) -> *const ASN1_INTEGER;
348     #[cfg(any(ossl110, libressl270))]
X509_REVOKED_get0_revocationDate(req: *const X509_REVOKED) -> *const ASN1_TIME349     pub fn X509_REVOKED_get0_revocationDate(req: *const X509_REVOKED) -> *const ASN1_TIME;
350     #[cfg(any(ossl110, libressl270))]
X509_REVOKED_get0_extensions(r: *const X509_REVOKED) -> *const stack_st_X509_EXTENSION351     pub fn X509_REVOKED_get0_extensions(r: *const X509_REVOKED) -> *const stack_st_X509_EXTENSION;
352 
X509_REVOKED_set_serialNumber(r: *mut X509_REVOKED, serial: *mut ASN1_INTEGER) -> c_int353     pub fn X509_REVOKED_set_serialNumber(r: *mut X509_REVOKED, serial: *mut ASN1_INTEGER) -> c_int;
X509_REVOKED_set_revocationDate(r: *mut X509_REVOKED, tm: *mut ASN1_TIME) -> c_int354     pub fn X509_REVOKED_set_revocationDate(r: *mut X509_REVOKED, tm: *mut ASN1_TIME) -> c_int;
355 
X509_CRL_sign(x: *mut X509_CRL, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> c_int356     pub fn X509_CRL_sign(x: *mut X509_CRL, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> c_int;
X509_CRL_digest( x: *const X509_CRL, digest: *const EVP_MD, md: *mut c_uchar, len: *mut c_uint, ) -> c_int357     pub fn X509_CRL_digest(
358         x: *const X509_CRL,
359         digest: *const EVP_MD,
360         md: *mut c_uchar,
361         len: *mut c_uint,
362     ) -> c_int;
X509_CRL_verify(crl: *mut X509_CRL, pkey: *mut EVP_PKEY) -> c_int363     pub fn X509_CRL_verify(crl: *mut X509_CRL, pkey: *mut EVP_PKEY) -> c_int;
X509_CRL_get0_by_cert( x: *mut X509_CRL, ret: *mut *mut X509_REVOKED, cert: *mut X509, ) -> c_int364     pub fn X509_CRL_get0_by_cert(
365         x: *mut X509_CRL,
366         ret: *mut *mut X509_REVOKED,
367         cert: *mut X509,
368     ) -> c_int;
X509_CRL_get0_by_serial( x: *mut X509_CRL, ret: *mut *mut X509_REVOKED, serial: *mut ASN1_INTEGER, ) -> c_int369     pub fn X509_CRL_get0_by_serial(
370         x: *mut X509_CRL,
371         ret: *mut *mut X509_REVOKED,
372         serial: *mut ASN1_INTEGER,
373     ) -> c_int;
374 
375     #[cfg(any(ossl110, libressl281))]
X509_CRL_get_REVOKED(crl: *mut X509_CRL) -> *mut stack_st_X509_REVOKED376     pub fn X509_CRL_get_REVOKED(crl: *mut X509_CRL) -> *mut stack_st_X509_REVOKED;
377     #[cfg(any(ossl110, libressl281))]
X509_CRL_get0_nextUpdate(x: *const X509_CRL) -> *const ASN1_TIME378     pub fn X509_CRL_get0_nextUpdate(x: *const X509_CRL) -> *const ASN1_TIME;
379     #[cfg(any(ossl110, libressl281))]
X509_CRL_get0_lastUpdate(x: *const X509_CRL) -> *const ASN1_TIME380     pub fn X509_CRL_get0_lastUpdate(x: *const X509_CRL) -> *const ASN1_TIME;
381     #[cfg(any(ossl110, libressl281))]
X509_CRL_get_issuer(x: *const X509_CRL) -> *mut X509_NAME382     pub fn X509_CRL_get_issuer(x: *const X509_CRL) -> *mut X509_NAME;
383 
384     #[cfg(ossl110)]
X509_get0_extensions(req: *const ::X509) -> *const stack_st_X509_EXTENSION385     pub fn X509_get0_extensions(req: *const ::X509) -> *const stack_st_X509_EXTENSION;
386 
X509_CRL_set_version(crl: *mut X509_CRL, version: c_long) -> c_int387     pub fn X509_CRL_set_version(crl: *mut X509_CRL, version: c_long) -> c_int;
X509_CRL_set_issuer_name(crl: *mut X509_CRL, name: *mut X509_NAME) -> c_int388     pub fn X509_CRL_set_issuer_name(crl: *mut X509_CRL, name: *mut X509_NAME) -> c_int;
X509_CRL_sort(crl: *mut X509_CRL) -> c_int389     pub fn X509_CRL_sort(crl: *mut X509_CRL) -> c_int;
390 
391     #[cfg(any(ossl110, libressl270))]
X509_CRL_up_ref(crl: *mut X509_CRL) -> c_int392     pub fn X509_CRL_up_ref(crl: *mut X509_CRL) -> c_int;
X509_CRL_add0_revoked(crl: *mut X509_CRL, rev: *mut X509_REVOKED) -> c_int393     pub fn X509_CRL_add0_revoked(crl: *mut X509_CRL, rev: *mut X509_REVOKED) -> c_int;
394 }
395 cfg_if! {
396     if #[cfg(any(ossl110, libressl270))] {
397         extern "C" {
398             pub fn X509_CRL_set1_lastUpdate(crl: *mut X509_CRL, tm: *const ASN1_TIME) -> c_int;
399             pub fn X509_CRL_set1_nextUpdate(crl: *mut X509_CRL, tm: *const ASN1_TIME) -> c_int;
400         }
401     } else {
402         // libressl270 kept them, ossl110 "#define"s them to the variants above
403         extern "C" {
404             pub fn X509_CRL_set_lastUpdate(crl: *mut X509_CRL, tm: *const ASN1_TIME) -> c_int;
405             pub fn X509_CRL_set_nextUpdate(crl: *mut X509_CRL, tm: *const ASN1_TIME) -> c_int;
406         }
407     }
408 }
409 
410 const_ptr_api! {
411     extern "C" {
412         pub fn X509_NAME_entry_count(n: #[const_ptr_if(any(ossl110, libressl280))] X509_NAME) -> c_int;
413         pub fn X509_NAME_get_index_by_NID(n: #[const_ptr_if(libressl280)] X509_NAME, nid: c_int, last_pos: c_int) -> c_int;
414     }
415 }
416 const_ptr_api! {
417     extern "C" {
418         pub fn X509_NAME_get_entry(n: #[const_ptr_if(any(ossl110, libressl280))] X509_NAME, loc: c_int) -> *mut X509_NAME_ENTRY;
419         pub fn X509_NAME_add_entry_by_NID(
420             x: *mut X509_NAME,
421             field: c_int,
422             ty: c_int,
423             bytes: #[const_ptr_if(any(ossl110, libressl280))] c_uchar,
424             len: c_int,
425             loc: c_int,
426             set: c_int,
427         ) -> c_int;
428         pub fn X509_NAME_ENTRY_get_object(ne: #[const_ptr_if(any(ossl110, libressl280))] X509_NAME_ENTRY) -> *mut ASN1_OBJECT;
429         pub fn X509_NAME_ENTRY_get_data(ne: #[const_ptr_if(any(ossl110, libressl280))] X509_NAME_ENTRY) -> *mut ASN1_STRING;
430     }
431 }
432 extern "C" {
X509_NAME_add_entry_by_txt( x: *mut X509_NAME, field: *const c_char, ty: c_int, bytes: *const c_uchar, len: c_int, loc: c_int, set: c_int, ) -> c_int433     pub fn X509_NAME_add_entry_by_txt(
434         x: *mut X509_NAME,
435         field: *const c_char,
436         ty: c_int,
437         bytes: *const c_uchar,
438         len: c_int,
439         loc: c_int,
440         set: c_int,
441     ) -> c_int;
442 }
443 
444 // "raw" X509_EXTENSION related functions
445 extern "C" {
446     // in X509
X509_delete_ext(x: *mut X509, loc: c_int) -> *mut X509_EXTENSION447     pub fn X509_delete_ext(x: *mut X509, loc: c_int) -> *mut X509_EXTENSION;
X509_add_ext(x: *mut X509, ext: *mut X509_EXTENSION, loc: c_int) -> c_int448     pub fn X509_add_ext(x: *mut X509, ext: *mut X509_EXTENSION, loc: c_int) -> c_int;
X509_add1_ext_i2d( x: *mut X509, nid: c_int, value: *mut c_void, crit: c_int, flags: c_ulong, ) -> c_int449     pub fn X509_add1_ext_i2d(
450         x: *mut X509,
451         nid: c_int,
452         value: *mut c_void,
453         crit: c_int,
454         flags: c_ulong,
455     ) -> c_int;
456     // in X509_CRL
X509_CRL_delete_ext(x: *mut X509_CRL, loc: c_int) -> *mut X509_EXTENSION457     pub fn X509_CRL_delete_ext(x: *mut X509_CRL, loc: c_int) -> *mut X509_EXTENSION;
X509_CRL_add_ext(x: *mut X509_CRL, ext: *mut X509_EXTENSION, loc: c_int) -> c_int458     pub fn X509_CRL_add_ext(x: *mut X509_CRL, ext: *mut X509_EXTENSION, loc: c_int) -> c_int;
X509_CRL_add1_ext_i2d( x: *mut X509_CRL, nid: c_int, value: *mut c_void, crit: c_int, flags: c_ulong, ) -> c_int459     pub fn X509_CRL_add1_ext_i2d(
460         x: *mut X509_CRL,
461         nid: c_int,
462         value: *mut c_void,
463         crit: c_int,
464         flags: c_ulong,
465     ) -> c_int;
466     // in X509_REVOKED
X509_REVOKED_delete_ext(x: *mut X509_REVOKED, loc: c_int) -> *mut X509_EXTENSION467     pub fn X509_REVOKED_delete_ext(x: *mut X509_REVOKED, loc: c_int) -> *mut X509_EXTENSION;
X509_REVOKED_add_ext( x: *mut X509_REVOKED, ext: *mut X509_EXTENSION, loc: c_int, ) -> c_int468     pub fn X509_REVOKED_add_ext(
469         x: *mut X509_REVOKED,
470         ext: *mut X509_EXTENSION,
471         loc: c_int,
472     ) -> c_int;
X509_REVOKED_add1_ext_i2d( x: *mut X509_REVOKED, nid: c_int, value: *mut c_void, crit: c_int, flags: c_ulong, ) -> c_int473     pub fn X509_REVOKED_add1_ext_i2d(
474         x: *mut X509_REVOKED,
475         nid: c_int,
476         value: *mut c_void,
477         crit: c_int,
478         flags: c_ulong,
479     ) -> c_int;
480     // X509_EXTENSION stack
481     // - these getters always used *const STACK
X509v3_get_ext_count(x: *const stack_st_X509_EXTENSION) -> c_int482     pub fn X509v3_get_ext_count(x: *const stack_st_X509_EXTENSION) -> c_int;
X509v3_get_ext_by_NID( x: *const stack_st_X509_EXTENSION, nid: c_int, lastpos: c_int, ) -> c_int483     pub fn X509v3_get_ext_by_NID(
484         x: *const stack_st_X509_EXTENSION,
485         nid: c_int,
486         lastpos: c_int,
487     ) -> c_int;
X509v3_get_ext_by_critical( x: *const stack_st_X509_EXTENSION, crit: c_int, lastpos: c_int, ) -> c_int488     pub fn X509v3_get_ext_by_critical(
489         x: *const stack_st_X509_EXTENSION,
490         crit: c_int,
491         lastpos: c_int,
492     ) -> c_int;
X509v3_get_ext(x: *const stack_st_X509_EXTENSION, loc: c_int) -> *mut X509_EXTENSION493     pub fn X509v3_get_ext(x: *const stack_st_X509_EXTENSION, loc: c_int) -> *mut X509_EXTENSION;
X509v3_delete_ext(x: *mut stack_st_X509_EXTENSION, loc: c_int) -> *mut X509_EXTENSION494     pub fn X509v3_delete_ext(x: *mut stack_st_X509_EXTENSION, loc: c_int) -> *mut X509_EXTENSION;
X509v3_add_ext( x: *mut *mut stack_st_X509_EXTENSION, ex: *mut X509_EXTENSION, loc: c_int, ) -> *mut stack_st_X509_EXTENSION495     pub fn X509v3_add_ext(
496         x: *mut *mut stack_st_X509_EXTENSION,
497         ex: *mut X509_EXTENSION,
498         loc: c_int,
499     ) -> *mut stack_st_X509_EXTENSION;
500     // - X509V3_add1_i2d in x509v3.rs
501     // X509_EXTENSION itself
X509_EXTENSION_create_by_NID( ex: *mut *mut X509_EXTENSION, nid: c_int, crit: c_int, data: *mut ASN1_OCTET_STRING, ) -> *mut X509_EXTENSION502     pub fn X509_EXTENSION_create_by_NID(
503         ex: *mut *mut X509_EXTENSION,
504         nid: c_int,
505         crit: c_int,
506         data: *mut ASN1_OCTET_STRING,
507     ) -> *mut X509_EXTENSION;
X509_EXTENSION_set_critical(ex: *mut X509_EXTENSION, crit: c_int) -> c_int508     pub fn X509_EXTENSION_set_critical(ex: *mut X509_EXTENSION, crit: c_int) -> c_int;
X509_EXTENSION_set_data(ex: *mut X509_EXTENSION, data: *mut ASN1_OCTET_STRING) -> c_int509     pub fn X509_EXTENSION_set_data(ex: *mut X509_EXTENSION, data: *mut ASN1_OCTET_STRING) -> c_int;
X509_EXTENSION_get_object(ext: *mut X509_EXTENSION) -> *mut ASN1_OBJECT510     pub fn X509_EXTENSION_get_object(ext: *mut X509_EXTENSION) -> *mut ASN1_OBJECT;
X509_EXTENSION_get_data(ext: *mut X509_EXTENSION) -> *mut ASN1_OCTET_STRING511     pub fn X509_EXTENSION_get_data(ext: *mut X509_EXTENSION) -> *mut ASN1_OCTET_STRING;
512 }
513 const_ptr_api! {
514     extern "C" {
515         // in X509
516         pub fn X509_get_ext_count(x: #[const_ptr_if(any(ossl110, libressl280))] X509) -> c_int;
517         pub fn X509_get_ext_by_NID(x: #[const_ptr_if(any(ossl110, libressl280))] X509, nid: c_int, lastpos: c_int) -> c_int;
518         pub fn X509_get_ext_by_OBJ(x: #[const_ptr_if(any(ossl110, libressl280))] X509, obj: #[const_ptr_if(any(ossl110, libressl280))] ASN1_OBJECT, lastpos: c_int) -> c_int;
519         pub fn X509_get_ext_by_critical(x: #[const_ptr_if(any(ossl110, libressl280))] X509, crit: c_int, lastpos: c_int) -> c_int;
520         pub fn X509_get_ext(x: #[const_ptr_if(any(ossl110, libressl280))] X509, loc: c_int) -> *mut X509_EXTENSION;
521         pub fn X509_get_ext_d2i(
522             x: #[const_ptr_if(any(ossl110, libressl280))] ::X509,
523             nid: c_int,
524             crit: *mut c_int,
525             idx: *mut c_int,
526         ) -> *mut c_void;
527         // in X509_CRL
528         pub fn X509_CRL_get_ext_count(x: #[const_ptr_if(any(ossl110, libressl280))] X509_CRL) -> c_int;
529         pub fn X509_CRL_get_ext_by_NID(x: #[const_ptr_if(any(ossl110, libressl280))] X509_CRL, nid: c_int, lastpos: c_int) -> c_int;
530         pub fn X509_CRL_get_ext_by_OBJ(x: #[const_ptr_if(any(ossl110, libressl280))] X509_CRL, obj: #[const_ptr_if(any(ossl110, libressl280))] ASN1_OBJECT, lastpos: c_int) -> c_int;
531         pub fn X509_CRL_get_ext_by_critical(x: #[const_ptr_if(any(ossl110, libressl280))] X509_CRL, crit: c_int, lastpos: c_int) -> c_int;
532         pub fn X509_CRL_get_ext(x: #[const_ptr_if(any(ossl110, libressl280))] X509_CRL, loc: c_int) -> *mut X509_EXTENSION;
533         pub fn X509_CRL_get_ext_d2i(
534             x: #[const_ptr_if(any(ossl110, libressl280))] ::X509_CRL,
535             nid: c_int,
536             crit: *mut c_int,
537             idx: *mut c_int,
538         ) -> *mut c_void;
539         // in X509_REVOKED
540         pub fn X509_REVOKED_get_ext_count(x: #[const_ptr_if(any(ossl110, libressl280))] X509_REVOKED) -> c_int;
541         pub fn X509_REVOKED_get_ext_by_NID(x: #[const_ptr_if(any(ossl110, libressl280))] X509_REVOKED, nid: c_int, lastpos: c_int) -> c_int;
542         pub fn X509_REVOKED_get_ext_by_OBJ(x: #[const_ptr_if(any(ossl110, libressl280))] X509_REVOKED, obj: #[const_ptr_if(any(ossl110, libressl280))] ASN1_OBJECT, lastpos: c_int) -> c_int;
543         pub fn X509_REVOKED_get_ext_by_critical(x: #[const_ptr_if(any(ossl110, libressl280))] X509_REVOKED, crit: c_int, lastpos: c_int) -> c_int;
544         pub fn X509_REVOKED_get_ext(x: #[const_ptr_if(any(ossl110, libressl280))] X509_REVOKED, loc: c_int) -> *mut X509_EXTENSION;
545         pub fn X509_REVOKED_get_ext_d2i(
546             x: #[const_ptr_if(any(ossl110, libressl280))] ::X509_REVOKED,
547             nid: c_int,
548             crit: *mut c_int,
549             idx: *mut c_int,
550         ) -> *mut c_void;
551         // X509_EXTENSION stack
552         pub fn X509v3_get_ext_by_OBJ(x: *const stack_st_X509_EXTENSION, obj: #[const_ptr_if(any(ossl110, libressl280))] ASN1_OBJECT, lastpos: c_int) -> c_int;
553         // X509_EXTENSION itself
554         pub fn X509_EXTENSION_create_by_OBJ(ex: *mut *mut X509_EXTENSION, obj: #[const_ptr_if(any(ossl110, libressl280))] ASN1_OBJECT, crit: c_int, data: *mut ASN1_OCTET_STRING) -> *mut X509_EXTENSION;
555         pub fn X509_EXTENSION_set_object(ex: *mut X509_EXTENSION, obj: #[const_ptr_if(any(ossl110, libressl280))] ASN1_OBJECT) -> c_int;
556         pub fn X509_EXTENSION_get_critical(ex: #[const_ptr_if(any(ossl110, libressl280))] X509_EXTENSION) -> c_int;
557     }
558 }
559 
560 extern "C" {
X509_verify_cert(ctx: *mut X509_STORE_CTX) -> c_int561     pub fn X509_verify_cert(ctx: *mut X509_STORE_CTX) -> c_int;
562 }
563 
564 #[cfg(any(ossl110, libressl270))]
565 extern "C" {
X509_STORE_get0_objects(ctx: *mut X509_STORE) -> *mut stack_st_X509_OBJECT566     pub fn X509_STORE_get0_objects(ctx: *mut X509_STORE) -> *mut stack_st_X509_OBJECT;
X509_OBJECT_get0_X509(x: *const X509_OBJECT) -> *mut X509567     pub fn X509_OBJECT_get0_X509(x: *const X509_OBJECT) -> *mut X509;
568 }
569 
570 cfg_if! {
571     if #[cfg(ossl110)] {
572         extern "C" {
573             pub fn X509_OBJECT_free(a: *mut X509_OBJECT);
574         }
575     } else {
576         extern "C" {
577             pub fn X509_OBJECT_free_contents(a: *mut X509_OBJECT);
578         }
579     }
580 }
581