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

fix constant types

parent 11c5af3e
Loading
Loading
Loading
Loading
+82 −70
Original line number Diff line number Diff line
@@ -253,159 +253,171 @@ pub type SSL_custom_ext_parse_cb_ex = Option<
    ) -> c_int,
>;

pub const SSL_OP_LEGACY_SERVER_CONNECT: c_ulong = 0x00000004;
cfg_if! {
    if #[cfg(ossl300)] {
        macro_rules! ssl_op_type {
            () => {u64};
        }
    } else {
        macro_rules! ssl_op_type {
            () => {c_ulong};
        }
    }
}

pub const SSL_OP_LEGACY_SERVER_CONNECT: ssl_op_type!() = 0x00000004;
cfg_if! {
    if #[cfg(libressl261)] {
        pub const SSL_OP_TLSEXT_PADDING: c_ulong = 0x0;
        pub const SSL_OP_TLSEXT_PADDING: ssl_op_type!() = 0x0;
    } else if #[cfg(any(ossl102, libressl))] {
        pub const SSL_OP_TLSEXT_PADDING: c_ulong = 0x10;
        pub const SSL_OP_TLSEXT_PADDING: ssl_op_type!() = 0x10;
    }
}
#[cfg(ossl101)]
pub const SSL_OP_SAFARI_ECDHE_ECDSA_BUG: c_ulong = 0x00000040;
pub const SSL_OP_SAFARI_ECDHE_ECDSA_BUG: ssl_op_type!() = 0x00000040;

pub const SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: c_ulong = 0x00000800;
pub const SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: ssl_op_type!() = 0x00000800;

pub const SSL_OP_NO_QUERY_MTU: c_ulong = 0x00001000;
pub const SSL_OP_COOKIE_EXCHANGE: c_ulong = 0x00002000;
pub const SSL_OP_NO_TICKET: c_ulong = 0x00004000;
pub const SSL_OP_NO_QUERY_MTU: ssl_op_type!() = 0x00001000;
pub const SSL_OP_COOKIE_EXCHANGE: ssl_op_type!() = 0x00002000;
pub const SSL_OP_NO_TICKET: ssl_op_type!() = 0x00004000;
cfg_if! {
    if #[cfg(ossl101)] {
        pub const SSL_OP_CISCO_ANYCONNECT: c_ulong = 0x00008000;
        pub const SSL_OP_CISCO_ANYCONNECT: ssl_op_type!() = 0x00008000;
    } else {
        pub const SSL_OP_CISCO_ANYCONNECT: c_ulong = 0x0;
        pub const SSL_OP_CISCO_ANYCONNECT: ssl_op_type!() = 0x0;
    }
}

pub const SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: c_ulong = 0x00010000;
pub const SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: ssl_op_type!() = 0x00010000;
cfg_if! {
    if #[cfg(ossl101)] {
        pub const SSL_OP_NO_COMPRESSION: c_ulong = 0x00020000;
        pub const SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: c_ulong = 0x00040000;
        pub const SSL_OP_NO_COMPRESSION: ssl_op_type!() = 0x00020000;
        pub const SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: ssl_op_type!() = 0x00040000;
    } else {
        pub const SSL_OP_NO_COMPRESSION: c_ulong = 0x0;
        pub const SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: c_ulong = 0x0;
        pub const SSL_OP_NO_COMPRESSION: ssl_op_type!() = 0x0;
        pub const SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: ssl_op_type!() = 0x0;
    }
}

#[cfg(ossl111)]
pub const SSL_OP_ENABLE_MIDDLEBOX_COMPAT: c_ulong = 0x00100000;
pub const SSL_OP_ENABLE_MIDDLEBOX_COMPAT: ssl_op_type!() = 0x00100000;

