Skip to content

Commit

Permalink
Merge branch 'main' into psk-bindings-callback
Browse files Browse the repository at this point in the history
  • Loading branch information
jmayclin authored Feb 27, 2025
2 parents 61c2d98 + 3b1255c commit 31df9d9
Show file tree
Hide file tree
Showing 164 changed files with 5,347 additions and 2,592 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Configure AWS Credentials
# Only continue with the workflow to emit metrics on code that has been merged to main.
if: github.event_name != 'pull_request'
uses: aws-actions/configure-aws-credentials@v4.0.2
uses: aws-actions/configure-aws-credentials@v4.1.0
with:
role-to-assume: arn:aws:iam::024603541914:role/GitHubOIDCRole
role-session-name: s2ntlsghabenchsession
Expand Down
21 changes: 13 additions & 8 deletions .github/workflows/ci_linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,25 @@ jobs:
run: |
./codebuild/bin/run_kwstyle.sh
./codebuild/bin/cpp_style_comment_linter.sh
pepeight:
ruff:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: Run autopep8
id: autopep8
uses: peter-evans/autopep8@v2
with:
args: --diff --exit-code .

- name: Set up uv
uses: astral-sh/setup-uv@v5

- name: Run Ruff formatting check
working-directory: tests/integrationv2
id: ruff_format
run: uv run ruff format --check .
continue-on-error: true

- name: Check exit code
if: steps.autopep8.outputs.exit-code != 0
if: steps.ruff_format.outcome == 'failure'
run: |
echo "Run 'autopep8 --in-place .' to fix"
echo "Run 'ruff format .' to fix formatting issues"
exit 1
clang-format:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/usage_guide.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
folder: docs/usage-guide/book

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4.0.2
uses: aws-actions/configure-aws-credentials@v4.1.0
if: github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name
with:
role-to-assume: arn:aws:iam::024603541914:role/GitHubOIDCRole
Expand Down
3 changes: 0 additions & 3 deletions .pep8

This file was deleted.

