Unverified Commit c4d4c659 authored by Steven Fackler's avatar Steven Fackler
Browse files

Add provider support

parent 52a7192d
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -39,9 +39,13 @@ const INCLUDES: &str = "
#include <openssl/cms.h>
#endif

#if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x010100000
#if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x10100000
#include <openssl/kdf.h>
#endif

#if OPENSSL_VERSION_NUMBER >= 0x30000000
#include <openssl/provider.h>
#endif
";

pub fn run(include_dirs: &[PathBuf]) {
+2 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ pub use handwritten::ocsp::*;
pub use handwritten::pem::*;
pub use handwritten::pkcs12::*;
pub use handwritten::pkcs7::*;
pub use handwritten::provider::*;
pub use handwritten::rand::*;
pub use handwritten::rsa::*;
pub use handwritten::safestack::*;
@@ -49,6 +50,7 @@ mod ocsp;
mod pem;
mod pkcs12;
mod pkcs7;
mod provider;
mod rand;
mod rsa;
mod safestack;
+15 −0
Original line number Diff line number Diff line
use libc::*;
use *;

extern "C" {
    #[cfg(ossl300)]
    pub fn OSSL_PROVIDER_load(ctx: *mut OSSL_LIB_CTX, name: *const c_char) -> *mut OSSL_PROVIDER;
    #[cfg(ossl300)]
    pub fn OSSL_PROVIDER_try_load(
        ctx: *mut OSSL_LIB_CTX,
        name: *const c_char,
        retain_fallbacks: c_int,
    ) -> *mut OSSL_PROVIDER;
    #[cfg(ossl300)]
    pub fn OSSL_PROVIDER_unload(prov: *mut OSSL_PROVIDER) -> c_int;
}
+3 −0
Original line number Diff line number Diff line
@@ -1071,5 +1071,8 @@ cfg_if! {

pub enum OCSP_RESPONSE {}

#[cfg(ossl300)]
pub enum OSSL_PROVIDER {}

#[cfg(ossl300)]
pub enum OSSL_LIB_CTX {}
+3 −1
Original line number Diff line number Diff line
@@ -237,8 +237,10 @@ mod test {
    use crate::x509::X509;

    #[test]
    #[cfg_attr(ossl300, ignore)] // 3.0.0 can't load RC2-40-CBC
    fn cms_encrypt_decrypt() {
        #[cfg(ossl300)]
        let _provider = crate::provider::Provider::try_load(None, "legacy", true).unwrap();

        // load cert with public key only
        let pub_cert_bytes = include_bytes!("../test/cms_pubkey.der");
        let pub_cert = X509::from_der(pub_cert_bytes).expect("failed to load pub cert");
Loading