Skip to content

Commit

Permalink
Implement BIO_f_ssl stub
Browse files Browse the repository at this point in the history
  • Loading branch information
ctz committed Feb 23, 2024
1 parent 59e4ab5 commit 8daacdb
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions rustls-libssl/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ fn write_version_file() -> String {
}

const ENTRYPOINTS: &[&str] = &[
"BIO_f_ssl",
"OPENSSL_init_ssl",
"SSL_alert_desc_string",
"SSL_alert_desc_string_long",
Expand Down
20 changes: 19 additions & 1 deletion rustls-libssl/src/bio.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use core::ffi::{c_char, c_int, c_long, c_void};
use core::ffi::{c_char, c_int, c_long, c_void, CStr};
use std::io;

// nb. cannot use any BIO types from openssl_sys: it doesn't
Expand Down Expand Up @@ -223,6 +223,24 @@ impl Drop for Bio {
}
}

static NAME: &CStr = crate::constants::constant_cstr!("ssl");
const BIO_TYPE_SSL: i32 = 0x0200 | 7;

pub static SSL_BIO_METHOD: bio_method_st = bio_method_st {
type_: BIO_TYPE_SSL,
name: NAME.as_ptr(),
bwrite: None,
bwrite_old: None,
bread: None,
bread_old: None,
bputs: None,
bgets: None,
ctrl: None,
create: None,
destroy: None,
callback_ctrl: None,
};

// This is a public interface between libcrypto and libssl, but is
// defined in `internal/bio.h`. Hmm.
#[repr(C)]
Expand Down
8 changes: 7 additions & 1 deletion rustls-libssl/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use openssl_sys::{
stack_st_X509, OPENSSL_malloc, X509, X509_STORE, X509_STORE_CTX, X509_V_ERR_UNSPECIFIED,
};

use crate::bio::{Bio, BIO};
use crate::bio::{Bio, BIO, BIO_METHOD};
use crate::error::{ffi_panic_boundary, Error, MysteriouslyOppositeReturnValue};
use crate::ffi::{
free_arc, to_arc_mut_ptr, try_clone_arc, try_mut_slice_int, try_ref_from_ptr, try_slice,
Expand Down Expand Up @@ -68,6 +68,12 @@ entry! {
}
}

entry! {
pub fn _BIO_f_ssl() -> *const BIO_METHOD {
&crate::bio::SSL_BIO_METHOD
}
}

type SSL_METHOD = crate::SslMethod;

entry! {
Expand Down

0 comments on commit 8daacdb

Please sign in to comment.