diff --git a/bindings/rust/integration/Cargo.toml b/bindings/rust/integration/Cargo.toml index 854d7667f7f..6ba02e2ecb2 100644 --- a/bindings/rust/integration/Cargo.toml +++ b/bindings/rust/integration/Cargo.toml @@ -6,15 +6,11 @@ edition = "2021" publish = false [dependencies] -s2n-tls = { path = "../s2n-tls", features = ["testing"] } +s2n-tls = { path = "../s2n-tls"} s2n-tls-sys = { path = "../s2n-tls-sys" } criterion = { version = "0.3", features = ["html_reports"] } anyhow = "1" -[[bench]] -name = "handshake" -harness = false - [[bench]] name = "s2nc" harness = false diff --git a/bindings/rust/integration/benches/handshake.rs b/bindings/rust/integration/benches/handshake.rs deleted file mode 100644 index c8cd9370a86..00000000000 --- a/bindings/rust/integration/benches/handshake.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -use criterion::{criterion_group, criterion_main, Criterion}; -use s2n_tls::{ - security, - testing::{build_config, establish_connection}, -}; - -pub fn handshake(c: &mut Criterion) { - let mut group = c.benchmark_group("s2n-tls_client_server"); - - for policy in security::ALL_POLICIES { - let config = build_config(policy).unwrap(); - group.bench_function(format!("handshake_{:?}", policy), move |b| { - // This does include connection initialization overhead. - // TODO: create a separate benchmark that excludes this step. - b.iter(|| establish_connection(config.clone())); - }); - } - - group.finish(); -} - -criterion_group!(benches, handshake); -criterion_main!(benches); diff --git a/bindings/rust/s2n-tls/Cargo.toml b/bindings/rust/s2n-tls/Cargo.toml index 017aa535469..2fac580b995 100644 --- a/bindings/rust/s2n-tls/Cargo.toml +++ b/bindings/rust/s2n-tls/Cargo.toml @@ -15,10 +15,8 @@ unstable-ktls = ["s2n-tls-sys/unstable-ktls"] quic = ["s2n-tls-sys/quic"] fips = ["s2n-tls-sys/fips"] pq = ["s2n-tls-sys/pq"] -testing = ["bytes"] [dependencies] -bytes = { version = "1", optional = true } errno = { version = "0.3" } libc = "0.2" s2n-tls-sys = { version = "=0.2.8", path = "../s2n-tls-sys", features = ["internal"] } diff --git a/bindings/rust/s2n-tls/src/lib.rs b/bindings/rust/s2n-tls/src/lib.rs index 40bbb6dd1ff..88cb541a4b7 100644 --- a/bindings/rust/s2n-tls/src/lib.rs +++ b/bindings/rust/s2n-tls/src/lib.rs @@ -25,5 +25,5 @@ pub mod security; pub use s2n_tls_sys as ffi; -#[cfg(any(feature = "testing", test))] -pub mod testing; +#[cfg(test)] +mod testing; diff --git a/bindings/rust/s2n-tls/src/testing.rs b/bindings/rust/s2n-tls/src/testing.rs index 3fe64c0d687..feb5afc9b6e 100644 --- a/bindings/rust/s2n-tls/src/testing.rs +++ b/bindings/rust/s2n-tls/src/testing.rs @@ -77,7 +77,6 @@ pub trait Context { pub enum Mode { Client, - Server, } #[derive(Debug)] @@ -128,33 +127,11 @@ impl Pair { } } - pub fn poll_send(&mut self, sender: Mode, buf: &[u8]) -> Poll> { - let result = match sender { - Mode::Client => self.client.0.poll_action(&mut self.client.1, |conn| { - connection::Connection::poll_send(conn, buf) - }), - Mode::Server => self.server.0.poll_action(&mut self.server.1, |conn| { - connection::Connection::poll_send(conn, buf) - }), - }; - self.server.1.transfer(&mut self.client.1); - match result { - Poll::Ready(result) => { - result?; - Ok(()).into() - } - Poll::Pending => Poll::Pending, - } - } - pub fn poll_recv(&mut self, receiver: Mode, buf: &mut [u8]) -> Poll> { let result = match receiver { Mode::Client => self.client.0.poll_action(&mut self.client.1, |conn| { connection::Connection::poll_recv(conn, buf) }), - Mode::Server => self.server.0.poll_action(&mut self.server.1, |conn| { - connection::Connection::poll_recv(conn, buf) - }), }; match result { Poll::Ready(result) => { @@ -294,25 +271,6 @@ pub fn tls_pair(config: crate::config::Config) -> Pair { Pair::new(server, client) } -pub fn establish_connection(config: crate::config::Config) { - // create and configure a server connection - let mut server = crate::connection::Connection::new_server(); - server - .set_config(config.clone()) - .expect("Failed to bind config to server connection"); - let server = Harness::new(server); - - // create a client connection - let mut client = crate::connection::Connection::new_client(); - client - .set_config(config) - .expect("Unable to set client config"); - let client = Harness::new(client); - - let pair = Pair::new(server, client); - poll_tls_pair(pair); -} - pub fn poll_tls_pair(mut pair: Pair) -> Pair { loop { match pair.poll() { diff --git a/bindings/rust/s2n-tls/src/testing/s2n_tls.rs b/bindings/rust/s2n-tls/src/testing/s2n_tls.rs index e66d8046efc..ed4ad974bdd 100644 --- a/bindings/rust/s2n-tls/src/testing/s2n_tls.rs +++ b/bindings/rust/s2n-tls/src/testing/s2n_tls.rs @@ -32,10 +32,6 @@ impl Harness { pub fn connection(&self) -> &Connection { &self.connection } - - pub fn connection_mut(&mut self) -> &mut Connection { - &mut self.connection - } } impl super::Connection for Harness {