mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-30 22:43:08 +03:00
Merge branch 'development' into ccm_chunked
Conflicts: library/ccm.c Conflict resolved by re-applying the MBEDTLS_BYTE_0 macro. Conflict resolved by ignoring the MBEDTLS_PUT_UINT16_BE macro used in development branch on the 'b' buffer, because the 'b' buffer is removed in current branch.
This commit is contained in:
@ -161,6 +161,7 @@ pre_initialize_variables () {
|
||||
: ${ARMC5_BIN_DIR:=/usr/bin}
|
||||
: ${ARMC6_BIN_DIR:=/usr/bin}
|
||||
: ${ARM_NONE_EABI_GCC_PREFIX:=arm-none-eabi-}
|
||||
: ${ARM_LINUX_GNUEABI_GCC_PREFIX:=arm-linux-gnueabi-}
|
||||
|
||||
# if MAKEFLAGS is not set add the -j option to speed up invocations of make
|
||||
if [ -z "${MAKEFLAGS+set}" ]; then
|
||||
@ -230,6 +231,9 @@ General options:
|
||||
--arm-none-eabi-gcc-prefix=<string>
|
||||
Prefix for a cross-compiler for arm-none-eabi
|
||||
(default: "${ARM_NONE_EABI_GCC_PREFIX}")
|
||||
--arm-linux-gnueabi-gcc-prefix=<string>
|
||||
Prefix for a cross-compiler for arm-linux-gnueabi
|
||||
(default: "${ARM_LINUX_GNUEABI_GCC_PREFIX}")
|
||||
--armcc Run ARM Compiler builds (on by default).
|
||||
--except Exclude the COMPONENTs listed on the command line,
|
||||
instead of running only those.
|
||||
@ -387,6 +391,7 @@ pre_parse_command_line () {
|
||||
case "$1" in
|
||||
--append-outcome) append_outcome=1;;
|
||||
--arm-none-eabi-gcc-prefix) shift; ARM_NONE_EABI_GCC_PREFIX="$1";;
|
||||
--arm-linux-gnueabi-gcc-prefix) shift; ARM_LINUX_GNUEABI_GCC_PREFIX="$1";;
|
||||
--armcc) no_armcc=;;
|
||||
--armc5-bin-dir) shift; ARMC5_BIN_DIR="$1";;
|
||||
--armc6-bin-dir) shift; ARMC6_BIN_DIR="$1";;
|
||||
@ -2369,14 +2374,29 @@ component_build_arm_none_eabi_gcc () {
|
||||
${ARM_NONE_EABI_GCC_PREFIX}size library/*.o
|
||||
}
|
||||
|
||||
component_build_arm_none_eabi_gcc_arm5vte () {
|
||||
msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=arm5vte" # ~ 10s
|
||||
component_build_arm_linux_gnueabi_gcc_arm5vte () {
|
||||
msg "build: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -march=arm5vte" # ~ 10s
|
||||
scripts/config.py baremetal
|
||||
# Build for a target platform that's close to what Debian uses
|
||||
# for its "armel" distribution (https://wiki.debian.org/ArmEabiPort).
|
||||
# See https://github.com/ARMmbed/mbedtls/pull/2169 and comments.
|
||||
# It would be better to build with arm-linux-gnueabi-gcc but
|
||||
# we don't have that on our CI at this time.
|
||||
# Build everything including programs, see for example
|
||||
# https://github.com/ARMmbed/mbedtls/pull/3449#issuecomment-675313720
|
||||
make CC="${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc" AR="${ARM_LINUX_GNUEABI_GCC_PREFIX}ar" CFLAGS='-Werror -Wall -Wextra -march=armv5te -O1' LDFLAGS='-march=armv5te'
|
||||
|
||||
msg "size: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -march=armv5te -O1"
|
||||
${ARM_LINUX_GNUEABI_GCC_PREFIX}size library/*.o
|
||||
}
|
||||
support_build_arm_linux_gnueabi_gcc_arm5vte () {
|
||||
type ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc >/dev/null 2>&1
|
||||
}
|
||||
|
||||
component_build_arm_none_eabi_gcc_arm5vte () {
|
||||
msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=arm5vte" # ~ 10s
|
||||
scripts/config.py baremetal
|
||||
# This is an imperfect substitute for
|
||||
# component_build_arm_linux_gnueabi_gcc_arm5vte
|
||||
# in case the gcc-arm-linux-gnueabi toolchain is not available
|
||||
make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" CFLAGS='-std=c99 -Werror -Wall -Wextra -march=armv5te -O1' LDFLAGS='-march=armv5te' SHELL='sh -x' lib
|
||||
|
||||
msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=armv5te -O1"
|
||||
@ -2437,11 +2457,22 @@ component_build_armcc () {
|
||||
}
|
||||
|
||||
component_test_tls13_experimental () {
|
||||
msg "build: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled"
|
||||
msg "build: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled, without padding"
|
||||
scripts/config.pl set MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL
|
||||
scripts/config.pl set MBEDTLS_SSL_CID_TLS1_3_PADDING_GRANULARITY 1
|
||||
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||
make
|
||||
msg "test: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled"
|
||||
msg "test: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled, without padding"
|
||||
make test
|
||||
}
|
||||
|
||||
component_test_tls13_experimental_with_padding () {
|
||||
msg "build: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled, with padding"
|
||||
scripts/config.pl set MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL
|
||||
scripts/config.pl set MBEDTLS_SSL_CID_TLS1_3_PADDING_GRANULARITY 16
|
||||
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||
make
|
||||
msg "test: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled, with padding"
|
||||
make test
|
||||
}
|
||||
|
||||
|
@ -23,12 +23,13 @@ set -eu
|
||||
|
||||
if [ $# -ne 0 ] && [ "$1" = "--help" ]; then
|
||||
cat <<EOF
|
||||
$0 [-u]
|
||||
$0 [-l | -u]
|
||||
This script checks that all generated file are up-to-date. If some aren't, by
|
||||
default the scripts reports it and exits in error; with the -u option, it just
|
||||
updates them instead.
|
||||
|
||||
-u Update the files rather than return an error for out-of-date files.
|
||||
-l List generated files, but do not update them.
|
||||
EOF
|
||||
exit
|
||||
fi
|
||||
@ -39,10 +40,13 @@ if [ -d library -a -d include -a -d tests ]; then :; else
|
||||
fi
|
||||
|
||||
UPDATE=
|
||||
if [ $# -ne 0 ] && [ "$1" = "-u" ]; then
|
||||
shift
|
||||
UPDATE='y'
|
||||
fi
|
||||
LIST=
|
||||
while getopts lu OPTLET; do
|
||||
case $OPTLET in
|
||||
l) LIST=1;;
|
||||
u) UPDATE=1;;
|
||||
esac
|
||||
done
|
||||
|
||||
# check SCRIPT FILENAME[...]
|
||||
# check SCRIPT DIRECTORY
|
||||
@ -58,6 +62,11 @@ check()
|
||||
SCRIPT=$1
|
||||
shift
|
||||
|
||||
if [ -n "$LIST" ]; then
|
||||
printf '%s\n' "$@"
|
||||
return
|
||||
fi
|
||||
|
||||
directory=
|
||||
if [ -d "$1" ]; then
|
||||
directory="$1"
|
||||
|
131
tests/ssl-opt.sh
131
tests/ssl-opt.sh
@ -77,6 +77,14 @@ else
|
||||
O_LEGACY_CLI=false
|
||||
fi
|
||||
|
||||
if [ -n "${OPENSSL_NEXT:-}" ]; then
|
||||
O_NEXT_SRV="$OPENSSL_NEXT s_server -www -cert data_files/server5.crt -key data_files/server5.key"
|
||||
O_NEXT_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_NEXT s_client"
|
||||
else
|
||||
O_NEXT_SRV=false
|
||||
O_NEXT_CLI=false
|
||||
fi
|
||||
|
||||
if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
|
||||
G_NEXT_SRV="$GNUTLS_NEXT_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
|
||||
else
|
||||
@ -346,6 +354,57 @@ requires_openssl_legacy() {
|
||||
fi
|
||||
}
|
||||
|
||||
requires_openssl_next() {
|
||||
if [ -z "${OPENSSL_NEXT_AVAILABLE:-}" ]; then
|
||||
if which "${OPENSSL_NEXT:-}" >/dev/null 2>&1; then
|
||||
OPENSSL_NEXT_AVAILABLE="YES"
|
||||
else
|
||||
OPENSSL_NEXT_AVAILABLE="NO"
|
||||
fi
|
||||
fi
|
||||
if [ "$OPENSSL_NEXT_AVAILABLE" = "NO" ]; then
|
||||
SKIP_NEXT="YES"
|
||||
fi
|
||||
}
|
||||
|
||||
# skip next test if tls1_3 is not available
|
||||
requires_openssl_tls1_3() {
|
||||
requires_openssl_next
|
||||
if [ "$OPENSSL_NEXT_AVAILABLE" = "NO" ]; then
|
||||
OPENSSL_TLS1_3_AVAILABLE="NO"
|
||||
fi
|
||||
if [ -z "${OPENSSL_TLS1_3_AVAILABLE:-}" ]; then
|
||||
if $OPENSSL_NEXT s_client -help 2>&1 | grep tls1_3 >/dev/null
|
||||
then
|
||||
OPENSSL_TLS1_3_AVAILABLE="YES"
|
||||
else
|
||||
OPENSSL_TLS1_3_AVAILABLE="NO"
|
||||
fi
|
||||
fi
|
||||
if [ "$OPENSSL_TLS1_3_AVAILABLE" = "NO" ]; then
|
||||
SKIP_NEXT="YES"
|
||||
fi
|
||||
}
|
||||
|
||||
# skip next test if tls1_3 is not available
|
||||
requires_gnutls_tls1_3() {
|
||||
requires_gnutls_next
|
||||
if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then
|
||||
GNUTLS_TLS1_3_AVAILABLE="NO"
|
||||
fi
|
||||
if [ -z "${GNUTLS_TLS1_3_AVAILABLE:-}" ]; then
|
||||
if $GNUTLS_NEXT_CLI -l 2>&1 | grep VERS-TLS1.3 >/dev/null
|
||||
then
|
||||
GNUTLS_TLS1_3_AVAILABLE="YES"
|
||||
else
|
||||
GNUTLS_TLS1_3_AVAILABLE="NO"
|
||||
fi
|
||||
fi
|
||||
if [ "$GNUTLS_TLS1_3_AVAILABLE" = "NO" ]; then
|
||||
SKIP_NEXT="YES"
|
||||
fi
|
||||
}
|
||||
|
||||
# skip next test if IPv6 isn't available on this host
|
||||
requires_ipv6() {
|
||||
if [ -z "${HAS_IPV6:-}" ]; then
|
||||
@ -693,6 +752,11 @@ find_in_both() {
|
||||
fi
|
||||
}
|
||||
|
||||
SKIP_HANDSHAKE_CHECK="NO"
|
||||
skip_handshake_stage_check() {
|
||||
SKIP_HANDSHAKE_CHECK="YES"
|
||||
}
|
||||
|
||||
# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
|
||||
# Options: -s pattern pattern that must be present in server output
|
||||
# -c pattern pattern that must be present in client output
|
||||
@ -855,21 +919,25 @@ run_test() {
|
||||
# (useful to avoid tests with only negative assertions and non-zero
|
||||
# expected client exit to incorrectly succeed in case of catastrophic
|
||||
# failure)
|
||||
if is_polar "$SRV_CMD"; then
|
||||
if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
|
||||
else
|
||||
fail "server or client failed to reach handshake stage"
|
||||
return
|
||||
if [ "X$SKIP_HANDSHAKE_CHECK" != "XYES" ]
|
||||
then
|
||||
if is_polar "$SRV_CMD"; then
|
||||
if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
|
||||
else
|
||||
fail "server or client failed to reach handshake stage"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if is_polar "$CLI_CMD"; then
|
||||
if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
|
||||
else
|
||||
fail "server or client failed to reach handshake stage"
|
||||
return
|
||||
if is_polar "$CLI_CMD"; then
|
||||
if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
|
||||
else
|
||||
fail "server or client failed to reach handshake stage"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
SKIP_HANDSHAKE_CHECK="NO"
|
||||
# Check server exit code (only for Mbed TLS: GnuTLS and OpenSSL don't
|
||||
# exit with status 0 when interrupted by a signal, and we don't really
|
||||
# care anyway), in case e.g. the server reports a memory leak.
|
||||
@ -8478,6 +8546,47 @@ run_test "export keys functionality" \
|
||||
-c "EAP-TLS IV is:" \
|
||||
-s "EAP-TLS IV is:"
|
||||
|
||||
# openssl feature tests: check if tls1.3 exists.
|
||||
requires_openssl_tls1_3
|
||||
run_test "TLS1.3: Test openssl tls1_3 feature" \
|
||||
"$O_NEXT_SRV -tls1_3 -msg" \
|
||||
"$O_NEXT_CLI -tls1_3 -msg" \
|
||||
0 \
|
||||
-c "TLS 1.3" \
|
||||
-s "TLS 1.3"
|
||||
|
||||
# gnutls feature tests: check if tls1.3 exists.
|
||||
requires_gnutls_tls1_3
|
||||
run_test "TLS1.3: Test gnutls tls1_3 feature" \
|
||||
"$G_NEXT_SRV --priority=NORMAL:-VERS-ALL:+VERS-TLS1.3" \
|
||||
"$G_NEXT_CLI localhost --priority=NORMAL:-VERS-ALL:+VERS-TLS1.3 -V" \
|
||||
0 \
|
||||
-s "Version: TLS1.3" \
|
||||
-c "Version: TLS1.3"
|
||||
|
||||
# TLS1.3 test cases
|
||||
# TODO: remove or rewrite this test case if #4832 is resolved.
|
||||
requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
|
||||
requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL
|
||||
skip_handshake_stage_check
|
||||
run_test "TLS1.3: Not supported version check: tls1_2 and tls1_3" \
|
||||
"$P_SRV debug_level=1 min_version=tls1_2 max_version=tls1_3" \
|
||||
"$P_CLI debug_level=1 min_version=tls1_2 max_version=tls1_3" \
|
||||
1 \
|
||||
-s "SSL - The requested feature is not available" \
|
||||
-c "SSL - The requested feature is not available" \
|
||||
-s "Hybrid TLS 1.2 + TLS 1.3 configurations are not yet supported" \
|
||||
-c "Hybrid TLS 1.2 + TLS 1.3 configurations are not yet supported"
|
||||
|
||||
requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
|
||||
requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL
|
||||
run_test "TLS1.3: handshake dispatch test: tls1_3 only" \
|
||||
"$P_SRV min_version=tls1_3 max_version=tls1_3" \
|
||||
"$P_CLI min_version=tls1_3 max_version=tls1_3" \
|
||||
1 \
|
||||
-s "SSL - The requested feature is not available" \
|
||||
-c "SSL - The requested feature is not available"
|
||||
|
||||
# Test heap memory usage after handshake
|
||||
requires_config_enabled MBEDTLS_MEMORY_DEBUG
|
||||
requires_config_enabled MBEDTLS_MEMORY_BUFFER_ALLOC_C
|
||||
|
@ -60,10 +60,16 @@ void debug_print_msg_threshold( int threshold, int level, char * file,
|
||||
memset( buffer.buf, 0, 2000 );
|
||||
buffer.ptr = buffer.buf;
|
||||
|
||||
mbedtls_ssl_config_defaults( &conf,
|
||||
MBEDTLS_SSL_IS_CLIENT,
|
||||
MBEDTLS_SSL_TRANSPORT_STREAM,
|
||||
MBEDTLS_SSL_PRESET_DEFAULT );
|
||||
|
||||
mbedtls_ssl_conf_dbg( &conf, string_debug, &buffer);
|
||||
|
||||
TEST_ASSERT( mbedtls_ssl_setup( &ssl, &conf ) == 0 );
|
||||
|
||||
mbedtls_debug_set_threshold( threshold );
|
||||
mbedtls_ssl_conf_dbg( &conf, string_debug, &buffer);
|
||||
|
||||
mbedtls_debug_print_msg( &ssl, level, file, line,
|
||||
"Text message, 2 == %d", 2 );
|
||||
@ -89,10 +95,15 @@ void mbedtls_debug_print_ret( char * file, int line, char * text, int value,
|
||||
memset( buffer.buf, 0, 2000 );
|
||||
buffer.ptr = buffer.buf;
|
||||
|
||||
TEST_ASSERT( mbedtls_ssl_setup( &ssl, &conf ) == 0 );
|
||||
mbedtls_ssl_config_defaults( &conf,
|
||||
MBEDTLS_SSL_IS_CLIENT,
|
||||
MBEDTLS_SSL_TRANSPORT_STREAM,
|
||||
MBEDTLS_SSL_PRESET_DEFAULT );
|
||||
|
||||
mbedtls_ssl_conf_dbg( &conf, string_debug, &buffer);
|
||||
|
||||
TEST_ASSERT( mbedtls_ssl_setup( &ssl, &conf ) == 0 );
|
||||
|
||||
mbedtls_debug_print_ret( &ssl, 0, file, line, text, value);
|
||||
|
||||
TEST_ASSERT( strcmp( buffer.buf, result_str ) == 0 );
|
||||
@ -116,11 +127,15 @@ void mbedtls_debug_print_buf( char * file, int line, char * text,
|
||||
memset( buffer.buf, 0, 2000 );
|
||||
buffer.ptr = buffer.buf;
|
||||
|
||||
|
||||
TEST_ASSERT( mbedtls_ssl_setup( &ssl, &conf ) == 0 );
|
||||
mbedtls_ssl_config_defaults( &conf,
|
||||
MBEDTLS_SSL_IS_CLIENT,
|
||||
MBEDTLS_SSL_TRANSPORT_STREAM,
|
||||
MBEDTLS_SSL_PRESET_DEFAULT );
|
||||
|
||||
mbedtls_ssl_conf_dbg( &conf, string_debug, &buffer);
|
||||
|
||||
TEST_ASSERT( mbedtls_ssl_setup( &ssl, &conf ) == 0 );
|
||||
|
||||
mbedtls_debug_print_buf( &ssl, 0, file, line, text, data->x, data->len );
|
||||
|
||||
TEST_ASSERT( strcmp( buffer.buf, result_str ) == 0 );
|
||||
@ -146,10 +161,15 @@ void mbedtls_debug_print_crt( char * crt_file, char * file, int line,
|
||||
memset( buffer.buf, 0, 2000 );
|
||||
buffer.ptr = buffer.buf;
|
||||
|
||||
TEST_ASSERT( mbedtls_ssl_setup( &ssl, &conf ) == 0 );
|
||||
mbedtls_ssl_config_defaults( &conf,
|
||||
MBEDTLS_SSL_IS_CLIENT,
|
||||
MBEDTLS_SSL_TRANSPORT_STREAM,
|
||||
MBEDTLS_SSL_PRESET_DEFAULT );
|
||||
|
||||
mbedtls_ssl_conf_dbg( &conf, string_debug, &buffer);
|
||||
|
||||
TEST_ASSERT( mbedtls_ssl_setup( &ssl, &conf ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_x509_crt_parse_file( &crt, crt_file ) == 0 );
|
||||
mbedtls_debug_print_crt( &ssl, 0, file, line, prefix, &crt);
|
||||
|
||||
@ -177,12 +197,17 @@ void mbedtls_debug_print_mpi( int radix, char * value, char * file, int line,
|
||||
memset( buffer.buf, 0, 2000 );
|
||||
buffer.ptr = buffer.buf;
|
||||
|
||||
mbedtls_ssl_config_defaults( &conf,
|
||||
MBEDTLS_SSL_IS_CLIENT,
|
||||
MBEDTLS_SSL_TRANSPORT_STREAM,
|
||||
MBEDTLS_SSL_PRESET_DEFAULT );
|
||||
|
||||
mbedtls_ssl_conf_dbg( &conf, string_debug, &buffer);
|
||||
|
||||
TEST_ASSERT( mbedtls_ssl_setup( &ssl, &conf ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &val, radix, value ) == 0 );
|
||||
|
||||
mbedtls_ssl_conf_dbg( &conf, string_debug, &buffer);
|
||||
|
||||
mbedtls_debug_print_mpi( &ssl, 0, file, line, prefix, &val);
|
||||
|
||||
TEST_ASSERT( strcmp( buffer.buf, result_str ) == 0 );
|
||||
|
@ -6021,6 +6021,62 @@ SSL TLS 1.3 Key schedule: Handshake secrets derivation helper
|
||||
# Vector from RFC 8448
|
||||
ssl_tls1_3_derive_handshake_secrets:MBEDTLS_MD_SHA256:"005cb112fd8eb4ccc623bb88a07c64b3ede1605363fc7d0df8c7ce4ff0fb4ae6":"f736cb34fe25e701551bee6fd24c1cc7102a7daf9405cb15d97aafe16f757d03":"2faac08f851d35fea3604fcb4de82dc62c9b164a70974d0462e27f1ab278700f":"fe927ae271312e8bf0275b581c54eef020450dc4ecffaa05a1a35d27518e7803"
|
||||
|
||||
SSL TLS 1.3 Record Encryption, tls13.ulfheim.net Example #1
|
||||
# - Server App Key: 0b6d22c8ff68097ea871c672073773bf
|
||||
# - Server App IV: 1b13dd9f8d8f17091d34b349
|
||||
# - Client App Key: 49134b95328f279f0183860589ac6707
|
||||
# - Client App IV: bc4dd5f7b98acff85466261d
|
||||
# - App data payload: 70696e67
|
||||
# - Complete record: 1703030015c74061535eb12f5f25a781957874742ab7fb305dd5
|
||||
# - Padding used: No (== granularity 1)
|
||||
ssl_tls1_3_record_protection:MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:MBEDTLS_SSL_IS_CLIENT:0:1:"0b6d22c8ff68097ea871c672073773bf":"1b13dd9f8d8f17091d34b349":"49134b95328f279f0183860589ac6707":"bc4dd5f7b98acff85466261d":"70696e67":"c74061535eb12f5f25a781957874742ab7fb305dd5"
|
||||
|
||||
SSL TLS 1.3 Record Encryption, tls13.ulfheim.net Example #2
|
||||
# - Server App Key: 0b6d22c8ff68097ea871c672073773bf
|
||||
# - Server App IV: 1b13dd9f8d8f17091d34b349
|
||||
# - Client App Key: 49134b95328f279f0183860589ac6707
|
||||
# - Client App IV: bc4dd5f7b98acff85466261d
|
||||
# - App data payload: 706f6e67
|
||||
# - Complete record: 1703030015370e5f168afa7fb16b663ecdfca3dbb81931a90ca7
|
||||
# - Padding used: No (== granularity 1)
|
||||
ssl_tls1_3_record_protection:MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:MBEDTLS_SSL_IS_SERVER:1:1:"0b6d22c8ff68097ea871c672073773bf":"1b13dd9f8d8f17091d34b349":"49134b95328f279f0183860589ac6707":"bc4dd5f7b98acff85466261d":"706f6e67":"370e5f168afa7fb16b663ecdfca3dbb81931a90ca7"
|
||||
|
||||
SSL TLS 1.3 Record Encryption RFC 8448 Example #1
|
||||
# Application Data record sent by Client in 1-RTT example of RFC 8448, Section 3
|
||||
# - Server App Key: 9f 02 28 3b 6c 9c 07 ef c2 6b b9 f2 ac 92 e3 56
|
||||
# - Server App IV: cf 78 2b 88 dd 83 54 9a ad f1 e9 84
|
||||
# - Client App Key: 17 42 2d da 59 6e d5 d9 ac d8 90 e3 c6 3f 50 51
|
||||
# - Client App IV: 5b 78 92 3d ee 08 57 90 33 e5 23 d9
|
||||
# - App data payload: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
|
||||
# 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f
|
||||
# 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f
|
||||
# 30 31
|
||||
# - Complete record: 17 03 03 00 43 a2 3f 70 54 b6 2c 94 d0 af fa fe
|
||||
# 82 28 ba 55 cb ef ac ea 42 f9 14 aa 66 bc ab 3f
|
||||
# 2b 98 19 a8 a5 b4 6b 39 5b d5 4a 9a 20 44 1e 2b
|
||||
# 62 97 4e 1f 5a 62 92 a2 97 70 14 bd 1e 3d ea e6
|
||||
# 3a ee bb 21 69 49 15 e4
|
||||
# - Padding used: No (== granularity 1)
|
||||
ssl_tls1_3_record_protection:MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:MBEDTLS_SSL_IS_CLIENT:0:1:"9f02283b6c9c07efc26bb9f2ac92e356":"cf782b88dd83549aadf1e984":"17422dda596ed5d9acd890e3c63f5051":"5b78923dee08579033e523d9":"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031":"a23f7054b62c94d0affafe8228ba55cbefacea42f914aa66bcab3f2b9819a8a5b46b395bd54a9a20441e2b62974e1f5a6292a2977014bd1e3deae63aeebb21694915e4"
|
||||
|
||||
SSL TLS 1.3 Record Encryption RFC 8448 Example #2
|
||||
# Application Data record sent by Server in 1-RTT example of RFC 8448, Section 3
|
||||
# - Server App Key: 9f 02 28 3b 6c 9c 07 ef c2 6b b9 f2 ac 92 e3 56
|
||||
# - Server App IV: cf 78 2b 88 dd 83 54 9a ad f1 e9 84
|
||||
# - Client App Key: 17 42 2d da 59 6e d5 d9 ac d8 90 e3 c6 3f 50 51
|
||||
# - Client App IV: 5b 78 92 3d ee 08 57 90 33 e5 23 d9
|
||||
# - App data payload: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
|
||||
# 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f
|
||||
# 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f
|
||||
# 30 31
|
||||
# - Complete record: 17 03 03 00 43 2e 93 7e 11 ef 4a c7 40 e5 38 ad
|
||||
# 36 00 5f c4 a4 69 32 fc 32 25 d0 5f 82 aa 1b 36
|
||||
# e3 0e fa f9 7d 90 e6 df fc 60 2d cb 50 1a 59 a8
|
||||
# fc c4 9c 4b f2 e5 f0 a2 1c 00 47 c2 ab f3 32 54
|
||||
# 0d d0 32 e1 67 c2 95 5d
|
||||
# - Padding used: No (== granularity 1)
|
||||
ssl_tls1_3_record_protection:MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:MBEDTLS_SSL_IS_SERVER:1:1:"9f02283b6c9c07efc26bb9f2ac92e356":"cf782b88dd83549aadf1e984":"17422dda596ed5d9acd890e3c63f5051":"5b78923dee08579033e523d9":"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031":"2e937e11ef4ac740e538ad36005fc4a46932fc3225d05f82aa1b36e30efaf97d90e6dffc602dcb501a59a8fcc49c4bf2e5f0a21c0047c2abf332540dd032e167c2955d"
|
||||
|
||||
SSL TLS 1.3 Key schedule: Application secrets derivation helper
|
||||
# Vector from RFC 8448
|
||||
ssl_tls1_3_derive_application_secrets:MBEDTLS_MD_SHA256:"e2d32d4ed66dd37897a0e80c84107503ce58bf8aad4cb55a5002d77ecb890ece":"b0aeffc46a2cfe33114e6fd7d51f9f04b1ca3c497dab08934a774a9d9ad7dbf3":"2abbf2b8e381d23dbebe1dd2a7d16a8bf484cb4950d23fb7fb7fa8547062d9a1":"cc21f1bf8feb7dd5fa505bd9c4b468a9984d554a993dc49e6d285598fb672691":"3fd93d4ffddc98e64b14dd107aedf8ee4add23f4510f58a4592d0b201bee56b4"
|
||||
|
@ -3944,6 +3944,104 @@ void ssl_tls1_3_create_psk_binder( int hash_alg,
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */
|
||||
void ssl_tls1_3_record_protection( int ciphersuite,
|
||||
int endpoint,
|
||||
int ctr,
|
||||
int padding_used,
|
||||
data_t *server_write_key,
|
||||
data_t *server_write_iv,
|
||||
data_t *client_write_key,
|
||||
data_t *client_write_iv,
|
||||
data_t *plaintext,
|
||||
data_t *ciphertext )
|
||||
{
|
||||
mbedtls_ssl_key_set keys;
|
||||
mbedtls_ssl_transform transform_send;
|
||||
mbedtls_ssl_transform transform_recv;
|
||||
mbedtls_record rec;
|
||||
unsigned char *buf = NULL;
|
||||
size_t buf_len;
|
||||
int other_endpoint;
|
||||
|
||||
TEST_ASSERT( endpoint == MBEDTLS_SSL_IS_CLIENT ||
|
||||
endpoint == MBEDTLS_SSL_IS_SERVER );
|
||||
|
||||
if( endpoint == MBEDTLS_SSL_IS_SERVER )
|
||||
other_endpoint = MBEDTLS_SSL_IS_CLIENT;
|
||||
if( endpoint == MBEDTLS_SSL_IS_CLIENT )
|
||||
other_endpoint = MBEDTLS_SSL_IS_SERVER;
|
||||
|
||||
TEST_ASSERT( server_write_key->len == client_write_key->len );
|
||||
TEST_ASSERT( server_write_iv->len == client_write_iv->len );
|
||||
|
||||
memcpy( keys.client_write_key,
|
||||
client_write_key->x, client_write_key->len );
|
||||
memcpy( keys.client_write_iv,
|
||||
client_write_iv->x, client_write_iv->len );
|
||||
memcpy( keys.server_write_key,
|
||||
server_write_key->x, server_write_key->len );
|
||||
memcpy( keys.server_write_iv,
|
||||
server_write_iv->x, server_write_iv->len );
|
||||
|
||||
keys.key_len = server_write_key->len;
|
||||
keys.iv_len = server_write_iv->len;
|
||||
|
||||
mbedtls_ssl_transform_init( &transform_recv );
|
||||
mbedtls_ssl_transform_init( &transform_send );
|
||||
|
||||
TEST_ASSERT( mbedtls_ssl_tls13_populate_transform(
|
||||
&transform_send, endpoint,
|
||||
ciphersuite, &keys, NULL ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ssl_tls13_populate_transform(
|
||||
&transform_recv, other_endpoint,
|
||||
ciphersuite, &keys, NULL ) == 0 );
|
||||
|
||||
/* Make sure we have enough space in the buffer even if
|
||||
* we use more padding than the KAT. */
|
||||
buf_len = ciphertext->len + MBEDTLS_SSL_CID_TLS1_3_PADDING_GRANULARITY;
|
||||
ASSERT_ALLOC( buf, buf_len );
|
||||
rec.type = MBEDTLS_SSL_MSG_APPLICATION_DATA;
|
||||
|
||||
/* TLS 1.3 uses the version identifier from TLS 1.2 on the wire. */
|
||||
mbedtls_ssl_write_version( MBEDTLS_SSL_MAJOR_VERSION_3,
|
||||
MBEDTLS_SSL_MINOR_VERSION_3,
|
||||
MBEDTLS_SSL_TRANSPORT_STREAM,
|
||||
rec.ver );
|
||||
|
||||
/* Copy plaintext into record structure */
|
||||
rec.buf = buf;
|
||||
rec.buf_len = buf_len;
|
||||
rec.data_offset = 0;
|
||||
TEST_ASSERT( plaintext->len <= ciphertext->len );
|
||||
memcpy( rec.buf + rec.data_offset, plaintext->x, plaintext->len );
|
||||
rec.data_len = plaintext->len;
|
||||
#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
|
||||
rec.cid_len = 0;
|
||||
#endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */
|
||||
|
||||
memset( &rec.ctr[0], 0, 8 );
|
||||
rec.ctr[7] = ctr;
|
||||
|
||||
TEST_ASSERT( mbedtls_ssl_encrypt_buf( NULL, &transform_send, &rec,
|
||||
NULL, NULL ) == 0 );
|
||||
|
||||
if( padding_used == MBEDTLS_SSL_CID_TLS1_3_PADDING_GRANULARITY )
|
||||
{
|
||||
ASSERT_COMPARE( rec.buf + rec.data_offset, rec.data_len,
|
||||
ciphertext->x, ciphertext->len );
|
||||
}
|
||||
|
||||
TEST_ASSERT( mbedtls_ssl_decrypt_buf( NULL, &transform_recv, &rec ) == 0 );
|
||||
ASSERT_COMPARE( rec.buf + rec.data_offset, rec.data_len,
|
||||
plaintext->x, plaintext->len );
|
||||
|
||||
mbedtls_free( buf );
|
||||
mbedtls_ssl_transform_free( &transform_send );
|
||||
mbedtls_ssl_transform_free( &transform_recv );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */
|
||||
void ssl_tls1_3_key_evolution( int hash_alg,
|
||||
data_t *secret,
|
||||
|
Reference in New Issue
Block a user