Skip to content

Commit

Permalink
Fix versions where SSL functions are available
Browse files Browse the repository at this point in the history
  • Loading branch information
drbrain committed Jul 17, 2023
1 parent 8815e7a commit 36f5fe9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion openssl-sys/src/handwritten/ssl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ const_ptr_api! {
}
}
extern "C" {
#[cfg(any(not(ossl102), libressl273, not(boringssl)))]
pub fn SSL_CIPHER_find(ssl: *mut SSL, ptr: *const c_uchar) -> *const SSL_CIPHER;
#[cfg(ossl111)]
pub fn SSL_CIPHER_get_handshake_digest(cipher: *const SSL_CIPHER) -> *const EVP_MD;
Expand Down Expand Up @@ -576,6 +577,7 @@ extern "C" {
pub fn SSL_state_string(ssl: *const SSL) -> *const c_char;
pub fn SSL_state_string_long(ssl: *const SSL) -> *const c_char;

#[cfg(not(boringssl))]
pub fn SSL_SESSION_new() -> *mut SSL_SESSION;
pub fn SSL_SESSION_get_time(s: *const SSL_SESSION) -> c_long;
pub fn SSL_SESSION_get_timeout(s: *const SSL_SESSION) -> c_long;
Expand Down Expand Up @@ -835,7 +837,7 @@ extern "C" {
out: *mut c_uchar,
outlen: size_t,
) -> size_t;
#[cfg(any(ossl110, libressl273))]
#[cfg(ossl111)]
pub fn SSL_SESSION_set1_master_key(
session: *mut SSL_SESSION,
key: *const c_uchar,
Expand Down
1 change: 1 addition & 0 deletions openssl/src/ssl/callbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ where
}
}

#[cfg(ossl111)]
struct Psk(Vec<u8>);

#[cfg(ossl111)]
Expand Down
4 changes: 4 additions & 0 deletions openssl/src/ssl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2028,6 +2028,7 @@ impl SslCipherRef {
/// Returns an SslCipher matching the two-byte TLS cipher ID (allocated by the IANA, in network
/// byte order).
#[corresponds(SSL_CIPHER_find)]
#[cfg(not(boringssl))]
pub fn find<'a>(ssl: &'a SslRef, cipher_id: &[u8]) -> Option<&'a SslCipherRef> {
if cipher_id.len() != 2 {
return None;
Expand Down Expand Up @@ -2182,8 +2183,10 @@ impl SslSession {
}

/// A builder for `SslSession`s.
#[cfg(not(boringssl))]
pub struct SslSessionBuilder(SslSession);

#[cfg(not(boringssl))]
impl SslSessionBuilder {
/// Creates a new `SslSessionBuilder`.
#[corresponds(SSL_SESSION_new)]
Expand Down Expand Up @@ -2221,6 +2224,7 @@ impl SslSessionBuilder {
/// This could be used to set up a session-based PSK. You must ensure the length of the key is
/// suitable for the ciphersuite associated with the session.
#[corresponds(SSL_SESSION_set1_master_key)]
#[cfg(ossl111)]
pub fn set_master_key(&mut self, key: &[u8]) -> Result<(), ErrorStack> {
unsafe {
cvt(ffi::SSL_SESSION_set1_master_key(
Expand Down
3 changes: 2 additions & 1 deletion openssl/src/ssl/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,7 @@ fn psk_ciphers() {
}

#[test]
#[cfg(ossl111)]
#[cfg(all(ossl111, not(libressl380), not(boringssl)))]
fn psk_tls13_callbacks() {
use crate::ssl::{SslCipherRef, SslSession, SslSessionBuilder, SslVersion};

Expand Down Expand Up @@ -1651,6 +1651,7 @@ fn set_num_tickets() {
}

#[test]
#[cfg(any(ossl110, libressl273))]
fn ssl_cipher_find() {
use crate::ssl::SslCipherRef;

Expand Down

0 comments on commit 36f5fe9

Please sign in to comment.