Skip to content

Commit fdd35b9

Browse files
authored
build and link s2n-tls with openssl3 (#3441)
1 parent 8ca9445 commit fdd35b9

File tree

5 files changed

+85
-15
lines changed

5 files changed

+85
-15
lines changed

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<img src="docs/images/s2n_logo_github.png" alt="s2n">
22

3-
s2n-tls is a C99 implementation of the TLS/SSL protocols that is designed to be simple, small, fast, and with security as a priority. It is released and licensed under the Apache License 2.0.
3+
s2n-tls is a C99 implementation of the TLS/SSL protocols that is designed to be simple, small, fast, and with security as a priority. It is released and licensed under the Apache License 2.0.
44

55
[![Build Status](https://codebuild.us-west-2.amazonaws.com/badges?uuid=eyJlbmNyeXB0ZWREYXRhIjoiMndlTzJNbHVxWEo3Nm82alp4eGdGNm4rTWdxZDVYU2VTbitIR0ZLbHVtcFFGOW5majk5QnhqaUp3ZEkydG1ueWg0NGlhRE43a1ZnUzZaQTVnSm91TzFFPSIsIml2UGFyYW1ldGVyU3BlYyI6IlJLbW42NENlYXhJNy80QnYiLCJtYXRlcmlhbFNldFNlcmlhbCI6MX0%3D&branch=main)](https://github.com/aws/s2n-tls/)
66
[![Apache 2 License](https://img.shields.io/github/license/aws/s2n-tls.svg)](http://aws.amazon.com/apache-2-0/)
@@ -76,7 +76,7 @@ Doxygen installation instructions are available at the [Doxygen](https://doxygen
7676

7777
## Using s2n-tls
7878

79-
The s2n-tls I/O APIs are designed to be intuitive to developers familiar with the widely-used POSIX I/O APIs, and s2n-tls supports blocking, non-blocking, and full-duplex I/O. Additionally there are no locks or mutexes within s2n-tls.
79+
The s2n-tls I/O APIs are designed to be intuitive to developers familiar with the widely-used POSIX I/O APIs, and s2n-tls supports blocking, non-blocking, and full-duplex I/O. Additionally there are no locks or mutexes within s2n-tls.
8080

8181
```c
8282
/* Create a server mode connection handle */
@@ -95,7 +95,7 @@ s2n_blocked_status blocked;
9595
if (s2n_negotiate(conn, &blocked) < 0) {
9696
... error ...
9797
}
98-
98+
9999
/* Write data to the connection */
100100
int bytes_written;
101101
bytes_written = s2n_send(conn, "Hello World", sizeof("Hello World"), &blocked);
@@ -105,9 +105,9 @@ For details on building the s2n-tls library and how to use s2n-tls in an applica
105105

106106
## s2n-tls features
107107

108-
s2n-tls implements SSLv3, TLS1.0, TLS1.1, TLS1.2, and TLS1.3. For encryption, s2n-tls supports 128-bit and 256-bit AES in the CBC and GCM modes, ChaCha20, 3DES, and RC4. For forward secrecy, s2n-tls supports both DHE and ECDHE. s2n-tls also supports the Server Name Indicator (SNI), Application-Layer Protocol Negotiation (ALPN), and Online Certificate Status Protocol (OCSP) TLS extensions. SSLv3, RC4, 3DES, and DHE are each disabled by default for security reasons.
108+
s2n-tls implements SSLv3, TLS1.0, TLS1.1, TLS1.2, and TLS1.3. For encryption, s2n-tls supports 128-bit and 256-bit AES in the CBC and GCM modes, ChaCha20, 3DES, and RC4. For forward secrecy, s2n-tls supports both DHE and ECDHE. s2n-tls also supports the Server Name Indicator (SNI), Application-Layer Protocol Negotiation (ALPN), and Online Certificate Status Protocol (OCSP) TLS extensions. SSLv3, RC4, 3DES, and DHE are each disabled by default for security reasons.
109109

110-
As it can be difficult to keep track of which encryption algorithms and protocols are best to use, s2n-tls features a simple API to use the latest "default" set of preferences. If you prefer to remain on a specific version for backwards compatibility, that is also supported.
110+
As it can be difficult to keep track of which encryption algorithms and protocols are best to use, s2n-tls features a simple API to use the latest "default" set of preferences. If you prefer to remain on a specific version for backwards compatibility, that is also supported.
111111

112112
```c
113113
/* Use the latest s2n-tls "default" set of ciphersuite and protocol preferences */
@@ -124,15 +124,15 @@ Internally s2n-tls takes a systematic approach to data protection and includes s
124124
##### Small and auditable code base
125125
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.
126126
127-
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.
127+
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.
128128
129129
##### Static analysis, fuzz-testing and penetration testing
130130
131-
In addition to code reviews, s2n-tls is subject to regular static analysis, fuzz-testing, and penetration testing. Several penetration tests have occurred, including two by commercial vendors.
131+
In addition to code reviews, s2n-tls is subject to regular static analysis, fuzz-testing, and penetration testing. Several penetration tests have occurred, including two by commercial vendors.
132132
133133
##### Unit tests and end-to-end testing
134134
135-
s2n-tls includes positive and negative unit tests and end-to-end test cases.
135+
s2n-tls includes positive and negative unit tests and end-to-end test cases.
136136
137137
##### Erase on read
138138
s2n-tls encrypts or erases plaintext data as quickly as possible. For example, decrypted data buffers are erased as they are read by the application.
@@ -144,28 +144,28 @@ s2n-tls uses operating system features to protect data from being swapped to dis
144144
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.
145145
146146
##### Compartmentalized random number generation
147-
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.
147+
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.
148148
149149
##### Modularized encryption
150150
s2n-tls has been structured so that different encryption libraries may be used. Today s2n-tls supports OpenSSL, LibreSSL, BoringSSL, and the Apple Common Crypto framework to perform the underlying cryptographic operations.
151151
152152
##### Timing blinding
153-
s2n-tls includes structured support for blinding time-based side-channels that may leak sensitive data. For example, if s2n-tls fails to parse a TLS record or handshake message, s2n-tls will add a randomized delay of between 10 and 30 seconds, granular to nanoseconds, before responding. This raises the complexity of real-world timing side-channel attacks by a factor of at least tens of trillions.
153+
s2n-tls includes structured support for blinding time-based side-channels that may leak sensitive data. For example, if s2n-tls fails to parse a TLS record or handshake message, s2n-tls will add a randomized delay of between 10 and 30 seconds, granular to nanoseconds, before responding. This raises the complexity of real-world timing side-channel attacks by a factor of at least tens of trillions.
154154
155155
##### Table based state-machines
156-
s2n-tls uses simple tables to drive the TLS/SSL state machines, making it difficult for invalid out-of-order states to arise.
156+
s2n-tls uses simple tables to drive the TLS/SSL state machines, making it difficult for invalid out-of-order states to arise.
157157
158158
##### C safety
159-
s2n-tls is written in C, but makes light use of standard C library functions and wraps all memory handling, string handling, and serialization in systematic boundary-enforcing checks.
159+
s2n-tls is written in C, but makes light use of standard C library functions and wraps all memory handling, string handling, and serialization in systematic boundary-enforcing checks.
160160
161161
## Security issue notifications
162162
If you discover a potential security issue in s2n-tls we ask that you notify
163-
AWS Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue.
163+
AWS Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue.
164164
165-
If you package or distribute s2n-tls, or use s2n-tls as part of a large multi-user service, you may be eligible for pre-notification of future s2n-tls releases. Please contact [email protected].
165+
If you package or distribute s2n-tls, or use s2n-tls as part of a large multi-user service, you may be eligible for pre-notification of future s2n-tls releases. Please contact [email protected].
166166
167167
## Contributing to s2n-tls
168168
If you are interested in contributing to s2n-tls, please see our [development guide](https://github.com/aws/s2n-tls/blob/main/docs/DEVELOPMENT-GUIDE.md).
169169
170170
## Language Bindings for s2n-tls
171-
See our [language bindings list](https://github.com/aws/s2n-tls/blob/main/docs/BINDINGS.md) for language bindings for s2n-tls that we're aware of.
171+
See our [language bindings list](https://github.com/aws/s2n-tls/blob/main/docs/BINDINGS.md) for language bindings for s2n-tls that we're aware of.

codebuild/bin/install_default_dependencies.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ if [[ ("$S2N_LIBCRYPTO" == "openssl-1.1.1") || ("$TESTS" == "integration" || "$T
3737
fi
3838
fi
3939

40+
# Download and Install Openssl 3.0
41+
if [[ "$S2N_LIBCRYPTO" == "openssl-3.0" && ! -d "$OPENSSL_3_0_INSTALL_DIR" ]]; then
42+
mkdir -p "$OPENSSL_3_0_INSTALL_DIR"
43+
codebuild/bin/install_openssl_3_0.sh "$(mktemp -d)" "$OPENSSL_3_0_INSTALL_DIR" "$OS_NAME" > /dev/null ;
44+
fi
45+
4046
# Download and Install Openssl 1.0.2
4147
if [[ "$S2N_LIBCRYPTO" == "openssl-1.0.2" && ! -d "$OPENSSL_1_0_2_INSTALL_DIR" ]]; then
4248
mkdir -p "$OPENSSL_1_0_2_INSTALL_DIR"||true
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License").
5+
# You may not use this file except in compliance with the License.
6+
# A copy of the License is located at
7+
#
8+
# http://aws.amazon.com/apache2.0
9+
#
10+
# or in the "license" file accompanying this file. This file is distributed
11+
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
# express or implied. See the License for the specific language governing
13+
# permissions and limitations under the License.
14+
#
15+
16+
set -ex
17+
pushd "$(pwd)"
18+
19+
usage() {
20+
echo "install_openssl_3_0.sh build_dir install_dir os_name"
21+
exit 1
22+
}
23+
24+
if [ "$#" -ne "3" ]; then
25+
usage
26+
fi
27+
28+
BUILD_DIR=$1
29+
INSTALL_DIR=$2
30+
OS_NAME=$3
31+
source codebuild/bin/jobs.sh
32+
RELEASE=3.0.5
33+
34+
mkdir -p $BUILD_DIR
35+
cd "$BUILD_DIR"
36+
curl --retry 3 -L https://github.com/openssl/openssl/archive/refs/tags/openssl-${RELEASE}.zip --output OpenSSL_${RELEASE}.zip
37+
unzip OpenSSL_${RELEASE}.zip
38+
cd openssl-openssl-${RELEASE}
39+
40+
CONFIGURE="./Configure "
41+
42+
mkdir -p $INSTALL_DIR
43+
# Use g3 to get debug symbols in libcrypto to chase memory leaks
44+
$CONFIGURE shared -g3 -fPIC \
45+
no-md2 no-rc5 no-rfc3779 no-sctp no-ssl-trace no-zlib \
46+
no-hw no-mdc2 no-seed no-idea enable-ec_nistp_64_gcc_128 no-camellia\
47+
no-bf no-ripemd no-dsa no-ssl2 no-ssl3 no-capieng \
48+
-DSSL_FORBID_ENULL -DOPENSSL_NO_DTLS1 -DOPENSSL_NO_HEARTBEATS \
49+
--prefix="$INSTALL_DIR"
50+
51+
make -j $JOBS
52+
make -j $JOBS test
53+
make -j $JOBS install
54+
55+
popd
56+
57+
exit 0

codebuild/bin/s2n_set_build_preset.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,9 @@ case "${S2N_BUILD_PRESET-default}" in
6767
: "${S2N_LIBCRYPTO:=openssl-1.1.1}"
6868
: "${GCC_VERSION:=9}"
6969
;;
70+
"openssl-3.0")
71+
: "${S2N_LIBCRYPTO:=openssl-3.0}"
72+
: "${GCC_VERSION:=9}"
73+
;;
7074
esac
7175

codebuild/bin/s2n_setup_env.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ source codebuild/bin/s2n_set_build_preset.sh
4141
: "${SCAN_BUILD_INSTALL_DIR:=$TEST_DEPS_DIR/scan-build}"
4242
: "${OPENSSL_0_9_8_INSTALL_DIR:=$TEST_DEPS_DIR/openssl-0.9.8}"
4343
: "${OPENSSL_1_1_1_INSTALL_DIR:=$TEST_DEPS_DIR/openssl-1.1.1}"
44+
: "${OPENSSL_3_0_INSTALL_DIR:=$TEST_DEPS_DIR/openssl-3.0}"
4445
: "${OPENSSL_1_0_2_INSTALL_DIR:=$TEST_DEPS_DIR/openssl-1.0.2}"
4546
: "${OQS_OPENSSL_1_1_1_INSTALL_DIR:=$TEST_DEPS_DIR/oqs_openssl-1.1.1}"
4647
: "${OPENSSL_1_0_2_FIPS_INSTALL_DIR:=$TEST_DEPS_DIR/openssl-1.0.2-fips}"
@@ -97,6 +98,7 @@ export LATEST_CLANG_INSTALL_DIR
9798
export SCAN_BUILD_INSTALL_DIR
9899
export OPENSSL_0_9_8_INSTALL_DIR
99100
export OPENSSL_1_1_1_INSTALL_DIR
101+
export OPENSSL_3_0_INSTALL_DIR
100102
export OPENSSL_1_0_2_INSTALL_DIR
101103
export OPENSSL_1_0_2_FIPS_INSTALL_DIR
102104
export OQS_OPENSSL_1_1_1_INSTALL_DIR
@@ -122,6 +124,7 @@ fi
122124
# Select the libcrypto to build s2n against. If this is unset, default to the latest stable version(Openssl 1.1.1)
123125
if [[ -z $S2N_LIBCRYPTO ]]; then export LIBCRYPTO_ROOT=$OPENSSL_1_1_1_INSTALL_DIR ; fi
124126
if [[ "$S2N_LIBCRYPTO" == "openssl-1.1.1" ]]; then export LIBCRYPTO_ROOT=$OPENSSL_1_1_1_INSTALL_DIR ; fi
127+
if [[ "$S2N_LIBCRYPTO" == "openssl-3.0" ]]; then export LIBCRYPTO_ROOT=$OPENSSL_3_0_INSTALL_DIR ; fi
125128
if [[ "$S2N_LIBCRYPTO" == "openssl-1.0.2" ]]; then export LIBCRYPTO_ROOT=$OPENSSL_1_0_2_INSTALL_DIR ; fi
126129
if [[ "$S2N_LIBCRYPTO" == "openssl-1.0.2-fips" ]]; then
127130
export LIBCRYPTO_ROOT=$OPENSSL_1_0_2_FIPS_INSTALL_DIR ;

0 commit comments

Comments
 (0)