Commit b4c735e8 authored by Steven Fackler's avatar Steven Fackler
Browse files

Initial support for OpenSSL 3.0.0-alpha1

parent e446d819
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -31,6 +31,9 @@ pub fn get(openssl_version: Option<u64>, libressl_version: Option<u64>) -> Vec<&
    } else {
        let openssl_version = openssl_version.unwrap();

        if openssl_version >= 0x3_00_00_00_0 {
            cfgs.push("ossl300");
        }
        if openssl_version >= 0x1_00_01_00_0 {
            cfgs.push("ossl101");
        }
+5 −0
Original line number Diff line number Diff line
@@ -4,8 +4,13 @@
#define VERSION2(n, v) RUST_VERSION_##n##_##v
#define VERSION(n, v) VERSION2(n, v)

#define NEW_VERSION2(a, b, c) RUST_VERSION_NEW_OPENSSL_##a##_##b##_##c
#define NEW_VERSION(a, b, c) NEW_VERSION2(a, b, c)

#ifdef LIBRESSL_VERSION_NUMBER
VERSION(LIBRESSL, LIBRESSL_VERSION_NUMBER)
#elif defined OPENSSL_VERSION_MAJOR
NEW_VERSION(OPENSSL_VERSION_MAJOR, OPENSSL_VERSION_MINOR, OPENSSL_VERSION_PATCH)
#else
VERSION(OPENSSL, OPENSSL_VERSION_NUMBER)
#endif
+18 −1
Original line number Diff line number Diff line
@@ -170,11 +170,15 @@ See rust-openssl README for more information:
        let line = line.trim();

        let openssl_prefix = "RUST_VERSION_OPENSSL_";
        let new_openssl_prefix = "RUST_VERSION_NEW_OPENSSL_";
        let libressl_prefix = "RUST_VERSION_LIBRESSL_";
        let conf_prefix = "RUST_CONF_";
        if line.starts_with(openssl_prefix) {
            let version = &line[openssl_prefix.len()..];
            openssl_version = Some(parse_version(version));
        } else if line.starts_with(new_openssl_prefix) {
            let version = &line[new_openssl_prefix.len()..];
            openssl_version = Some(parse_new_version(version));
        } else if line.starts_with(libressl_prefix) {
            let version = &line[libressl_prefix.len()..];
            libressl_version = Some(parse_version(version));
@@ -228,8 +232,10 @@ See rust-openssl README for more information:
        let openssl_version = openssl_version.unwrap();
        println!("cargo:version_number={:x}", openssl_version);

        if openssl_version >= 0x1_01_02_00_0 {
        if openssl_version >= 0x4_00_00_00_0 {
            version_error()
        } else if openssl_version >= 0x3_00_00_00_0 {
            Version::Openssl11x
        } else if openssl_version >= 0x1_01_01_00_0 {
            println!("cargo:version=111");
            Version::Openssl11x
@@ -280,6 +286,17 @@ fn parse_version(version: &str) -> u64 {
    u64::from_str_radix(version, 16).unwrap()
}

// parses a string that looks like 3_0_0
fn parse_new_version(version: &str) -> u64 {
    println!("version: {}", version);
    let mut it = version.split('_');
    let major = it.next().unwrap().parse::<u64>().unwrap();
    let minor = it.next().unwrap().parse::<u64>().unwrap();
    let patch = it.next().unwrap().parse::<u64>().unwrap();

    (major << 28) | (minor << 20) | (patch << 4)
}

/// Given a libdir for OpenSSL (where artifacts are located) as well as the name
/// of the libraries we're linking to, figure out whether we should link them
/// statically or dynamically.
+14 −2
Original line number Diff line number Diff line
@@ -6,9 +6,21 @@ pub enum CMS_ContentInfo {}
extern "C" {
    #[cfg(ossl101)]
    pub fn CMS_ContentInfo_free(cms: *mut ::CMS_ContentInfo);
    #[cfg(ossl101)]
}

cfg_if! {
    if #[cfg(ossl300)] {
        extern "C" {
            pub fn i2d_CMS_ContentInfo(a: *const ::CMS_ContentInfo, pp: *mut *mut c_uchar) -> c_int;
        }
    } else if #[cfg(ossl101)] {
        extern "C" {
            pub fn i2d_CMS_ContentInfo(a: *mut ::CMS_ContentInfo, pp: *mut *mut c_uchar) -> c_int;
        }
    }
}

extern "C" {
    #[cfg(ossl101)]
    pub fn d2i_CMS_ContentInfo(
        a: *mut *mut ::CMS_ContentInfo,
+14 −1
Original line number Diff line number Diff line
@@ -31,8 +31,21 @@ pub struct ERR_STRING_DATA {
    pub string: *const c_char,
}

cfg_if! {
    if #[cfg(ossl300)] {
        extern "C" {
            pub fn ERR_new();
            pub fn ERR_set_debug(file: *const c_char, line: c_int, func: *const c_char);
            pub fn ERR_set_error(lib: c_int, reason: c_int, fmt: *const c_char, ...);
        }
    } else {
        extern "C" {
            pub fn ERR_put_error(lib: c_int, func: c_int, reason: c_int, file: *const c_char, line: c_int);
        }
    }
}

extern "C" {
    pub fn ERR_set_error_data(data: *mut c_char, flags: c_int);

    pub fn ERR_get_error() -> c_ulong;
Loading