Unverified Commit 079e9fe6 authored by Steven Fackler's avatar Steven Fackler Committed by GitHub
Browse files

Merge pull request #1629 from vishwin/master

Fix up LibreSSL bits
parents e76289f6 adea4b99
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -174,6 +174,11 @@ jobs:
              library:
                name: libressl
                version: 2.5.5
            - target: x86_64-unknown-linux-gnu
              bindgen: true
              library:
                name: libressl
                version: 3.4.3
            - target: x86_64-unknown-linux-gnu
              bindgen: true
              library:
@@ -184,6 +189,11 @@ jobs:
              library:
                name: libressl
                version: 2.5.5
            - target: x86_64-unknown-linux-gnu
              bindgen: false
              library:
                name: libressl
                version: 3.4.3
            - target: x86_64-unknown-linux-gnu
              bindgen: false
              library:
+6 −0
Original line number Diff line number Diff line
@@ -7,6 +7,9 @@ pub fn get(openssl_version: Option<u64>, libressl_version: Option<u64>) -> Vec<&
        if libressl_version >= 0x2_05_01_00_0 {
            cfgs.push("libressl251");
        }
        if libressl_version >= 0x2_05_02_00_0 {
            cfgs.push("libressl252");
        }
        if libressl_version >= 0x2_06_01_00_0 {
            cfgs.push("libressl261");
        }
@@ -34,6 +37,9 @@ pub fn get(openssl_version: Option<u64>, libressl_version: Option<u64>) -> Vec<&
        if libressl_version >= 0x3_03_02_00_0 {
            cfgs.push("libressl332");
        }
        if libressl_version >= 0x3_04_00_00_0 {
            cfgs.push("libressl340");
        }
        if libressl_version >= 0x3_05_00_00_0 {
            cfgs.push("libressl350");
        }