15 changes: 11 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ loaded in an application with an otherwise conflicting libcrypto version." OFF)
option(S2N_LTO, "Enables link time optimizations when building s2n-tls." OFF)
option(S2N_STACKTRACE "Enables stacktrace functionality in s2n-tls. Note that this functionality is
only available on platforms that support execinfo." ON)
option(S2N_OVERRIDE_LIBCRYPTO_RAND_ENGINE "Allow s2n-tls to override the libcrypto random implementation with the custom
s2n-tls implementation, when appropriate. Disabling this flag is not recommended. See docs/BUILD.md for details." ON)
option(COVERAGE "Enable profiling collection for code coverage calculation" OFF)
option(BUILD_TESTING "Build tests for s2n-tls. By default only unit tests are built." ON)
option(S2N_INTEG_TESTS "Enable the integrationv2 tests" OFF)
Expand Down Expand Up @@ -163,7 +165,7 @@ endif ()
if(BUILD_TESTING AND BUILD_SHARED_LIBS OR S2N_FUZZ_TEST)
target_compile_options(${PROJECT_NAME} PRIVATE -fvisibility=default)
else()
target_compile_options(${PROJECT_NAME} PRIVATE -fvisibility=hidden -DS2N_EXPORTS)
target_compile_options(${PROJECT_NAME} PRIVATE -fvisibility=hidden -DS2N_EXPORTS=1)
endif()

if(S2N_LTO)
Expand Down Expand Up @@ -195,7 +197,7 @@ target_compile_options(${PROJECT_NAME} PRIVATE -include "${S2N_PRELUDE}")
# Match on Release, RelWithDebInfo and MinSizeRel
# See: https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html#variable:CMAKE_BUILD_TYPE
if(CMAKE_BUILD_TYPE MATCHES Rel)
add_definitions(-DS2N_BUILD_RELEASE)
add_definitions(-DS2N_BUILD_RELEASE=1)
endif()

if(NO_STACK_PROTECTOR)
Expand Down Expand Up @@ -247,6 +249,11 @@ if (COVERAGE)
target_link_options(${PROJECT_NAME} PUBLIC -fprofile-instr-generate -fcoverage-mapping)
endif()

if (NOT S2N_OVERRIDE_LIBCRYPTO_RAND_ENGINE)
message(STATUS "Disabling libcrypto RAND engine override")
add_definitions(-DS2N_DISABLE_RAND_ENGINE_OVERRIDE=1)
endif()

# For interning, we need to find the static libcrypto library. Cmake configs
# can branch on the variable BUILD_SHARED_LIBS to e.g. avoid having to define
# multiple targets. An example is AWS-LC:
Expand Down Expand Up @@ -309,7 +316,7 @@ function(feature_probe_result PROBE_NAME IS_AVAILABLE)

# define the probe if available
if(NORMALIZED)
add_definitions(-D${PROBE_NAME})
add_definitions(-D${PROBE_NAME}=1)
endif()
endfunction()

Expand Down Expand Up @@ -419,7 +426,7 @@ if (S2N_INTERN_LIBCRYPTO)
DEPENDS libcrypto.symbols
)
add_dependencies(${PROJECT_NAME} s2n_libcrypto)
add_definitions(-DS2N_INTERN_LIBCRYPTO)
add_definitions(-DS2N_INTERN_LIBCRYPTO=1)

if ((BUILD_SHARED_LIBS AND BUILD_TESTING) OR NOT BUILD_SHARED_LIBS)
# if libcrypto needs to be interned, rewrite libcrypto references so use of internal functions will link correctly
Expand Down
2 changes: 1 addition & 1 deletion api/s2n.h
Original file line number Diff line number Diff line change
Expand Up @@ -1774,7 +1774,7 @@ S2N_API extern int s2n_connection_get_write_fd(struct s2n_connection *conn, int
S2N_API extern int s2n_connection_use_corked_io(struct s2n_connection *conn);

/**
* Function pointer for a user provided send callback.
* Function pointer for a user provided recv callback.
*/
typedef int s2n_recv_fn(void *io_context, uint8_t *buf, uint32_t len);

Expand Down
12 changes: 8 additions & 4 deletions api/unstable/crl.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,16 @@ struct s2n_cert_validation_info;
*
* If the validation performed in the callback is successful, `s2n_cert_validation_accept()` MUST be called to allow
* `s2n_negotiate()` to continue the handshake. If the validation is unsuccessful, `s2n_cert_validation_reject()`
* MUST be called, which will cause `s2n_negotiate()` to error. The behavior of `s2n_negotiate()` is undefined if
* neither `s2n_cert_validation_accept()` or `s2n_cert_validation_reject()` are called.
* MUST be called, which will cause `s2n_negotiate()` to error.
*
* To use the validation callback asynchronously, return `S2N_SUCCESS` without calling `s2n_cert_validation_accept()`
* or `s2n_cert_validation_reject()`. This will pause the handshake, and `s2n_negotiate()` will throw an `S2N_ERR_T_BLOCKED`
* error and `s2n_blocked_status` will be set to `S2N_BLOCKED_ON_APPLICATION_INPUT`. Applications should call
* `s2n_cert_validation_accept()` or `s2n_cert_validation_reject()` to unpause the handshake before retrying `s2n_negotiate()`.
*
* The `info` parameter is passed to the callback in order to call APIs specific to the cert validation callback, like
* `s2n_cert_validation_accept()` and `s2n_cert_validation_reject()`. The `info` argument is only valid for the
* lifetime of the callback, and must not be used after the callback has finished.
* `s2n_cert_validation_accept()` and `s2n_cert_validation_reject()`. The `info` argument shares the same lifetime as
* `s2n_connection`.
*
* After calling `s2n_cert_validation_reject()`, `s2n_negotiate()` will fail with a protocol error indicating that
* the cert has been rejected from the callback. If more information regarding an application's custom validation
Expand Down
2 changes: 1 addition & 1 deletion bindings/rust/extended/s2n-tls-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "s2n-tls-sys"
description = "A C99 implementation of the TLS/SSL protocols"
version = "0.3.11"
version = "0.3.12"
authors = ["AWS s2n"]
edition = "2021"
rust-version = "1.63.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "s2n-tls-sys"
description = "A C99 implementation of the TLS/SSL protocols"
version = "0.3.11"
version = "0.3.12"
authors = ["AWS s2n"]
edition = "2021"
rust-version = "1.63.0"
Expand Down
6 changes: 3 additions & 3 deletions bindings/rust/extended/s2n-tls-tokio/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "s2n-tls-tokio"
description = "An implementation of TLS streams for Tokio built on top of s2n-tls"
version = "0.3.11"
version = "0.3.12"
authors = ["AWS s2n"]
edition = "2021"
rust-version = "1.63.0"
Expand All @@ -16,11 +16,11 @@ errno = { version = "0.3" }
# A minimum libc version of 0.2.121 is required by aws-lc-sys 0.14.0.
libc = { version = "0.2.121" }
pin-project-lite = { version = "0.2" }
s2n-tls = { version = "=0.3.11", path = "../s2n-tls" }
s2n-tls = { version = "=0.3.12", path = "../s2n-tls" }
tokio = { version = "1", features = ["net", "time"] }

[dev-dependencies]
s2n-tls = { path = "../s2n-tls", features = ["unstable-testing"] }
rand = { version = "0.8" }
rand = { version = "0.9" }
tokio = { version = "1", features = [ "io-std", "io-util", "macros", "net", "rt-multi-thread", "test-util", "time"] }
tokio-macros = "=2.3.0"
2 changes: 1 addition & 1 deletion bindings/rust/extended/s2n-tls-tokio/tests/handshake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async fn handshake_with_pool_multithread() -> Result<(), Box<dyn std::error::Err
let server = server.clone();
tasks.push_back(tokio::spawn(async move {
// Start each handshake at a randomly determined time
let rand = rand::thread_rng().gen_range(0..50);
let rand = rand::rng().random_range(0..50);
time::sleep(Duration::from_millis(rand)).await;

let (server_stream, client_stream) = common::get_streams().await.unwrap();
Expand Down
8 changes: 3 additions & 5 deletions bindings/rust/extended/s2n-tls/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "s2n-tls"
description = "A C99 implementation of the TLS/SSL protocols"
version = "0.3.11"
version = "0.3.12"
authors = ["AWS s2n"]
edition = "2021"
rust-version = "1.63.0"
Expand All @@ -22,15 +22,13 @@ unstable-testing = []
errno = { version = "0.3" }
# A minimum libc version of 0.2.121 is required by aws-lc-sys 0.14.0.
libc = "0.2.121"
s2n-tls-sys = { version = "=0.3.11", path = "../s2n-tls-sys", features = ["internal"] }
s2n-tls-sys = { version = "=0.3.12", path = "../s2n-tls-sys", features = ["internal"] }
pin-project-lite = "0.2"
hex = "0.4"

[dev-dependencies]
futures-test = "0.3"
# The openssl crate broke MSRV with 0.10.67
# TODO unpin this once fixed - https://github.com/sfackler/rust-openssl/issues/2317
openssl = "<0.10.67"
openssl = "0.10"
openssl-sys = "0.9"
foreign-types = "0.3"
temp-env = "0.3"
Expand Down
6 changes: 3 additions & 3 deletions bindings/rust/extended/s2n-tls/src/callbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub use pkey::*;
/// callbacks were configured through the Rust bindings.
pub(crate) unsafe fn with_context<F, T>(conn_ptr: *mut s2n_connection, action: F) -> T
where
F: FnOnce(&mut Connection, &mut Context) -> T,
F: FnOnce(&mut Connection, &Context) -> T,
{
let raw = NonNull::new(conn_ptr).expect("connection should not be null");
// Since this is a callback, it receives a pointer to the connection
Expand All @@ -60,8 +60,8 @@ where
// We must make the connection `ManuallyDrop` before `action`, otherwise a panic
// in `action` would cause the unwind mechanism to drop the connection.
let mut conn = ManuallyDrop::new(Connection::from_raw(raw));
let mut config = conn.config().expect("config should not be null");
let context = config.context_mut();
let config = conn.config().expect("config should not be null");
let context = config.context();
action(&mut conn, context)
}

Expand Down
Loading

0 comments on commit 31df9d9

Please sign in to comment.