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 pub const ASN1_R_HEADER_TOO_LONG: c_int = 123;
10 
11 #[repr(C)]
12 pub struct X509_VAL {
13     pub notBefore: *mut ASN1_TIME,
14     pub notAfter: *mut ASN1_TIME,
15 }
16 
17 pub enum X509_NAME_ENTRY {}
18 
19 stack!(stack_st_X509_NAME);
20 
21 pub enum X509_EXTENSION {}
22 
23 stack!(stack_st_X509_EXTENSION);
24 
25 stack!(stack_st_X509_ATTRIBUTE);
26 
27 cfg_if! {
28     if #[cfg(ossl110)] {
29         pub enum X509_REQ_INFO {}
30     } else {
31         #[repr(C)]
32         pub struct X509_REQ_INFO {
33             pub enc: ASN1_ENCODING,
34             pub version: *mut ::ASN1_INTEGER,
35             pub subject: *mut ::X509_NAME,
36             pubkey: *mut c_void,
37             pub attributes: *mut stack_st_X509_ATTRIBUTE,
38         }
39     }
40 }
41 
42 cfg_if! {
43     if #[cfg(ossl110)] {
44         pub enum X509_CRL {}
45     } else {
46         #[repr(C)]
47         pub struct X509_CRL {
48             pub crl: *mut X509_CRL_INFO,
49             sig_alg: *mut X509_ALGOR,
50             signature: *mut c_void,
51             references: c_int,
52             flags: c_int,
53             akid: *mut c_void,
54             idp: *mut c_void,
55             idp_flags: c_int,
56             idp_reasons: c_int,
57             crl_number: *mut ASN1_INTEGER,
58             base_crl_number: *mut ASN1_INTEGER,
59             sha1_hash: [c_uchar; 20],
60             issuers: *mut c_void,
61             meth: *const c_void,
62             meth_data: *mut c_void,
63         }
64     }
65 }
66 
67 stack!(stack_st_X509_CRL);
68 
69 cfg_if! {
70     if #[cfg(ossl110)] {
71         pub enum X509_CRL_INFO {}
72     } else {
73         #[repr(C)]
74         pub struct X509_CRL_INFO {
75             version: *mut ASN1_INTEGER,
76             sig_alg: *mut X509_ALGOR,
77             pub issuer: *mut X509_NAME,
78             pub lastUpdate: *mut ASN1_TIME,
79             pub nextUpdate: *mut ASN1_TIME,
80             pub revoked: *mut stack_st_X509_REVOKED,
81             extensions: *mut stack_st_X509_EXTENSION,
82             enc: ASN1_ENCODING,
83         }
84     }
85 }
86 
87 cfg_if! {
88     if #[cfg(ossl110)] {
89         pub enum X509_REVOKED {}
90     } else {
91         #[repr(C)]
92         pub struct X509_REVOKED {
93             pub serialNumber: *mut ASN1_INTEGER,
94             pub revocationDate: *mut ASN1_TIME,
95             pub extensions: *mut stack_st_X509_EXTENSION,
96             issuer: *mut stack_st_GENERAL_NAME,
97             reason: c_int,
98             sequence: c_int,
99         }
100     }
101 }
102 
103 stack!(stack_st_X509_REVOKED);
104 
105 cfg_if! {
106     if #[cfg(ossl110)] {
107         pub enum X509_REQ {}
108     } else {
109         #[repr(C)]
110         pub struct X509_REQ {
111             pub req_info: *mut X509_REQ_INFO,
112             sig_alg: *mut c_void,
113             signature: *mut c_void,
114             references: c_int,
115         }
116     }
117 }
118 
119 cfg_if! {
120     if #[cfg(ossl110)] {
121         pub enum X509_CINF {}
122     } else {
123         #[repr(C)]
124         pub struct X509_CINF {
125             version: *mut c_void,
126             serialNumber: *mut c_void,
127             signature: *mut c_void,
128             issuer: *mut c_void,
129             pub validity: *mut X509_VAL,
130             subject: *mut c_void,
131             key: *mut c_void,
132             issuerUID: *mut c_void,
133             subjectUID: *mut c_void,
134             pub extensions: *mut stack_st_X509_EXTENSION,
135             enc: ASN1_ENCODING,
136         }
137     }
138 }
139 
140 stack!(stack_st_X509);
141 
142 cfg_if! {
143     if #[cfg(not(ossl110))] {
144         pub const X509_LU_FAIL: c_int = 0;
145         pub const X509_LU_X509: c_int = 1;
146         pub const X509_LU_CRL: c_int = 2;
147     }
148 }
149 
150 cfg_if! {
151     if #[cfg(any(ossl110, libressl270))] {
152         pub enum X509_OBJECT {}
153     } else {
154         #[repr(C)]
155         pub struct X509_OBJECT {
156             pub type_: c_int,
157             pub data: X509_OBJECT_data,
158         }
159         #[repr(C)]
160         pub union X509_OBJECT_data {
161             pub ptr: *mut c_char,
162             pub x509: *mut X509,
163             pub crl: *mut X509_CRL,
164             pub pkey: *mut EVP_PKEY,
165         }
166     }
167 }
168 
169 stack!(stack_st_X509_OBJECT);
170 
171 pub enum X509_LOOKUP {}
172 
173 stack!(stack_st_X509_LOOKUP);
174 
175 extern "C" {
X509_verify_cert_error_string(n: c_long) -> *const c_char176     pub fn X509_verify_cert_error_string(n: c_long) -> *const c_char;
177 
X509_sign(x: *mut X509, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> c_int178     pub fn X509_sign(x: *mut X509, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> c_int;
179 
X509_digest( x: *const X509, digest: *const EVP_MD, buf: *mut c_uchar, len: *mut c_uint, ) -> c_int180     pub fn X509_digest(
181         x: *const X509,
182         digest: *const EVP_MD,
183         buf: *mut c_uchar,
184         len: *mut c_uint,
185     ) -> c_int;
186 
X509_REQ_sign(x: *mut X509_REQ, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> c_int187     pub fn X509_REQ_sign(x: *mut X509_REQ, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> c_int;
188 }
189 
190 const_ptr_api! {
191     extern "C" {
192         pub fn i2d_X509_bio(b: *mut BIO, x: #[const_ptr_if(ossl300)] X509) -> c_int;
193         pub fn i2d_X509_REQ_bio(b: *mut BIO, x: #[const_ptr_if(ossl300)] X509_REQ) -> c_int;
194         pub fn i2d_PrivateKey_bio(b: *mut BIO, x: #[const_ptr_if(ossl300)] EVP_PKEY) -> c_int;
195         pub fn i2d_PUBKEY_bio(b: *mut BIO, x: #[const_ptr_if(ossl300)] EVP_PKEY) -> c_int;
196 
197         pub fn i2d_PUBKEY(k: #[const_ptr_if(ossl300)] EVP_PKEY, buf: *mut *mut u8) -> c_int;
198         pub fn i2d_RSA_PUBKEY(k: #[const_ptr_if(ossl300)] RSA, buf: *mut *mut u8) -> c_int;
199         pub fn i2d_DSA_PUBKEY(a: #[const_ptr_if(ossl300)] DSA, pp: *mut *mut c_uchar) -> c_int;
200         pub fn i2d_PrivateKey(k: #[const_ptr_if(ossl300)] EVP_PKEY, buf: *mut *mut u8) -> c_int;
201         pub fn i2d_ECPrivateKey(ec_key: #[const_ptr_if(ossl300)] EC_KEY, pp: *mut *mut c_uchar) -> c_int;
202         pub fn i2d_EC_PUBKEY(a: #[const_ptr_if(ossl300)] EC_KEY, pp: *mut *mut c_uchar) -> c_int;
203     }
204 }
205 extern "C" {
d2i_PUBKEY(k: *mut *mut EVP_PKEY, buf: *mut *const u8, len: c_long) -> *mut EVP_PKEY206     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 RSA207     pub fn d2i_RSA_PUBKEY(k: *mut *mut RSA, buf: *mut *const u8, len: c_long) -> *mut RSA;
d2i_DSA_PUBKEY(k: *mut *mut DSA, pp: *mut *const c_uchar, length: c_long) -> *mut DSA208     pub fn d2i_DSA_PUBKEY(k: *mut *mut DSA, pp: *mut *const c_uchar, length: c_long) -> *mut DSA;
d2i_EC_PUBKEY( a: *mut *mut EC_KEY, pp: *mut *const c_uchar, length: c_long, ) -> *mut EC_KEY209     pub fn d2i_EC_PUBKEY(
210         a: *mut *mut EC_KEY,
211         pp: *mut *const c_uchar,
212         length: c_long,
213     ) -> *mut EC_KEY;
214 
d2i_ECPrivateKey( k: *mut *mut EC_KEY, pp: *mut *const c_uchar, length: c_long, ) -> *mut EC_KEY215     pub fn d2i_ECPrivateKey(
216         k: *mut *mut EC_KEY,
217         pp: *mut *const c_uchar,
218         length: c_long,
219     ) -> *mut EC_KEY;
220 }
221 
222 const_ptr_api! {
223     extern "C" {
224         #[cfg(ossl102)]
225         pub fn X509_ALGOR_get0(
226             paobj: *mut #[const_ptr_if(ossl110)] ASN1_OBJECT,
227             pptype: *mut c_int,
228             ppval: *mut #[const_ptr_if(ossl110)] c_void,
229             alg: #[const_ptr_if(ossl110)] X509_ALGOR,
230         );
231     }
232 }
233 
234 extern "C" {
X509_gmtime_adj(time: *mut ASN1_TIME, adj: c_long) -> *mut ASN1_TIME235     pub fn X509_gmtime_adj(time: *mut ASN1_TIME, adj: c_long) -> *mut ASN1_TIME;
236 
X509_to_X509_REQ(x: *mut X509, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> *mut X509_REQ237     pub fn X509_to_X509_REQ(x: *mut X509, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> *mut X509_REQ;
238 
X509_ALGOR_free(x: *mut X509_ALGOR)239     pub fn X509_ALGOR_free(x: *mut X509_ALGOR);
240 
X509_REVOKED_new() -> *mut X509_REVOKED241     pub fn X509_REVOKED_new() -> *mut X509_REVOKED;
X509_REVOKED_free(x: *mut X509_REVOKED)242     pub fn X509_REVOKED_free(x: *mut X509_REVOKED);
243 }
244 const_ptr_api! {
245     extern "C" {
246         #[cfg(any(ossl110, libressl270))]
247         pub fn X509_REVOKED_dup(rev: #[const_ptr_if(ossl300)] X509_REVOKED) -> *mut X509_REVOKED;
248     }
249 }
250 
251 extern "C" {
d2i_X509_REVOKED( a: *mut *mut X509_REVOKED, pp: *mut *const c_uchar, length: c_long, ) -> *mut X509_REVOKED252     pub fn d2i_X509_REVOKED(
253         a: *mut *mut X509_REVOKED,
254         pp: *mut *const c_uchar,
255         length: c_long,
256     ) -> *mut X509_REVOKED;
257 }
258 const_ptr_api! {
259     extern "C" {
260         pub fn i2d_X509_REVOKED(x: #[const_ptr_if(ossl300)] X509_REVOKED, buf: *mut *mut u8) -> c_int;
261     }
262 }
263 extern "C" {
X509_CRL_new() -> *mut X509_CRL264     pub fn X509_CRL_new() -> *mut X509_CRL;
X509_CRL_free(x: *mut X509_CRL)265     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_CRL266     pub fn d2i_X509_CRL(
267         a: *mut *mut X509_CRL,
268         pp: *mut *const c_uchar,
269         length: c_long,
270     ) -> *mut X509_CRL;
271 }
272 const_ptr_api! {
273     extern "C" {
274         pub fn i2d_X509_CRL(x: #[const_ptr_if(ossl300)] X509_CRL, buf: *mut *mut u8) -> c_int;
275     }
276 }
277 
278 extern "C" {
X509_REQ_new() -> *mut X509_REQ279     pub fn X509_REQ_new() -> *mut X509_REQ;
X509_REQ_free(x: *mut X509_REQ)280     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_REQ281     pub fn d2i_X509_REQ(
282         a: *mut *mut X509_REQ,
283         pp: *mut *const c_uchar,
284         length: c_long,
285     ) -> *mut X509_REQ;
286 }
287 const_ptr_api! {
288     extern "C" {
289         pub fn i2d_X509_REQ(x: #[const_ptr_if(ossl300)] X509_REQ, buf: *mut *mut u8) -> c_int;
290 
291         #[cfg(any(ossl102, libressl273))]
292         pub fn X509_get0_signature(
293             psig: *mut #[const_ptr_if(any(ossl110, libressl273))] ASN1_BIT_STRING,
294             palg: *mut #[const_ptr_if(any(ossl110, libressl273))] X509_ALGOR,
295             x: *const X509,
296         );
297     }
298 }
299 extern "C" {
300     #[cfg(ossl102)]
X509_get_signature_nid(x: *const X509) -> c_int301     pub fn X509_get_signature_nid(x: *const X509) -> c_int;
302 
X509_EXTENSION_free(ext: *mut X509_EXTENSION)303     pub fn X509_EXTENSION_free(ext: *mut X509_EXTENSION);
304 
X509_NAME_ENTRY_free(x: *mut X509_NAME_ENTRY)305     pub fn X509_NAME_ENTRY_free(x: *mut X509_NAME_ENTRY);
306 
X509_NAME_new() -> *mut X509_NAME307     pub fn X509_NAME_new() -> *mut X509_NAME;
X509_NAME_free(x: *mut X509_NAME)308     pub fn X509_NAME_free(x: *mut X509_NAME);
309 
X509_new() -> *mut X509310     pub fn X509_new() -> *mut X509;
X509_free(x: *mut X509)311     pub fn X509_free(x: *mut X509);
312 }
313 const_ptr_api! {
314     extern "C" {
315         pub fn i2d_X509(x: #[const_ptr_if(ossl300)] X509, buf: *mut *mut u8) -> c_int;
316     }
317 }
318 extern "C" {
d2i_X509(a: *mut *mut X509, pp: *mut *const c_uchar, length: c_long) -> *mut X509319     pub fn d2i_X509(a: *mut *mut X509, pp: *mut *const c_uchar, length: c_long) -> *mut X509;
d2i_X509_bio(b: *mut BIO, a: *mut *mut X509) -> *mut X509320     pub fn d2i_X509_bio(b: *mut BIO, a: *mut *mut X509) -> *mut X509;
321 
X509_get_pubkey(x: *mut X509) -> *mut EVP_PKEY322     pub fn X509_get_pubkey(x: *mut X509) -> *mut EVP_PKEY;
323 
X509_set_version(x: *mut X509, version: c_long) -> c_int324     pub fn X509_set_version(x: *mut X509, version: c_long) -> c_int;
325     #[cfg(ossl110)]
X509_get_version(x: *const X509) -> c_long326     pub fn X509_get_version(x: *const X509) -> c_long;
X509_set_serialNumber(x: *mut X509, sn: *mut ASN1_INTEGER) -> c_int327     pub fn X509_set_serialNumber(x: *mut X509, sn: *mut ASN1_INTEGER) -> c_int;
X509_get_serialNumber(x: *mut X509) -> *mut ASN1_INTEGER328     pub fn X509_get_serialNumber(x: *mut X509) -> *mut ASN1_INTEGER;
329 }
330 const_ptr_api! {
331     extern "C" {
332         pub fn X509_set_issuer_name(x: *mut X509, name: #[const_ptr_if(ossl300)] X509_NAME) -> c_int;
333     }
334 }
335 extern "C" {
X509_subject_name_hash(x: *mut ::X509) -> c_ulong336     pub fn X509_subject_name_hash(x: *mut ::X509) -> c_ulong;
337 }
338 const_ptr_api! {
339     extern "C" {
340         pub fn X509_get_issuer_name(x: #[const_ptr_if(any(ossl110, libressl280))] ::X509) -> *mut ::X509_NAME;
341         pub fn X509_set_subject_name(x: *mut X509, name: #[const_ptr_if(ossl300)] X509_NAME) -> c_int;
342         pub fn X509_get_subject_name(x: #[const_ptr_if(any(ossl110, libressl280))] ::X509) -> *mut ::X509_NAME;
343     }
344 }
345 cfg_if! {
346     if #[cfg(ossl110)] {
347         extern "C" {
348             pub fn X509_set1_notBefore(x: *mut ::X509, tm: *const ::ASN1_TIME) -> c_int;
349             pub fn X509_set1_notAfter(x: *mut ::X509, tm: *const ::ASN1_TIME) -> c_int;
350         }
351     } else {
352         extern "C" {
353             pub fn X509_set_notBefore(x: *mut ::X509, tm: *const ::ASN1_TIME) -> c_int;
354             pub fn X509_set_notAfter(x: *mut ::X509, tm: *const ::ASN1_TIME) -> c_int;
355         }
356     }
357 }
358 extern "C" {
359     #[cfg(ossl110)]
X509_REQ_get_version(req: *const X509_REQ) -> c_long360     pub fn X509_REQ_get_version(req: *const X509_REQ) -> c_long;
X509_REQ_set_version(req: *mut X509_REQ, version: c_long) -> c_int361     pub fn X509_REQ_set_version(req: *mut X509_REQ, version: c_long) -> c_int;
362     #[cfg(ossl110)]
X509_REQ_get_subject_name(req: *const X509_REQ) -> *mut X509_NAME363     pub fn X509_REQ_get_subject_name(req: *const X509_REQ) -> *mut X509_NAME;
364 }
365 const_ptr_api! {
366     extern "C" {
367         pub fn X509_REQ_set_subject_name(req: *mut X509_REQ, name: #[const_ptr_if(ossl300)] X509_NAME) -> c_int;
368     }
369 }
370 extern "C" {
X509_REQ_set_pubkey(req: *mut X509_REQ, pkey: *mut EVP_PKEY) -> c_int371     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_PKEY372     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_EXTENSION373     pub fn X509_REQ_get_extensions(req: *mut X509_REQ) -> *mut stack_st_X509_EXTENSION;
374 }
375 const_ptr_api! {
376     extern "C" {
377         pub fn X509_REQ_add_extensions(req: *mut X509_REQ, exts: #[const_ptr_if(ossl300)] stack_st_X509_EXTENSION)
378             -> c_int;
379     }
380 }
381 extern "C" {
X509_set_pubkey(x: *mut X509, pkey: *mut EVP_PKEY) -> c_int382     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_int383     pub fn X509_REQ_verify(req: *mut X509_REQ, pkey: *mut EVP_PKEY) -> c_int;
384     #[cfg(any(ossl110, libressl273))]
X509_getm_notBefore(x: *const X509) -> *mut ASN1_TIME385     pub fn X509_getm_notBefore(x: *const X509) -> *mut ASN1_TIME;
386     #[cfg(any(ossl110, libressl273))]
X509_getm_notAfter(x: *const X509) -> *mut ASN1_TIME387     pub fn X509_getm_notAfter(x: *const X509) -> *mut ASN1_TIME;
388     #[cfg(any(ossl110, libressl273))]
X509_up_ref(x: *mut X509) -> c_int389     pub fn X509_up_ref(x: *mut X509) -> c_int;
390 
391     #[cfg(any(ossl110, libressl270))]
X509_REVOKED_get0_serialNumber(req: *const X509_REVOKED) -> *const ASN1_INTEGER392     pub fn X509_REVOKED_get0_serialNumber(req: *const X509_REVOKED) -> *const ASN1_INTEGER;
393     #[cfg(any(ossl110, libressl270))]
X509_REVOKED_get0_revocationDate(req: *const X509_REVOKED) -> *const ASN1_TIME394     pub fn X509_REVOKED_get0_revocationDate(req: *const X509_REVOKED) -> *const ASN1_TIME;
395     #[cfg(any(ossl110, libressl270))]
X509_REVOKED_get0_extensions(r: *const X509_REVOKED) -> *const stack_st_X509_EXTENSION396     pub fn X509_REVOKED_get0_extensions(r: *const X509_REVOKED) -> *const stack_st_X509_EXTENSION;
397 
X509_REVOKED_set_serialNumber(r: *mut X509_REVOKED, serial: *mut ASN1_INTEGER) -> c_int398     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_int399     pub fn X509_REVOKED_set_revocationDate(r: *mut X509_REVOKED, tm: *mut ASN1_TIME) -> c_int;
400 
X509_CRL_sign(x: *mut X509_CRL, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> c_int401     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_int402     pub fn X509_CRL_digest(
403         x: *const X509_CRL,
404         digest: *const EVP_MD,
405         md: *mut c_uchar,
406         len: *mut c_uint,
407     ) -> c_int;
X509_CRL_verify(crl: *mut X509_CRL, pkey: *mut EVP_PKEY) -> c_int408     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_int409     pub fn X509_CRL_get0_by_cert(
410         x: *mut X509_CRL,
411         ret: *mut *mut X509_REVOKED,
412         cert: *mut X509,
413     ) -> c_int;
414 }
415 const_ptr_api! {
416     extern "C" {
417         pub fn X509_CRL_get0_by_serial(
418             x: *mut X509_CRL,
419             ret: *mut *mut X509_REVOKED,
420             serial: #[const_ptr_if(ossl300)] ASN1_INTEGER,
421         ) -> c_int;
422     }
423 }
424 
425 extern "C" {
426     #[cfg(any(ossl110, libressl281))]
X509_CRL_get_REVOKED(crl: *mut X509_CRL) -> *mut stack_st_X509_REVOKED427     pub fn X509_CRL_get_REVOKED(crl: *mut X509_CRL) -> *mut stack_st_X509_REVOKED;
428     #[cfg(any(ossl110, libressl281))]
X509_CRL_get0_nextUpdate(x: *const X509_CRL) -> *const ASN1_TIME429     pub fn X509_CRL_get0_nextUpdate(x: *const X509_CRL) -> *const ASN1_TIME;
430     #[cfg(any(ossl110, libressl281))]
X509_CRL_get0_lastUpdate(x: *const X509_CRL) -> *const ASN1_TIME431     pub fn X509_CRL_get0_lastUpdate(x: *const X509_CRL) -> *const ASN1_TIME;
432     #[cfg(any(ossl110, libressl281))]
X509_CRL_get_issuer(x: *const X509_CRL) -> *mut X509_NAME433     pub fn X509_CRL_get_issuer(x: *const X509_CRL) -> *mut X509_NAME;
434 
435     #[cfg(ossl110)]
X509_get0_extensions(req: *const ::X509) -> *const stack_st_X509_EXTENSION436     pub fn X509_get0_extensions(req: *const ::X509) -> *const stack_st_X509_EXTENSION;
437 
X509_CRL_set_version(crl: *mut X509_CRL, version: c_long) -> c_int438     pub fn X509_CRL_set_version(crl: *mut X509_CRL, version: c_long) -> c_int;
439 }
440 const_ptr_api! {
441     extern "C" {
442         pub fn X509_CRL_set_issuer_name(crl: *mut X509_CRL, name: #[const_ptr_if(ossl300)] X509_NAME) -> c_int;
443     }
444 }
445 extern "C" {
X509_CRL_sort(crl: *mut X509_CRL) -> c_int446     pub fn X509_CRL_sort(crl: *mut X509_CRL) -> c_int;
447 
448     #[cfg(any(ossl110, libressl270))]
X509_CRL_up_ref(crl: *mut X509_CRL) -> c_int449     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_int450     pub fn X509_CRL_add0_revoked(crl: *mut X509_CRL, rev: *mut X509_REVOKED) -> c_int;
451 }
452 cfg_if! {
453     if #[cfg(any(ossl110, libressl270))] {
454         extern "C" {
455             pub fn X509_CRL_set1_lastUpdate(crl: *mut X509_CRL, tm: *const ASN1_TIME) -> c_int;
456             pub fn X509_CRL_set1_nextUpdate(crl: *mut X509_CRL, tm: *const ASN1_TIME) -> c_int;
457         }
458     } else {
459         // libressl270 kept them, ossl110 "#define"s them to the variants above
460         extern "C" {
461             pub fn X509_CRL_set_lastUpdate(crl: *mut X509_CRL, tm: *const ASN1_TIME) -> c_int;
462             pub fn X509_CRL_set_nextUpdate(crl: *mut X509_CRL, tm: *const ASN1_TIME) -> c_int;
463         }
464     }
465 }
466 
467 const_ptr_api! {
468     extern "C" {
469         pub fn X509_NAME_entry_count(n: #[const_ptr_if(any(ossl110, libressl280))] X509_NAME) -> c_int;
470         pub fn X509_NAME_get_index_by_NID(n: #[const_ptr_if(any(ossl300, libressl280))] X509_NAME, nid: c_int, last_pos: c_int) -> c_int;
471         pub fn X509_NAME_get_entry(n: #[const_ptr_if(any(ossl110, libressl280))] X509_NAME, loc: c_int) -> *mut X509_NAME_ENTRY;
472         pub fn X509_NAME_add_entry_by_NID(
473             x: *mut X509_NAME,
474             field: c_int,
475             ty: c_int,
476             bytes: #[const_ptr_if(any(ossl110, libressl280))] c_uchar,
477             len: c_int,
478             loc: c_int,
479             set: c_int,
480         ) -> c_int;
481         pub fn i2d_X509_NAME(n: #[const_ptr_if(ossl300)] X509_NAME, buf: *mut *mut u8) -> c_int;
482         pub fn X509_NAME_ENTRY_get_object(ne: #[const_ptr_if(any(ossl110, libressl280))] X509_NAME_ENTRY) -> *mut ASN1_OBJECT;
483         pub fn X509_NAME_ENTRY_get_data(ne: #[const_ptr_if(any(ossl110, libressl280))] X509_NAME_ENTRY) -> *mut ASN1_STRING;
484     }
485 }
486 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_int487     pub fn X509_NAME_add_entry_by_txt(
488         x: *mut X509_NAME,
489         field: *const c_char,
490         ty: c_int,
491         bytes: *const c_uchar,
492         len: c_int,
493         loc: c_int,
494         set: c_int,
495     ) -> c_int;
d2i_X509_NAME( n: *mut *mut X509_NAME, pp: *mut *const c_uchar, length: c_long, ) -> *mut X509_NAME496     pub fn d2i_X509_NAME(
497         n: *mut *mut X509_NAME,
498         pp: *mut *const c_uchar,
499         length: c_long,
500     ) -> *mut X509_NAME;
501 }
502 
503 // "raw" X509_EXTENSION related functions
504 extern "C" {
505     // in X509
X509_delete_ext(x: *mut X509, loc: c_int) -> *mut X509_EXTENSION506     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_int507     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_int508     pub fn X509_add1_ext_i2d(
509         x: *mut X509,
510         nid: c_int,
511         value: *mut c_void,
512         crit: c_int,
513         flags: c_ulong,
514     ) -> c_int;
515     // in X509_CRL
X509_CRL_delete_ext(x: *mut X509_CRL, loc: c_int) -> *mut X509_EXTENSION516     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_int517     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_int518     pub fn X509_CRL_add1_ext_i2d(
519         x: *mut X509_CRL,
520         nid: c_int,
521         value: *mut c_void,
522         crit: c_int,
523         flags: c_ulong,
524     ) -> c_int;
525     // in X509_REVOKED
X509_REVOKED_delete_ext(x: *mut X509_REVOKED, loc: c_int) -> *mut X509_EXTENSION526     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_int527     pub fn X509_REVOKED_add_ext(
528         x: *mut X509_REVOKED,
529         ext: *mut X509_EXTENSION,
530         loc: c_int,
531     ) -> 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_int532     pub fn X509_REVOKED_add1_ext_i2d(
533         x: *mut X509_REVOKED,
534         nid: c_int,
535         value: *mut c_void,
536         crit: c_int,
537         flags: c_ulong,
538     ) -> c_int;
539     // X509_EXTENSION stack
540     // - these getters always used *const STACK
X509v3_get_ext_count(x: *const stack_st_X509_EXTENSION) -> c_int541     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_int542     pub fn X509v3_get_ext_by_NID(
543         x: *const stack_st_X509_EXTENSION,
544         nid: c_int,
545         lastpos: c_int,
546     ) -> c_int;
X509v3_get_ext_by_critical( x: *const stack_st_X509_EXTENSION, crit: c_int, lastpos: c_int, ) -> c_int547     pub fn X509v3_get_ext_by_critical(
548         x: *const stack_st_X509_EXTENSION,
549         crit: c_int,
550         lastpos: c_int,
551     ) -> c_int;
X509v3_get_ext(x: *const stack_st_X509_EXTENSION, loc: c_int) -> *mut X509_EXTENSION552     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_EXTENSION553     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_EXTENSION554     pub fn X509v3_add_ext(
555         x: *mut *mut stack_st_X509_EXTENSION,
556         ex: *mut X509_EXTENSION,
557         loc: c_int,
558     ) -> *mut stack_st_X509_EXTENSION;
559     // - X509V3_add1_i2d in x509v3.rs
560     // 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_EXTENSION561     pub fn X509_EXTENSION_create_by_NID(
562         ex: *mut *mut X509_EXTENSION,
563         nid: c_int,
564         crit: c_int,
565         data: *mut ASN1_OCTET_STRING,
566     ) -> *mut X509_EXTENSION;
X509_EXTENSION_set_critical(ex: *mut X509_EXTENSION, crit: c_int) -> c_int567     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_int568     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_OBJECT569     pub fn X509_EXTENSION_get_object(ext: *mut X509_EXTENSION) -> *mut ASN1_OBJECT;
X509_EXTENSION_get_data(ext: *mut X509_EXTENSION) -> *mut ASN1_OCTET_STRING570     pub fn X509_EXTENSION_get_data(ext: *mut X509_EXTENSION) -> *mut ASN1_OCTET_STRING;
571 }
572 const_ptr_api! {
573     extern "C" {
574         // in X509
575         pub fn X509_get_ext_count(x: #[const_ptr_if(any(ossl110, libressl280))] X509) -> c_int;
576         pub fn X509_get_ext_by_NID(x: #[const_ptr_if(any(ossl110, libressl280))] X509, nid: c_int, lastpos: c_int) -> c_int;
577         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;
578         pub fn X509_get_ext_by_critical(x: #[const_ptr_if(any(ossl110, libressl280))] X509, crit: c_int, lastpos: c_int) -> c_int;
579         pub fn X509_get_ext(x: #[const_ptr_if(any(ossl110, libressl280))] X509, loc: c_int) -> *mut X509_EXTENSION;
580         pub fn X509_get_ext_d2i(
581             x: #[const_ptr_if(any(ossl110, libressl280))] ::X509,
582             nid: c_int,
583             crit: *mut c_int,
584             idx: *mut c_int,
585         ) -> *mut c_void;
586         // in X509_CRL
587         pub fn X509_CRL_get_ext_count(x: #[const_ptr_if(any(ossl110, libressl280))] X509_CRL) -> c_int;
588         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;
589         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;
590         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;
591         pub fn X509_CRL_get_ext(x: #[const_ptr_if(any(ossl110, libressl280))] X509_CRL, loc: c_int) -> *mut X509_EXTENSION;
592         pub fn X509_CRL_get_ext_d2i(
593             x: #[const_ptr_if(any(ossl110, libressl280))] ::X509_CRL,
594             nid: c_int,
595             crit: *mut c_int,
596             idx: *mut c_int,
597         ) -> *mut c_void;
598         // in X509_REVOKED
599         pub fn X509_REVOKED_get_ext_count(x: #[const_ptr_if(any(ossl110, libressl280))] X509_REVOKED) -> c_int;
600         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;
601         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;
602         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;
603         pub fn X509_REVOKED_get_ext(x: #[const_ptr_if(any(ossl110, libressl280))] X509_REVOKED, loc: c_int) -> *mut X509_EXTENSION;
604         pub fn X509_REVOKED_get_ext_d2i(
605             x: #[const_ptr_if(any(ossl110, libressl280))] ::X509_REVOKED,
606             nid: c_int,
607             crit: *mut c_int,
608             idx: *mut c_int,
609         ) -> *mut c_void;
610         // X509_EXTENSION stack
611         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;
612         // X509_EXTENSION itself
613         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;
614         pub fn X509_EXTENSION_set_object(ex: *mut X509_EXTENSION, obj: #[const_ptr_if(any(ossl110, libressl280))] ASN1_OBJECT) -> c_int;
615         pub fn X509_EXTENSION_get_critical(ex: #[const_ptr_if(any(ossl110, libressl280))] X509_EXTENSION) -> c_int;
616     }
617 }
618 
619 extern "C" {
X509_verify_cert(ctx: *mut X509_STORE_CTX) -> c_int620     pub fn X509_verify_cert(ctx: *mut X509_STORE_CTX) -> c_int;
621 }
622 
623 const_ptr_api! {
624     extern "C" {
625         #[cfg(any(ossl110, libressl270))]
626         pub fn X509_STORE_get0_objects(ctx: #[const_ptr_if(ossl300)] X509_STORE) -> *mut stack_st_X509_OBJECT;
627     }
628 }
629 #[cfg(any(ossl110, libressl270))]
630 extern "C" {
X509_OBJECT_get0_X509(x: *const X509_OBJECT) -> *mut X509631     pub fn X509_OBJECT_get0_X509(x: *const X509_OBJECT) -> *mut X509;
632 }
633 
634 cfg_if! {
635     if #[cfg(ossl110)] {
636         extern "C" {
637             pub fn X509_OBJECT_free(a: *mut X509_OBJECT);
638         }
639     } else {
640         extern "C" {
641             pub fn X509_OBJECT_free_contents(a: *mut X509_OBJECT);
642         }
643     }
644 }
645 
646 extern "C" {
X509_get_default_cert_file_env() -> *const c_char647     pub fn X509_get_default_cert_file_env() -> *const c_char;
X509_get_default_cert_file() -> *const c_char648     pub fn X509_get_default_cert_file() -> *const c_char;
X509_get_default_cert_dir_env() -> *const c_char649     pub fn X509_get_default_cert_dir_env() -> *const c_char;
X509_get_default_cert_dir() -> *const c_char650     pub fn X509_get_default_cert_dir() -> *const c_char;
651 }
652