+22 −19
Original line number Diff line number Diff line
@@ -411,13 +411,13 @@ extern "C" {
    #[cfg(ossl111)]
    pub fn SSL_CTX_set_keylog_callback(ctx: *mut SSL_CTX, cb: SSL_CTX_keylog_cb_func);

    #[cfg(ossl111)]
    #[cfg(any(ossl111, libressl340))]
    pub fn SSL_CTX_set_max_early_data(ctx: *mut SSL_CTX, max_early_data: u32) -> c_int;
    #[cfg(ossl111)]
    #[cfg(any(ossl111, libressl340))]
    pub fn SSL_CTX_get_max_early_data(ctx: *const SSL_CTX) -> u32;
    #[cfg(ossl111)]
    #[cfg(any(ossl111, libressl340))]
    pub fn SSL_set_max_early_data(ctx: *mut SSL, max_early_data: u32) -> c_int;
    #[cfg(ossl111)]
    #[cfg(any(ossl111, libressl340))]
    pub fn SSL_get_max_early_data(ctx: *const SSL) -> u32;

    pub fn SSL_get_finished(s: *const SSL, buf: *mut c_void, count: size_t) -> size_t;
@@ -439,6 +439,8 @@ cfg_if! {
        extern "C" {
            pub fn SSL_CTX_set_min_proto_version(ctx: *mut ::SSL_CTX, version: u16) -> c_int;
            pub fn SSL_CTX_set_max_proto_version(ctx: *mut ::SSL_CTX, version: u16) -> c_int;
            pub fn SSL_set_min_proto_version(s: *mut SSL, version: u16) -> c_int;
            pub fn SSL_set_max_proto_version(s: *mut SSL, version: u16) -> c_int;
        }
    }
}
@@ -448,6 +450,8 @@ cfg_if! {
        extern "C" {
            pub fn SSL_CTX_get_min_proto_version(ctx: *mut ::SSL_CTX) -> c_int;
            pub fn SSL_CTX_get_max_proto_version(ctx: *mut ::SSL_CTX) -> c_int;
            pub fn SSL_get_min_proto_version(s: *mut SSL) -> c_int;
            pub fn SSL_get_max_proto_version(s: *mut SSL) -> c_int;
        }
    }
}
@@ -482,9 +486,9 @@ extern "C" {
    pub fn SSL_set_bio(ssl: *mut SSL, rbio: *mut BIO, wbio: *mut BIO);
    pub fn SSL_get_rbio(ssl: *const SSL) -> *mut BIO;
    pub fn SSL_get_wbio(ssl: *const SSL) -> *mut BIO;
    #[cfg(ossl111)]
    #[cfg(any(ossl111, libressl340))]
    pub fn SSL_CTX_set_ciphersuites(ctx: *mut SSL_CTX, str: *const c_char) -> c_int;
    #[cfg(ossl111)]
    #[cfg(any(ossl111, libressl340))]
    pub fn SSL_set_ciphersuites(ssl: *mut ::SSL, str: *const c_char) -> c_int;
    pub fn SSL_set_verify(
        ssl: *mut SSL,
@@ -518,12 +522,12 @@ extern "C" {

    pub fn SSL_SESSION_get_time(s: *const SSL_SESSION) -> c_long;
    pub fn SSL_SESSION_get_timeout(s: *const SSL_SESSION) -> c_long;
    #[cfg(ossl110)]
    #[cfg(any(ossl110, libressl270))]
    pub fn SSL_SESSION_get_protocol_version(s: *const SSL_SESSION) -> c_int;

    #[cfg(ossl111)]
    #[cfg(any(ossl111, libressl340))]
    pub fn SSL_SESSION_set_max_early_data(ctx: *mut SSL_SESSION, max_early_data: u32) -> c_int;
    #[cfg(ossl111)]
    #[cfg(any(ossl111, libressl340))]
    pub fn SSL_SESSION_get_max_early_data(ctx: *const SSL_SESSION) -> u32;

    pub fn SSL_SESSION_get_id(s: *const SSL_SESSION, len: *mut c_uint) -> *const c_uchar;
@@ -560,7 +564,7 @@ extern "C" {
    );
    pub fn SSL_CTX_set_verify_depth(ctx: *mut SSL_CTX, depth: c_int);

    #[cfg(ossl111)]
    #[cfg(any(ossl111, libressl340))]
    pub fn SSL_CTX_set_post_handshake_auth(ctx: *mut SSL_CTX, val: c_int);

    pub fn SSL_CTX_check_private_key(ctx: *const SSL_CTX) -> c_int;
@@ -626,7 +630,7 @@ extern "C" {
    pub fn SSL_connect(ssl: *mut SSL) -> c_int;
    pub fn SSL_read(ssl: *mut SSL, buf: *mut c_void, num: c_int) -> c_int;
    pub fn SSL_peek(ssl: *mut SSL, buf: *mut c_void, num: c_int) -> c_int;
    #[cfg(ossl111)]
    #[cfg(any(ossl111, libressl340))]
    pub fn SSL_read_early_data(
        s: *mut ::SSL,
        buf: *mut c_void,
@@ -637,7 +641,7 @@ extern "C" {

extern "C" {
    pub fn SSL_write(ssl: *mut SSL, buf: *const c_void, num: c_int) -> c_int;
    #[cfg(ossl111)]
    #[cfg(any(ossl111, libressl340))]
    pub fn SSL_write_early_data(
        s: *mut SSL,
        buf: *const c_void,
@@ -699,7 +703,6 @@ extern "C" {

    pub fn SSL_CTX_set_client_CA_list(ctx: *mut SSL_CTX, list: *mut stack_st_X509_NAME);

    #[cfg(not(libressl))]
    pub fn SSL_CTX_add_client_CA(ctx: *mut SSL_CTX, cacert: *mut X509) -> c_int;

    pub fn SSL_CTX_set_default_verify_paths(ctx: *mut SSL_CTX) -> c_int;
@@ -738,9 +741,9 @@ const_ptr_api! {
}

extern "C" {
    #[cfg(ossl102)]
    #[cfg(any(ossl102, libressl270))]
    pub fn SSL_CTX_get0_certificate(ctx: *const SSL_CTX) -> *mut X509;
    #[cfg(ossl102)]
    #[cfg(any(ossl102, libressl340))]
    pub fn SSL_CTX_get0_privatekey(ctx: *const SSL_CTX) -> *mut EVP_PKEY;

    pub fn SSL_set_shutdown(ss: *mut SSL, mode: c_int);
@@ -754,9 +757,9 @@ extern "C" {
    #[cfg(ossl110)]
    pub fn SSL_get0_verified_chain(ssl: *const SSL) -> *mut stack_st_X509;

    #[cfg(ossl110)]
    #[cfg(any(ossl110, libressl270))]
    pub fn SSL_get_client_random(ssl: *const SSL, out: *mut c_uchar, len: size_t) -> size_t;
    #[cfg(ossl110)]
    #[cfg(any(ossl110, libressl270))]
    pub fn SSL_get_server_random(ssl: *const SSL, out: *mut c_uchar, len: size_t) -> size_t;
    #[cfg(any(ossl110, libressl273))]
    pub fn SSL_SESSION_get_master_key(
@@ -863,9 +866,9 @@ extern "C" {
}

extern "C" {
    #[cfg(ossl110)]
    #[cfg(any(ossl110, libressl270))]
    pub fn SSL_CIPHER_get_cipher_nid(c: *const SSL_CIPHER) -> c_int;
    #[cfg(ossl110)]
    #[cfg(any(ossl110, libressl270))]
    pub fn SSL_CIPHER_get_digest_nid(c: *const SSL_CIPHER) -> c_int;
}

+51 −50
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ use std::ptr;

use *;

#[cfg(not(any(libressl, ossl110)))]
#[cfg(not(ossl110))]
pub const SSL_MAX_KRB5_PRINCIPAL_LENGTH: c_int = 256;

#[cfg(not(ossl110))]
@@ -11,7 +11,7 @@ pub const SSL_MAX_SSL_SESSION_ID_LENGTH: c_int = 32;
#[cfg(not(ossl110))]
pub const SSL_MAX_SID_CTX_LENGTH: c_int = 32;

#[cfg(not(any(libressl, ossl110)))]
#[cfg(not(ossl110))]
pub const SSL_MAX_KEY_ARG_LENGTH: c_int = 8;
#[cfg(not(ossl110))]
pub const SSL_MAX_MASTER_KEY_LENGTH: c_int = 48;
@@ -139,7 +139,7 @@ cfg_if! {
        pub const SSL_OP_NO_DTLSv1_2: ssl_op_type!() = 0x80000000;
    }
}
#[cfg(ossl111)]
#[cfg(any(ossl111, libressl340))]
pub const SSL_OP_NO_TLSv1_3: ssl_op_type!() = 0x20000000;

#[cfg(ossl110h)]
@@ -337,7 +337,7 @@ pub const SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP: c_int = 71;
#[cfg(any(libressl, all(ossl101, not(ossl110))))]
pub const SSL_CTRL_CLEAR_OPTIONS: c_int = 77;
pub const SSL_CTRL_GET_EXTRA_CHAIN_CERTS: c_int = 82;
#[cfg(ossl111)]
#[cfg(any(ossl111, libressl252))]
pub const SSL_CTRL_SET_GROUPS_LIST: c_int = 92;
#[cfg(any(libressl, all(ossl102, not(ossl110))))]
pub const SSL_CTRL_SET_ECDH_AUTO: c_int = 94;
@@ -347,13 +347,13 @@ pub const SSL_CTRL_SET_SIGALGS_LIST: c_int = 98;
pub const SSL_CTRL_SET_VERIFY_CERT_STORE: c_int = 106;
#[cfg(ossl110)]
pub const SSL_CTRL_GET_EXTMS_SUPPORT: c_int = 122;
#[cfg(ossl110)]
#[cfg(any(ossl110, libressl261))]
pub const SSL_CTRL_SET_MIN_PROTO_VERSION: c_int = 123;
#[cfg(ossl110)]
#[cfg(any(ossl110, libressl261))]
pub const SSL_CTRL_SET_MAX_PROTO_VERSION: c_int = 124;
#[cfg(ossl110g)]
#[cfg(any(ossl110g, libressl270))]
pub const SSL_CTRL_GET_MIN_PROTO_VERSION: c_int = 130;
#[cfg(ossl110g)]
#[cfg(any(ossl110g, libressl270))]
pub const SSL_CTRL_GET_MAX_PROTO_VERSION: c_int = 131;

pub unsafe fn SSL_CTX_set_tmp_dh(ctx: *mut SSL_CTX, dh: *mut DH) -> c_long {
@@ -388,7 +388,8 @@ pub unsafe fn SSL_CTX_set0_verify_cert_store(ctx: *mut SSL_CTX, st: *mut X509_ST
    SSL_CTX_ctrl(ctx, SSL_CTRL_SET_VERIFY_CERT_STORE, 0, st as *mut c_void)
}

#[cfg(ossl111)]
cfg_if! {
    if #[cfg(ossl111)] {
        pub unsafe fn SSL_CTX_set1_groups_list(ctx: *mut SSL_CTX, s: *const c_char) -> c_long {
            SSL_CTX_ctrl(
                ctx,
@@ -397,6 +398,12 @@ pub unsafe fn SSL_CTX_set1_groups_list(ctx: *mut SSL_CTX, s: *const c_char) -> c
                s as *const c_void as *mut c_void,
            )
        }
    } else if #[cfg(libressl251)] {
        extern "C" {
            pub fn SSL_CTX_set1_groups_list(ctx: *mut SSL_CTX, s: *const c_char) -> c_int;
        }
    }
}

#[cfg(ossl102)]
pub unsafe fn SSL_CTX_set1_sigalgs_list(ctx: *mut SSL_CTX, s: *const c_char) -> c_long {
@@ -418,7 +425,7 @@ pub unsafe fn SSL_CTX_set_ecdh_auto(ctx: *mut SSL_CTX, onoff: c_int) -> c_int {
    ) as c_int
}

#[cfg(any(libress, all(ossl102, not(ossl110))))]
#[cfg(any(libressl, all(ossl102, not(ossl110))))]
pub unsafe fn SSL_set_ecdh_auto(ssl: *mut ::SSL, onoff: c_int) -> c_int {
    SSL_ctrl(
        ssl,
@@ -447,22 +454,7 @@ cfg_if! {
                ptr::null_mut(),
            ) as c_int
        }
    }
}

cfg_if! {
    if #[cfg(ossl110g)] {
        pub unsafe fn SSL_CTX_get_min_proto_version(ctx: *mut SSL_CTX) -> c_int {
            SSL_CTX_ctrl(ctx, SSL_CTRL_GET_MIN_PROTO_VERSION, 0, ptr::null_mut()) as c_int
        }

        pub unsafe fn SSL_CTX_get_max_proto_version(ctx: *mut SSL_CTX) -> c_int {
            SSL_CTX_ctrl(ctx, SSL_CTRL_GET_MAX_PROTO_VERSION, 0, ptr::null_mut()) as c_int
        }
    }
}

#[cfg(ossl110)]
        pub unsafe fn SSL_set_min_proto_version(s: *mut SSL, version: c_int) -> c_int {
            SSL_ctrl(
                s,
@@ -472,7 +464,6 @@ pub unsafe fn SSL_set_min_proto_version(s: *mut SSL, version: c_int) -> c_int {
            ) as c_int
        }

#[cfg(ossl110)]
        pub unsafe fn SSL_set_max_proto_version(s: *mut SSL, version: c_int) -> c_int {
            SSL_ctrl(
                s,
@@ -481,16 +472,26 @@ pub unsafe fn SSL_set_max_proto_version(s: *mut SSL, version: c_int) -> c_int {
                ptr::null_mut(),
            ) as c_int
        }
    }
}

#[cfg(ossl110g)]
cfg_if! {
    if #[cfg(ossl110g)] {
        pub unsafe fn SSL_CTX_get_min_proto_version(ctx: *mut SSL_CTX) -> c_int {
            SSL_CTX_ctrl(ctx, SSL_CTRL_GET_MIN_PROTO_VERSION, 0, ptr::null_mut()) as c_int
        }

        pub unsafe fn SSL_CTX_get_max_proto_version(ctx: *mut SSL_CTX) -> c_int {
            SSL_CTX_ctrl(ctx, SSL_CTRL_GET_MAX_PROTO_VERSION, 0, ptr::null_mut()) as c_int
        }
        pub unsafe fn SSL_get_min_proto_version(s: *mut SSL) -> c_int {
            SSL_ctrl(s, SSL_CTRL_GET_MIN_PROTO_VERSION, 0, ptr::null_mut()) as c_int
        }

#[cfg(ossl110g)]
        pub unsafe fn SSL_get_max_proto_version(s: *mut SSL) -> c_int {
            SSL_ctrl(s, SSL_CTRL_GET_MAX_PROTO_VERSION, 0, ptr::null_mut()) as c_int
        }
    }
}

#[cfg(ossl111)]
pub const SSL_CLIENT_HELLO_SUCCESS: c_int = 1;
@@ -499,11 +500,11 @@ pub const SSL_CLIENT_HELLO_ERROR: c_int = 0;
#[cfg(ossl111)]
pub const SSL_CLIENT_HELLO_RETRY: c_int = -1;

#[cfg(ossl111)]
#[cfg(any(ossl111, libressl340))]
pub const SSL_READ_EARLY_DATA_ERROR: c_int = 0;
#[cfg(ossl111)]
#[cfg(any(ossl111, libressl340))]
pub const SSL_READ_EARLY_DATA_SUCCESS: c_int = 1;
#[cfg(ossl111)]
#[cfg(any(ossl111, libressl340))]
pub const SSL_READ_EARLY_DATA_FINISH: c_int = 2;

cfg_if! {
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ use *;
pub const TLS1_VERSION: c_int = 0x301;
pub const TLS1_1_VERSION: c_int = 0x302;
pub const TLS1_2_VERSION: c_int = 0x303;
#[cfg(ossl111)]
#[cfg(any(ossl111, libressl340))]
pub const TLS1_3_VERSION: c_int = 0x304;

pub const TLS1_AD_DECODE_ERROR: c_int = 50;
Loading