pub const SSL_OP_CIPHER_SERVER_PREFERENCE: c_ulong = 0x00400000;
pub const SSL_OP_CIPHER_SERVER_PREFERENCE: ssl_op_type!() = 0x00400000;
cfg_if! {
    if #[cfg(libressl280)] {
        pub const SSL_OP_TLS_ROLLBACK_BUG: c_ulong = 0;
        pub const SSL_OP_TLS_ROLLBACK_BUG: ssl_op_type!() = 0;
    } else {
        pub const SSL_OP_TLS_ROLLBACK_BUG: c_ulong = 0x00800000;
        pub const SSL_OP_TLS_ROLLBACK_BUG: ssl_op_type!() = 0x00800000;
    }
}

cfg_if! {
    if #[cfg(ossl101)] {
        pub const SSL_OP_NO_SSLv3: c_ulong = 0x02000000;
        pub const SSL_OP_NO_SSLv3: ssl_op_type!() = 0x02000000;
    } else {
        pub const SSL_OP_NO_SSLv3: c_ulong = 0x0;
        pub const SSL_OP_NO_SSLv3: ssl_op_type!() = 0x0;
    }
}
pub const SSL_OP_NO_TLSv1_1: c_ulong = 0x10000000;
pub const SSL_OP_NO_TLSv1_2: c_ulong = 0x08000000;
pub const SSL_OP_NO_TLSv1_1: ssl_op_type!() = 0x10000000;
pub const SSL_OP_NO_TLSv1_2: ssl_op_type!() = 0x08000000;

pub const SSL_OP_NO_TLSv1: c_ulong = 0x04000000;
pub const SSL_OP_NO_TLSv1: ssl_op_type!() = 0x04000000;
cfg_if! {
    if #[cfg(ossl102)] {
        pub const SSL_OP_NO_DTLSv1: c_ulong = 0x04000000;
        pub const SSL_OP_NO_DTLSv1_2: c_ulong = 0x08000000;
        pub const SSL_OP_NO_DTLSv1: ssl_op_type!() = 0x04000000;
        pub const SSL_OP_NO_DTLSv1_2: ssl_op_type!() = 0x08000000;
    } else if #[cfg(libressl332)] {
        pub const SSL_OP_NO_DTLSv1: c_ulong = 0x40000000;
        pub const SSL_OP_NO_DTLSv1_2: c_ulong = 0x80000000;
        pub const SSL_OP_NO_DTLSv1: ssl_op_type!() = 0x40000000;
        pub const SSL_OP_NO_DTLSv1_2: ssl_op_type!() = 0x80000000;
    }
}
#[cfg(ossl111)]
pub const SSL_OP_NO_TLSv1_3: c_ulong = 0x20000000;
pub const SSL_OP_NO_TLSv1_3: ssl_op_type!() = 0x20000000;

#[cfg(ossl110h)]
pub const SSL_OP_NO_RENEGOTIATION: c_ulong = 0x40000000;
pub const SSL_OP_NO_RENEGOTIATION: ssl_op_type!() = 0x40000000;

cfg_if! {
    if #[cfg(ossl111)] {
        pub const SSL_OP_NO_SSL_MASK: c_ulong = SSL_OP_NO_SSLv2
        pub const SSL_OP_NO_SSL_MASK: ssl_op_type!() = SSL_OP_NO_SSLv2
            | SSL_OP_NO_SSLv3
            | SSL_OP_NO_TLSv1
            | SSL_OP_NO_TLSv1_1
            | SSL_OP_NO_TLSv1_2
            | SSL_OP_NO_TLSv1_3;
    } else if #[cfg(ossl102)] {
        pub const SSL_OP_NO_SSL_MASK: c_ulong =
        pub const SSL_OP_NO_SSL_MASK: ssl_op_type!() =
            SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1 | SSL_OP_NO_TLSv1_2;
    }
}

cfg_if! {
    if #[cfg(libressl261)] {
        pub const SSL_OP_CRYPTOPRO_TLSEXT_BUG: c_ulong = 0x0;
        pub const SSL_OP_CRYPTOPRO_TLSEXT_BUG: ssl_op_type!() = 0x0;
    } else {
        pub const SSL_OP_CRYPTOPRO_TLSEXT_BUG: c_ulong = 0x80000000;
        pub const SSL_OP_CRYPTOPRO_TLSEXT_BUG: ssl_op_type!() = 0x80000000;
    }
}

