Skip to content

Commit 43fab3b

Browse files
krisztian-kovacsJonas Maier
authored andcommitted
openssl-sys: add wrappers for timestamping functions
1 parent 10dba51 commit 43fab3b

File tree

3 files changed

+111
-1
lines changed

3 files changed

+111
-1
lines changed

openssl-sys/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ mod openssl {
6262
pub use self::ssl::*;
6363
pub use self::ssl3::*;
6464
pub use self::tls1::*;
65+
pub use self::ts::*;
6566
pub use self::types::*;
6667
pub use self::x509::*;
6768
pub use self::x509_vfy::*;
@@ -92,6 +93,7 @@ mod openssl {
9293
mod ssl;
9394
mod ssl3;
9495
mod tls1;
96+
mod ts;
9597
mod types;
9698
mod x509;
9799
mod x509_vfy;

openssl-sys/src/ts.rs

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
use libc::*;
2+
3+
#[allow(unused_imports)]
4+
use *;
5+
6+
pub enum TS_MSG_IMPRINT {}
7+
pub enum TS_REQ {}
8+
pub enum TS_RESP {}
9+
10+
cfg_if! {
11+
if #[cfg(ossl110)] {
12+
pub enum TS_VERIFY_CTX {}
13+
} else {
14+
#[repr(C)]
15+
pub struct TS_VERIFY_CTX {
16+
flags: c_uint,
17+
store: *mut X509_STORE,
18+
certs: *mut stack_st_X509,
19+
policy: *mut ASN1_OBJECT,
20+
md_alg: *mut X509_ALGOR,
21+
imprint: *mut c_uchar,
22+
imprint_len: c_uint,
23+
data: *mut BIO,
24+
nonce: *mut ASN1_INTEGER,
25+
tsa_name: *mut GENERAL_NAME,
26+
}
27+
}
28+
}
29+
30+
pub const TS_VFY_SIGNATURE: c_uint = 0x1;
31+
pub const TS_VFY_VERSION: c_uint = 0x2;
32+
pub const TS_VFY_POLICY: c_uint = 0x4;
33+
pub const TS_VFY_IMPRINT: c_uint = 0x8;
34+
pub const TS_VFY_DATA: c_uint = 0x10;
35+
pub const TS_VFY_NONCE: c_uint = 0x20;
36+
pub const TS_VFY_SIGNER: c_uint = 0x40;
37+
pub const TS_VFY_TSA_NAME: c_uint = 0x80;
38+
39+
pub const TS_VFY_ALL_IMPRINT: c_uint = TS_VFY_SIGNATURE
40+
| TS_VFY_VERSION
41+
| TS_VFY_POLICY
42+
| TS_VFY_IMPRINT
43+
| TS_VFY_NONCE
44+
| TS_VFY_SIGNER
45+
| TS_VFY_TSA_NAME;
46+
pub const TS_VFY_ALL_DATA: c_uint = TS_VFY_SIGNATURE
47+
| TS_VFY_VERSION
48+
| TS_VFY_POLICY
49+
| TS_VFY_DATA
50+
| TS_VFY_NONCE
51+
| TS_VFY_SIGNER
52+
| TS_VFY_TSA_NAME;
53+
54+
extern "C" {
55+
pub fn TS_MSG_IMPRINT_new() -> *mut TS_MSG_IMPRINT;
56+
pub fn TS_MSG_IMPRINT_free(a: *mut TS_MSG_IMPRINT);
57+
pub fn TS_MSG_IMPRINT_set_algo(a: *mut TS_MSG_IMPRINT, alg: *mut X509_ALGOR) -> c_int;
58+
pub fn TS_MSG_IMPRINT_set_msg(a: *mut TS_MSG_IMPRINT, d: *mut c_uchar, length: c_int) -> c_int;
59+
60+
pub fn TS_REQ_new() -> *mut TS_REQ;
61+
pub fn TS_REQ_free(a: *mut TS_REQ);
62+
pub fn d2i_TS_REQ(a: *mut *mut TS_REQ, pp: *mut *const c_uchar, length: c_long) -> *mut TS_REQ;
63+
pub fn i2d_TS_REQ(a: *const TS_REQ, pp: *mut *mut c_uchar) -> c_int;
64+
pub fn TS_REQ_set_msg_imprint(a: *mut TS_REQ, msg_imprint: *mut TS_MSG_IMPRINT) -> c_int;
65+
pub fn TS_REQ_set_nonce(a: *mut TS_REQ, nonce: *const ASN1_INTEGER) -> c_int;
66+
pub fn TS_REQ_set_cert_req(a: *mut TS_REQ, cert_req: c_int) -> c_int;
67+
68+
pub fn TS_RESP_new() -> *mut TS_RESP;
69+
pub fn TS_RESP_free(a: *mut TS_RESP);
70+
pub fn d2i_TS_RESP(
71+
a: *mut *mut TS_RESP,
72+
pp: *mut *const c_uchar,
73+
length: c_long,
74+
) -> *mut TS_RESP;
75+
pub fn i2d_TS_RESP(a: *const TS_RESP, pp: *mut *mut c_uchar) -> c_int;
76+
77+
pub fn TS_VERIFY_CTX_new() -> *mut TS_VERIFY_CTX;
78+
pub fn TS_VERIFY_CTX_free(ctx: *mut TS_VERIFY_CTX);
79+
#[cfg(ossl110)]
80+
pub fn TS_VERIFY_CTX_set_imprint(
81+
ctx: *mut TS_VERIFY_CTX,
82+
hexstr: *mut c_uchar,
83+
length: c_long,
84+
) -> *mut c_uchar;
85+
pub fn TS_RESP_verify_response(ctx: *mut TS_VERIFY_CTX, response: *mut TS_RESP) -> c_int;
86+
87+
pub fn TS_REQ_to_TS_VERIFY_CTX(req: *mut TS_REQ, ctx: *mut TS_VERIFY_CTX)
88+
-> *mut TS_VERIFY_CTX;
89+
}
90+
91+
cfg_if! {
92+
if #[cfg(any(ossl110, libressl280))] {
93+
extern "C" {
94+
pub fn TS_REQ_set_policy_id(
95+
a: *mut TS_REQ,
96+
policy: *const ASN1_OBJECT
97+
) -> c_int;
98+
}
99+
} else {
100+
extern "C" {
101+
pub fn TS_REQ_set_policy_id(
102+
a: *mut TS_REQ,
103+
policy: *mut ASN1_OBJECT
104+
) -> c_int;
105+
}
106+
}
107+
}

systest/build.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ fn main() {
6767
.header("openssl/aes.h")
6868
.header("openssl/ocsp.h")
6969
.header("openssl/evp.h")
70-
.header("openssl/x509_vfy.h");
70+
.header("openssl/x509_vfy.h")
71+
.header("openssl/ts.h");
7172

7273
if let Some(version) = libressl_version {
7374
cfg.header("openssl/poly1305.h");

0 commit comments

Comments
 (0)