From 3a4f96a73dd422301ee49902bfeeb61572be9bc8 Mon Sep 17 00:00:00 2001 From: Josh Robson Chase Date: Fri, 7 Jun 2019 10:26:17 -0400 Subject: [PATCH] Add basic bindings to the API CRLs --- openssl-sys/src/ossl_typ.rs | 2 -- openssl-sys/src/pem.rs | 7 ++++ openssl-sys/src/x509.rs | 71 +++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 2 deletions(-) diff --git a/openssl-sys/src/ossl_typ.rs b/openssl-sys/src/ossl_typ.rs index 449ecd91..b67b029e 100644 --- a/openssl-sys/src/ossl_typ.rs +++ b/openssl-sys/src/ossl_typ.rs @@ -341,8 +341,6 @@ cfg_if! { } } } -pub enum X509_CRL {} -stack!(stack_st_X509_CRL); pub enum X509_NAME {} diff --git a/openssl-sys/src/pem.rs b/openssl-sys/src/pem.rs index 7e7c6f11..3cdc8982 100644 --- a/openssl-sys/src/pem.rs +++ b/openssl-sys/src/pem.rs @@ -19,6 +19,13 @@ extern "C" { user_data: *mut c_void, ) -> *mut X509; pub fn PEM_write_bio_X509(bio: *mut BIO, x509: *mut X509) -> c_int; + pub fn PEM_read_bio_X509_CRL( + bio: *mut BIO, + out: *mut *mut X509_CRL, + callback: pem_password_cb, + user_data: *mut c_void, + ) -> *mut X509_CRL; + pub fn PEM_write_bio_X509_CRL(bio: *mut BIO, x509: *mut X509_CRL) -> c_int; pub fn PEM_read_bio_X509_REQ( bio: *mut BIO, out: *mut *mut X509_REQ, diff --git a/openssl-sys/src/x509.rs b/openssl-sys/src/x509.rs index fc6e4269..3752af18 100644 --- a/openssl-sys/src/x509.rs +++ b/openssl-sys/src/x509.rs @@ -37,6 +37,54 @@ cfg_if! { } } +pub enum X509_REVOKED {} +stack!(stack_st_X509_REVOKED); + +cfg_if! { + if #[cfg(ossl110)] { + pub enum X509_CRL {} + } else { + #[repr(C)] + pub struct X509_CRL { + pub crl: *mut X509_CRL_INFO, + sig_alg: *mut X509_ALGOR, + signature: *mut c_void, + references: c_int, + flags: c_int, + akid: *mut c_void, + idp: *mut c_void, + idp_flags: c_int, + idp_reasons: c_int, + crl_number: *mut ASN1_INTEGER, + base_crl_number: *mut ASN1_INTEGER, + sha1_hash: [c_uchar; 20], + issuers: *mut c_void, + meth: *const c_void, + meth_data: *mut c_void, + } + } +} + +stack!(stack_st_X509_CRL); + +cfg_if! { + if #[cfg(ossl110)] { + pub enum X509_CRL_INFO {} + } else { + #[repr(C)] + pub struct X509_CRL_INFO { + version: *mut ASN1_INTEGER, + sig_alg: *mut X509_ALGOR, + pub issuer: *mut X509_NAME, + pub lastUpdate: *mut ASN1_TIME, + pub nextUpdate: *mut ASN1_TIME, + revoked: *mut stack_st_X509_REVOKED, + extensions: *mut stack_st_X509_EXTENSION, + enc: ASN1_ENCODING, + } + } +} + cfg_if! { if #[cfg(ossl110)] { pub enum X509_REQ {} @@ -177,6 +225,15 @@ extern "C" { pub fn X509_ALGOR_free(x: *mut X509_ALGOR); + pub fn X509_CRL_new() -> *mut X509_CRL; + pub fn X509_CRL_free(x: *mut X509_CRL); + pub fn d2i_X509_CRL( + a: *mut *mut X509_CRL, + pp: *mut *const c_uchar, + length: c_long, + ) -> *mut X509_CRL; + pub fn i2d_X509_CRL(x: *mut X509_CRL, buf: *mut *mut u8) -> c_int; + pub fn X509_REQ_new() -> *mut X509_REQ; pub fn X509_REQ_free(x: *mut X509_REQ); pub fn d2i_X509_REQ( @@ -290,6 +347,20 @@ extern "C" { #[cfg(any(ossl110, libressl273))] pub fn X509_up_ref(x: *mut X509) -> c_int; + pub fn X509_CRL_verify(req: *mut X509_CRL, pkey: *mut EVP_PKEY) -> c_int; + pub fn X509_CRL_get0_by_serial( + x: *mut X509_CRL, + ret: *mut *mut X509_REVOKED, + serial: *mut ASN1_INTEGER, + ) -> c_int; + + #[cfg(ossl110)] + pub fn X509_CRL_get0_nextUpdate(x: *const X509_CRL) -> *const ASN1_TIME; + #[cfg(ossl110)] + pub fn X509_CRL_get0_lastUpdate(x: *const X509_CRL) -> *const ASN1_TIME; + #[cfg(ossl110)] + pub fn X509_CRL_get_issuer(x: *const X509_CRL) -> *mut X509_NAME; + #[cfg(ossl110)] pub fn X509_get0_extensions(req: *const ::X509) -> *const stack_st_X509_EXTENSION; }