Skip to content

Commit

Permalink
Merge branch 'main' into ocsp_timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
dougch authored Nov 13, 2024
2 parents 5ae251a + 2ba3dda commit 888f133
Show file tree
Hide file tree
Showing 52 changed files with 386 additions and 614 deletions.
19 changes: 15 additions & 4 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
### Release Summary:
<!-- If this is a feature or bug that impacts customers and is significant enough to include in the "Summary" section of the next version release, please include a brief (1-2 sentences) description of the change. The audience of this summary is future customers, not maintainers or reviewers. See https://github.com/aws/s2n-tls/releases/tag/v1.5.7 for an example. Otherwise, leave this section blank -->

### Resolved issues:

Resolves #ISSUE-NUMBER1, resolves #ISSUE-NUMBER2, etc.
resolves #ISSUE-NUMBER1, resolves #ISSUE-NUMBER2, etc.

### Description of changes:

Describe s2n’s current behavior and how your code changes that behavior. If there are no issues this PR is resolving, explain why this change is necessary.

### Call-outs:

Address any potentially confusing code. Is there code added that needs to be cleaned up later? Is there code that is missing because it’s still in development?
Address any potentially confusing code. Is there code added that needs to be cleaned up later? Is there code that is missing because it’s still in development? If a callout is specific to a section of code, it might make more sense to leave a comment on your own PR file diff.

### Testing:

How is this change tested (unit tests, fuzz tests, etc.)? Are there any testing steps to be verified by the reviewer?

How is this change tested (unit tests, fuzz tests, etc.)? What manual testing was performed? Are there any testing steps to be verified by the reviewer?
How can you convince your reviewers that this PR is safe and effective?
Is this a refactor change? If so, how have you proved that the intended behavior hasn't changed?

Remember:
* Any change to the library source code should at least include unit tests.
* Any change to the core stuffer or blob methods should include [CBMC proofs](https://github.com/aws/s2n-tls/tree/main/tests/cbmc).
* Any change to the CI or tests should:
1. prove that the test succeeds for good input
2. prove that the test fails for bad input (eg, a test for memory leaks fails when a memory leak is committed)


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
22 changes: 22 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This configuration file tells Dependabot which
# package ecosystems to update and where the package manifests are located.
# https://docs.github.com/en/enterprise-cloud@latest/code-security/dependabot/dependabot-version-updates/configuring-dependabot-version-updates

version: 2
updates:
# Maintain dependencies for GitHub Actions
# https://github.com/dependabot/dependabot-core/pull/6189
- package-ecosystem: "github-actions"
directory: "/.github/workflows"
schedule:
interval: "daily"

# Maintain dependencies for cargo
- package-ecosystem: "cargo"
directories:
- "/bindings/rust"
- "/bindings/rust-examples"
- "/tests/pcap"
- "/tests/regression"
schedule:
interval: "daily"
29 changes: 29 additions & 0 deletions .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: dependencies

on:
# Because of permissions issues with forked PRs,
# Only run on a schedule or pushes to main.
push:
branches:
- main
# Only run if these files were touched.
paths:
- "**/Cargo.toml"
- "**/Cargo.lock"
- ".github/workflows/dependencies.yml"

schedule:
# Run every day at 1800 UTC.
- cron: "0 18 * * *"

jobs:
audit:
runs-on: ubuntu-latest
permissions:
issues: write # Open/update issues.
checks: write # Create/update a check run.
steps:
- uses: actions/checkout@v4
- uses: rustsec/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
17 changes: 12 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,13 @@ endif()

target_compile_options(${PROJECT_NAME} PUBLIC -fPIC)

add_definitions(-D_POSIX_C_SOURCE=200809L)
if(CMAKE_BUILD_TYPE MATCHES Release)
add_definitions(-D_FORTIFY_SOURCE=2)
set(S2N_PRELUDE "${CMAKE_CURRENT_LIST_DIR}/utils/s2n_prelude.h")
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)
endif()

if(NO_STACK_PROTECTOR)
Expand Down Expand Up @@ -331,7 +335,7 @@ function(feature_probe PROBE_NAME)
SOURCES "${CMAKE_CURRENT_LIST_DIR}/tests/features/${PROBE_NAME}.c"
LINK_LIBRARIES ${LINK_LIB} ${OS_LIBS}
CMAKE_FLAGS ${ADDITIONAL_FLAGS}
COMPILE_DEFINITIONS -c ${GLOBAL_FLAGS} ${PROBE_FLAGS}
COMPILE_DEFINITIONS -I "${CMAKE_CURRENT_LIST_DIR}" -include "${CMAKE_CURRENT_LIST_DIR}/utils/s2n_prelude.h" -c ${GLOBAL_FLAGS} ${PROBE_FLAGS}
${ARGN}
OUTPUT_VARIABLE TRY_COMPILE_OUTPUT
)
Expand Down Expand Up @@ -475,6 +479,8 @@ if (BUILD_TESTING)
add_library(testss2n STATIC ${TESTLIB_SRC} ${EXAMPLES_SRC})
target_include_directories(testss2n PUBLIC tests)
target_compile_options(testss2n PRIVATE -std=gnu99)
# make sure all linked tests include the prelude
target_compile_options(testss2n PUBLIC -include "${S2N_PRELUDE}")
target_link_libraries(testss2n PUBLIC ${PROJECT_NAME})
if (SECCOMP)
message(STATUS "Linking tests with seccomp")
Expand Down Expand Up @@ -505,6 +511,7 @@ if (BUILD_TESTING)
--error-limit=no \
--num-callers=40 \
--undef-value-errors=no \
--track-fds=yes \
--log-fd=2 \
--suppressions=valgrind.suppressions")