cfg_if! {
    if #[cfg(ossl300)] {
        pub const SSL_OP_ALL: c_ulong = SSL_OP_CRYPTOPRO_TLSEXT_BUG
        pub const SSL_OP_ALL: ssl_op_type!() = SSL_OP_CRYPTOPRO_TLSEXT_BUG
            | SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS
            | SSL_OP_TLSEXT_PADDING
            | SSL_OP_SAFARI_ECDHE_ECDSA_BUG;
    } else if #[cfg(ossl110f)] {
        pub const SSL_OP_ALL: c_ulong = SSL_OP_CRYPTOPRO_TLSEXT_BUG
        pub const SSL_OP_ALL: ssl_op_type!() = SSL_OP_CRYPTOPRO_TLSEXT_BUG
            | SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS
            | SSL_OP_LEGACY_SERVER_CONNECT
            | SSL_OP_TLSEXT_PADDING
            | SSL_OP_SAFARI_ECDHE_ECDSA_BUG;
    } else if #[cfg(libressl261)] {
        pub const SSL_OP_ALL: c_ulong = 0x4;
        pub const SSL_OP_ALL: ssl_op_type!() = 0x4;
    } else if #[cfg(libressl)] {
        pub const SSL_OP_ALL: c_ulong = 0x80000014;
        pub const SSL_OP_ALL: ssl_op_type!() = 0x80000014;
    } else {
        pub const SSL_OP_ALL: c_ulong = 0x80000BFF;
        pub const SSL_OP_ALL: ssl_op_type!() = 0x80000BFF;
    }
}

