Skip to content

Commit

Permalink
Sync assorted LibreSSL symbols from various versions
Browse files Browse the repository at this point in the history
While here, fix a typo
  • Loading branch information
vishwin committed May 6, 2022
1 parent a71d738 commit d95497c
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 62 deletions.
3 changes: 3 additions & 0 deletions openssl-sys/build/cfgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
33 changes: 18 additions & 15 deletions openssl-sys/src/handwritten/ssl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand All @@ -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;
}
}
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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(
Expand Down Expand Up @@ -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;
}

Expand Down
95 changes: 48 additions & 47 deletions openssl-sys/src/ssl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -388,14 +388,21 @@ 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)]
pub unsafe fn SSL_CTX_set1_groups_list(ctx: *mut SSL_CTX, s: *const c_char) -> c_long {
SSL_CTX_ctrl(
ctx,
SSL_CTRL_SET_GROUPS_LIST,
0,
s as *const c_void as *mut c_void,
)
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,
SSL_CTRL_SET_GROUPS_LIST,
0,
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)]
Expand All @@ -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,
Expand Down Expand Up @@ -447,6 +454,24 @@ cfg_if! {
ptr::null_mut(),
) as c_int
}

pub unsafe fn SSL_set_min_proto_version(s: *mut SSL, version: c_int) -> c_int {
SSL_ctrl(
s,
SSL_CTRL_SET_MIN_PROTO_VERSION,
version as c_long,
ptr::null_mut(),
) as c_int
}

pub unsafe fn SSL_set_max_proto_version(s: *mut SSL, version: c_int) -> c_int {
SSL_ctrl(
s,
SSL_CTRL_SET_MAX_PROTO_VERSION,
version as c_long,
ptr::null_mut(),
) as c_int
}
}
}

Expand All @@ -459,51 +484,27 @@ cfg_if! {
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
}
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(ossl110)]
pub unsafe fn SSL_set_min_proto_version(s: *mut SSL, version: c_int) -> c_int {
SSL_ctrl(
s,
SSL_CTRL_SET_MIN_PROTO_VERSION,
version as c_long,
ptr::null_mut(),
) as c_int
}

#[cfg(ossl110)]
pub unsafe fn SSL_set_max_proto_version(s: *mut SSL, version: c_int) -> c_int {
SSL_ctrl(
s,
SSL_CTRL_SET_MAX_PROTO_VERSION,
version as c_long,
ptr::null_mut(),
) as c_int
}

#[cfg(ossl110g)]
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;
#[cfg(ossl111)]
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! {
Expand Down

0 comments on commit d95497c

Please sign in to comment.