Expand Down Expand Up @@ -633,7 +640,7 @@ if (BUILD_TESTING)
pytest
-x -n=${N} --reruns=2 --durations=10 --cache-clear -rpfsq
-o log_cli=true --log-cli-level=DEBUG --provider-version=$ENV{S2N_LIBCRYPTO}
--provider-criterion=off --fips-mode=0 ${test_file_path}
--fips-mode=0 ${test_file_path}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests/integrationv2
)
else()
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ s2n_config_set_cipher_preferences(config, "20150306")
Internally s2n-tls takes a systematic approach to data protection and includes several mechanisms designed to improve safety.
##### Small and auditable code base
Ignoring tests, blank lines and comments, s2n-tls is about 6,000 lines of code. s2n's code is also structured and written with a focus on reviewability. All s2n-tls code is subject to code review, and we plan to complete security evaluations of s2n-tls on an annual basis.
##### Auditable code base
s2n-tls's code is structured and written with a focus on reviewability. All s2n-tls code is subject to code review, and we plan to complete security evaluations of s2n-tls on an annual basis.
To date there have been two external code-level reviews of s2n-tls, including one by a commercial security vendor. s2n-tls has also been shared with some trusted members of the broader cryptography, security, and Open Source communities. Any issues discovered are always recorded in the s2n-tls issue tracker.
Expand All @@ -148,7 +148,7 @@ s2n-tls encrypts or erases plaintext data as quickly as possible. For example, d
s2n-tls uses operating system features to protect data from being swapped to disk or appearing in core dumps.
##### Minimalist feature adoption
s2n-tls avoids implementing rarely used options and extensions, as well as features with a history of triggering protocol-level vulnerabilities. For example there is no support for session renegotiation or DTLS.
s2n-tls avoids implementing rarely used options and extensions, as well as features with a history of triggering protocol-level vulnerabilities. For example, there is no support for DTLS.
##### Compartmentalized random number generation
The security of TLS and its associated encryption algorithms depends upon secure random number generation. s2n-tls provides every thread with two separate random number generators. One for "public" randomly generated data that may appear in the clear, and one for "private" data that should remain secret. This approach lessens the risk of potential predictability weaknesses in random number generation algorithms from leaking information across contexts.
Expand Down
19 changes: 4 additions & 15 deletions api/s2n.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,12 @@

#pragma once

#if ((__GNUC__ >= 4) || defined(__clang__)) && defined(S2N_EXPORTS)
/**
* Marks a function as belonging to the public s2n API.
*/
#define S2N_API __attribute__((visibility("default")))
#else
#ifndef S2N_API
/**
* Marks a function as belonging to the public s2n API.
*/
#define S2N_API
#endif /* __GNUC__ >= 4 || defined(__clang__) */
#endif

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -234,8 +229,8 @@ S2N_API extern unsigned long s2n_get_openssl_version(void);
S2N_API extern int s2n_init(void);

/**
* Cleans up any internal resources used by s2n-tls. This function should be called from each thread or process
* that is created subsequent to calling `s2n_init` when that thread or process is done calling other s2n-tls functions.
* Cleans up thread-local resources used by s2n-tls. Does not perform a full library cleanup. To fully
* clean up the library use s2n_cleanup_final().
*
* @returns S2N_SUCCESS on success. S2N_FAILURE on failure
*/
Expand All @@ -244,12 +239,6 @@ S2N_API extern int s2n_cleanup(void);
/*
* Performs a complete deinitialization and cleanup of the s2n-tls library.
*
* s2n_cleanup_final will always perform a complete cleanup. In contrast,
* s2n_cleanup will only perform a complete cleanup if the atexit handler
* is disabled and s2n_cleanup is called by the thread that called s2n_init.
* Therefore s2n_cleanup_final should be used instead of s2n_cleanup in cases
* where the user needs full control over when the complete cleanup executes.
*
* @returns S2N_SUCCESS on success. S2N_FAILURE on failure
*/
S2N_API extern int s2n_cleanup_final(void);
Expand Down
13 changes: 0 additions & 13 deletions bindings/rust/integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,4 @@ publish = false
[dependencies]
s2n-tls = { path = "../s2n-tls"}
s2n-tls-sys = { path = "../s2n-tls-sys" }
criterion = { version = "0.3", features = ["html_reports"] }
anyhow = "1"
unicode-width = "=0.1.13" # newer versions require newer rust, see https://github.com/aws/s2n-tls/issues/4786