cfg_if! {
    if #[cfg(ossl110)] {
        pub const SSL_OP_MICROSOFT_SESS_ID_BUG: c_ulong = 0x00000000;
        pub const SSL_OP_NETSCAPE_CHALLENGE_BUG: c_ulong = 0x00000000;
        pub const SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: c_ulong = 0x00000000;
        pub const SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: c_ulong = 0x00000000;
        pub const SSL_OP_SSLEAY_080_CLIENT_DH_BUG: c_ulong = 0x00000000;
        pub const SSL_OP_TLS_D5_BUG: c_ulong = 0x00000000;
        pub const SSL_OP_TLS_BLOCK_PADDING_BUG: c_ulong = 0x00000000;
        pub const SSL_OP_SINGLE_ECDH_USE: c_ulong = 0x00000000;
        pub const SSL_OP_SINGLE_DH_USE: c_ulong = 0x00000000;
        pub const SSL_OP_NO_SSLv2: c_ulong = 0x00000000;
        pub const SSL_OP_MICROSOFT_SESS_ID_BUG: ssl_op_type!() = 0x00000000;
        pub const SSL_OP_NETSCAPE_CHALLENGE_BUG: ssl_op_type!() = 0x00000000;
        pub const SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: ssl_op_type!() = 0x00000000;
        pub const SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: ssl_op_type!() = 0x00000000;
        pub const SSL_OP_SSLEAY_080_CLIENT_DH_BUG: ssl_op_type!() = 0x00000000;
        pub const SSL_OP_TLS_D5_BUG: ssl_op_type!() = 0x00000000;
        pub const SSL_OP_TLS_BLOCK_PADDING_BUG: ssl_op_type!() = 0x00000000;
        pub const SSL_OP_SINGLE_ECDH_USE: ssl_op_type!() = 0x00000000;
        pub const SSL_OP_SINGLE_DH_USE: ssl_op_type!() = 0x00000000;
        pub const SSL_OP_NO_SSLv2: ssl_op_type!() = 0x00000000;
    } else if #[cfg(ossl101)] {
        pub const SSL_OP_MICROSOFT_SESS_ID_BUG: c_ulong = 0x00000001;
        pub const SSL_OP_NETSCAPE_CHALLENGE_BUG: c_ulong = 0x00000002;
        pub const SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: c_ulong = 0x00000008;
        pub const SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: c_ulong = 0x00000020;
        pub const SSL_OP_SSLEAY_080_CLIENT_DH_BUG: c_ulong = 0x00000080;
        pub const SSL_OP_TLS_D5_BUG: c_ulong = 0x00000100;
        pub const SSL_OP_TLS_BLOCK_PADDING_BUG: c_ulong = 0x00000200;
        pub const SSL_OP_SINGLE_ECDH_USE: c_ulong = 0x00080000;
        pub const SSL_OP_SINGLE_DH_USE: c_ulong = 0x00100000;
        pub const SSL_OP_NO_SSLv2: c_ulong = 0x01000000;
        pub const SSL_OP_MICROSOFT_SESS_ID_BUG: ssl_op_type!() = 0x00000001;
        pub const SSL_OP_NETSCAPE_CHALLENGE_BUG: ssl_op_type!() = 0x00000002;
        pub const SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: ssl_op_type!() = 0x00000008;
        pub const SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: ssl_op_type!() = 0x00000020;
        pub const SSL_OP_SSLEAY_080_CLIENT_DH_BUG: ssl_op_type!() = 0x00000080;
        pub const SSL_OP_TLS_D5_BUG: ssl_op_type!() = 0x00000100;
        pub const SSL_OP_TLS_BLOCK_PADDING_BUG: ssl_op_type!() = 0x00000200;
        pub const SSL_OP_SINGLE_ECDH_USE: ssl_op_type!() = 0x00080000;
        pub const SSL_OP_SINGLE_DH_USE: ssl_op_type!() = 0x00100000;
        pub const SSL_OP_NO_SSLv2: ssl_op_type!() = 0x01000000;
    } else {
        pub const SSL_OP_MICROSOFT_SESS_ID_BUG: c_ulong = 0x0;
        pub const SSL_OP_NETSCAPE_CHALLENGE_BUG: c_ulong = 0x0;
        pub const SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: c_ulong = 0x0;
        pub const SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: c_ulong = 0x0;
        pub const SSL_OP_SSLEAY_080_CLIENT_DH_BUG: c_ulong = 0x0;
        pub const SSL_OP_TLS_D5_BUG: c_ulong = 0x0;
        pub const SSL_OP_TLS_BLOCK_PADDING_BUG: c_ulong = 0x0;
        pub const SSL_OP_MICROSOFT_SESS_ID_BUG: ssl_op_type!() = 0x0;
        pub const SSL_OP_NETSCAPE_CHALLENGE_BUG: ssl_op_type!() = 0x0;
        pub const SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: ssl_op_type!() = 0x0;
        pub const SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: ssl_op_type!() = 0x0;
        pub const SSL_OP_SSLEAY_080_CLIENT_DH_BUG: ssl_op_type!() = 0x0;
        pub const SSL_OP_TLS_D5_BUG: ssl_op_type!() = 0x0;
        pub const SSL_OP_TLS_BLOCK_PADDING_BUG: ssl_op_type!() = 0x0;
        #[cfg(libressl261)]
        pub const SSL_OP_SINGLE_ECDH_USE: c_ulong = 0x0;
        pub const SSL_OP_SINGLE_ECDH_USE: ssl_op_type!() = 0x0;
        #[cfg(not(libressl261))]
        pub const SSL_OP_SINGLE_ECDH_USE: c_ulong = 0x00080000;
        pub const SSL_OP_SINGLE_DH_USE: c_ulong = 0x00100000;
        pub const SSL_OP_NO_SSLv2: c_ulong = 0x0;
        pub const SSL_OP_SINGLE_ECDH_USE: ssl_op_type!() = 0x00080000;
        pub const SSL_OP_SINGLE_DH_USE: ssl_op_type!() = 0x00100000;
        pub const SSL_OP_NO_SSLv2: ssl_op_type!() = 0x0;
    }
}