[[bench]]
name = "s2nc"
harness = false

[[bench]]
name = "s2nd"
harness = false

[dev-dependencies]
regex = "=1.9.6" # newer versions require rust 1.65, see https://github.com/aws/s2n-tls/issues/4242
30 changes: 0 additions & 30 deletions bindings/rust/integration/benches/s2nc.rs

This file was deleted.

30 changes: 0 additions & 30 deletions bindings/rust/integration/benches/s2nd.rs

This file was deleted.

4 changes: 2 additions & 2 deletions bindings/rust/s2n-tls-hyper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ publish = false
default = []

[dependencies]
s2n-tls = { version = "=0.3.5", path = "../s2n-tls" }
s2n-tls-tokio = { version = "=0.3.5", path = "../s2n-tls-tokio" }
s2n-tls = { version = "=0.3.7", path = "../s2n-tls" }
s2n-tls-tokio = { version = "=0.3.7", path = "../s2n-tls-tokio" }
hyper = { version = "1" }
hyper-util = { version = "0.1", features = ["client-legacy", "tokio", "http1"] }
tower-service = { version = "0.3" }
Expand Down
16 changes: 11 additions & 5 deletions bindings/rust/s2n-tls-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,14 @@ fn build_vendored() {

build.files(include!("./files.rs"));

if env("PROFILE") == "release" {
// fortify source is only available in release mode
build.define("_FORTIFY_SOURCE", "2");
// https://doc.rust-lang.org/cargo/reference/environment-variables.html
// * OPT_LEVEL, DEBUG — values of the corresponding variables for the profile currently being built.
// * PROFILE — release for release builds, debug for other builds. This is determined based on if
// the profile inherits from the dev or release profile. Using this environment variable is not
// recommended. Using other environment variables like OPT_LEVEL provide a more correct view of
// the actual settings being used.
if env("OPT_LEVEL") != "0" {
build.define("S2N_BUILD_RELEASE", "1");
build.define("NDEBUG", "1");

// build s2n-tls with LTO if supported
Expand Down Expand Up @@ -166,15 +171,16 @@ fn builder(libcrypto: &Libcrypto) -> cc::Build {
};

build
.flag("-include")
.flag("lib/utils/s2n_prelude.h")
.flag("-std=c11")
.flag("-fgnu89-inline")
// make sure the stack is non-executable
.flag_if_supported("-z relro")
.flag_if_supported("-z now")
.flag_if_supported("-z noexecstack")
// we use some deprecated libcrypto features so don't warn here
.flag_if_supported("-Wno-deprecated-declarations")
.define("_POSIX_C_SOURCE", "200112L");
.flag_if_supported("-Wno-deprecated-declarations");

build
}
Expand Down
2 changes: 1 addition & 1 deletion bindings/rust/s2n-tls-sys/templates/Cargo.template
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.5"
version = "0.3.7"
authors = ["AWS s2n"]
edition = "2021"
rust-version = "1.63.0"
Expand Down
4 changes: 2 additions & 2 deletions bindings/rust/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.5"
version = "0.3.7"
authors = ["AWS s2n"]
edition = "2021"
rust-version = "1.63.0"
Expand All @@ -15,7 +15,7 @@ default = []
errno = { version = "0.3" }
libc = { version = "0.2" }
pin-project-lite = { version = "0.2" }
s2n-tls = { version = "=0.3.5", path = "../s2n-tls" }
s2n-tls = { version = "=0.3.7", path = "../s2n-tls" }
tokio = { version = "1", features = ["net", "time"] }

[dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions bindings/rust/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.5"
version = "0.3.7"
authors = ["AWS s2n"]
edition = "2021"
rust-version = "1.63.0"
Expand All @@ -21,7 +21,7 @@ unstable-testing = []
[dependencies]
errno = { version = "0.3" }
libc = "0.2"
s2n-tls-sys = { version = "=0.3.5", path = "../s2n-tls-sys", features = ["internal"] }
s2n-tls-sys = { version = "=0.3.7", path = "../s2n-tls-sys", features = ["internal"] }
pin-project-lite = "0.2"
hex = "0.4"

Expand Down
2 changes: 2 additions & 0 deletions codebuild/bin/build_aws_crt_cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ source codebuild/bin/s2n_setup_env.sh
BUILD_DIR=$1
INSTALL_DIR=$2

# Make sure there isn't another source tree hanging around.
rm -rf /opt/s2n-tls || true
mkdir -p "$BUILD_DIR/s2n"
# In case $BUILD_DIR is a subdirectory of current directory
for file in *;do test "$file" != "$BUILD_DIR" && cp -r "$file" "$BUILD_DIR/s2n";done
Expand Down
Loading

0 comments on commit 888f133

Please sign in to comment.