1#!/bin/sh 2 3# ssl-opt.sh 4# 5# Copyright The Mbed TLS Contributors 6# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 7# 8# Purpose 9# 10# Executes tests to prove various TLS/SSL options and extensions. 11# 12# The goal is not to cover every ciphersuite/version, but instead to cover 13# specific options (max fragment length, truncated hmac, etc) or procedures 14# (session resumption from cache or ticket, renego, etc). 15# 16# The tests assume a build with default options, with exceptions expressed 17# with a dependency. The tests focus on functionality and do not consider 18# performance. 19# 20 21set -u 22 23# Limit the size of each log to 10 GiB, in case of failures with this script 24# where it may output seemingly unlimited length error logs. 25ulimit -f 20971520 26 27ORIGINAL_PWD=$PWD 28if ! cd "$(dirname "$0")"; then 29 exit 125 30fi 31 32# default values, can be overridden by the environment 33: ${P_SRV:=../programs/ssl/ssl_server2} 34: ${P_CLI:=../programs/ssl/ssl_client2} 35: ${P_PXY:=../programs/test/udp_proxy} 36: ${P_QUERY:=../programs/test/query_compile_time_config} 37: ${OPENSSL:=openssl} 38: ${GNUTLS_CLI:=gnutls-cli} 39: ${GNUTLS_SERV:=gnutls-serv} 40: ${PERL:=perl} 41 42# The OPENSSL variable used to be OPENSSL_CMD for historical reasons. 43# To help the migration, error out if the old variable is set, 44# but only if it has a different value than the new one. 45if [ "${OPENSSL_CMD+set}" = set ]; then 46 # the variable is set, we can now check its value 47 if [ "$OPENSSL_CMD" != "$OPENSSL" ]; then 48 echo "Please use OPENSSL instead of OPENSSL_CMD." >&2 49 exit 125 50 fi 51fi 52 53guess_config_name() { 54 if git diff --quiet ../include/mbedtls/config.h 2>/dev/null; then 55 echo "default" 56 else 57 echo "unknown" 58 fi 59} 60: ${MBEDTLS_TEST_OUTCOME_FILE=} 61: ${MBEDTLS_TEST_CONFIGURATION:="$(guess_config_name)"} 62: ${MBEDTLS_TEST_PLATFORM:="$(uname -s | tr -c \\n0-9A-Za-z _)-$(uname -m | tr -c \\n0-9A-Za-z _)"} 63 64O_SRV="$OPENSSL s_server -www -cert data_files/server5.crt -key data_files/server5.key" 65O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL s_client" 66G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key" 67G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt" 68TCP_CLIENT="$PERL scripts/tcp_client.pl" 69 70# alternative versions of OpenSSL and GnuTLS (no default path) 71 72if [ -n "${OPENSSL_LEGACY:-}" ]; then 73 O_LEGACY_SRV="$OPENSSL_LEGACY s_server -www -cert data_files/server5.crt -key data_files/server5.key" 74 O_LEGACY_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_LEGACY s_client" 75else 76 O_LEGACY_SRV=false 77 O_LEGACY_CLI=false 78fi 79 80if [ -n "${OPENSSL_NEXT:-}" ]; then 81 O_NEXT_SRV="$OPENSSL_NEXT s_server -www -cert data_files/server5.crt -key data_files/server5.key" 82 O_NEXT_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_NEXT s_client" 83else 84 O_NEXT_SRV=false 85 O_NEXT_CLI=false 86fi 87 88if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then 89 G_NEXT_SRV="$GNUTLS_NEXT_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key" 90else 91 G_NEXT_SRV=false 92fi 93 94if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then 95 G_NEXT_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_NEXT_CLI --x509cafile data_files/test-ca_cat12.crt" 96else 97 G_NEXT_CLI=false 98fi 99 100TESTS=0 101FAILS=0 102SKIPS=0 103 104CONFIG_H='../include/mbedtls/config.h' 105 106MEMCHECK=0 107FILTER='.*' 108EXCLUDE='^$' 109 110SHOW_TEST_NUMBER=0 111RUN_TEST_NUMBER='' 112 113PRESERVE_LOGS=0 114 115# Pick a "unique" server port in the range 10000-19999, and a proxy 116# port which is this plus 10000. Each port number may be independently 117# overridden by a command line option. 118SRV_PORT=$(($$ % 10000 + 10000)) 119PXY_PORT=$((SRV_PORT + 10000)) 120 121print_usage() { 122 echo "Usage: $0 [options]" 123 printf " -h|--help\tPrint this help.\n" 124 printf " -m|--memcheck\tCheck memory leaks and errors.\n" 125 printf " -f|--filter\tOnly matching tests are executed (substring or BRE)\n" 126 printf " -e|--exclude\tMatching tests are excluded (substring or BRE)\n" 127 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n" 128 printf " -s|--show-numbers\tShow test numbers in front of test names\n" 129 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n" 130 printf " --outcome-file\tFile where test outcomes are written\n" 131 printf " \t(default: \$MBEDTLS_TEST_OUTCOME_FILE, none if empty)\n" 132 printf " --port \tTCP/UDP port (default: randomish 1xxxx)\n" 133 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n" 134 printf " --seed \tInteger seed value to use for this test run\n" 135} 136 137get_options() { 138 while [ $# -gt 0 ]; do 139 case "$1" in 140 -f|--filter) 141 shift; FILTER=$1 142 ;; 143 -e|--exclude) 144 shift; EXCLUDE=$1 145 ;; 146 -m|--memcheck) 147 MEMCHECK=1 148 ;; 149 -n|--number) 150 shift; RUN_TEST_NUMBER=$1 151 ;; 152 -s|--show-numbers) 153 SHOW_TEST_NUMBER=1 154 ;; 155 -p|--preserve-logs) 156 PRESERVE_LOGS=1 157 ;; 158 --outcome-file) 159 shift; MBEDTLS_TEST_OUTCOME_FILE=$1 160 ;; 161 --port) 162 shift; SRV_PORT=$1 163 ;; 164 --proxy-port) 165 shift; PXY_PORT=$1 166 ;; 167 --seed) 168 shift; SEED="$1" 169 ;; 170 -h|--help) 171 print_usage 172 exit 0 173 ;; 174 *) 175 echo "Unknown argument: '$1'" 176 print_usage 177 exit 1 178 ;; 179 esac 180 shift 181 done 182} 183 184# Read boolean configuration options from config.h for easy and quick 185# testing. Skip non-boolean options (with something other than spaces 186# and a comment after "#define SYMBOL"). The variable contains a 187# space-separated list of symbols. 188CONFIGS_ENABLED=" $(echo `$P_QUERY -l` )" 189# Skip next test; use this macro to skip tests which are legitimate 190# in theory and expected to be re-introduced at some point, but 191# aren't expected to succeed at the moment due to problems outside 192# our control (such as bugs in other TLS implementations). 193skip_next_test() { 194 SKIP_NEXT="YES" 195} 196 197# skip next test if the flag is not enabled in config.h 198requires_config_enabled() { 199 case $CONFIGS_ENABLED in 200 *" $1"[\ =]*) :;; 201 *) SKIP_NEXT="YES";; 202 esac 203} 204 205# skip next test if the flag is enabled in config.h 206requires_config_disabled() { 207 case $CONFIGS_ENABLED in 208 *" $1"[\ =]*) SKIP_NEXT="YES";; 209 esac 210} 211 212get_config_value_or_default() { 213 # This function uses the query_config command line option to query the 214 # required Mbed TLS compile time configuration from the ssl_server2 215 # program. The command will always return a success value if the 216 # configuration is defined and the value will be printed to stdout. 217 # 218 # Note that if the configuration is not defined or is defined to nothing, 219 # the output of this function will be an empty string. 220 ${P_SRV} "query_config=${1}" 221} 222 223requires_config_value_at_least() { 224 VAL="$( get_config_value_or_default "$1" )" 225 if [ -z "$VAL" ]; then 226 # Should never happen 227 echo "Mbed TLS configuration $1 is not defined" 228 exit 1 229 elif [ "$VAL" -lt "$2" ]; then 230 SKIP_NEXT="YES" 231 fi 232} 233 234requires_config_value_at_most() { 235 VAL=$( get_config_value_or_default "$1" ) 236 if [ -z "$VAL" ]; then 237 # Should never happen 238 echo "Mbed TLS configuration $1 is not defined" 239 exit 1 240 elif [ "$VAL" -gt "$2" ]; then 241 SKIP_NEXT="YES" 242 fi 243} 244 245requires_config_value_equals() { 246 VAL=$( get_config_value_or_default "$1" ) 247 if [ -z "$VAL" ]; then 248 # Should never happen 249 echo "Mbed TLS configuration $1 is not defined" 250 exit 1 251 elif [ "$VAL" -ne "$2" ]; then 252 SKIP_NEXT="YES" 253 fi 254} 255 256# Require Mbed TLS to support the given protocol version. 257# 258# Inputs: 259# * $1: protocol version in mbedtls syntax (argument to force_version=) 260requires_protocol_version() { 261 # Support for DTLS is detected separately in detect_dtls(). 262 case "$1" in 263 ssl3) requires_config_enabled MBEDTLS_SSL_PROTO_SSL3;; 264 tls1) requires_config_enabled MBEDTLS_SSL_PROTO_TLS1;; 265 tls1_1|dtls1) requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1;; 266 tls12|dtls12) requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2;; 267 *) echo "Unknown required protocol version: $1"; exit 1;; 268 esac 269} 270 271# Space-separated list of ciphersuites supported by this build of 272# Mbed TLS. 273P_CIPHERSUITES=" $($P_CLI --help 2>/dev/null | 274 grep TLS- | 275 tr -s ' \n' ' ')" 276requires_ciphersuite_enabled() { 277 case $P_CIPHERSUITES in 278 *" $1 "*) :;; 279 *) SKIP_NEXT="YES";; 280 esac 281} 282 283# detect_required_features CMD [RUN_TEST_OPTION...] 284# If CMD (call to a TLS client or server program) requires certain features, 285# arrange to only run the following test case if those features are enabled. 286detect_required_features() { 287 case "$1" in 288 *\ force_version=*) 289 tmp="${1##*\ force_version=}" 290 tmp="${tmp%%[!-0-9A-Z_a-z]*}" 291 requires_protocol_version "$tmp";; 292 esac 293 294 case "$1" in 295 *\ force_ciphersuite=*) 296 tmp="${1##*\ force_ciphersuite=}" 297 tmp="${tmp%%[!-0-9A-Z_a-z]*}" 298 case "$*" in 299 *"-s SSL - The server has no ciphersuites in common"*) 300 # This test case expects a ciphersuite mismatch, so it 301 # doesn't actually require the ciphersuite to be enabled. 302 :;; 303 *) requires_ciphersuite_enabled "$tmp";; 304 esac;; 305 esac 306 307 case " $1 " in 308 *[-_\ =]tickets=[^0]*) 309 requires_config_enabled MBEDTLS_SSL_TICKET_C;; 310 esac 311 case " $1 " in 312 *[-_\ =]alpn=*) 313 requires_config_enabled MBEDTLS_SSL_ALPN;; 314 esac 315 316 case " $1 " in 317 *\ badmac_limit=*) 318 requires_config_enabled MBEDTLS_SSL_DTLS_BADMAC_LIMIT;; 319 esac 320 321 case " $1 " in 322 *\ fallback=1\ *|*\ -fallback_scsv\ *) 323 requires_config_enabled MBEDTLS_SSL_FALLBACK_SCSV;; 324 esac 325 326 unset tmp 327} 328 329requires_certificate_authentication () { 330 if [ "$PSK_ONLY" = "YES" ]; then 331 SKIP_NEXT="YES" 332 fi 333} 334 335adapt_cmd_for_psk () { 336 case "$2" in 337 *openssl*) s='-psk abc123 -nocert';; 338 *gnutls-*) s='--pskkey=abc123';; 339 *) s='psk=abc123';; 340 esac 341 eval $1='"$2 $s"' 342 unset s 343} 344 345# maybe_adapt_for_psk [RUN_TEST_OPTION...] 346# If running in a PSK-only build, maybe adapt the test to use a pre-shared key. 347# 348# If not running in a PSK-only build, do nothing. 349# If the test looks like it doesn't use a pre-shared key but can run with a 350# pre-shared key, pass a pre-shared key. If the test looks like it can't run 351# with a pre-shared key, skip it. If the test looks like it's already using 352# a pre-shared key, do nothing. 353# 354# This code does not consider builds with ECDHE-PSK or RSA-PSK. 355# 356# Inputs: 357# * $CLI_CMD, $SRV_CMD, $PXY_CMD: client/server/proxy commands. 358# * $PSK_ONLY: YES if running in a PSK-only build (no asymmetric key exchanges). 359# * "$@": options passed to run_test. 360# 361# Outputs: 362# * $CLI_CMD, $SRV_CMD: may be modified to add PSK-relevant arguments. 363# * $SKIP_NEXT: set to YES if the test can't run with PSK. 364maybe_adapt_for_psk() { 365 if [ "$PSK_ONLY" != "YES" ]; then 366 return 367 fi 368 if [ "$SKIP_NEXT" = "YES" ]; then 369 return 370 fi 371 case "$CLI_CMD $SRV_CMD" in 372 *[-_\ =]psk*|*[-_\ =]PSK*) 373 return;; 374 *force_ciphersuite*) 375 # The test case forces a non-PSK cipher suite. In some cases, a 376 # PSK cipher suite could be substituted, but we're not ready for 377 # that yet. 378 SKIP_NEXT="YES" 379 return;; 380 *\ auth_mode=*|*[-_\ =]crt[_=]*) 381 # The test case involves certificates. PSK won't do. 382 SKIP_NEXT="YES" 383 return;; 384 esac 385 adapt_cmd_for_psk CLI_CMD "$CLI_CMD" 386 adapt_cmd_for_psk SRV_CMD "$SRV_CMD" 387} 388 389case " $CONFIGS_ENABLED " in 390 *\ MBEDTLS_KEY_EXCHANGE_[^P]*) PSK_ONLY="NO";; 391 *\ MBEDTLS_KEY_EXCHANGE_P[^S]*) PSK_ONLY="NO";; 392 *\ MBEDTLS_KEY_EXCHANGE_PS[^K]*) PSK_ONLY="NO";; 393 *\ MBEDTLS_KEY_EXCHANGE_PSK[^_]*) PSK_ONLY="NO";; 394 *\ MBEDTLS_KEY_EXCHANGE_PSK_ENABLED\ *) PSK_ONLY="YES";; 395 *) PSK_ONLY="NO";; 396esac 397 398# skip next test if OpenSSL doesn't support FALLBACK_SCSV 399requires_openssl_with_fallback_scsv() { 400 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then 401 if $OPENSSL s_client -help 2>&1 | grep fallback_scsv >/dev/null 402 then 403 OPENSSL_HAS_FBSCSV="YES" 404 else 405 OPENSSL_HAS_FBSCSV="NO" 406 fi 407 fi 408 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then 409 SKIP_NEXT="YES" 410 fi 411} 412 413# skip next test if either IN_CONTENT_LEN or MAX_CONTENT_LEN are below a value 414requires_max_content_len() { 415 requires_config_value_at_least "MBEDTLS_SSL_IN_CONTENT_LEN" $1 416 requires_config_value_at_least "MBEDTLS_SSL_OUT_CONTENT_LEN" $1 417} 418 419# skip next test if GnuTLS isn't available 420requires_gnutls() { 421 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then 422 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then 423 GNUTLS_AVAILABLE="YES" 424 else 425 GNUTLS_AVAILABLE="NO" 426 fi 427 fi 428 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then 429 SKIP_NEXT="YES" 430 fi 431} 432 433# skip next test if GnuTLS-next isn't available 434requires_gnutls_next() { 435 if [ -z "${GNUTLS_NEXT_AVAILABLE:-}" ]; then 436 if ( which "${GNUTLS_NEXT_CLI:-}" && which "${GNUTLS_NEXT_SERV:-}" ) >/dev/null 2>&1; then 437 GNUTLS_NEXT_AVAILABLE="YES" 438 else 439 GNUTLS_NEXT_AVAILABLE="NO" 440 fi 441 fi 442 if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then 443 SKIP_NEXT="YES" 444 fi 445} 446 447# skip next test if OpenSSL-legacy isn't available 448requires_openssl_legacy() { 449 if [ -z "${OPENSSL_LEGACY_AVAILABLE:-}" ]; then 450 if which "${OPENSSL_LEGACY:-}" >/dev/null 2>&1; then 451 OPENSSL_LEGACY_AVAILABLE="YES" 452 else 453 OPENSSL_LEGACY_AVAILABLE="NO" 454 fi 455 fi 456 if [ "$OPENSSL_LEGACY_AVAILABLE" = "NO" ]; then 457 SKIP_NEXT="YES" 458 fi 459} 460 461requires_openssl_next() { 462 if [ -z "${OPENSSL_NEXT_AVAILABLE:-}" ]; then 463 if which "${OPENSSL_NEXT:-}" >/dev/null 2>&1; then 464 OPENSSL_NEXT_AVAILABLE="YES" 465 else 466 OPENSSL_NEXT_AVAILABLE="NO" 467 fi 468 fi 469 if [ "$OPENSSL_NEXT_AVAILABLE" = "NO" ]; then 470 SKIP_NEXT="YES" 471 fi 472} 473 474# skip next test if IPv6 isn't available on this host 475requires_ipv6() { 476 if [ -z "${HAS_IPV6:-}" ]; then 477 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 & 478 SRV_PID=$! 479 sleep 1 480 kill $SRV_PID >/dev/null 2>&1 481 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then 482 HAS_IPV6="NO" 483 else 484 HAS_IPV6="YES" 485 fi 486 rm -r $SRV_OUT 487 fi 488 489 if [ "$HAS_IPV6" = "NO" ]; then 490 SKIP_NEXT="YES" 491 fi 492} 493 494# skip next test if it's i686 or uname is not available 495requires_not_i686() { 496 if [ -z "${IS_I686:-}" ]; then 497 IS_I686="YES" 498 if which "uname" >/dev/null 2>&1; then 499 if [ -z "$(uname -a | grep i686)" ]; then 500 IS_I686="NO" 501 fi 502 fi 503 fi 504 if [ "$IS_I686" = "YES" ]; then 505 SKIP_NEXT="YES" 506 fi 507} 508 509# Calculate the input & output maximum content lengths set in the config 510MAX_CONTENT_LEN=$( get_config_value_or_default "MBEDTLS_SSL_MAX_CONTENT_LEN" ) 511MAX_IN_LEN=$( get_config_value_or_default "MBEDTLS_SSL_IN_CONTENT_LEN" ) 512MAX_OUT_LEN=$( get_config_value_or_default "MBEDTLS_SSL_OUT_CONTENT_LEN" ) 513 514# Calculate the maximum content length that fits both 515if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then 516 MAX_CONTENT_LEN="$MAX_IN_LEN" 517fi 518if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then 519 MAX_CONTENT_LEN="$MAX_OUT_LEN" 520fi 521 522# skip the next test if the SSL output buffer is less than 16KB 523requires_full_size_output_buffer() { 524 if [ "$MAX_OUT_LEN" -ne 16384 ]; then 525 SKIP_NEXT="YES" 526 fi 527} 528 529# skip the next test if valgrind is in use 530not_with_valgrind() { 531 if [ "$MEMCHECK" -gt 0 ]; then 532 SKIP_NEXT="YES" 533 fi 534} 535 536# skip the next test if valgrind is NOT in use 537only_with_valgrind() { 538 if [ "$MEMCHECK" -eq 0 ]; then 539 SKIP_NEXT="YES" 540 fi 541} 542 543# multiply the client timeout delay by the given factor for the next test 544client_needs_more_time() { 545 CLI_DELAY_FACTOR=$1 546} 547 548# wait for the given seconds after the client finished in the next test 549server_needs_more_time() { 550 SRV_DELAY_SECONDS=$1 551} 552 553# print_name <name> 554print_name() { 555 TESTS=$(( $TESTS + 1 )) 556 LINE="" 557 558 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then 559 LINE="$TESTS " 560 fi 561 562 LINE="$LINE$1" 563 printf "%s " "$LINE" 564 LEN=$(( 72 - `echo "$LINE" | wc -c` )) 565 for i in `seq 1 $LEN`; do printf '.'; done 566 printf ' ' 567 568} 569 570# record_outcome <outcome> [<failure-reason>] 571# The test name must be in $NAME. 572record_outcome() { 573 echo "$1" 574 if [ -n "$MBEDTLS_TEST_OUTCOME_FILE" ]; then 575 printf '%s;%s;%s;%s;%s;%s\n' \ 576 "$MBEDTLS_TEST_PLATFORM" "$MBEDTLS_TEST_CONFIGURATION" \ 577 "ssl-opt" "$NAME" \ 578 "$1" "${2-}" \ 579 >>"$MBEDTLS_TEST_OUTCOME_FILE" 580 fi 581} 582 583# True if the presence of the given pattern in a log definitely indicates 584# that the test has failed. False if the presence is inconclusive. 585# 586# Inputs: 587# * $1: pattern found in the logs 588# * $TIMES_LEFT: >0 if retrying is an option 589# 590# Outputs: 591# * $outcome: set to a retry reason if the pattern is inconclusive, 592# unchanged otherwise. 593# * Return value: 1 if the pattern is inconclusive, 594# 0 if the failure is definitive. 595log_pattern_presence_is_conclusive() { 596 # If we've run out of attempts, then don't retry no matter what. 597 if [ $TIMES_LEFT -eq 0 ]; then 598 return 0 599 fi 600 case $1 in 601 "resend") 602 # An undesired resend may have been caused by the OS dropping or 603 # delaying a packet at an inopportune time. 604 outcome="RETRY(resend)" 605 return 1;; 606 esac 607} 608 609# fail <message> 610fail() { 611 record_outcome "FAIL" "$1" 612 echo " ! $1" 613 614 mv $SRV_OUT o-srv-${TESTS}.log 615 mv $CLI_OUT o-cli-${TESTS}.log 616 if [ -n "$PXY_CMD" ]; then 617 mv $PXY_OUT o-pxy-${TESTS}.log 618 fi 619 echo " ! outputs saved to o-XXX-${TESTS}.log" 620 621 if [ "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then 622 echo " ! server output:" 623 cat o-srv-${TESTS}.log 624 echo " ! ========================================================" 625 echo " ! client output:" 626 cat o-cli-${TESTS}.log 627 if [ -n "$PXY_CMD" ]; then 628 echo " ! ========================================================" 629 echo " ! proxy output:" 630 cat o-pxy-${TESTS}.log 631 fi 632 echo "" 633 fi 634 635 FAILS=$(( $FAILS + 1 )) 636} 637 638# is_polar <cmd_line> 639is_polar() { 640 case "$1" in 641 *ssl_client2*) true;; 642 *ssl_server2*) true;; 643 *) false;; 644 esac 645} 646 647# openssl s_server doesn't have -www with DTLS 648check_osrv_dtls() { 649 case "$SRV_CMD" in 650 *s_server*-dtls*) 651 NEEDS_INPUT=1 652 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )";; 653 *) NEEDS_INPUT=0;; 654 esac 655} 656 657# provide input to commands that need it 658provide_input() { 659 if [ $NEEDS_INPUT -eq 0 ]; then 660 return 661 fi 662 663 while true; do 664 echo "HTTP/1.0 200 OK" 665 sleep 1 666 done 667} 668 669# has_mem_err <log_file_name> 670has_mem_err() { 671 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" && 672 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null 673 then 674 return 1 # false: does not have errors 675 else 676 return 0 # true: has errors 677 fi 678} 679 680# Wait for process $2 named $3 to be listening on port $1. Print error to $4. 681if type lsof >/dev/null 2>/dev/null; then 682 wait_app_start() { 683 newline=' 684' 685 START_TIME=$(date +%s) 686 if [ "$DTLS" -eq 1 ]; then 687 proto=UDP 688 else 689 proto=TCP 690 fi 691 # Make a tight loop, server normally takes less than 1s to start. 692 while true; do 693 SERVER_PIDS=$(lsof -a -n -b -i "$proto:$1" -t) 694 # When we use a proxy, it will be listening on the same port we 695 # are checking for as well as the server and lsof will list both. 696 case ${newline}${SERVER_PIDS}${newline} in 697 *${newline}${2}${newline}*) break;; 698 esac 699 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then 700 echo "$3 START TIMEOUT" 701 echo "$3 START TIMEOUT" >> $4 702 break 703 fi 704 # Linux and *BSD support decimal arguments to sleep. On other 705 # OSes this may be a tight loop. 706 sleep 0.1 2>/dev/null || true 707 done 708 } 709else 710 echo "Warning: lsof not available, wait_app_start = sleep" 711 wait_app_start() { 712 sleep "$START_DELAY" 713 } 714fi 715 716# Wait for server process $2 to be listening on port $1. 717wait_server_start() { 718 wait_app_start $1 $2 "SERVER" $SRV_OUT 719} 720 721# Wait for proxy process $2 to be listening on port $1. 722wait_proxy_start() { 723 wait_app_start $1 $2 "PROXY" $PXY_OUT 724} 725 726# Given the client or server debug output, parse the unix timestamp that is 727# included in the first 4 bytes of the random bytes and check that it's within 728# acceptable bounds 729check_server_hello_time() { 730 # Extract the time from the debug (lvl 3) output of the client 731 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")" 732 # Get the Unix timestamp for now 733 CUR_TIME=$(date +'%s') 734 THRESHOLD_IN_SECS=300 735 736 # Check if the ServerHello time was printed 737 if [ -z "$SERVER_HELLO_TIME" ]; then 738 return 1 739 fi 740 741 # Check the time in ServerHello is within acceptable bounds 742 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then 743 # The time in ServerHello is at least 5 minutes before now 744 return 1 745 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then 746 # The time in ServerHello is at least 5 minutes later than now 747 return 1 748 else 749 return 0 750 fi 751} 752 753# Get handshake memory usage from server or client output and put it into the variable specified by the first argument 754handshake_memory_get() { 755 OUTPUT_VARIABLE="$1" 756 OUTPUT_FILE="$2" 757 758 # Get memory usage from a pattern like "Heap memory usage after handshake: 23112 bytes. Peak memory usage was 33112" 759 MEM_USAGE=$(sed -n 's/.*Heap memory usage after handshake: //p' < "$OUTPUT_FILE" | grep -o "[0-9]*" | head -1) 760 761 # Check if memory usage was read 762 if [ -z "$MEM_USAGE" ]; then 763 echo "Error: Can not read the value of handshake memory usage" 764 return 1 765 else 766 eval "$OUTPUT_VARIABLE=$MEM_USAGE" 767 return 0 768 fi 769} 770 771# Get handshake memory usage from server or client output and check if this value 772# is not higher than the maximum given by the first argument 773handshake_memory_check() { 774 MAX_MEMORY="$1" 775 OUTPUT_FILE="$2" 776 777 # Get memory usage 778 if ! handshake_memory_get "MEMORY_USAGE" "$OUTPUT_FILE"; then 779 return 1 780 fi 781 782 # Check if memory usage is below max value 783 if [ "$MEMORY_USAGE" -gt "$MAX_MEMORY" ]; then 784 echo "\nFailed: Handshake memory usage was $MEMORY_USAGE bytes," \ 785 "but should be below $MAX_MEMORY bytes" 786 return 1 787 else 788 return 0 789 fi 790} 791 792# wait for client to terminate and set CLI_EXIT 793# must be called right after starting the client 794wait_client_done() { 795 CLI_PID=$! 796 797 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR )) 798 CLI_DELAY_FACTOR=1 799 800 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) & 801 DOG_PID=$! 802 803 wait $CLI_PID 804 CLI_EXIT=$? 805 806 kill $DOG_PID >/dev/null 2>&1 807 wait $DOG_PID 808 809 echo "EXIT: $CLI_EXIT" >> $CLI_OUT 810 811 sleep $SRV_DELAY_SECONDS 812 SRV_DELAY_SECONDS=0 813} 814 815# check if the given command uses dtls and sets global variable DTLS 816detect_dtls() { 817 case "$1" in 818 *dtls=1*|*-dtls*|*-u*) DTLS=1;; 819 *) DTLS=0;; 820 esac 821} 822 823# check if the given command uses gnutls and sets global variable CMD_IS_GNUTLS 824is_gnutls() { 825 case "$1" in 826 *gnutls-cli*) 827 CMD_IS_GNUTLS=1 828 ;; 829 *gnutls-serv*) 830 CMD_IS_GNUTLS=1 831 ;; 832 *) 833 CMD_IS_GNUTLS=0 834 ;; 835 esac 836} 837 838# Determine what calc_verify trace is to be expected, if any. 839# 840# calc_verify is only called for two things: to calculate the 841# extended master secret, and to process client authentication. 842# 843# Warning: the current implementation assumes that extended_ms is not 844# disabled on the client or on the server. 845# 846# Inputs: 847# * $1: the value of the server auth_mode parameter. 848# 'required' if client authentication is expected, 849# 'none' or absent if not. 850# * $CONFIGS_ENABLED 851# 852# Outputs: 853# * $maybe_calc_verify: set to a trace expected in the debug logs 854set_maybe_calc_verify() { 855 maybe_calc_verify= 856 case $CONFIGS_ENABLED in 857 *\ MBEDTLS_SSL_EXTENDED_MASTER_SECRET\ *) :;; 858 *) 859 case ${1-} in 860 ''|none) return;; 861 required) :;; 862 *) echo "Bad parameter 1 to set_maybe_calc_verify: $1"; exit 1;; 863 esac 864 esac 865 case $CONFIGS_ENABLED in 866 *\ MBEDTLS_USE_PSA_CRYPTO\ *) maybe_calc_verify="PSA calc verify";; 867 *) maybe_calc_verify="<= calc verify";; 868 esac 869} 870 871# Compare file content 872# Usage: find_in_both pattern file1 file2 873# extract from file1 the first line matching the pattern 874# check in file2 that the same line can be found 875find_in_both() { 876 srv_pattern=$(grep -m 1 "$1" "$2"); 877 if [ -z "$srv_pattern" ]; then 878 return 1; 879 fi 880 881 if grep "$srv_pattern" $3 >/dev/null; then : 882 return 0; 883 else 884 return 1; 885 fi 886} 887 888# Analyze the commands that will be used in a test. 889# 890# Analyze and possibly instrument $PXY_CMD, $CLI_CMD, $SRV_CMD to pass 891# extra arguments or go through wrappers. 892# 893# Inputs: 894# * $@: supplemental options to run_test() (after the mandatory arguments). 895# * $CLI_CMD, $PXY_CMD, $SRV_CMD: the client, proxy and server commands. 896# * $DTLS: 1 if DTLS, otherwise 0. 897# 898# Outputs: 899# * $CLI_CMD, $PXY_CMD, $SRV_CMD: may be tweaked. 900analyze_test_commands() { 901 # if the test uses DTLS but no custom proxy, add a simple proxy 902 # as it provides timing info that's useful to debug failures 903 if [ -z "$PXY_CMD" ] && [ "$DTLS" -eq 1 ]; then 904 PXY_CMD="$P_PXY" 905 case " $SRV_CMD " in 906 *' server_addr=::1 '*) 907 PXY_CMD="$PXY_CMD server_addr=::1 listen_addr=::1";; 908 esac 909 fi 910 911 # update CMD_IS_GNUTLS variable 912 is_gnutls "$SRV_CMD" 913 914 # if the server uses gnutls but doesn't set priority, explicitly 915 # set the default priority 916 if [ "$CMD_IS_GNUTLS" -eq 1 ]; then 917 case "$SRV_CMD" in 918 *--priority*) :;; 919 *) SRV_CMD="$SRV_CMD --priority=NORMAL";; 920 esac 921 fi 922 923 # update CMD_IS_GNUTLS variable 924 is_gnutls "$CLI_CMD" 925 926 # if the client uses gnutls but doesn't set priority, explicitly 927 # set the default priority 928 if [ "$CMD_IS_GNUTLS" -eq 1 ]; then 929 case "$CLI_CMD" in 930 *--priority*) :;; 931 *) CLI_CMD="$CLI_CMD --priority=NORMAL";; 932 esac 933 fi 934 935 # fix client port 936 if [ -n "$PXY_CMD" ]; then 937 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g ) 938 else 939 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g ) 940 fi 941 942 # prepend valgrind to our commands if active 943 if [ "$MEMCHECK" -gt 0 ]; then 944 if is_polar "$SRV_CMD"; then 945 SRV_CMD="valgrind --leak-check=full $SRV_CMD" 946 fi 947 if is_polar "$CLI_CMD"; then 948 CLI_CMD="valgrind --leak-check=full $CLI_CMD" 949 fi 950 fi 951} 952 953# Check for failure conditions after a test case. 954# 955# Inputs from run_test: 956# * positional parameters: test options (see run_test documentation) 957# * $CLI_EXIT: client return code 958# * $CLI_EXPECT: expected client return code 959# * $SRV_RET: server return code 960# * $CLI_OUT, $SRV_OUT, $PXY_OUT: files containing client/server/proxy logs 961# * $TIMES_LEFT: if nonzero, a RETRY outcome is allowed 962# 963# Outputs: 964# * $outcome: one of PASS/RETRY*/FAIL 965check_test_failure() { 966 outcome=FAIL 967 968 if [ $TIMES_LEFT -gt 0 ] && 969 grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null 970 then 971 outcome="RETRY(client-timeout)" 972 return 973 fi 974 975 # check if the client and server went at least to the handshake stage 976 # (useful to avoid tests with only negative assertions and non-zero 977 # expected client exit to incorrectly succeed in case of catastrophic 978 # failure) 979 if is_polar "$SRV_CMD"; then 980 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :; 981 else 982 fail "server or client failed to reach handshake stage" 983 return 984 fi 985 fi 986 if is_polar "$CLI_CMD"; then 987 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :; 988 else 989 fail "server or client failed to reach handshake stage" 990 return 991 fi 992 fi 993 994 # Check server exit code (only for Mbed TLS: GnuTLS and OpenSSL don't 995 # exit with status 0 when interrupted by a signal, and we don't really 996 # care anyway), in case e.g. the server reports a memory leak. 997 if [ $SRV_RET != 0 ] && is_polar "$SRV_CMD"; then 998 fail "Server exited with status $SRV_RET" 999 return 1000 fi 1001 1002 # check client exit code 1003 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \ 1004 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ] 1005 then 1006 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)" 1007 return 1008 fi 1009 1010 # check other assertions 1011 # lines beginning with == are added by valgrind, ignore them 1012 # lines with 'Serious error when reading debug info', are valgrind issues as well 1013 while [ $# -gt 0 ] 1014 do 1015 case $1 in 1016 "-s") 1017 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else 1018 fail "pattern '$2' MUST be present in the Server output" 1019 return 1020 fi 1021 ;; 1022 1023 "-c") 1024 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else 1025 fail "pattern '$2' MUST be present in the Client output" 1026 return 1027 fi 1028 ;; 1029 1030 "-S") 1031 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then 1032 if log_pattern_presence_is_conclusive "$2"; then 1033 fail "pattern '$2' MUST NOT be present in the Server output" 1034 fi 1035 return 1036 fi 1037 ;; 1038 1039 "-C") 1040 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then 1041 if log_pattern_presence_is_conclusive "$2"; then 1042 fail "pattern '$2' MUST NOT be present in the Client output" 1043 fi 1044 return 1045 fi 1046 ;; 1047 1048 # The filtering in the following two options (-u and -U) do the following 1049 # - ignore valgrind output 1050 # - filter out everything but lines right after the pattern occurrences 1051 # - keep one of each non-unique line 1052 # - count how many lines remain 1053 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1 1054 # if there were no duplicates. 1055 "-U") 1056 if [ $(grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then 1057 fail "lines following pattern '$2' must be unique in Server output" 1058 return 1059 fi 1060 ;; 1061 1062 "-u") 1063 if [ $(grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then 1064 fail "lines following pattern '$2' must be unique in Client output" 1065 return 1066 fi 1067 ;; 1068 "-F") 1069 if ! $2 "$SRV_OUT"; then 1070 fail "function call to '$2' failed on Server output" 1071 return 1072 fi 1073 ;; 1074 "-f") 1075 if ! $2 "$CLI_OUT"; then 1076 fail "function call to '$2' failed on Client output" 1077 return 1078 fi 1079 ;; 1080 "-g") 1081 if ! eval "$2 '$SRV_OUT' '$CLI_OUT'"; then 1082 fail "function call to '$2' failed on Server and Client output" 1083 return 1084 fi 1085 ;; 1086 1087 *) 1088 echo "Unknown test: $1" >&2 1089 exit 1 1090 esac 1091 shift 2 1092 done 1093 1094 # check valgrind's results 1095 if [ "$MEMCHECK" -gt 0 ]; then 1096 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then 1097 fail "Server has memory errors" 1098 return 1099 fi 1100 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then 1101 fail "Client has memory errors" 1102 return 1103 fi 1104 fi 1105 1106 # if we're here, everything is ok 1107 outcome=PASS 1108} 1109 1110# Run the current test case: start the server and if applicable the proxy, run 1111# the client, wait for all processes to finish or time out. 1112# 1113# Inputs: 1114# * $NAME: test case name 1115# * $CLI_CMD, $SRV_CMD, $PXY_CMD: commands to run 1116# * $CLI_OUT, $SRV_OUT, $PXY_OUT: files to contain client/server/proxy logs 1117# 1118# Outputs: 1119# * $CLI_EXIT: client return code 1120# * $SRV_RET: server return code 1121do_run_test_once() { 1122 # run the commands 1123 if [ -n "$PXY_CMD" ]; then 1124 printf "# %s\n%s\n" "$NAME" "$PXY_CMD" > $PXY_OUT 1125 $PXY_CMD >> $PXY_OUT 2>&1 & 1126 PXY_PID=$! 1127 wait_proxy_start "$PXY_PORT" "$PXY_PID" 1128 fi 1129 1130 check_osrv_dtls 1131 printf '# %s\n%s\n' "$NAME" "$SRV_CMD" > $SRV_OUT 1132 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 & 1133 SRV_PID=$! 1134 wait_server_start "$SRV_PORT" "$SRV_PID" 1135 1136 printf '# %s\n%s\n' "$NAME" "$CLI_CMD" > $CLI_OUT 1137 # The client must be a subprocess of the script in order for killing it to 1138 # work properly, that's why the ampersand is placed inside the eval command, 1139 # not at the end of the line: the latter approach will spawn eval as a 1140 # subprocess, and the $CLI_CMD as a grandchild. 1141 eval "$CLI_CMD &" >> $CLI_OUT 2>&1 1142 wait_client_done 1143 1144 sleep 0.05 1145 1146 # terminate the server (and the proxy) 1147 kill $SRV_PID 1148 wait $SRV_PID 1149 SRV_RET=$? 1150 1151 if [ -n "$PXY_CMD" ]; then 1152 kill $PXY_PID >/dev/null 2>&1 1153 wait $PXY_PID 1154 fi 1155} 1156 1157# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]] 1158# Options: -s pattern pattern that must be present in server output 1159# -c pattern pattern that must be present in client output 1160# -u pattern lines after pattern must be unique in client output 1161# -f call shell function on client output 1162# -S pattern pattern that must be absent in server output 1163# -C pattern pattern that must be absent in client output 1164# -U pattern lines after pattern must be unique in server output 1165# -F call shell function on server output 1166# -g call shell function on server and client output 1167run_test() { 1168 NAME="$1" 1169 shift 1 1170 1171 if is_excluded "$NAME"; then 1172 SKIP_NEXT="NO" 1173 # There was no request to run the test, so don't record its outcome. 1174 return 1175 fi 1176 1177 print_name "$NAME" 1178 1179 # Do we only run numbered tests? 1180 if [ -n "$RUN_TEST_NUMBER" ]; then 1181 case ",$RUN_TEST_NUMBER," in 1182 *",$TESTS,"*) :;; 1183 *) SKIP_NEXT="YES";; 1184 esac 1185 fi 1186 1187 # does this test use a proxy? 1188 if [ "X$1" = "X-p" ]; then 1189 PXY_CMD="$2" 1190 shift 2 1191 else 1192 PXY_CMD="" 1193 fi 1194 1195 # get commands and client output 1196 SRV_CMD="$1" 1197 CLI_CMD="$2" 1198 CLI_EXPECT="$3" 1199 shift 3 1200 1201 # Check if test uses files 1202 case "$SRV_CMD $CLI_CMD" in 1203 *data_files/*) 1204 requires_config_enabled MBEDTLS_FS_IO;; 1205 esac 1206 1207 # Check if the test uses DTLS. 1208 detect_dtls "$SRV_CMD" 1209 if [ "$DTLS" -eq 1 ]; then 1210 requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 1211 fi 1212 1213 # If the client or server requires certain features that can be detected 1214 # from their command-line arguments, check that they're enabled. 1215 detect_required_features "$SRV_CMD" "$@" 1216 detect_required_features "$CLI_CMD" "$@" 1217 1218 # If we're in a PSK-only build and the test can be adapted to PSK, do that. 1219 maybe_adapt_for_psk "$@" 1220 1221 # should we skip? 1222 if [ "X$SKIP_NEXT" = "XYES" ]; then 1223 SKIP_NEXT="NO" 1224 record_outcome "SKIP" 1225 SKIPS=$(( $SKIPS + 1 )) 1226 return 1227 fi 1228 1229 analyze_test_commands "$@" 1230 1231 # One regular run and two retries 1232 TIMES_LEFT=3 1233 while [ $TIMES_LEFT -gt 0 ]; do 1234 TIMES_LEFT=$(( $TIMES_LEFT - 1 )) 1235 1236 do_run_test_once 1237 1238 check_test_failure "$@" 1239 case $outcome in 1240 PASS) break;; 1241 RETRY*) printf "$outcome ";; 1242 FAIL) return;; 1243 esac 1244 done 1245 1246 # If we get this far, the test case passed. 1247 record_outcome "PASS" 1248 if [ "$PRESERVE_LOGS" -gt 0 ]; then 1249 mv $SRV_OUT o-srv-${TESTS}.log 1250 mv $CLI_OUT o-cli-${TESTS}.log 1251 if [ -n "$PXY_CMD" ]; then 1252 mv $PXY_OUT o-pxy-${TESTS}.log 1253 fi 1254 fi 1255 1256 rm -f $SRV_OUT $CLI_OUT $PXY_OUT 1257} 1258 1259run_test_psa() { 1260 requires_config_enabled MBEDTLS_USE_PSA_CRYPTO 1261 set_maybe_calc_verify none 1262 run_test "PSA-supported ciphersuite: $1" \ 1263 "$P_SRV debug_level=3 force_version=tls12" \ 1264 "$P_CLI debug_level=3 force_version=tls12 force_ciphersuite=$1" \ 1265 0 \ 1266 -c "Successfully setup PSA-based decryption cipher context" \ 1267 -c "Successfully setup PSA-based encryption cipher context" \ 1268 -c "$maybe_calc_verify" \ 1269 -c "calc PSA finished" \ 1270 -s "Successfully setup PSA-based decryption cipher context" \ 1271 -s "Successfully setup PSA-based encryption cipher context" \ 1272 -s "$maybe_calc_verify" \ 1273 -s "calc PSA finished" \ 1274 -C "Failed to setup PSA-based cipher context"\ 1275 -S "Failed to setup PSA-based cipher context"\ 1276 -s "Protocol is TLSv1.2" \ 1277 -c "Perform PSA-based ECDH computation."\ 1278 -c "Perform PSA-based computation of digest of ServerKeyExchange" \ 1279 -S "error" \ 1280 -C "error" 1281 unset maybe_calc_verify 1282} 1283 1284run_test_psa_force_curve() { 1285 requires_config_enabled MBEDTLS_USE_PSA_CRYPTO 1286 set_maybe_calc_verify none 1287 run_test "PSA - ECDH with $1" \ 1288 "$P_SRV debug_level=4 force_version=tls12" \ 1289 "$P_CLI debug_level=4 force_version=tls12 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256 curves=$1" \ 1290 0 \ 1291 -c "Successfully setup PSA-based decryption cipher context" \ 1292 -c "Successfully setup PSA-based encryption cipher context" \ 1293 -c "$maybe_calc_verify" \ 1294 -c "calc PSA finished" \ 1295 -s "Successfully setup PSA-based decryption cipher context" \ 1296 -s "Successfully setup PSA-based encryption cipher context" \ 1297 -s "$maybe_calc_verify" \ 1298 -s "calc PSA finished" \ 1299 -C "Failed to setup PSA-based cipher context"\ 1300 -S "Failed to setup PSA-based cipher context"\ 1301 -s "Protocol is TLSv1.2" \ 1302 -c "Perform PSA-based ECDH computation."\ 1303 -c "Perform PSA-based computation of digest of ServerKeyExchange" \ 1304 -S "error" \ 1305 -C "error" 1306 unset maybe_calc_verify 1307} 1308 1309# Test that the server's memory usage after a handshake is reduced when a client specifies 1310# a maximum fragment length. 1311# first argument ($1) is MFL for SSL client 1312# second argument ($2) is memory usage for SSL client with default MFL (16k) 1313run_test_memory_after_hanshake_with_mfl() 1314{ 1315 # The test passes if the difference is around 2*(16k-MFL) 1316 MEMORY_USAGE_LIMIT="$(( $2 - ( 2 * ( 16384 - $1 )) ))" 1317 1318 # Leave some margin for robustness 1319 MEMORY_USAGE_LIMIT="$(( ( MEMORY_USAGE_LIMIT * 110 ) / 100 ))" 1320 1321 run_test "Handshake memory usage (MFL $1)" \ 1322 "$P_SRV debug_level=3 auth_mode=required force_version=tls12" \ 1323 "$P_CLI debug_level=3 force_version=tls12 \ 1324 crt_file=data_files/server5.crt key_file=data_files/server5.key \ 1325 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM max_frag_len=$1" \ 1326 0 \ 1327 -F "handshake_memory_check $MEMORY_USAGE_LIMIT" 1328} 1329 1330 1331# Test that the server's memory usage after a handshake is reduced when a client specifies 1332# different values of Maximum Fragment Length: default (16k), 4k, 2k, 1k and 512 bytes 1333run_tests_memory_after_hanshake() 1334{ 1335 # all tests in this sequence requires the same configuration (see requires_config_enabled()) 1336 SKIP_THIS_TESTS="$SKIP_NEXT" 1337 1338 # first test with default MFU is to get reference memory usage 1339 MEMORY_USAGE_MFL_16K=0 1340 run_test "Handshake memory usage initial (MFL 16384 - default)" \ 1341 "$P_SRV debug_level=3 auth_mode=required force_version=tls12" \ 1342 "$P_CLI debug_level=3 force_version=tls12 \ 1343 crt_file=data_files/server5.crt key_file=data_files/server5.key \ 1344 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM" \ 1345 0 \ 1346 -F "handshake_memory_get MEMORY_USAGE_MFL_16K" 1347 1348 SKIP_NEXT="$SKIP_THIS_TESTS" 1349 run_test_memory_after_hanshake_with_mfl 4096 "$MEMORY_USAGE_MFL_16K" 1350 1351 SKIP_NEXT="$SKIP_THIS_TESTS" 1352 run_test_memory_after_hanshake_with_mfl 2048 "$MEMORY_USAGE_MFL_16K" 1353 1354 SKIP_NEXT="$SKIP_THIS_TESTS" 1355 run_test_memory_after_hanshake_with_mfl 1024 "$MEMORY_USAGE_MFL_16K" 1356 1357 SKIP_NEXT="$SKIP_THIS_TESTS" 1358 run_test_memory_after_hanshake_with_mfl 512 "$MEMORY_USAGE_MFL_16K" 1359} 1360 1361cleanup() { 1362 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION 1363 rm -f context_srv.txt 1364 rm -f context_cli.txt 1365 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1 1366 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1 1367 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1 1368 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1 1369 exit 1 1370} 1371 1372# 1373# MAIN 1374# 1375 1376get_options "$@" 1377 1378# Make the outcome file path relative to the original directory, not 1379# to .../tests 1380case "$MBEDTLS_TEST_OUTCOME_FILE" in 1381 [!/]*) 1382 MBEDTLS_TEST_OUTCOME_FILE="$ORIGINAL_PWD/$MBEDTLS_TEST_OUTCOME_FILE" 1383 ;; 1384esac 1385 1386# Optimize filters: if $FILTER and $EXCLUDE can be expressed as shell 1387# patterns rather than regular expressions, use a case statement instead 1388# of calling grep. To keep the optimizer simple, it is incomplete and only 1389# detects simple cases: plain substring, everything, nothing. 1390# 1391# As an exception, the character '.' is treated as an ordinary character 1392# if it is the only special character in the string. This is because it's 1393# rare to need "any one character", but needing a literal '.' is common 1394# (e.g. '-f "DTLS 1.2"'). 1395need_grep= 1396case "$FILTER" in 1397 '^$') simple_filter=;; 1398 '.*') simple_filter='*';; 1399 *[][$+*?\\^{\|}]*) # Regexp special characters (other than .), we need grep 1400 need_grep=1;; 1401 *) # No regexp or shell-pattern special character 1402 simple_filter="*$FILTER*";; 1403esac 1404case "$EXCLUDE" in 1405 '^$') simple_exclude=;; 1406 '.*') simple_exclude='*';; 1407 *[][$+*?\\^{\|}]*) # Regexp special characters (other than .), we need grep 1408 need_grep=1;; 1409 *) # No regexp or shell-pattern special character 1410 simple_exclude="*$EXCLUDE*";; 1411esac 1412if [ -n "$need_grep" ]; then 1413 is_excluded () { 1414 ! echo "$1" | grep "$FILTER" | grep -q -v "$EXCLUDE" 1415 } 1416else 1417 is_excluded () { 1418 case "$1" in 1419 $simple_exclude) true;; 1420 $simple_filter) false;; 1421 *) true;; 1422 esac 1423 } 1424fi 1425 1426# sanity checks, avoid an avalanche of errors 1427P_SRV_BIN="${P_SRV%%[ ]*}" 1428P_CLI_BIN="${P_CLI%%[ ]*}" 1429P_PXY_BIN="${P_PXY%%[ ]*}" 1430if [ ! -x "$P_SRV_BIN" ]; then 1431 echo "Command '$P_SRV_BIN' is not an executable file" 1432 exit 1 1433fi 1434if [ ! -x "$P_CLI_BIN" ]; then 1435 echo "Command '$P_CLI_BIN' is not an executable file" 1436 exit 1 1437fi 1438if [ ! -x "$P_PXY_BIN" ]; then 1439 echo "Command '$P_PXY_BIN' is not an executable file" 1440 exit 1 1441fi 1442if [ "$MEMCHECK" -gt 0 ]; then 1443 if which valgrind >/dev/null 2>&1; then :; else 1444 echo "Memcheck not possible. Valgrind not found" 1445 exit 1 1446 fi 1447fi 1448if which $OPENSSL >/dev/null 2>&1; then :; else 1449 echo "Command '$OPENSSL' not found" 1450 exit 1 1451fi 1452 1453# used by watchdog 1454MAIN_PID="$$" 1455 1456# We use somewhat arbitrary delays for tests: 1457# - how long do we wait for the server to start (when lsof not available)? 1458# - how long do we allow for the client to finish? 1459# (not to check performance, just to avoid waiting indefinitely) 1460# Things are slower with valgrind, so give extra time here. 1461# 1462# Note: without lsof, there is a trade-off between the running time of this 1463# script and the risk of spurious errors because we didn't wait long enough. 1464# The watchdog delay on the other hand doesn't affect normal running time of 1465# the script, only the case where a client or server gets stuck. 1466if [ "$MEMCHECK" -gt 0 ]; then 1467 START_DELAY=6 1468 DOG_DELAY=60 1469else 1470 START_DELAY=2 1471 DOG_DELAY=20 1472fi 1473 1474# some particular tests need more time: 1475# - for the client, we multiply the usual watchdog limit by a factor 1476# - for the server, we sleep for a number of seconds after the client exits 1477# see client_need_more_time() and server_needs_more_time() 1478CLI_DELAY_FACTOR=1 1479SRV_DELAY_SECONDS=0 1480 1481# fix commands to use this port, force IPv4 while at it 1482# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later 1483# Note: Using 'localhost' rather than 127.0.0.1 here is unwise, as on many 1484# machines that will resolve to ::1, and we don't want ipv6 here. 1485P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT" 1486P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT" 1487P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT ${SEED:+"seed=$SEED"}" 1488O_SRV="$O_SRV -accept $SRV_PORT" 1489O_CLI="$O_CLI -connect 127.0.0.1:+SRV_PORT" 1490G_SRV="$G_SRV -p $SRV_PORT" 1491G_CLI="$G_CLI -p +SRV_PORT" 1492 1493if [ -n "${OPENSSL_LEGACY:-}" ]; then 1494 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem" 1495 O_LEGACY_CLI="$O_LEGACY_CLI -connect 127.0.0.1:+SRV_PORT" 1496fi 1497 1498# Newer versions of OpenSSL have a syntax to enable all "ciphers", even 1499# low-security ones. This covers not just cipher suites but also protocol 1500# versions. It is necessary, for example, to use (D)TLS 1.0/1.1 on 1501# OpenSSL 1.1.1f from Ubuntu 20.04. The syntax was only introduced in 1502# OpenSSL 1.1.0 (21e0c1d23afff48601eb93135defddae51f7e2e3) and I can't find 1503# a way to discover it from -help, so check the openssl version. 1504case $($OPENSSL version) in 1505 "OpenSSL 0"*|"OpenSSL 1.0"*) :;; 1506 *) 1507 O_CLI="$O_CLI -cipher ALL@SECLEVEL=0" 1508 O_SRV="$O_SRV -cipher ALL@SECLEVEL=0" 1509 ;; 1510esac 1511 1512if [ -n "${OPENSSL_NEXT:-}" ]; then 1513 O_NEXT_SRV="$O_NEXT_SRV -accept $SRV_PORT" 1514 O_NEXT_CLI="$O_NEXT_CLI -connect 127.0.0.1:+SRV_PORT" 1515fi 1516 1517if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then 1518 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT" 1519fi 1520 1521if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then 1522 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT" 1523fi 1524 1525# Allow SHA-1, because many of our test certificates use it 1526P_SRV="$P_SRV allow_sha1=1" 1527P_CLI="$P_CLI allow_sha1=1" 1528 1529# Also pick a unique name for intermediate files 1530SRV_OUT="srv_out.$$" 1531CLI_OUT="cli_out.$$" 1532PXY_OUT="pxy_out.$$" 1533SESSION="session.$$" 1534 1535SKIP_NEXT="NO" 1536 1537trap cleanup INT TERM HUP 1538 1539# Basic test 1540 1541# Checks that: 1542# - things work with all ciphersuites active (used with config-full in all.sh) 1543# - the expected parameters are selected 1544requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2 1545requires_ciphersuite_enabled TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256 1546requires_config_enabled MBEDTLS_SHA512_C # "signature_algorithm ext: 6" 1547requires_config_enabled MBEDTLS_ECP_DP_SECP521R1_ENABLED 1548run_test "Default" \ 1549 "$P_SRV debug_level=3" \ 1550 "$P_CLI" \ 1551 0 \ 1552 -s "Protocol is TLSv1.2" \ 1553 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \ 1554 -s "client hello v3, signature_algorithm ext: 6" \ 1555 -s "ECDHE curve: secp521r1" \ 1556 -S "error" \ 1557 -C "error" 1558 1559requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2 1560requires_ciphersuite_enabled TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256 1561run_test "Default, DTLS" \ 1562 "$P_SRV dtls=1" \ 1563 "$P_CLI dtls=1" \ 1564 0 \ 1565 -s "Protocol is DTLSv1.2" \ 1566 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" 1567 1568run_test "TLS client auth: required" \ 1569 "$P_SRV auth_mode=required" \ 1570 "$P_CLI" \ 1571 0 \ 1572 -s "Verifying peer X.509 certificate... ok" 1573 1574requires_config_enabled MBEDTLS_X509_CRT_PARSE_C 1575requires_config_enabled MBEDTLS_ECDSA_C 1576requires_config_enabled MBEDTLS_SHA256_C 1577run_test "TLS: password protected client key" \ 1578 "$P_SRV auth_mode=required" \ 1579 "$P_CLI crt_file=data_files/server5.crt key_file=data_files/server5.key.enc key_pwd=PolarSSLTest" \ 1580 0 1581 1582requires_config_enabled MBEDTLS_X509_CRT_PARSE_C 1583requires_config_enabled MBEDTLS_ECDSA_C 1584requires_config_enabled MBEDTLS_SHA256_C 1585run_test "TLS: password protected server key" \ 1586 "$P_SRV crt_file=data_files/server5.crt key_file=data_files/server5.key.enc key_pwd=PolarSSLTest" \ 1587 "$P_CLI" \ 1588 0 1589 1590requires_config_enabled MBEDTLS_X509_CRT_PARSE_C 1591requires_config_enabled MBEDTLS_ECDSA_C 1592requires_config_enabled MBEDTLS_RSA_C 1593requires_config_enabled MBEDTLS_SHA256_C 1594run_test "TLS: password protected server key, two certificates" \ 1595 "$P_SRV \ 1596 key_file=data_files/server5.key.enc key_pwd=PolarSSLTest crt_file=data_files/server5.crt \ 1597 key_file2=data_files/server2.key.enc key_pwd2=PolarSSLTest crt_file2=data_files/server2.crt" \ 1598 "$P_CLI" \ 1599 0 1600 1601requires_config_enabled MBEDTLS_ZLIB_SUPPORT 1602run_test "Default (compression enabled)" \ 1603 "$P_SRV debug_level=3" \ 1604 "$P_CLI debug_level=3" \ 1605 0 \ 1606 -s "Allocating compression buffer" \ 1607 -c "Allocating compression buffer" \ 1608 -s "Record expansion is unknown (compression)" \ 1609 -c "Record expansion is unknown (compression)" \ 1610 -S "error" \ 1611 -C "error" 1612 1613requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK 1614run_test "CA callback on client" \ 1615 "$P_SRV debug_level=3" \ 1616 "$P_CLI ca_callback=1 debug_level=3 " \ 1617 0 \ 1618 -c "use CA callback for X.509 CRT verification" \ 1619 -S "error" \ 1620 -C "error" 1621 1622requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK 1623requires_config_enabled MBEDTLS_X509_CRT_PARSE_C 1624requires_config_enabled MBEDTLS_ECDSA_C 1625requires_config_enabled MBEDTLS_SHA256_C 1626run_test "CA callback on server" \ 1627 "$P_SRV auth_mode=required" \ 1628 "$P_CLI ca_callback=1 debug_level=3 crt_file=data_files/server5.crt \ 1629 key_file=data_files/server5.key" \ 1630 0 \ 1631 -c "use CA callback for X.509 CRT verification" \ 1632 -s "Verifying peer X.509 certificate... ok" \ 1633 -S "error" \ 1634 -C "error" 1635 1636# Test using an opaque private key for client authentication 1637requires_config_enabled MBEDTLS_USE_PSA_CRYPTO 1638requires_config_enabled MBEDTLS_X509_CRT_PARSE_C 1639requires_config_enabled MBEDTLS_ECDSA_C 1640requires_config_enabled MBEDTLS_SHA256_C 1641run_test "Opaque key for client authentication" \ 1642 "$P_SRV auth_mode=required crt_file=data_files/server5.crt \ 1643 key_file=data_files/server5.key" \ 1644 "$P_CLI key_opaque=1 crt_file=data_files/server5.crt \ 1645 key_file=data_files/server5.key" \ 1646 0 \ 1647 -c "key type: Opaque" \ 1648 -c "Ciphersuite is TLS-ECDHE-ECDSA" \ 1649 -s "Verifying peer X.509 certificate... ok" \ 1650 -s "Ciphersuite is TLS-ECDHE-ECDSA" \ 1651 -S "error" \ 1652 -C "error" 1653 1654# Test using an opaque private key for server authentication 1655requires_config_enabled MBEDTLS_USE_PSA_CRYPTO 1656requires_config_enabled MBEDTLS_X509_CRT_PARSE_C 1657requires_config_enabled MBEDTLS_ECDSA_C 1658requires_config_enabled MBEDTLS_SHA256_C 1659run_test "Opaque key for server authentication" \ 1660 "$P_SRV auth_mode=required key_opaque=1 crt_file=data_files/server5.crt \ 1661 key_file=data_files/server5.key" \ 1662 "$P_CLI crt_file=data_files/server5.crt \ 1663 key_file=data_files/server5.key" \ 1664 0 \ 1665 -c "Verifying peer X.509 certificate... ok" \ 1666 -c "Ciphersuite is TLS-ECDHE-ECDSA" \ 1667 -s "key types: Opaque - invalid PK" \ 1668 -s "Ciphersuite is TLS-ECDHE-ECDSA" \ 1669 -S "error" \ 1670 -C "error" 1671 1672# Test using an opaque private key for client/server authentication 1673requires_config_enabled MBEDTLS_USE_PSA_CRYPTO 1674requires_config_enabled MBEDTLS_X509_CRT_PARSE_C 1675requires_config_enabled MBEDTLS_ECDSA_C 1676requires_config_enabled MBEDTLS_SHA256_C 1677run_test "Opaque key for client/server authentication" \ 1678 "$P_SRV auth_mode=required key_opaque=1 crt_file=data_files/server5.crt \ 1679 key_file=data_files/server5.key" \ 1680 "$P_CLI key_opaque=1 crt_file=data_files/server5.crt \ 1681 key_file=data_files/server5.key" \ 1682 0 \ 1683 -c "key type: Opaque" \ 1684 -c "Verifying peer X.509 certificate... ok" \ 1685 -c "Ciphersuite is TLS-ECDHE-ECDSA" \ 1686 -s "key types: Opaque - invalid PK" \ 1687 -s "Verifying peer X.509 certificate... ok" \ 1688 -s "Ciphersuite is TLS-ECDHE-ECDSA" \ 1689 -S "error" \ 1690 -C "error" 1691 1692# Opaque keys not supported for static ECDH 1693requires_config_enabled MBEDTLS_USE_PSA_CRYPTO 1694requires_config_enabled MBEDTLS_X509_CRT_PARSE_C 1695run_test "Opaque key: server: ECDH-ECDSA not supported" \ 1696 "$P_SRV debug_level=1 key_opaque=1 1697 crt_file=data_files/server5.crt key_file=data_files/server5.key" \ 1698 "$P_CLI force_ciphersuite=TLS-ECDH-ECDSA-WITH-AES-128-GCM-SHA256" \ 1699 1 \ 1700 -s "server key not ECDH capable" \ 1701 -s "ssl_get_ecdh_params_from_cert() returned" \ 1702 -s "error" \ 1703 -c "error" 1704 1705# Opaque keys not supported for static ECDH 1706requires_config_enabled MBEDTLS_USE_PSA_CRYPTO 1707requires_config_enabled MBEDTLS_X509_CRT_PARSE_C 1708run_test "Opaque key: server: ECDH-RSA not supported" \ 1709 "$P_SRV debug_level=1 key_opaque=1 1710 crt_file=data_files/server5.crt key_file=data_files/server5.key" \ 1711 "$P_CLI force_ciphersuite=TLS-ECDH-RSA-WITH-AES-128-GCM-SHA256" \ 1712 1 \ 1713 -s "server key not ECDH capable" \ 1714 -s "ssl_get_ecdh_params_from_cert() returned" \ 1715 -s "error" \ 1716 -c "error" 1717 1718# Opaque PSKs not supported for mixed PSK 1719 1720requires_config_enabled MBEDTLS_USE_PSA_CRYPTO 1721run_test "Opaque psk: client: ECDHE-PSK not supported" \ 1722 "$P_SRV debug_level=1 psk=abc123 psk_identity=foo" \ 1723 "$P_CLI debug_level=1 psk=abc123 psk_identity=foo psk_opaque=1 \ 1724 force_version=tls12 \ 1725 force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA" \ 1726 1 \ 1727 -c "opaque PSK not supported with ECDHE-PSK" \ 1728 -s "error" \ 1729 -c "error" 1730 1731requires_config_enabled MBEDTLS_USE_PSA_CRYPTO 1732run_test "Opaque psk: client: DHE-PSK not supported" \ 1733 "$P_SRV debug_level=1 psk=abc123 psk_identity=foo" \ 1734 "$P_CLI debug_level=1 psk=abc123 psk_identity=foo psk_opaque=1 \ 1735 force_version=tls12 \ 1736 force_ciphersuite=TLS-DHE-PSK-WITH-AES-128-CBC-SHA" \ 1737 1 \ 1738 -c "opaque PSK not supported with DHE-PSK" \ 1739 -s "error" \ 1740 -c "error" 1741 1742requires_config_enabled MBEDTLS_USE_PSA_CRYPTO 1743run_test "Opaque psk: client: RSA-PSK not supported" \ 1744 "$P_SRV debug_level=1 psk=abc123 psk_identity=foo" \ 1745 "$P_CLI debug_level=1 psk=abc123 psk_identity=foo psk_opaque=1 \ 1746 force_version=tls12 \ 1747 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA" \ 1748 1 \ 1749 -c "opaque PSK not supported with RSA-PSK" \ 1750 -s "error" \ 1751 -c "error" 1752 1753requires_config_enabled MBEDTLS_USE_PSA_CRYPTO 1754run_test "Opaque psk: server: ECDHE-PSK not supported" \ 1755 "$P_SRV debug_level=1 psk=abc123 psk_identity=foo psk_opaque=1 \ 1756 force_version=tls12 \ 1757 force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA" \ 1758 "$P_CLI debug_level=1 psk=abc123 psk_identity=foo" \ 1759 1 \ 1760 -s "opaque PSK not supported with ECDHE-PSK" \ 1761 -s "error" \ 1762 -c "error" 1763 1764requires_config_enabled MBEDTLS_USE_PSA_CRYPTO 1765run_test "Opaque psk: server: DHE-PSK not supported" \ 1766 "$P_SRV debug_level=1 psk=abc123 psk_identity=foo psk_opaque=1 \ 1767 force_version=tls12 \ 1768 force_ciphersuite=TLS-DHE-PSK-WITH-AES-128-CBC-SHA" \ 1769 "$P_CLI debug_level=1 psk=abc123 psk_identity=foo" \ 1770 1 \ 1771 -s "opaque PSK not supported with DHE-PSK" \ 1772 -s "error" \ 1773 -c "error" 1774 1775requires_config_enabled MBEDTLS_USE_PSA_CRYPTO 1776run_test "Opaque psk: server: RSA-PSK not supported" \ 1777 "$P_SRV debug_level=1 psk=abc123 psk_identity=foo psk_opaque=1 \ 1778 force_version=tls12 \ 1779 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA" \ 1780 "$P_CLI debug_level=1 psk=abc123 psk_identity=foo" \ 1781 1 \ 1782 -s "opaque PSK not supported with RSA-PSK" \ 1783 -s "error" \ 1784 -c "error" 1785 1786# Test ciphersuites which we expect to be fully supported by PSA Crypto 1787# and check that we don't fall back to Mbed TLS' internal crypto primitives. 1788run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CCM 1789run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 1790run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CCM 1791run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CCM-8 1792run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 1793run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384 1794run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA 1795run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 1796run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384 1797 1798requires_config_enabled MBEDTLS_ECP_DP_SECP521R1_ENABLED 1799run_test_psa_force_curve "secp521r1" 1800requires_config_enabled MBEDTLS_ECP_DP_BP512R1_ENABLED 1801run_test_psa_force_curve "brainpoolP512r1" 1802requires_config_enabled MBEDTLS_ECP_DP_SECP384R1_ENABLED 1803run_test_psa_force_curve "secp384r1" 1804requires_config_enabled MBEDTLS_ECP_DP_BP384R1_ENABLED 1805run_test_psa_force_curve "brainpoolP384r1" 1806requires_config_enabled MBEDTLS_ECP_DP_SECP256R1_ENABLED 1807run_test_psa_force_curve "secp256r1" 1808requires_config_enabled MBEDTLS_ECP_DP_SECP256K1_ENABLED 1809run_test_psa_force_curve "secp256k1" 1810requires_config_enabled MBEDTLS_ECP_DP_BP256R1_ENABLED 1811run_test_psa_force_curve "brainpoolP256r1" 1812requires_config_enabled MBEDTLS_ECP_DP_SECP224R1_ENABLED 1813run_test_psa_force_curve "secp224r1" 1814## SECP224K1 is buggy via the PSA API 1815## (https://github.com/Mbed-TLS/mbedtls/issues/3541), 1816## so it is disabled in PSA even when it's enabled in Mbed TLS. 1817## The proper dependency would be on PSA_WANT_ECC_SECP_K1_224 but 1818## dependencies on PSA symbols in ssl-opt.sh are not implemented yet. 1819#requires_config_enabled MBEDTLS_ECP_DP_SECP224K1_ENABLED 1820#run_test_psa_force_curve "secp224k1" 1821requires_config_enabled MBEDTLS_ECP_DP_SECP192R1_ENABLED 1822run_test_psa_force_curve "secp192r1" 1823requires_config_enabled MBEDTLS_ECP_DP_SECP192K1_ENABLED 1824run_test_psa_force_curve "secp192k1" 1825 1826# Test current time in ServerHello 1827requires_config_enabled MBEDTLS_HAVE_TIME 1828run_test "ServerHello contains gmt_unix_time" \ 1829 "$P_SRV debug_level=3" \ 1830 "$P_CLI debug_level=3" \ 1831 0 \ 1832 -f "check_server_hello_time" \ 1833 -F "check_server_hello_time" 1834 1835# Test for uniqueness of IVs in AEAD ciphersuites 1836run_test "Unique IV in GCM" \ 1837 "$P_SRV exchanges=20 debug_level=4" \ 1838 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \ 1839 0 \ 1840 -u "IV used" \ 1841 -U "IV used" 1842 1843# Tests for certificate verification callback 1844run_test "Configuration-specific CRT verification callback" \ 1845 "$P_SRV debug_level=3" \ 1846 "$P_CLI context_crt_cb=0 debug_level=3" \ 1847 0 \ 1848 -S "error" \ 1849 -c "Verify requested for " \ 1850 -c "Use configuration-specific verification callback" \ 1851 -C "Use context-specific verification callback" \ 1852 -C "error" 1853 1854run_test "Context-specific CRT verification callback" \ 1855 "$P_SRV debug_level=3" \ 1856 "$P_CLI context_crt_cb=1 debug_level=3" \ 1857 0 \ 1858 -S "error" \ 1859 -c "Verify requested for " \ 1860 -c "Use context-specific verification callback" \ 1861 -C "Use configuration-specific verification callback" \ 1862 -C "error" 1863 1864# Tests for rc4 option 1865 1866# Manual dependencies on the ciphersuite support are necessary 1867# because the automatic requirements from force_ciphersuite=... detection 1868# make an exception for these test cases since they expect a handshake 1869# failure. 1870requires_config_enabled MBEDTLS_ARC4_C 1871requires_config_enabled MBEDTLS_SHA1_C 1872requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED 1873requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES 1874run_test "RC4: server disabled, client enabled" \ 1875 "$P_SRV" \ 1876 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 1877 1 \ 1878 -s "SSL - The server has no ciphersuites in common" 1879 1880requires_config_enabled MBEDTLS_ARC4_C 1881requires_config_enabled MBEDTLS_SHA1_C 1882requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED 1883requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES 1884run_test "RC4: server half, client enabled" \ 1885 "$P_SRV arc4=1" \ 1886 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 1887 1 \ 1888 -s "SSL - The server has no ciphersuites in common" 1889 1890requires_config_enabled MBEDTLS_ARC4_C 1891requires_config_enabled MBEDTLS_SHA1_C 1892requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED 1893requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES 1894run_test "RC4: server enabled, client disabled" \ 1895 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 1896 "$P_CLI" \ 1897 1 \ 1898 -s "SSL - The server has no ciphersuites in common" 1899 1900# Run even if the ciphersuite is disabled by default, but only if the 1901# requisite cryptographic mechanisms are present. 1902# Having "force_ciphersuite=..." in the client or server arguments would 1903# prevent that due to the automatic detection, so hide behind some 1904# shell expansion to fool the automatic detection. 1905with_rc4_ciphersuite() { 1906 exec "$@" force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA 1907} 1908requires_config_enabled MBEDTLS_ARC4_C 1909requires_config_enabled MBEDTLS_SHA1_C 1910requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED 1911run_test "RC4: both enabled" \ 1912 "with_rc4_ciphersuite $P_SRV" \ 1913 "with_rc4_ciphersuite $P_CLI" \ 1914 0 \ 1915 -S "SSL - None of the common ciphersuites is usable" \ 1916 -S "SSL - The server has no ciphersuites in common" 1917 1918# Test empty CA list in CertificateRequest in TLS 1.1 and earlier 1919 1920requires_gnutls 1921run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \ 1922 "$G_SRV"\ 1923 "$P_CLI force_version=tls1_1" \ 1924 0 1925 1926requires_gnutls 1927run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \ 1928 "$G_SRV"\ 1929 "$P_CLI force_version=tls1" \ 1930 0 1931 1932# Tests for SHA-1 support 1933 1934run_test "SHA-1 forbidden by default in server certificate" \ 1935 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \ 1936 "$P_CLI debug_level=2 allow_sha1=0" \ 1937 1 \ 1938 -c "The certificate is signed with an unacceptable hash" 1939 1940run_test "SHA-1 explicitly allowed in server certificate" \ 1941 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \ 1942 "$P_CLI allow_sha1=1" \ 1943 0 1944 1945run_test "SHA-256 allowed by default in server certificate" \ 1946 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \ 1947 "$P_CLI allow_sha1=0" \ 1948 0 1949 1950run_test "SHA-1 forbidden by default in client certificate" \ 1951 "$P_SRV auth_mode=required allow_sha1=0" \ 1952 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \ 1953 1 \ 1954 -s "The certificate is signed with an unacceptable hash" 1955 1956run_test "SHA-1 explicitly allowed in client certificate" \ 1957 "$P_SRV auth_mode=required allow_sha1=1" \ 1958 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \ 1959 0 1960 1961run_test "SHA-256 allowed by default in client certificate" \ 1962 "$P_SRV auth_mode=required allow_sha1=0" \ 1963 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \ 1964 0 1965 1966# Tests for datagram packing 1967run_test "DTLS: multiple records in same datagram, client and server" \ 1968 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \ 1969 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \ 1970 0 \ 1971 -c "next record in same datagram" \ 1972 -s "next record in same datagram" 1973 1974run_test "DTLS: multiple records in same datagram, client only" \ 1975 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \ 1976 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \ 1977 0 \ 1978 -s "next record in same datagram" \ 1979 -C "next record in same datagram" 1980 1981run_test "DTLS: multiple records in same datagram, server only" \ 1982 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \ 1983 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \ 1984 0 \ 1985 -S "next record in same datagram" \ 1986 -c "next record in same datagram" 1987 1988run_test "DTLS: multiple records in same datagram, neither client nor server" \ 1989 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \ 1990 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \ 1991 0 \ 1992 -S "next record in same datagram" \ 1993 -C "next record in same datagram" 1994 1995# Tests for Truncated HMAC extension 1996 1997run_test "Truncated HMAC: client default, server default" \ 1998 "$P_SRV debug_level=4" \ 1999 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ 2000 0 \ 2001 -s "dumping 'expected mac' (20 bytes)" \ 2002 -S "dumping 'expected mac' (10 bytes)" 2003 2004requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 2005run_test "Truncated HMAC: client disabled, server default" \ 2006 "$P_SRV debug_level=4" \ 2007 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \ 2008 0 \ 2009 -s "dumping 'expected mac' (20 bytes)" \ 2010 -S "dumping 'expected mac' (10 bytes)" 2011 2012requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 2013run_test "Truncated HMAC: client enabled, server default" \ 2014 "$P_SRV debug_level=4" \ 2015 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \ 2016 0 \ 2017 -s "dumping 'expected mac' (20 bytes)" \ 2018 -S "dumping 'expected mac' (10 bytes)" 2019 2020requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 2021run_test "Truncated HMAC: client enabled, server disabled" \ 2022 "$P_SRV debug_level=4 trunc_hmac=0" \ 2023 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \ 2024 0 \ 2025 -s "dumping 'expected mac' (20 bytes)" \ 2026 -S "dumping 'expected mac' (10 bytes)" 2027 2028requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 2029run_test "Truncated HMAC: client disabled, server enabled" \ 2030 "$P_SRV debug_level=4 trunc_hmac=1" \ 2031 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \ 2032 0 \ 2033 -s "dumping 'expected mac' (20 bytes)" \ 2034 -S "dumping 'expected mac' (10 bytes)" 2035 2036requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 2037run_test "Truncated HMAC: client enabled, server enabled" \ 2038 "$P_SRV debug_level=4 trunc_hmac=1" \ 2039 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \ 2040 0 \ 2041 -S "dumping 'expected mac' (20 bytes)" \ 2042 -s "dumping 'expected mac' (10 bytes)" 2043 2044run_test "Truncated HMAC, DTLS: client default, server default" \ 2045 "$P_SRV dtls=1 debug_level=4" \ 2046 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ 2047 0 \ 2048 -s "dumping 'expected mac' (20 bytes)" \ 2049 -S "dumping 'expected mac' (10 bytes)" 2050 2051requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 2052run_test "Truncated HMAC, DTLS: client disabled, server default" \ 2053 "$P_SRV dtls=1 debug_level=4" \ 2054 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \ 2055 0 \ 2056 -s "dumping 'expected mac' (20 bytes)" \ 2057 -S "dumping 'expected mac' (10 bytes)" 2058 2059requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 2060run_test "Truncated HMAC, DTLS: client enabled, server default" \ 2061 "$P_SRV dtls=1 debug_level=4" \ 2062 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \ 2063 0 \ 2064 -s "dumping 'expected mac' (20 bytes)" \ 2065 -S "dumping 'expected mac' (10 bytes)" 2066 2067requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 2068run_test "Truncated HMAC, DTLS: client enabled, server disabled" \ 2069 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \ 2070 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \ 2071 0 \ 2072 -s "dumping 'expected mac' (20 bytes)" \ 2073 -S "dumping 'expected mac' (10 bytes)" 2074 2075requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 2076run_test "Truncated HMAC, DTLS: client disabled, server enabled" \ 2077 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \ 2078 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \ 2079 0 \ 2080 -s "dumping 'expected mac' (20 bytes)" \ 2081 -S "dumping 'expected mac' (10 bytes)" 2082 2083requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 2084run_test "Truncated HMAC, DTLS: client enabled, server enabled" \ 2085 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \ 2086 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \ 2087 0 \ 2088 -S "dumping 'expected mac' (20 bytes)" \ 2089 -s "dumping 'expected mac' (10 bytes)" 2090 2091# Tests for Context serialization 2092 2093requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION 2094run_test "Context serialization, client serializes, CCM" \ 2095 "$P_SRV dtls=1 serialize=0 exchanges=2" \ 2096 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \ 2097 0 \ 2098 -c "Deserializing connection..." \ 2099 -S "Deserializing connection..." 2100 2101requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION 2102run_test "Context serialization, client serializes, ChaChaPoly" \ 2103 "$P_SRV dtls=1 serialize=0 exchanges=2" \ 2104 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \ 2105 0 \ 2106 -c "Deserializing connection..." \ 2107 -S "Deserializing connection..." 2108 2109requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION 2110run_test "Context serialization, client serializes, GCM" \ 2111 "$P_SRV dtls=1 serialize=0 exchanges=2" \ 2112 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \ 2113 0 \ 2114 -c "Deserializing connection..." \ 2115 -S "Deserializing connection..." 2116 2117requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION 2118requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2119run_test "Context serialization, client serializes, with CID" \ 2120 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \ 2121 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \ 2122 0 \ 2123 -c "Deserializing connection..." \ 2124 -S "Deserializing connection..." 2125 2126requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION 2127run_test "Context serialization, server serializes, CCM" \ 2128 "$P_SRV dtls=1 serialize=1 exchanges=2" \ 2129 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \ 2130 0 \ 2131 -C "Deserializing connection..." \ 2132 -s "Deserializing connection..." 2133 2134requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION 2135run_test "Context serialization, server serializes, ChaChaPoly" \ 2136 "$P_SRV dtls=1 serialize=1 exchanges=2" \ 2137 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \ 2138 0 \ 2139 -C "Deserializing connection..." \ 2140 -s "Deserializing connection..." 2141 2142requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION 2143run_test "Context serialization, server serializes, GCM" \ 2144 "$P_SRV dtls=1 serialize=1 exchanges=2" \ 2145 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \ 2146 0 \ 2147 -C "Deserializing connection..." \ 2148 -s "Deserializing connection..." 2149 2150requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION 2151requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2152run_test "Context serialization, server serializes, with CID" \ 2153 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \ 2154 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \ 2155 0 \ 2156 -C "Deserializing connection..." \ 2157 -s "Deserializing connection..." 2158 2159requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION 2160run_test "Context serialization, both serialize, CCM" \ 2161 "$P_SRV dtls=1 serialize=1 exchanges=2" \ 2162 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \ 2163 0 \ 2164 -c "Deserializing connection..." \ 2165 -s "Deserializing connection..." 2166 2167requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION 2168run_test "Context serialization, both serialize, ChaChaPoly" \ 2169 "$P_SRV dtls=1 serialize=1 exchanges=2" \ 2170 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \ 2171 0 \ 2172 -c "Deserializing connection..." \ 2173 -s "Deserializing connection..." 2174 2175requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION 2176run_test "Context serialization, both serialize, GCM" \ 2177 "$P_SRV dtls=1 serialize=1 exchanges=2" \ 2178 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \ 2179 0 \ 2180 -c "Deserializing connection..." \ 2181 -s "Deserializing connection..." 2182 2183requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION 2184requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2185run_test "Context serialization, both serialize, with CID" \ 2186 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \ 2187 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \ 2188 0 \ 2189 -c "Deserializing connection..." \ 2190 -s "Deserializing connection..." 2191 2192requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION 2193run_test "Context serialization, re-init, client serializes, CCM" \ 2194 "$P_SRV dtls=1 serialize=0 exchanges=2" \ 2195 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \ 2196 0 \ 2197 -c "Deserializing connection..." \ 2198 -S "Deserializing connection..." 2199 2200requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION 2201run_test "Context serialization, re-init, client serializes, ChaChaPoly" \ 2202 "$P_SRV dtls=1 serialize=0 exchanges=2" \ 2203 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \ 2204 0 \ 2205 -c "Deserializing connection..." \ 2206 -S "Deserializing connection..." 2207 2208requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION 2209run_test "Context serialization, re-init, client serializes, GCM" \ 2210 "$P_SRV dtls=1 serialize=0 exchanges=2" \ 2211 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \ 2212 0 \ 2213 -c "Deserializing connection..." \ 2214 -S "Deserializing connection..." 2215 2216requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION 2217requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2218run_test "Context serialization, re-init, client serializes, with CID" \ 2219 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \ 2220 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \ 2221 0 \ 2222 -c "Deserializing connection..." \ 2223 -S "Deserializing connection..." 2224 2225requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION 2226run_test "Context serialization, re-init, server serializes, CCM" \ 2227 "$P_SRV dtls=1 serialize=2 exchanges=2" \ 2228 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \ 2229 0 \ 2230 -C "Deserializing connection..." \ 2231 -s "Deserializing connection..." 2232 2233requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION 2234run_test "Context serialization, re-init, server serializes, ChaChaPoly" \ 2235 "$P_SRV dtls=1 serialize=2 exchanges=2" \ 2236 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \ 2237 0 \ 2238 -C "Deserializing connection..." \ 2239 -s "Deserializing connection..." 2240 2241requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION 2242run_test "Context serialization, re-init, server serializes, GCM" \ 2243 "$P_SRV dtls=1 serialize=2 exchanges=2" \ 2244 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \ 2245 0 \ 2246 -C "Deserializing connection..." \ 2247 -s "Deserializing connection..." 2248 2249requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION 2250requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2251run_test "Context serialization, re-init, server serializes, with CID" \ 2252 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \ 2253 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \ 2254 0 \ 2255 -C "Deserializing connection..." \ 2256 -s "Deserializing connection..." 2257 2258requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION 2259run_test "Context serialization, re-init, both serialize, CCM" \ 2260 "$P_SRV dtls=1 serialize=2 exchanges=2" \ 2261 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \ 2262 0 \ 2263 -c "Deserializing connection..." \ 2264 -s "Deserializing connection..." 2265 2266requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION 2267run_test "Context serialization, re-init, both serialize, ChaChaPoly" \ 2268 "$P_SRV dtls=1 serialize=2 exchanges=2" \ 2269 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \ 2270 0 \ 2271 -c "Deserializing connection..." \ 2272 -s "Deserializing connection..." 2273 2274requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION 2275run_test "Context serialization, re-init, both serialize, GCM" \ 2276 "$P_SRV dtls=1 serialize=2 exchanges=2" \ 2277 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \ 2278 0 \ 2279 -c "Deserializing connection..." \ 2280 -s "Deserializing connection..." 2281 2282requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION 2283requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2284run_test "Context serialization, re-init, both serialize, with CID" \ 2285 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \ 2286 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \ 2287 0 \ 2288 -c "Deserializing connection..." \ 2289 -s "Deserializing connection..." 2290 2291requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION 2292run_test "Saving the serialized context to a file" \ 2293 "$P_SRV dtls=1 serialize=1 context_file=context_srv.txt" \ 2294 "$P_CLI dtls=1 serialize=1 context_file=context_cli.txt" \ 2295 0 \ 2296 -s "Save serialized context to a file... ok" \ 2297 -c "Save serialized context to a file... ok" 2298rm -f context_srv.txt 2299rm -f context_cli.txt 2300 2301# Tests for DTLS Connection ID extension 2302 2303# So far, the CID API isn't implemented, so we can't 2304# grep for output witnessing its use. This needs to be 2305# changed once the CID extension is implemented. 2306 2307requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2308run_test "Connection ID: Cli enabled, Srv disabled" \ 2309 "$P_SRV debug_level=3 dtls=1 cid=0" \ 2310 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \ 2311 0 \ 2312 -s "Disable use of CID extension." \ 2313 -s "found CID extension" \ 2314 -s "Client sent CID extension, but CID disabled" \ 2315 -c "Enable use of CID extension." \ 2316 -c "client hello, adding CID extension" \ 2317 -S "server hello, adding CID extension" \ 2318 -C "found CID extension" \ 2319 -S "Copy CIDs into SSL transform" \ 2320 -C "Copy CIDs into SSL transform" \ 2321 -c "Use of Connection ID was rejected by the server" 2322 2323requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2324run_test "Connection ID: Cli disabled, Srv enabled" \ 2325 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \ 2326 "$P_CLI debug_level=3 dtls=1 cid=0" \ 2327 0 \ 2328 -c "Disable use of CID extension." \ 2329 -C "client hello, adding CID extension" \ 2330 -S "found CID extension" \ 2331 -s "Enable use of CID extension." \ 2332 -S "server hello, adding CID extension" \ 2333 -C "found CID extension" \ 2334 -S "Copy CIDs into SSL transform" \ 2335 -C "Copy CIDs into SSL transform" \ 2336 -s "Use of Connection ID was not offered by client" 2337 2338requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2339run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty" \ 2340 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \ 2341 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef" \ 2342 0 \ 2343 -c "Enable use of CID extension." \ 2344 -s "Enable use of CID extension." \ 2345 -c "client hello, adding CID extension" \ 2346 -s "found CID extension" \ 2347 -s "Use of CID extension negotiated" \ 2348 -s "server hello, adding CID extension" \ 2349 -c "found CID extension" \ 2350 -c "Use of CID extension negotiated" \ 2351 -s "Copy CIDs into SSL transform" \ 2352 -c "Copy CIDs into SSL transform" \ 2353 -c "Peer CID (length 2 Bytes): de ad" \ 2354 -s "Peer CID (length 2 Bytes): be ef" \ 2355 -s "Use of Connection ID has been negotiated" \ 2356 -c "Use of Connection ID has been negotiated" 2357 2358requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2359run_test "Connection ID, 3D: Cli+Srv enabled, Cli+Srv CID nonempty" \ 2360 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \ 2361 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead" \ 2362 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef" \ 2363 0 \ 2364 -c "Enable use of CID extension." \ 2365 -s "Enable use of CID extension." \ 2366 -c "client hello, adding CID extension" \ 2367 -s "found CID extension" \ 2368 -s "Use of CID extension negotiated" \ 2369 -s "server hello, adding CID extension" \ 2370 -c "found CID extension" \ 2371 -c "Use of CID extension negotiated" \ 2372 -s "Copy CIDs into SSL transform" \ 2373 -c "Copy CIDs into SSL transform" \ 2374 -c "Peer CID (length 2 Bytes): de ad" \ 2375 -s "Peer CID (length 2 Bytes): be ef" \ 2376 -s "Use of Connection ID has been negotiated" \ 2377 -c "Use of Connection ID has been negotiated" \ 2378 -c "ignoring unexpected CID" \ 2379 -s "ignoring unexpected CID" 2380 2381requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2382run_test "Connection ID, MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \ 2383 -p "$P_PXY mtu=800" \ 2384 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \ 2385 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \ 2386 0 \ 2387 -c "Enable use of CID extension." \ 2388 -s "Enable use of CID extension." \ 2389 -c "client hello, adding CID extension" \ 2390 -s "found CID extension" \ 2391 -s "Use of CID extension negotiated" \ 2392 -s "server hello, adding CID extension" \ 2393 -c "found CID extension" \ 2394 -c "Use of CID extension negotiated" \ 2395 -s "Copy CIDs into SSL transform" \ 2396 -c "Copy CIDs into SSL transform" \ 2397 -c "Peer CID (length 2 Bytes): de ad" \ 2398 -s "Peer CID (length 2 Bytes): be ef" \ 2399 -s "Use of Connection ID has been negotiated" \ 2400 -c "Use of Connection ID has been negotiated" 2401 2402requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2403run_test "Connection ID, 3D+MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \ 2404 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \ 2405 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \ 2406 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \ 2407 0 \ 2408 -c "Enable use of CID extension." \ 2409 -s "Enable use of CID extension." \ 2410 -c "client hello, adding CID extension" \ 2411 -s "found CID extension" \ 2412 -s "Use of CID extension negotiated" \ 2413 -s "server hello, adding CID extension" \ 2414 -c "found CID extension" \ 2415 -c "Use of CID extension negotiated" \ 2416 -s "Copy CIDs into SSL transform" \ 2417 -c "Copy CIDs into SSL transform" \ 2418 -c "Peer CID (length 2 Bytes): de ad" \ 2419 -s "Peer CID (length 2 Bytes): be ef" \ 2420 -s "Use of Connection ID has been negotiated" \ 2421 -c "Use of Connection ID has been negotiated" \ 2422 -c "ignoring unexpected CID" \ 2423 -s "ignoring unexpected CID" 2424 2425requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2426run_test "Connection ID: Cli+Srv enabled, Cli CID empty" \ 2427 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \ 2428 "$P_CLI debug_level=3 dtls=1 cid=1" \ 2429 0 \ 2430 -c "Enable use of CID extension." \ 2431 -s "Enable use of CID extension." \ 2432 -c "client hello, adding CID extension" \ 2433 -s "found CID extension" \ 2434 -s "Use of CID extension negotiated" \ 2435 -s "server hello, adding CID extension" \ 2436 -c "found CID extension" \ 2437 -c "Use of CID extension negotiated" \ 2438 -s "Copy CIDs into SSL transform" \ 2439 -c "Copy CIDs into SSL transform" \ 2440 -c "Peer CID (length 4 Bytes): de ad be ef" \ 2441 -s "Peer CID (length 0 Bytes):" \ 2442 -s "Use of Connection ID has been negotiated" \ 2443 -c "Use of Connection ID has been negotiated" 2444 2445requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2446run_test "Connection ID: Cli+Srv enabled, Srv CID empty" \ 2447 "$P_SRV debug_level=3 dtls=1 cid=1" \ 2448 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \ 2449 0 \ 2450 -c "Enable use of CID extension." \ 2451 -s "Enable use of CID extension." \ 2452 -c "client hello, adding CID extension" \ 2453 -s "found CID extension" \ 2454 -s "Use of CID extension negotiated" \ 2455 -s "server hello, adding CID extension" \ 2456 -c "found CID extension" \ 2457 -c "Use of CID extension negotiated" \ 2458 -s "Copy CIDs into SSL transform" \ 2459 -c "Copy CIDs into SSL transform" \ 2460 -s "Peer CID (length 4 Bytes): de ad be ef" \ 2461 -c "Peer CID (length 0 Bytes):" \ 2462 -s "Use of Connection ID has been negotiated" \ 2463 -c "Use of Connection ID has been negotiated" 2464 2465requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2466run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty" \ 2467 "$P_SRV debug_level=3 dtls=1 cid=1" \ 2468 "$P_CLI debug_level=3 dtls=1 cid=1" \ 2469 0 \ 2470 -c "Enable use of CID extension." \ 2471 -s "Enable use of CID extension." \ 2472 -c "client hello, adding CID extension" \ 2473 -s "found CID extension" \ 2474 -s "Use of CID extension negotiated" \ 2475 -s "server hello, adding CID extension" \ 2476 -c "found CID extension" \ 2477 -c "Use of CID extension negotiated" \ 2478 -s "Copy CIDs into SSL transform" \ 2479 -c "Copy CIDs into SSL transform" \ 2480 -S "Use of Connection ID has been negotiated" \ 2481 -C "Use of Connection ID has been negotiated" 2482 2483requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2484run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CCM-8" \ 2485 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \ 2486 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \ 2487 0 \ 2488 -c "Enable use of CID extension." \ 2489 -s "Enable use of CID extension." \ 2490 -c "client hello, adding CID extension" \ 2491 -s "found CID extension" \ 2492 -s "Use of CID extension negotiated" \ 2493 -s "server hello, adding CID extension" \ 2494 -c "found CID extension" \ 2495 -c "Use of CID extension negotiated" \ 2496 -s "Copy CIDs into SSL transform" \ 2497 -c "Copy CIDs into SSL transform" \ 2498 -c "Peer CID (length 2 Bytes): de ad" \ 2499 -s "Peer CID (length 2 Bytes): be ef" \ 2500 -s "Use of Connection ID has been negotiated" \ 2501 -c "Use of Connection ID has been negotiated" 2502 2503requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2504run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CCM-8" \ 2505 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \ 2506 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \ 2507 0 \ 2508 -c "Enable use of CID extension." \ 2509 -s "Enable use of CID extension." \ 2510 -c "client hello, adding CID extension" \ 2511 -s "found CID extension" \ 2512 -s "Use of CID extension negotiated" \ 2513 -s "server hello, adding CID extension" \ 2514 -c "found CID extension" \ 2515 -c "Use of CID extension negotiated" \ 2516 -s "Copy CIDs into SSL transform" \ 2517 -c "Copy CIDs into SSL transform" \ 2518 -c "Peer CID (length 4 Bytes): de ad be ef" \ 2519 -s "Peer CID (length 0 Bytes):" \ 2520 -s "Use of Connection ID has been negotiated" \ 2521 -c "Use of Connection ID has been negotiated" 2522 2523requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2524run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CCM-8" \ 2525 "$P_SRV debug_level=3 dtls=1 cid=1" \ 2526 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \ 2527 0 \ 2528 -c "Enable use of CID extension." \ 2529 -s "Enable use of CID extension." \ 2530 -c "client hello, adding CID extension" \ 2531 -s "found CID extension" \ 2532 -s "Use of CID extension negotiated" \ 2533 -s "server hello, adding CID extension" \ 2534 -c "found CID extension" \ 2535 -c "Use of CID extension negotiated" \ 2536 -s "Copy CIDs into SSL transform" \ 2537 -c "Copy CIDs into SSL transform" \ 2538 -s "Peer CID (length 4 Bytes): de ad be ef" \ 2539 -c "Peer CID (length 0 Bytes):" \ 2540 -s "Use of Connection ID has been negotiated" \ 2541 -c "Use of Connection ID has been negotiated" 2542 2543requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2544run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CCM-8" \ 2545 "$P_SRV debug_level=3 dtls=1 cid=1" \ 2546 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \ 2547 0 \ 2548 -c "Enable use of CID extension." \ 2549 -s "Enable use of CID extension." \ 2550 -c "client hello, adding CID extension" \ 2551 -s "found CID extension" \ 2552 -s "Use of CID extension negotiated" \ 2553 -s "server hello, adding CID extension" \ 2554 -c "found CID extension" \ 2555 -c "Use of CID extension negotiated" \ 2556 -s "Copy CIDs into SSL transform" \ 2557 -c "Copy CIDs into SSL transform" \ 2558 -S "Use of Connection ID has been negotiated" \ 2559 -C "Use of Connection ID has been negotiated" 2560 2561requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2562run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CBC" \ 2563 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \ 2564 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \ 2565 0 \ 2566 -c "Enable use of CID extension." \ 2567 -s "Enable use of CID extension." \ 2568 -c "client hello, adding CID extension" \ 2569 -s "found CID extension" \ 2570 -s "Use of CID extension negotiated" \ 2571 -s "server hello, adding CID extension" \ 2572 -c "found CID extension" \ 2573 -c "Use of CID extension negotiated" \ 2574 -s "Copy CIDs into SSL transform" \ 2575 -c "Copy CIDs into SSL transform" \ 2576 -c "Peer CID (length 2 Bytes): de ad" \ 2577 -s "Peer CID (length 2 Bytes): be ef" \ 2578 -s "Use of Connection ID has been negotiated" \ 2579 -c "Use of Connection ID has been negotiated" 2580 2581requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2582run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CBC" \ 2583 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \ 2584 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \ 2585 0 \ 2586 -c "Enable use of CID extension." \ 2587 -s "Enable use of CID extension." \ 2588 -c "client hello, adding CID extension" \ 2589 -s "found CID extension" \ 2590 -s "Use of CID extension negotiated" \ 2591 -s "server hello, adding CID extension" \ 2592 -c "found CID extension" \ 2593 -c "Use of CID extension negotiated" \ 2594 -s "Copy CIDs into SSL transform" \ 2595 -c "Copy CIDs into SSL transform" \ 2596 -c "Peer CID (length 4 Bytes): de ad be ef" \ 2597 -s "Peer CID (length 0 Bytes):" \ 2598 -s "Use of Connection ID has been negotiated" \ 2599 -c "Use of Connection ID has been negotiated" 2600 2601requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2602run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CBC" \ 2603 "$P_SRV debug_level=3 dtls=1 cid=1" \ 2604 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \ 2605 0 \ 2606 -c "Enable use of CID extension." \ 2607 -s "Enable use of CID extension." \ 2608 -c "client hello, adding CID extension" \ 2609 -s "found CID extension" \ 2610 -s "Use of CID extension negotiated" \ 2611 -s "server hello, adding CID extension" \ 2612 -c "found CID extension" \ 2613 -c "Use of CID extension negotiated" \ 2614 -s "Copy CIDs into SSL transform" \ 2615 -c "Copy CIDs into SSL transform" \ 2616 -s "Peer CID (length 4 Bytes): de ad be ef" \ 2617 -c "Peer CID (length 0 Bytes):" \ 2618 -s "Use of Connection ID has been negotiated" \ 2619 -c "Use of Connection ID has been negotiated" 2620 2621requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2622run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CBC" \ 2623 "$P_SRV debug_level=3 dtls=1 cid=1" \ 2624 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \ 2625 0 \ 2626 -c "Enable use of CID extension." \ 2627 -s "Enable use of CID extension." \ 2628 -c "client hello, adding CID extension" \ 2629 -s "found CID extension" \ 2630 -s "Use of CID extension negotiated" \ 2631 -s "server hello, adding CID extension" \ 2632 -c "found CID extension" \ 2633 -c "Use of CID extension negotiated" \ 2634 -s "Copy CIDs into SSL transform" \ 2635 -c "Copy CIDs into SSL transform" \ 2636 -S "Use of Connection ID has been negotiated" \ 2637 -C "Use of Connection ID has been negotiated" 2638 2639requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2640requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 2641run_test "Connection ID: Cli+Srv enabled, renegotiate without change of CID" \ 2642 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \ 2643 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \ 2644 0 \ 2645 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \ 2646 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \ 2647 -s "(initial handshake) Use of Connection ID has been negotiated" \ 2648 -c "(initial handshake) Use of Connection ID has been negotiated" \ 2649 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \ 2650 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \ 2651 -s "(after renegotiation) Use of Connection ID has been negotiated" \ 2652 -c "(after renegotiation) Use of Connection ID has been negotiated" 2653 2654requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2655requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 2656run_test "Connection ID: Cli+Srv enabled, renegotiate with different CID" \ 2657 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \ 2658 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \ 2659 0 \ 2660 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \ 2661 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \ 2662 -s "(initial handshake) Use of Connection ID has been negotiated" \ 2663 -c "(initial handshake) Use of Connection ID has been negotiated" \ 2664 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \ 2665 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \ 2666 -s "(after renegotiation) Use of Connection ID has been negotiated" \ 2667 -c "(after renegotiation) Use of Connection ID has been negotiated" 2668 2669requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2670requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 2671run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate with different CID" \ 2672 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead cid_val_renego=beef renegotiation=1" \ 2673 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \ 2674 0 \ 2675 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \ 2676 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \ 2677 -s "(initial handshake) Use of Connection ID has been negotiated" \ 2678 -c "(initial handshake) Use of Connection ID has been negotiated" \ 2679 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \ 2680 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \ 2681 -s "(after renegotiation) Use of Connection ID has been negotiated" \ 2682 -c "(after renegotiation) Use of Connection ID has been negotiated" 2683 2684requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2685requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 2686run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate with different CID" \ 2687 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \ 2688 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \ 2689 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \ 2690 0 \ 2691 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \ 2692 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \ 2693 -s "(initial handshake) Use of Connection ID has been negotiated" \ 2694 -c "(initial handshake) Use of Connection ID has been negotiated" \ 2695 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \ 2696 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \ 2697 -s "(after renegotiation) Use of Connection ID has been negotiated" \ 2698 -c "(after renegotiation) Use of Connection ID has been negotiated" \ 2699 -c "ignoring unexpected CID" \ 2700 -s "ignoring unexpected CID" 2701 2702requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2703requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 2704run_test "Connection ID: Cli+Srv enabled, renegotiate without CID" \ 2705 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \ 2706 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \ 2707 0 \ 2708 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \ 2709 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \ 2710 -s "(initial handshake) Use of Connection ID has been negotiated" \ 2711 -c "(initial handshake) Use of Connection ID has been negotiated" \ 2712 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \ 2713 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \ 2714 -C "(after renegotiation) Use of Connection ID has been negotiated" \ 2715 -S "(after renegotiation) Use of Connection ID has been negotiated" 2716 2717requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2718requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 2719run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate without CID" \ 2720 "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \ 2721 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \ 2722 0 \ 2723 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \ 2724 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \ 2725 -s "(initial handshake) Use of Connection ID has been negotiated" \ 2726 -c "(initial handshake) Use of Connection ID has been negotiated" \ 2727 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \ 2728 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \ 2729 -C "(after renegotiation) Use of Connection ID has been negotiated" \ 2730 -S "(after renegotiation) Use of Connection ID has been negotiated" 2731 2732requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2733requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 2734run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate without CID" \ 2735 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \ 2736 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \ 2737 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \ 2738 0 \ 2739 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \ 2740 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \ 2741 -s "(initial handshake) Use of Connection ID has been negotiated" \ 2742 -c "(initial handshake) Use of Connection ID has been negotiated" \ 2743 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \ 2744 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \ 2745 -C "(after renegotiation) Use of Connection ID has been negotiated" \ 2746 -S "(after renegotiation) Use of Connection ID has been negotiated" \ 2747 -c "ignoring unexpected CID" \ 2748 -s "ignoring unexpected CID" 2749 2750requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2751requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 2752run_test "Connection ID: Cli+Srv enabled, CID on renegotiation" \ 2753 "$P_SRV debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \ 2754 "$P_CLI debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \ 2755 0 \ 2756 -S "(initial handshake) Use of Connection ID has been negotiated" \ 2757 -C "(initial handshake) Use of Connection ID has been negotiated" \ 2758 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \ 2759 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \ 2760 -c "(after renegotiation) Use of Connection ID has been negotiated" \ 2761 -s "(after renegotiation) Use of Connection ID has been negotiated" 2762 2763requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2764requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 2765run_test "Connection ID, no packing: Cli+Srv enabled, CID on renegotiation" \ 2766 "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \ 2767 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \ 2768 0 \ 2769 -S "(initial handshake) Use of Connection ID has been negotiated" \ 2770 -C "(initial handshake) Use of Connection ID has been negotiated" \ 2771 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \ 2772 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \ 2773 -c "(after renegotiation) Use of Connection ID has been negotiated" \ 2774 -s "(after renegotiation) Use of Connection ID has been negotiated" 2775 2776requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2777requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 2778run_test "Connection ID, 3D+MTU: Cli+Srv enabled, CID on renegotiation" \ 2779 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \ 2780 "$P_SRV debug_level=3 mtu=800 dtls=1 dgram_packing=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \ 2781 "$P_CLI debug_level=3 mtu=800 dtls=1 dgram_packing=1 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \ 2782 0 \ 2783 -S "(initial handshake) Use of Connection ID has been negotiated" \ 2784 -C "(initial handshake) Use of Connection ID has been negotiated" \ 2785 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \ 2786 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \ 2787 -c "(after renegotiation) Use of Connection ID has been negotiated" \ 2788 -s "(after renegotiation) Use of Connection ID has been negotiated" \ 2789 -c "ignoring unexpected CID" \ 2790 -s "ignoring unexpected CID" 2791 2792requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2793requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 2794run_test "Connection ID: Cli+Srv enabled, Cli disables on renegotiation" \ 2795 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \ 2796 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \ 2797 0 \ 2798 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \ 2799 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \ 2800 -s "(initial handshake) Use of Connection ID has been negotiated" \ 2801 -c "(initial handshake) Use of Connection ID has been negotiated" \ 2802 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \ 2803 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \ 2804 -C "(after renegotiation) Use of Connection ID has been negotiated" \ 2805 -S "(after renegotiation) Use of Connection ID has been negotiated" \ 2806 -s "(after renegotiation) Use of Connection ID was not offered by client" 2807 2808requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2809requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 2810run_test "Connection ID, 3D: Cli+Srv enabled, Cli disables on renegotiation" \ 2811 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \ 2812 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \ 2813 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \ 2814 0 \ 2815 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \ 2816 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \ 2817 -s "(initial handshake) Use of Connection ID has been negotiated" \ 2818 -c "(initial handshake) Use of Connection ID has been negotiated" \ 2819 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \ 2820 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \ 2821 -C "(after renegotiation) Use of Connection ID has been negotiated" \ 2822 -S "(after renegotiation) Use of Connection ID has been negotiated" \ 2823 -s "(after renegotiation) Use of Connection ID was not offered by client" \ 2824 -c "ignoring unexpected CID" \ 2825 -s "ignoring unexpected CID" 2826 2827requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2828requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 2829run_test "Connection ID: Cli+Srv enabled, Srv disables on renegotiation" \ 2830 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \ 2831 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \ 2832 0 \ 2833 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \ 2834 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \ 2835 -s "(initial handshake) Use of Connection ID has been negotiated" \ 2836 -c "(initial handshake) Use of Connection ID has been negotiated" \ 2837 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \ 2838 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \ 2839 -C "(after renegotiation) Use of Connection ID has been negotiated" \ 2840 -S "(after renegotiation) Use of Connection ID has been negotiated" \ 2841 -c "(after renegotiation) Use of Connection ID was rejected by the server" 2842 2843requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2844requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 2845run_test "Connection ID, 3D: Cli+Srv enabled, Srv disables on renegotiation" \ 2846 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \ 2847 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \ 2848 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \ 2849 0 \ 2850 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \ 2851 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \ 2852 -s "(initial handshake) Use of Connection ID has been negotiated" \ 2853 -c "(initial handshake) Use of Connection ID has been negotiated" \ 2854 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \ 2855 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \ 2856 -C "(after renegotiation) Use of Connection ID has been negotiated" \ 2857 -S "(after renegotiation) Use of Connection ID has been negotiated" \ 2858 -c "(after renegotiation) Use of Connection ID was rejected by the server" \ 2859 -c "ignoring unexpected CID" \ 2860 -s "ignoring unexpected CID" 2861 2862# This and the test below it require MAX_CONTENT_LEN to be at least MFL+1, because the 2863# tests check that the buffer contents are reallocated when the message is 2864# larger than the buffer. 2865requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2866requires_config_enabled MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH 2867requires_max_content_len 513 2868run_test "Connection ID: Cli+Srv enabled, variable buffer lengths, MFL=512" \ 2869 "$P_SRV dtls=1 cid=1 cid_val=dead debug_level=2" \ 2870 "$P_CLI force_ciphersuite="TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" max_frag_len=512 dtls=1 cid=1 cid_val=beef" \ 2871 0 \ 2872 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \ 2873 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \ 2874 -s "(initial handshake) Use of Connection ID has been negotiated" \ 2875 -c "(initial handshake) Use of Connection ID has been negotiated" \ 2876 -s "Reallocating in_buf" \ 2877 -s "Reallocating out_buf" 2878 2879requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 2880requires_config_enabled MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH 2881requires_max_content_len 1025 2882run_test "Connection ID: Cli+Srv enabled, variable buffer lengths, MFL=1024" \ 2883 "$P_SRV dtls=1 cid=1 cid_val=dead debug_level=2" \ 2884 "$P_CLI force_ciphersuite="TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" max_frag_len=1024 dtls=1 cid=1 cid_val=beef" \ 2885 0 \ 2886 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \ 2887 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \ 2888 -s "(initial handshake) Use of Connection ID has been negotiated" \ 2889 -c "(initial handshake) Use of Connection ID has been negotiated" \ 2890 -s "Reallocating in_buf" \ 2891 -s "Reallocating out_buf" 2892 2893# Tests for Encrypt-then-MAC extension 2894 2895run_test "Encrypt then MAC: default" \ 2896 "$P_SRV debug_level=3 \ 2897 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ 2898 "$P_CLI debug_level=3" \ 2899 0 \ 2900 -c "client hello, adding encrypt_then_mac extension" \ 2901 -s "found encrypt then mac extension" \ 2902 -s "server hello, adding encrypt then mac extension" \ 2903 -c "found encrypt_then_mac extension" \ 2904 -c "using encrypt then mac" \ 2905 -s "using encrypt then mac" 2906 2907run_test "Encrypt then MAC: client enabled, server disabled" \ 2908 "$P_SRV debug_level=3 etm=0 \ 2909 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ 2910 "$P_CLI debug_level=3 etm=1" \ 2911 0 \ 2912 -c "client hello, adding encrypt_then_mac extension" \ 2913 -s "found encrypt then mac extension" \ 2914 -S "server hello, adding encrypt then mac extension" \ 2915 -C "found encrypt_then_mac extension" \ 2916 -C "using encrypt then mac" \ 2917 -S "using encrypt then mac" 2918 2919run_test "Encrypt then MAC: client enabled, aead cipher" \ 2920 "$P_SRV debug_level=3 etm=1 \ 2921 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \ 2922 "$P_CLI debug_level=3 etm=1" \ 2923 0 \ 2924 -c "client hello, adding encrypt_then_mac extension" \ 2925 -s "found encrypt then mac extension" \ 2926 -S "server hello, adding encrypt then mac extension" \ 2927 -C "found encrypt_then_mac extension" \ 2928 -C "using encrypt then mac" \ 2929 -S "using encrypt then mac" 2930 2931run_test "Encrypt then MAC: client enabled, stream cipher" \ 2932 "$P_SRV debug_level=3 etm=1 \ 2933 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 2934 "$P_CLI debug_level=3 etm=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 2935 0 \ 2936 -c "client hello, adding encrypt_then_mac extension" \ 2937 -s "found encrypt then mac extension" \ 2938 -S "server hello, adding encrypt then mac extension" \ 2939 -C "found encrypt_then_mac extension" \ 2940 -C "using encrypt then mac" \ 2941 -S "using encrypt then mac" 2942 2943run_test "Encrypt then MAC: client disabled, server enabled" \ 2944 "$P_SRV debug_level=3 etm=1 \ 2945 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ 2946 "$P_CLI debug_level=3 etm=0" \ 2947 0 \ 2948 -C "client hello, adding encrypt_then_mac extension" \ 2949 -S "found encrypt then mac extension" \ 2950 -S "server hello, adding encrypt then mac extension" \ 2951 -C "found encrypt_then_mac extension" \ 2952 -C "using encrypt then mac" \ 2953 -S "using encrypt then mac" 2954 2955run_test "Encrypt then MAC: client SSLv3, server enabled" \ 2956 "$P_SRV debug_level=3 min_version=ssl3 \ 2957 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ 2958 "$P_CLI debug_level=3 force_version=ssl3" \ 2959 0 \ 2960 -C "client hello, adding encrypt_then_mac extension" \ 2961 -S "found encrypt then mac extension" \ 2962 -S "server hello, adding encrypt then mac extension" \ 2963 -C "found encrypt_then_mac extension" \ 2964 -C "using encrypt then mac" \ 2965 -S "using encrypt then mac" 2966 2967run_test "Encrypt then MAC: client enabled, server SSLv3" \ 2968 "$P_SRV debug_level=3 force_version=ssl3 \ 2969 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ 2970 "$P_CLI debug_level=3 min_version=ssl3" \ 2971 0 \ 2972 -c "client hello, adding encrypt_then_mac extension" \ 2973 -S "found encrypt then mac extension" \ 2974 -S "server hello, adding encrypt then mac extension" \ 2975 -C "found encrypt_then_mac extension" \ 2976 -C "using encrypt then mac" \ 2977 -S "using encrypt then mac" 2978 2979# Tests for Extended Master Secret extension 2980 2981requires_config_enabled MBEDTLS_SSL_EXTENDED_MASTER_SECRET 2982run_test "Extended Master Secret: default" \ 2983 "$P_SRV debug_level=3" \ 2984 "$P_CLI debug_level=3" \ 2985 0 \ 2986 -c "client hello, adding extended_master_secret extension" \ 2987 -s "found extended master secret extension" \ 2988 -s "server hello, adding extended master secret extension" \ 2989 -c "found extended_master_secret extension" \ 2990 -c "session hash for extended master secret" \ 2991 -s "session hash for extended master secret" 2992 2993requires_config_enabled MBEDTLS_SSL_EXTENDED_MASTER_SECRET 2994run_test "Extended Master Secret: client enabled, server disabled" \ 2995 "$P_SRV debug_level=3 extended_ms=0" \ 2996 "$P_CLI debug_level=3 extended_ms=1" \ 2997 0 \ 2998 -c "client hello, adding extended_master_secret extension" \ 2999 -s "found extended master secret extension" \ 3000 -S "server hello, adding extended master secret extension" \ 3001 -C "found extended_master_secret extension" \ 3002 -C "session hash for extended master secret" \ 3003 -S "session hash for extended master secret" 3004 3005requires_config_enabled MBEDTLS_SSL_EXTENDED_MASTER_SECRET 3006run_test "Extended Master Secret: client disabled, server enabled" \ 3007 "$P_SRV debug_level=3 extended_ms=1" \ 3008 "$P_CLI debug_level=3 extended_ms=0" \ 3009 0 \ 3010 -C "client hello, adding extended_master_secret extension" \ 3011 -S "found extended master secret extension" \ 3012 -S "server hello, adding extended master secret extension" \ 3013 -C "found extended_master_secret extension" \ 3014 -C "session hash for extended master secret" \ 3015 -S "session hash for extended master secret" 3016 3017run_test "Extended Master Secret: client SSLv3, server enabled" \ 3018 "$P_SRV debug_level=3 min_version=ssl3" \ 3019 "$P_CLI debug_level=3 force_version=ssl3" \ 3020 0 \ 3021 -C "client hello, adding extended_master_secret extension" \ 3022 -S "found extended master secret extension" \ 3023 -S "server hello, adding extended master secret extension" \ 3024 -C "found extended_master_secret extension" \ 3025 -C "session hash for extended master secret" \ 3026 -S "session hash for extended master secret" 3027 3028run_test "Extended Master Secret: client enabled, server SSLv3" \ 3029 "$P_SRV debug_level=3 force_version=ssl3" \ 3030 "$P_CLI debug_level=3 min_version=ssl3" \ 3031 0 \ 3032 -c "client hello, adding extended_master_secret extension" \ 3033 -S "found extended master secret extension" \ 3034 -S "server hello, adding extended master secret extension" \ 3035 -C "found extended_master_secret extension" \ 3036 -C "session hash for extended master secret" \ 3037 -S "session hash for extended master secret" 3038 3039# Tests for FALLBACK_SCSV 3040 3041run_test "Fallback SCSV: default" \ 3042 "$P_SRV debug_level=2" \ 3043 "$P_CLI debug_level=3 force_version=tls1_1" \ 3044 0 \ 3045 -C "adding FALLBACK_SCSV" \ 3046 -S "received FALLBACK_SCSV" \ 3047 -S "inapropriate fallback" \ 3048 -C "is a fatal alert message (msg 86)" 3049 3050run_test "Fallback SCSV: explicitly disabled" \ 3051 "$P_SRV debug_level=2" \ 3052 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \ 3053 0 \ 3054 -C "adding FALLBACK_SCSV" \ 3055 -S "received FALLBACK_SCSV" \ 3056 -S "inapropriate fallback" \ 3057 -C "is a fatal alert message (msg 86)" 3058 3059run_test "Fallback SCSV: enabled" \ 3060 "$P_SRV debug_level=2" \ 3061 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \ 3062 1 \ 3063 -c "adding FALLBACK_SCSV" \ 3064 -s "received FALLBACK_SCSV" \ 3065 -s "inapropriate fallback" \ 3066 -c "is a fatal alert message (msg 86)" 3067 3068run_test "Fallback SCSV: enabled, max version" \ 3069 "$P_SRV debug_level=2" \ 3070 "$P_CLI debug_level=3 fallback=1" \ 3071 0 \ 3072 -c "adding FALLBACK_SCSV" \ 3073 -s "received FALLBACK_SCSV" \ 3074 -S "inapropriate fallback" \ 3075 -C "is a fatal alert message (msg 86)" 3076 3077requires_openssl_with_fallback_scsv 3078run_test "Fallback SCSV: default, openssl server" \ 3079 "$O_SRV" \ 3080 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \ 3081 0 \ 3082 -C "adding FALLBACK_SCSV" \ 3083 -C "is a fatal alert message (msg 86)" 3084 3085requires_openssl_with_fallback_scsv 3086run_test "Fallback SCSV: enabled, openssl server" \ 3087 "$O_SRV" \ 3088 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \ 3089 1 \ 3090 -c "adding FALLBACK_SCSV" \ 3091 -c "is a fatal alert message (msg 86)" 3092 3093requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1 3094requires_openssl_with_fallback_scsv 3095run_test "Fallback SCSV: disabled, openssl client" \ 3096 "$P_SRV debug_level=2" \ 3097 "$O_CLI -tls1_1" \ 3098 0 \ 3099 -S "received FALLBACK_SCSV" \ 3100 -S "inapropriate fallback" 3101 3102requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1 3103requires_openssl_with_fallback_scsv 3104run_test "Fallback SCSV: enabled, openssl client" \ 3105 "$P_SRV debug_level=2" \ 3106 "$O_CLI -tls1_1 -fallback_scsv" \ 3107 1 \ 3108 -s "received FALLBACK_SCSV" \ 3109 -s "inapropriate fallback" 3110 3111requires_openssl_with_fallback_scsv 3112run_test "Fallback SCSV: enabled, max version, openssl client" \ 3113 "$P_SRV debug_level=2" \ 3114 "$O_CLI -fallback_scsv" \ 3115 0 \ 3116 -s "received FALLBACK_SCSV" \ 3117 -S "inapropriate fallback" 3118 3119# Test sending and receiving empty application data records 3120 3121run_test "Encrypt then MAC: empty application data record" \ 3122 "$P_SRV auth_mode=none debug_level=4 etm=1" \ 3123 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \ 3124 0 \ 3125 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \ 3126 -s "dumping 'input payload after decrypt' (0 bytes)" \ 3127 -c "0 bytes written in 1 fragments" 3128 3129run_test "Encrypt then MAC: disabled, empty application data record" \ 3130 "$P_SRV auth_mode=none debug_level=4 etm=0" \ 3131 "$P_CLI auth_mode=none etm=0 request_size=0" \ 3132 0 \ 3133 -s "dumping 'input payload after decrypt' (0 bytes)" \ 3134 -c "0 bytes written in 1 fragments" 3135 3136run_test "Encrypt then MAC, DTLS: empty application data record" \ 3137 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \ 3138 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \ 3139 0 \ 3140 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \ 3141 -s "dumping 'input payload after decrypt' (0 bytes)" \ 3142 -c "0 bytes written in 1 fragments" 3143 3144run_test "Encrypt then MAC, DTLS: disabled, empty application data record" \ 3145 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \ 3146 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \ 3147 0 \ 3148 -s "dumping 'input payload after decrypt' (0 bytes)" \ 3149 -c "0 bytes written in 1 fragments" 3150 3151## ClientHello generated with 3152## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..." 3153## then manually twiddling the ciphersuite list. 3154## The ClientHello content is spelled out below as a hex string as 3155## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix". 3156## The expected response is an inappropriate_fallback alert. 3157requires_config_enabled MBEDTLS_SSL_FALLBACK_SCSV 3158run_test "Fallback SCSV: beginning of list" \ 3159 "$P_SRV debug_level=2" \ 3160 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \ 3161 0 \ 3162 -s "received FALLBACK_SCSV" \ 3163 -s "inapropriate fallback" 3164 3165requires_config_enabled MBEDTLS_SSL_FALLBACK_SCSV 3166run_test "Fallback SCSV: end of list" \ 3167 "$P_SRV debug_level=2" \ 3168 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \ 3169 0 \ 3170 -s "received FALLBACK_SCSV" \ 3171 -s "inapropriate fallback" 3172 3173## Here the expected response is a valid ServerHello prefix, up to the random. 3174requires_config_enabled MBEDTLS_SSL_FALLBACK_SCSV 3175run_test "Fallback SCSV: not in list" \ 3176 "$P_SRV debug_level=2" \ 3177 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \ 3178 0 \ 3179 -S "received FALLBACK_SCSV" \ 3180 -S "inapropriate fallback" 3181 3182# Tests for CBC 1/n-1 record splitting 3183 3184run_test "CBC Record splitting: TLS 1.2, no splitting" \ 3185 "$P_SRV" \ 3186 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \ 3187 request_size=123 force_version=tls12" \ 3188 0 \ 3189 -s "Read from client: 123 bytes read" \ 3190 -S "Read from client: 1 bytes read" \ 3191 -S "122 bytes read" 3192 3193run_test "CBC Record splitting: TLS 1.1, no splitting" \ 3194 "$P_SRV" \ 3195 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \ 3196 request_size=123 force_version=tls1_1" \ 3197 0 \ 3198 -s "Read from client: 123 bytes read" \ 3199 -S "Read from client: 1 bytes read" \ 3200 -S "122 bytes read" 3201 3202run_test "CBC Record splitting: TLS 1.0, splitting" \ 3203 "$P_SRV" \ 3204 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \ 3205 request_size=123 force_version=tls1" \ 3206 0 \ 3207 -S "Read from client: 123 bytes read" \ 3208 -s "Read from client: 1 bytes read" \ 3209 -s "122 bytes read" 3210 3211run_test "CBC Record splitting: SSLv3, splitting" \ 3212 "$P_SRV min_version=ssl3" \ 3213 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \ 3214 request_size=123 force_version=ssl3" \ 3215 0 \ 3216 -S "Read from client: 123 bytes read" \ 3217 -s "Read from client: 1 bytes read" \ 3218 -s "122 bytes read" 3219 3220run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \ 3221 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 3222 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \ 3223 request_size=123 force_version=tls1" \ 3224 0 \ 3225 -s "Read from client: 123 bytes read" \ 3226 -S "Read from client: 1 bytes read" \ 3227 -S "122 bytes read" 3228 3229run_test "CBC Record splitting: TLS 1.0, splitting disabled" \ 3230 "$P_SRV" \ 3231 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \ 3232 request_size=123 force_version=tls1 recsplit=0" \ 3233 0 \ 3234 -s "Read from client: 123 bytes read" \ 3235 -S "Read from client: 1 bytes read" \ 3236 -S "122 bytes read" 3237 3238run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \ 3239 "$P_SRV nbio=2" \ 3240 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \ 3241 request_size=123 force_version=tls1" \ 3242 0 \ 3243 -S "Read from client: 123 bytes read" \ 3244 -s "Read from client: 1 bytes read" \ 3245 -s "122 bytes read" 3246 3247# Tests for Session Tickets 3248 3249run_test "Session resume using tickets: basic" \ 3250 "$P_SRV debug_level=3 tickets=1" \ 3251 "$P_CLI debug_level=3 tickets=1 reconnect=1" \ 3252 0 \ 3253 -c "client hello, adding session ticket extension" \ 3254 -s "found session ticket extension" \ 3255 -s "server hello, adding session ticket extension" \ 3256 -c "found session_ticket extension" \ 3257 -c "parse new session ticket" \ 3258 -S "session successfully restored from cache" \ 3259 -s "session successfully restored from ticket" \ 3260 -s "a session has been resumed" \ 3261 -c "a session has been resumed" 3262 3263run_test "Session resume using tickets: cache disabled" \ 3264 "$P_SRV debug_level=3 tickets=1 cache_max=0" \ 3265 "$P_CLI debug_level=3 tickets=1 reconnect=1" \ 3266 0 \ 3267 -c "client hello, adding session ticket extension" \ 3268 -s "found session ticket extension" \ 3269 -s "server hello, adding session ticket extension" \ 3270 -c "found session_ticket extension" \ 3271 -c "parse new session ticket" \ 3272 -S "session successfully restored from cache" \ 3273 -s "session successfully restored from ticket" \ 3274 -s "a session has been resumed" \ 3275 -c "a session has been resumed" 3276 3277run_test "Session resume using tickets: timeout" \ 3278 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \ 3279 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \ 3280 0 \ 3281 -c "client hello, adding session ticket extension" \ 3282 -s "found session ticket extension" \ 3283 -s "server hello, adding session ticket extension" \ 3284 -c "found session_ticket extension" \ 3285 -c "parse new session ticket" \ 3286 -S "session successfully restored from cache" \ 3287 -S "session successfully restored from ticket" \ 3288 -S "a session has been resumed" \ 3289 -C "a session has been resumed" 3290 3291run_test "Session resume using tickets: session copy" \ 3292 "$P_SRV debug_level=3 tickets=1 cache_max=0" \ 3293 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_mode=0" \ 3294 0 \ 3295 -c "client hello, adding session ticket extension" \ 3296 -s "found session ticket extension" \ 3297 -s "server hello, adding session ticket extension" \ 3298 -c "found session_ticket extension" \ 3299 -c "parse new session ticket" \ 3300 -S "session successfully restored from cache" \ 3301 -s "session successfully restored from ticket" \ 3302 -s "a session has been resumed" \ 3303 -c "a session has been resumed" 3304 3305run_test "Session resume using tickets: openssl server" \ 3306 "$O_SRV" \ 3307 "$P_CLI debug_level=3 tickets=1 reconnect=1" \ 3308 0 \ 3309 -c "client hello, adding session ticket extension" \ 3310 -c "found session_ticket extension" \ 3311 -c "parse new session ticket" \ 3312 -c "a session has been resumed" 3313 3314run_test "Session resume using tickets: openssl client" \ 3315 "$P_SRV debug_level=3 tickets=1" \ 3316 "( $O_CLI -sess_out $SESSION; \ 3317 $O_CLI -sess_in $SESSION; \ 3318 rm -f $SESSION )" \ 3319 0 \ 3320 -s "found session ticket extension" \ 3321 -s "server hello, adding session ticket extension" \ 3322 -S "session successfully restored from cache" \ 3323 -s "session successfully restored from ticket" \ 3324 -s "a session has been resumed" 3325 3326# Tests for Session Tickets with DTLS 3327 3328run_test "Session resume using tickets, DTLS: basic" \ 3329 "$P_SRV debug_level=3 dtls=1 tickets=1" \ 3330 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \ 3331 0 \ 3332 -c "client hello, adding session ticket extension" \ 3333 -s "found session ticket extension" \ 3334 -s "server hello, adding session ticket extension" \ 3335 -c "found session_ticket extension" \ 3336 -c "parse new session ticket" \ 3337 -S "session successfully restored from cache" \ 3338 -s "session successfully restored from ticket" \ 3339 -s "a session has been resumed" \ 3340 -c "a session has been resumed" 3341 3342run_test "Session resume using tickets, DTLS: cache disabled" \ 3343 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \ 3344 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \ 3345 0 \ 3346 -c "client hello, adding session ticket extension" \ 3347 -s "found session ticket extension" \ 3348 -s "server hello, adding session ticket extension" \ 3349 -c "found session_ticket extension" \ 3350 -c "parse new session ticket" \ 3351 -S "session successfully restored from cache" \ 3352 -s "session successfully restored from ticket" \ 3353 -s "a session has been resumed" \ 3354 -c "a session has been resumed" 3355 3356run_test "Session resume using tickets, DTLS: timeout" \ 3357 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \ 3358 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1 reco_delay=2" \ 3359 0 \ 3360 -c "client hello, adding session ticket extension" \ 3361 -s "found session ticket extension" \ 3362 -s "server hello, adding session ticket extension" \ 3363 -c "found session_ticket extension" \ 3364 -c "parse new session ticket" \ 3365 -S "session successfully restored from cache" \ 3366 -S "session successfully restored from ticket" \ 3367 -S "a session has been resumed" \ 3368 -C "a session has been resumed" 3369 3370run_test "Session resume using tickets, DTLS: session copy" \ 3371 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \ 3372 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1 reco_mode=0" \ 3373 0 \ 3374 -c "client hello, adding session ticket extension" \ 3375 -s "found session ticket extension" \ 3376 -s "server hello, adding session ticket extension" \ 3377 -c "found session_ticket extension" \ 3378 -c "parse new session ticket" \ 3379 -S "session successfully restored from cache" \ 3380 -s "session successfully restored from ticket" \ 3381 -s "a session has been resumed" \ 3382 -c "a session has been resumed" 3383 3384run_test "Session resume using tickets, DTLS: openssl server" \ 3385 "$O_SRV -dtls1" \ 3386 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \ 3387 0 \ 3388 -c "client hello, adding session ticket extension" \ 3389 -c "found session_ticket extension" \ 3390 -c "parse new session ticket" \ 3391 -c "a session has been resumed" 3392 3393# For reasons that aren't fully understood, this test randomly fails with high 3394# probability with OpenSSL 1.0.2g on the CI, see #5012. 3395requires_openssl_next 3396run_test "Session resume using tickets, DTLS: openssl client" \ 3397 "$P_SRV dtls=1 debug_level=3 tickets=1" \ 3398 "( $O_NEXT_CLI -dtls1 -sess_out $SESSION; \ 3399 $O_NEXT_CLI -dtls1 -sess_in $SESSION; \ 3400 rm -f $SESSION )" \ 3401 0 \ 3402 -s "found session ticket extension" \ 3403 -s "server hello, adding session ticket extension" \ 3404 -S "session successfully restored from cache" \ 3405 -s "session successfully restored from ticket" \ 3406 -s "a session has been resumed" 3407 3408# Tests for Session Resume based on session-ID and cache 3409 3410run_test "Session resume using cache: tickets enabled on client" \ 3411 "$P_SRV debug_level=3 tickets=0" \ 3412 "$P_CLI debug_level=3 tickets=1 reconnect=1" \ 3413 0 \ 3414 -c "client hello, adding session ticket extension" \ 3415 -s "found session ticket extension" \ 3416 -S "server hello, adding session ticket extension" \ 3417 -C "found session_ticket extension" \ 3418 -C "parse new session ticket" \ 3419 -s "session successfully restored from cache" \ 3420 -S "session successfully restored from ticket" \ 3421 -s "a session has been resumed" \ 3422 -c "a session has been resumed" 3423 3424run_test "Session resume using cache: tickets enabled on server" \ 3425 "$P_SRV debug_level=3 tickets=1" \ 3426 "$P_CLI debug_level=3 tickets=0 reconnect=1" \ 3427 0 \ 3428 -C "client hello, adding session ticket extension" \ 3429 -S "found session ticket extension" \ 3430 -S "server hello, adding session ticket extension" \ 3431 -C "found session_ticket extension" \ 3432 -C "parse new session ticket" \ 3433 -s "session successfully restored from cache" \ 3434 -S "session successfully restored from ticket" \ 3435 -s "a session has been resumed" \ 3436 -c "a session has been resumed" 3437 3438run_test "Session resume using cache: cache_max=0" \ 3439 "$P_SRV debug_level=3 tickets=0 cache_max=0" \ 3440 "$P_CLI debug_level=3 tickets=0 reconnect=1" \ 3441 0 \ 3442 -S "session successfully restored from cache" \ 3443 -S "session successfully restored from ticket" \ 3444 -S "a session has been resumed" \ 3445 -C "a session has been resumed" 3446 3447requires_config_enabled MBEDTLS_SSL_CACHE_C 3448run_test "Session resume using cache: cache_max=1" \ 3449 "$P_SRV debug_level=3 tickets=0 cache_max=1" \ 3450 "$P_CLI debug_level=3 tickets=0 reconnect=1" \ 3451 0 \ 3452 -s "session successfully restored from cache" \ 3453 -S "session successfully restored from ticket" \ 3454 -s "a session has been resumed" \ 3455 -c "a session has been resumed" 3456 3457requires_config_enabled MBEDTLS_SSL_CACHE_C 3458run_test "Session resume using cache: timeout > delay" \ 3459 "$P_SRV debug_level=3 tickets=0" \ 3460 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \ 3461 0 \ 3462 -s "session successfully restored from cache" \ 3463 -S "session successfully restored from ticket" \ 3464 -s "a session has been resumed" \ 3465 -c "a session has been resumed" 3466 3467requires_config_enabled MBEDTLS_SSL_CACHE_C 3468run_test "Session resume using cache: timeout < delay" \ 3469 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \ 3470 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \ 3471 0 \ 3472 -S "session successfully restored from cache" \ 3473 -S "session successfully restored from ticket" \ 3474 -S "a session has been resumed" \ 3475 -C "a session has been resumed" 3476 3477requires_config_enabled MBEDTLS_SSL_CACHE_C 3478run_test "Session resume using cache: no timeout" \ 3479 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \ 3480 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \ 3481 0 \ 3482 -s "session successfully restored from cache" \ 3483 -S "session successfully restored from ticket" \ 3484 -s "a session has been resumed" \ 3485 -c "a session has been resumed" 3486 3487requires_config_enabled MBEDTLS_SSL_CACHE_C 3488run_test "Session resume using cache: session copy" \ 3489 "$P_SRV debug_level=3 tickets=0" \ 3490 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_mode=0" \ 3491 0 \ 3492 -s "session successfully restored from cache" \ 3493 -S "session successfully restored from ticket" \ 3494 -s "a session has been resumed" \ 3495 -c "a session has been resumed" 3496 3497requires_config_enabled MBEDTLS_SSL_CACHE_C 3498run_test "Session resume using cache: openssl client" \ 3499 "$P_SRV debug_level=3 tickets=0" \ 3500 "( $O_CLI -sess_out $SESSION; \ 3501 $O_CLI -sess_in $SESSION; \ 3502 rm -f $SESSION )" \ 3503 0 \ 3504 -s "found session ticket extension" \ 3505 -S "server hello, adding session ticket extension" \ 3506 -s "session successfully restored from cache" \ 3507 -S "session successfully restored from ticket" \ 3508 -s "a session has been resumed" 3509 3510requires_config_enabled MBEDTLS_SSL_CACHE_C 3511run_test "Session resume using cache: openssl server" \ 3512 "$O_SRV" \ 3513 "$P_CLI debug_level=3 tickets=0 reconnect=1" \ 3514 0 \ 3515 -C "found session_ticket extension" \ 3516 -C "parse new session ticket" \ 3517 -c "a session has been resumed" 3518 3519# Tests for Session resume and extensions 3520 3521requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2 3522requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID 3523run_test "Session resume and connection ID" \ 3524 "$P_SRV debug_level=3 cid=1 cid_val=dead dtls=1 tickets=0" \ 3525 "$P_CLI debug_level=3 cid=1 cid_val=beef dtls=1 tickets=0 reconnect=1" \ 3526 0 \ 3527 -c "Enable use of CID extension." \ 3528 -s "Enable use of CID extension." \ 3529 -c "client hello, adding CID extension" \ 3530 -s "found CID extension" \ 3531 -s "Use of CID extension negotiated" \ 3532 -s "server hello, adding CID extension" \ 3533 -c "found CID extension" \ 3534 -c "Use of CID extension negotiated" \ 3535 -s "Copy CIDs into SSL transform" \ 3536 -c "Copy CIDs into SSL transform" \ 3537 -c "Peer CID (length 2 Bytes): de ad" \ 3538 -s "Peer CID (length 2 Bytes): be ef" \ 3539 -s "Use of Connection ID has been negotiated" \ 3540 -c "Use of Connection ID has been negotiated" 3541 3542# Tests for Session Resume based on session-ID and cache, DTLS 3543 3544requires_config_enabled MBEDTLS_SSL_CACHE_C 3545run_test "Session resume using cache, DTLS: tickets enabled on client" \ 3546 "$P_SRV dtls=1 debug_level=3 tickets=0" \ 3547 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 skip_close_notify=1" \ 3548 0 \ 3549 -c "client hello, adding session ticket extension" \ 3550 -s "found session ticket extension" \ 3551 -S "server hello, adding session ticket extension" \ 3552 -C "found session_ticket extension" \ 3553 -C "parse new session ticket" \ 3554 -s "session successfully restored from cache" \ 3555 -S "session successfully restored from ticket" \ 3556 -s "a session has been resumed" \ 3557 -c "a session has been resumed" 3558 3559requires_config_enabled MBEDTLS_SSL_CACHE_C 3560run_test "Session resume using cache, DTLS: tickets enabled on server" \ 3561 "$P_SRV dtls=1 debug_level=3 tickets=1" \ 3562 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \ 3563 0 \ 3564 -C "client hello, adding session ticket extension" \ 3565 -S "found session ticket extension" \ 3566 -S "server hello, adding session ticket extension" \ 3567 -C "found session_ticket extension" \ 3568 -C "parse new session ticket" \ 3569 -s "session successfully restored from cache" \ 3570 -S "session successfully restored from ticket" \ 3571 -s "a session has been resumed" \ 3572 -c "a session has been resumed" 3573 3574requires_config_enabled MBEDTLS_SSL_CACHE_C 3575run_test "Session resume using cache, DTLS: cache_max=0" \ 3576 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \ 3577 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \ 3578 0 \ 3579 -S "session successfully restored from cache" \ 3580 -S "session successfully restored from ticket" \ 3581 -S "a session has been resumed" \ 3582 -C "a session has been resumed" 3583 3584requires_config_enabled MBEDTLS_SSL_CACHE_C 3585run_test "Session resume using cache, DTLS: cache_max=1" \ 3586 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \ 3587 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \ 3588 0 \ 3589 -s "session successfully restored from cache" \ 3590 -S "session successfully restored from ticket" \ 3591 -s "a session has been resumed" \ 3592 -c "a session has been resumed" 3593 3594requires_config_enabled MBEDTLS_SSL_CACHE_C 3595run_test "Session resume using cache, DTLS: timeout > delay" \ 3596 "$P_SRV dtls=1 debug_level=3 tickets=0" \ 3597 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_delay=0" \ 3598 0 \ 3599 -s "session successfully restored from cache" \ 3600 -S "session successfully restored from ticket" \ 3601 -s "a session has been resumed" \ 3602 -c "a session has been resumed" 3603 3604requires_config_enabled MBEDTLS_SSL_CACHE_C 3605run_test "Session resume using cache, DTLS: timeout < delay" \ 3606 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \ 3607 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_delay=2" \ 3608 0 \ 3609 -S "session successfully restored from cache" \ 3610 -S "session successfully restored from ticket" \ 3611 -S "a session has been resumed" \ 3612 -C "a session has been resumed" 3613 3614requires_config_enabled MBEDTLS_SSL_CACHE_C 3615run_test "Session resume using cache, DTLS: no timeout" \ 3616 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \ 3617 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_delay=2" \ 3618 0 \ 3619 -s "session successfully restored from cache" \ 3620 -S "session successfully restored from ticket" \ 3621 -s "a session has been resumed" \ 3622 -c "a session has been resumed" 3623 3624requires_config_enabled MBEDTLS_SSL_CACHE_C 3625run_test "Session resume using cache, DTLS: session copy" \ 3626 "$P_SRV dtls=1 debug_level=3 tickets=0" \ 3627 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_mode=0" \ 3628 0 \ 3629 -s "session successfully restored from cache" \ 3630 -S "session successfully restored from ticket" \ 3631 -s "a session has been resumed" \ 3632 -c "a session has been resumed" 3633 3634# For reasons that aren't fully understood, this test randomly fails with high 3635# probability with OpenSSL 1.0.2g on the CI, see #5012. 3636requires_openssl_next 3637requires_config_enabled MBEDTLS_SSL_CACHE_C 3638run_test "Session resume using cache, DTLS: openssl client" \ 3639 "$P_SRV dtls=1 debug_level=3 tickets=0" \ 3640 "( $O_NEXT_CLI -dtls1 -sess_out $SESSION; \ 3641 $O_NEXT_CLI -dtls1 -sess_in $SESSION; \ 3642 rm -f $SESSION )" \ 3643 0 \ 3644 -s "found session ticket extension" \ 3645 -S "server hello, adding session ticket extension" \ 3646 -s "session successfully restored from cache" \ 3647 -S "session successfully restored from ticket" \ 3648 -s "a session has been resumed" 3649 3650requires_config_enabled MBEDTLS_SSL_CACHE_C 3651run_test "Session resume using cache, DTLS: openssl server" \ 3652 "$O_SRV -dtls1" \ 3653 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \ 3654 0 \ 3655 -C "found session_ticket extension" \ 3656 -C "parse new session ticket" \ 3657 -c "a session has been resumed" 3658 3659# Tests for Max Fragment Length extension 3660 3661requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 3662run_test "Max fragment length: enabled, default" \ 3663 "$P_SRV debug_level=3" \ 3664 "$P_CLI debug_level=3" \ 3665 0 \ 3666 -c "Maximum input fragment length is $MAX_CONTENT_LEN" \ 3667 -c "Maximum output fragment length is $MAX_CONTENT_LEN" \ 3668 -s "Maximum input fragment length is $MAX_CONTENT_LEN" \ 3669 -s "Maximum output fragment length is $MAX_CONTENT_LEN" \ 3670 -C "client hello, adding max_fragment_length extension" \ 3671 -S "found max fragment length extension" \ 3672 -S "server hello, max_fragment_length extension" \ 3673 -C "found max_fragment_length extension" 3674 3675requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 3676run_test "Max fragment length: enabled, default, larger message" \ 3677 "$P_SRV debug_level=3" \ 3678 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \ 3679 0 \ 3680 -c "Maximum input fragment length is $MAX_CONTENT_LEN" \ 3681 -c "Maximum output fragment length is $MAX_CONTENT_LEN" \ 3682 -s "Maximum input fragment length is $MAX_CONTENT_LEN" \ 3683 -s "Maximum output fragment length is $MAX_CONTENT_LEN" \ 3684 -C "client hello, adding max_fragment_length extension" \ 3685 -S "found max fragment length extension" \ 3686 -S "server hello, max_fragment_length extension" \ 3687 -C "found max_fragment_length extension" \ 3688 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \ 3689 -s "$MAX_CONTENT_LEN bytes read" \ 3690 -s "1 bytes read" 3691 3692requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 3693run_test "Max fragment length, DTLS: enabled, default, larger message" \ 3694 "$P_SRV debug_level=3 dtls=1" \ 3695 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \ 3696 1 \ 3697 -c "Maximum input fragment length is $MAX_CONTENT_LEN" \ 3698 -c "Maximum output fragment length is $MAX_CONTENT_LEN" \ 3699 -s "Maximum input fragment length is $MAX_CONTENT_LEN" \ 3700 -s "Maximum output fragment length is $MAX_CONTENT_LEN" \ 3701 -C "client hello, adding max_fragment_length extension" \ 3702 -S "found max fragment length extension" \ 3703 -S "server hello, max_fragment_length extension" \ 3704 -C "found max_fragment_length extension" \ 3705 -c "fragment larger than.*maximum " 3706 3707# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled 3708# (session fragment length will be 16384 regardless of mbedtls 3709# content length configuration.) 3710 3711requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 3712run_test "Max fragment length: disabled, larger message" \ 3713 "$P_SRV debug_level=3" \ 3714 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \ 3715 0 \ 3716 -C "Maximum input fragment length is 16384" \ 3717 -C "Maximum output fragment length is 16384" \ 3718 -S "Maximum input fragment length is 16384" \ 3719 -S "Maximum output fragment length is 16384" \ 3720 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \ 3721 -s "$MAX_CONTENT_LEN bytes read" \ 3722 -s "1 bytes read" 3723 3724requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 3725run_test "Max fragment length, DTLS: disabled, larger message" \ 3726 "$P_SRV debug_level=3 dtls=1" \ 3727 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \ 3728 1 \ 3729 -C "Maximum input fragment length is 16384" \ 3730 -C "Maximum output fragment length is 16384" \ 3731 -S "Maximum input fragment length is 16384" \ 3732 -S "Maximum output fragment length is 16384" \ 3733 -c "fragment larger than.*maximum " 3734 3735requires_max_content_len 4096 3736requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 3737run_test "Max fragment length: used by client" \ 3738 "$P_SRV debug_level=3" \ 3739 "$P_CLI debug_level=3 max_frag_len=4096" \ 3740 0 \ 3741 -c "Maximum input fragment length is 4096" \ 3742 -c "Maximum output fragment length is 4096" \ 3743 -s "Maximum input fragment length is 4096" \ 3744 -s "Maximum output fragment length is 4096" \ 3745 -c "client hello, adding max_fragment_length extension" \ 3746 -s "found max fragment length extension" \ 3747 -s "server hello, max_fragment_length extension" \ 3748 -c "found max_fragment_length extension" 3749 3750requires_max_content_len 1024 3751requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 3752run_test "Max fragment length: client 512, server 1024" \ 3753 "$P_SRV debug_level=3 max_frag_len=1024" \ 3754 "$P_CLI debug_level=3 max_frag_len=512" \ 3755 0 \ 3756 -c "Maximum input fragment length is 512" \ 3757 -c "Maximum output fragment length is 512" \ 3758 -s "Maximum input fragment length is 512" \ 3759 -s "Maximum output fragment length is 512" \ 3760 -c "client hello, adding max_fragment_length extension" \ 3761 -s "found max fragment length extension" \ 3762 -s "server hello, max_fragment_length extension" \ 3763 -c "found max_fragment_length extension" 3764 3765requires_max_content_len 2048 3766requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 3767run_test "Max fragment length: client 512, server 2048" \ 3768 "$P_SRV debug_level=3 max_frag_len=2048" \ 3769 "$P_CLI debug_level=3 max_frag_len=512" \ 3770 0 \ 3771 -c "Maximum input fragment length is 512" \ 3772 -c "Maximum output fragment length is 512" \ 3773 -s "Maximum input fragment length is 512" \ 3774 -s "Maximum output fragment length is 512" \ 3775 -c "client hello, adding max_fragment_length extension" \ 3776 -s "found max fragment length extension" \ 3777 -s "server hello, max_fragment_length extension" \ 3778 -c "found max_fragment_length extension" 3779 3780requires_max_content_len 4096 3781requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 3782run_test "Max fragment length: client 512, server 4096" \ 3783 "$P_SRV debug_level=3 max_frag_len=4096" \ 3784 "$P_CLI debug_level=3 max_frag_len=512" \ 3785 0 \ 3786 -c "Maximum input fragment length is 512" \ 3787 -c "Maximum output fragment length is 512" \ 3788 -s "Maximum input fragment length is 512" \ 3789 -s "Maximum output fragment length is 512" \ 3790 -c "client hello, adding max_fragment_length extension" \ 3791 -s "found max fragment length extension" \ 3792 -s "server hello, max_fragment_length extension" \ 3793 -c "found max_fragment_length extension" 3794 3795requires_max_content_len 1024 3796requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 3797run_test "Max fragment length: client 1024, server 512" \ 3798 "$P_SRV debug_level=3 max_frag_len=512" \ 3799 "$P_CLI debug_level=3 max_frag_len=1024" \ 3800 0 \ 3801 -c "Maximum input fragment length is 1024" \ 3802 -c "Maximum output fragment length is 1024" \ 3803 -s "Maximum input fragment length is 1024" \ 3804 -s "Maximum output fragment length is 512" \ 3805 -c "client hello, adding max_fragment_length extension" \ 3806 -s "found max fragment length extension" \ 3807 -s "server hello, max_fragment_length extension" \ 3808 -c "found max_fragment_length extension" 3809 3810requires_max_content_len 2048 3811requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 3812run_test "Max fragment length: client 1024, server 2048" \ 3813 "$P_SRV debug_level=3 max_frag_len=2048" \ 3814 "$P_CLI debug_level=3 max_frag_len=1024" \ 3815 0 \ 3816 -c "Maximum input fragment length is 1024" \ 3817 -c "Maximum output fragment length is 1024" \ 3818 -s "Maximum input fragment length is 1024" \ 3819 -s "Maximum output fragment length is 1024" \ 3820 -c "client hello, adding max_fragment_length extension" \ 3821 -s "found max fragment length extension" \ 3822 -s "server hello, max_fragment_length extension" \ 3823 -c "found max_fragment_length extension" 3824 3825requires_max_content_len 4096 3826requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 3827run_test "Max fragment length: client 1024, server 4096" \ 3828 "$P_SRV debug_level=3 max_frag_len=4096" \ 3829 "$P_CLI debug_level=3 max_frag_len=1024" \ 3830 0 \ 3831 -c "Maximum input fragment length is 1024" \ 3832 -c "Maximum output fragment length is 1024" \ 3833 -s "Maximum input fragment length is 1024" \ 3834 -s "Maximum output fragment length is 1024" \ 3835 -c "client hello, adding max_fragment_length extension" \ 3836 -s "found max fragment length extension" \ 3837 -s "server hello, max_fragment_length extension" \ 3838 -c "found max_fragment_length extension" 3839 3840requires_max_content_len 2048 3841requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 3842run_test "Max fragment length: client 2048, server 512" \ 3843 "$P_SRV debug_level=3 max_frag_len=512" \ 3844 "$P_CLI debug_level=3 max_frag_len=2048" \ 3845 0 \ 3846 -c "Maximum input fragment length is 2048" \ 3847 -c "Maximum output fragment length is 2048" \ 3848 -s "Maximum input fragment length is 2048" \ 3849 -s "Maximum output fragment length is 512" \ 3850 -c "client hello, adding max_fragment_length extension" \ 3851 -s "found max fragment length extension" \ 3852 -s "server hello, max_fragment_length extension" \ 3853 -c "found max_fragment_length extension" 3854 3855requires_max_content_len 2048 3856requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 3857run_test "Max fragment length: client 2048, server 1024" \ 3858 "$P_SRV debug_level=3 max_frag_len=1024" \ 3859 "$P_CLI debug_level=3 max_frag_len=2048" \ 3860 0 \ 3861 -c "Maximum input fragment length is 2048" \ 3862 -c "Maximum output fragment length is 2048" \ 3863 -s "Maximum input fragment length is 2048" \ 3864 -s "Maximum output fragment length is 1024" \ 3865 -c "client hello, adding max_fragment_length extension" \ 3866 -s "found max fragment length extension" \ 3867 -s "server hello, max_fragment_length extension" \ 3868 -c "found max_fragment_length extension" 3869 3870requires_max_content_len 4096 3871requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 3872run_test "Max fragment length: client 2048, server 4096" \ 3873 "$P_SRV debug_level=3 max_frag_len=4096" \ 3874 "$P_CLI debug_level=3 max_frag_len=2048" \ 3875 0 \ 3876 -c "Maximum input fragment length is 2048" \ 3877 -c "Maximum output fragment length is 2048" \ 3878 -s "Maximum input fragment length is 2048" \ 3879 -s "Maximum output fragment length is 2048" \ 3880 -c "client hello, adding max_fragment_length extension" \ 3881 -s "found max fragment length extension" \ 3882 -s "server hello, max_fragment_length extension" \ 3883 -c "found max_fragment_length extension" 3884 3885requires_max_content_len 4096 3886requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 3887run_test "Max fragment length: client 4096, server 512" \ 3888 "$P_SRV debug_level=3 max_frag_len=512" \ 3889 "$P_CLI debug_level=3 max_frag_len=4096" \ 3890 0 \ 3891 -c "Maximum input fragment length is 4096" \ 3892 -c "Maximum output fragment length is 4096" \ 3893 -s "Maximum input fragment length is 4096" \ 3894 -s "Maximum output fragment length is 512" \ 3895 -c "client hello, adding max_fragment_length extension" \ 3896 -s "found max fragment length extension" \ 3897 -s "server hello, max_fragment_length extension" \ 3898 -c "found max_fragment_length extension" 3899 3900requires_max_content_len 4096 3901requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 3902run_test "Max fragment length: client 4096, server 1024" \ 3903 "$P_SRV debug_level=3 max_frag_len=1024" \ 3904 "$P_CLI debug_level=3 max_frag_len=4096" \ 3905 0 \ 3906 -c "Maximum input fragment length is 4096" \ 3907 -c "Maximum output fragment length is 4096" \ 3908 -s "Maximum input fragment length is 4096" \ 3909 -s "Maximum output fragment length is 1024" \ 3910 -c "client hello, adding max_fragment_length extension" \ 3911 -s "found max fragment length extension" \ 3912 -s "server hello, max_fragment_length extension" \ 3913 -c "found max_fragment_length extension" 3914 3915requires_max_content_len 4096 3916requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 3917run_test "Max fragment length: client 4096, server 2048" \ 3918 "$P_SRV debug_level=3 max_frag_len=2048" \ 3919 "$P_CLI debug_level=3 max_frag_len=4096" \ 3920 0 \ 3921 -c "Maximum input fragment length is 4096" \ 3922 -c "Maximum output fragment length is 4096" \ 3923 -s "Maximum input fragment length is 4096" \ 3924 -s "Maximum output fragment length is 2048" \ 3925 -c "client hello, adding max_fragment_length extension" \ 3926 -s "found max fragment length extension" \ 3927 -s "server hello, max_fragment_length extension" \ 3928 -c "found max_fragment_length extension" 3929 3930requires_max_content_len 4096 3931requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 3932run_test "Max fragment length: used by server" \ 3933 "$P_SRV debug_level=3 max_frag_len=4096" \ 3934 "$P_CLI debug_level=3" \ 3935 0 \ 3936 -c "Maximum input fragment length is $MAX_CONTENT_LEN" \ 3937 -c "Maximum output fragment length is $MAX_CONTENT_LEN" \ 3938 -s "Maximum input fragment length is $MAX_CONTENT_LEN" \ 3939 -s "Maximum output fragment length is 4096" \ 3940 -C "client hello, adding max_fragment_length extension" \ 3941 -S "found max fragment length extension" \ 3942 -S "server hello, max_fragment_length extension" \ 3943 -C "found max_fragment_length extension" 3944 3945requires_max_content_len 4096 3946requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 3947requires_gnutls 3948run_test "Max fragment length: gnutls server" \ 3949 "$G_SRV" \ 3950 "$P_CLI debug_level=3 max_frag_len=4096" \ 3951 0 \ 3952 -c "Maximum input fragment length is 4096" \ 3953 -c "Maximum output fragment length is 4096" \ 3954 -c "client hello, adding max_fragment_length extension" \ 3955 -c "found max_fragment_length extension" 3956 3957requires_max_content_len 2048 3958requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 3959run_test "Max fragment length: client, message just fits" \ 3960 "$P_SRV debug_level=3" \ 3961 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \ 3962 0 \ 3963 -c "Maximum input fragment length is 2048" \ 3964 -c "Maximum output fragment length is 2048" \ 3965 -s "Maximum input fragment length is 2048" \ 3966 -s "Maximum output fragment length is 2048" \ 3967 -c "client hello, adding max_fragment_length extension" \ 3968 -s "found max fragment length extension" \ 3969 -s "server hello, max_fragment_length extension" \ 3970 -c "found max_fragment_length extension" \ 3971 -c "2048 bytes written in 1 fragments" \ 3972 -s "2048 bytes read" 3973 3974requires_max_content_len 2048 3975requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 3976run_test "Max fragment length: client, larger message" \ 3977 "$P_SRV debug_level=3" \ 3978 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \ 3979 0 \ 3980 -c "Maximum input fragment length is 2048" \ 3981 -c "Maximum output fragment length is 2048" \ 3982 -s "Maximum input fragment length is 2048" \ 3983 -s "Maximum output fragment length is 2048" \ 3984 -c "client hello, adding max_fragment_length extension" \ 3985 -s "found max fragment length extension" \ 3986 -s "server hello, max_fragment_length extension" \ 3987 -c "found max_fragment_length extension" \ 3988 -c "2345 bytes written in 2 fragments" \ 3989 -s "2048 bytes read" \ 3990 -s "297 bytes read" 3991 3992requires_max_content_len 2048 3993requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 3994run_test "Max fragment length: DTLS client, larger message" \ 3995 "$P_SRV debug_level=3 dtls=1" \ 3996 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \ 3997 1 \ 3998 -c "Maximum input fragment length is 2048" \ 3999 -c "Maximum output fragment length is 2048" \ 4000 -s "Maximum input fragment length is 2048" \ 4001 -s "Maximum output fragment length is 2048" \ 4002 -c "client hello, adding max_fragment_length extension" \ 4003 -s "found max fragment length extension" \ 4004 -s "server hello, max_fragment_length extension" \ 4005 -c "found max_fragment_length extension" \ 4006 -c "fragment larger than.*maximum" 4007 4008# Tests for renegotiation 4009 4010# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION 4011run_test "Renegotiation: none, for reference" \ 4012 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \ 4013 "$P_CLI debug_level=3 exchanges=2" \ 4014 0 \ 4015 -C "client hello, adding renegotiation extension" \ 4016 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ 4017 -S "found renegotiation extension" \ 4018 -s "server hello, secure renegotiation extension" \ 4019 -c "found renegotiation extension" \ 4020 -C "=> renegotiate" \ 4021 -S "=> renegotiate" \ 4022 -S "write hello request" 4023 4024requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 4025run_test "Renegotiation: client-initiated" \ 4026 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \ 4027 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \ 4028 0 \ 4029 -c "client hello, adding renegotiation extension" \ 4030 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ 4031 -s "found renegotiation extension" \ 4032 -s "server hello, secure renegotiation extension" \ 4033 -c "found renegotiation extension" \ 4034 -c "=> renegotiate" \ 4035 -s "=> renegotiate" \ 4036 -S "write hello request" 4037 4038requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 4039run_test "Renegotiation: server-initiated" \ 4040 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \ 4041 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \ 4042 0 \ 4043 -c "client hello, adding renegotiation extension" \ 4044 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ 4045 -s "found renegotiation extension" \ 4046 -s "server hello, secure renegotiation extension" \ 4047 -c "found renegotiation extension" \ 4048 -c "=> renegotiate" \ 4049 -s "=> renegotiate" \ 4050 -s "write hello request" 4051 4052# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that 4053# the server did not parse the Signature Algorithm extension. This test is valid only if an MD 4054# algorithm stronger than SHA-1 is enabled in config.h 4055requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 4056run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \ 4057 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \ 4058 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \ 4059 0 \ 4060 -c "client hello, adding renegotiation extension" \ 4061 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ 4062 -s "found renegotiation extension" \ 4063 -s "server hello, secure renegotiation extension" \ 4064 -c "found renegotiation extension" \ 4065 -c "=> renegotiate" \ 4066 -s "=> renegotiate" \ 4067 -S "write hello request" \ 4068 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated? 4069 4070# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that 4071# the server did not parse the Signature Algorithm extension. This test is valid only if an MD 4072# algorithm stronger than SHA-1 is enabled in config.h 4073requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 4074run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \ 4075 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \ 4076 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \ 4077 0 \ 4078 -c "client hello, adding renegotiation extension" \ 4079 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ 4080 -s "found renegotiation extension" \ 4081 -s "server hello, secure renegotiation extension" \ 4082 -c "found renegotiation extension" \ 4083 -c "=> renegotiate" \ 4084 -s "=> renegotiate" \ 4085 -s "write hello request" \ 4086 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated? 4087 4088requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 4089run_test "Renegotiation: double" \ 4090 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \ 4091 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \ 4092 0 \ 4093 -c "client hello, adding renegotiation extension" \ 4094 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ 4095 -s "found renegotiation extension" \ 4096 -s "server hello, secure renegotiation extension" \ 4097 -c "found renegotiation extension" \ 4098 -c "=> renegotiate" \ 4099 -s "=> renegotiate" \ 4100 -s "write hello request" 4101 4102requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 4103requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 4104requires_max_content_len 2048 4105run_test "Renegotiation with max fragment length: client 2048, server 512" \ 4106 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1 max_frag_len=512" \ 4107 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 max_frag_len=2048 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \ 4108 0 \ 4109 -c "Maximum input fragment length is 2048" \ 4110 -c "Maximum output fragment length is 2048" \ 4111 -s "Maximum input fragment length is 2048" \ 4112 -s "Maximum output fragment length is 512" \ 4113 -c "client hello, adding max_fragment_length extension" \ 4114 -s "found max fragment length extension" \ 4115 -s "server hello, max_fragment_length extension" \ 4116 -c "found max_fragment_length extension" \ 4117 -c "client hello, adding renegotiation extension" \ 4118 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ 4119 -s "found renegotiation extension" \ 4120 -s "server hello, secure renegotiation extension" \ 4121 -c "found renegotiation extension" \ 4122 -c "=> renegotiate" \ 4123 -s "=> renegotiate" \ 4124 -s "write hello request" 4125 4126requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 4127run_test "Renegotiation: client-initiated, server-rejected" \ 4128 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \ 4129 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \ 4130 1 \ 4131 -c "client hello, adding renegotiation extension" \ 4132 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ 4133 -S "found renegotiation extension" \ 4134 -s "server hello, secure renegotiation extension" \ 4135 -c "found renegotiation extension" \ 4136 -c "=> renegotiate" \ 4137 -S "=> renegotiate" \ 4138 -S "write hello request" \ 4139 -c "SSL - Unexpected message at ServerHello in renegotiation" \ 4140 -c "failed" 4141 4142requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 4143run_test "Renegotiation: server-initiated, client-rejected, default" \ 4144 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \ 4145 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \ 4146 0 \ 4147 -C "client hello, adding renegotiation extension" \ 4148 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ 4149 -S "found renegotiation extension" \ 4150 -s "server hello, secure renegotiation extension" \ 4151 -c "found renegotiation extension" \ 4152 -C "=> renegotiate" \ 4153 -S "=> renegotiate" \ 4154 -s "write hello request" \ 4155 -S "SSL - An unexpected message was received from our peer" \ 4156 -S "failed" 4157 4158requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 4159run_test "Renegotiation: server-initiated, client-rejected, not enforced" \ 4160 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \ 4161 renego_delay=-1 auth_mode=optional" \ 4162 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \ 4163 0 \ 4164 -C "client hello, adding renegotiation extension" \ 4165 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ 4166 -S "found renegotiation extension" \ 4167 -s "server hello, secure renegotiation extension" \ 4168 -c "found renegotiation extension" \ 4169 -C "=> renegotiate" \ 4170 -S "=> renegotiate" \ 4171 -s "write hello request" \ 4172 -S "SSL - An unexpected message was received from our peer" \ 4173 -S "failed" 4174 4175# delay 2 for 1 alert record + 1 application data record 4176requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 4177run_test "Renegotiation: server-initiated, client-rejected, delay 2" \ 4178 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \ 4179 renego_delay=2 auth_mode=optional" \ 4180 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \ 4181 0 \ 4182 -C "client hello, adding renegotiation extension" \ 4183 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ 4184 -S "found renegotiation extension" \ 4185 -s "server hello, secure renegotiation extension" \ 4186 -c "found renegotiation extension" \ 4187 -C "=> renegotiate" \ 4188 -S "=> renegotiate" \ 4189 -s "write hello request" \ 4190 -S "SSL - An unexpected message was received from our peer" \ 4191 -S "failed" 4192 4193requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 4194run_test "Renegotiation: server-initiated, client-rejected, delay 0" \ 4195 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \ 4196 renego_delay=0 auth_mode=optional" \ 4197 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \ 4198 0 \ 4199 -C "client hello, adding renegotiation extension" \ 4200 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ 4201 -S "found renegotiation extension" \ 4202 -s "server hello, secure renegotiation extension" \ 4203 -c "found renegotiation extension" \ 4204 -C "=> renegotiate" \ 4205 -S "=> renegotiate" \ 4206 -s "write hello request" \ 4207 -s "SSL - An unexpected message was received from our peer" 4208 4209requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 4210run_test "Renegotiation: server-initiated, client-accepted, delay 0" \ 4211 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \ 4212 renego_delay=0 auth_mode=optional" \ 4213 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \ 4214 0 \ 4215 -c "client hello, adding renegotiation extension" \ 4216 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ 4217 -s "found renegotiation extension" \ 4218 -s "server hello, secure renegotiation extension" \ 4219 -c "found renegotiation extension" \ 4220 -c "=> renegotiate" \ 4221 -s "=> renegotiate" \ 4222 -s "write hello request" \ 4223 -S "SSL - An unexpected message was received from our peer" \ 4224 -S "failed" 4225 4226requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 4227run_test "Renegotiation: periodic, just below period" \ 4228 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \ 4229 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \ 4230 0 \ 4231 -C "client hello, adding renegotiation extension" \ 4232 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ 4233 -S "found renegotiation extension" \ 4234 -s "server hello, secure renegotiation extension" \ 4235 -c "found renegotiation extension" \ 4236 -S "record counter limit reached: renegotiate" \ 4237 -C "=> renegotiate" \ 4238 -S "=> renegotiate" \ 4239 -S "write hello request" \ 4240 -S "SSL - An unexpected message was received from our peer" \ 4241 -S "failed" 4242 4243# one extra exchange to be able to complete renego 4244requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 4245run_test "Renegotiation: periodic, just above period" \ 4246 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \ 4247 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \ 4248 0 \ 4249 -c "client hello, adding renegotiation extension" \ 4250 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ 4251 -s "found renegotiation extension" \ 4252 -s "server hello, secure renegotiation extension" \ 4253 -c "found renegotiation extension" \ 4254 -s "record counter limit reached: renegotiate" \ 4255 -c "=> renegotiate" \ 4256 -s "=> renegotiate" \ 4257 -s "write hello request" \ 4258 -S "SSL - An unexpected message was received from our peer" \ 4259 -S "failed" 4260 4261requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 4262run_test "Renegotiation: periodic, two times period" \ 4263 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \ 4264 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \ 4265 0 \ 4266 -c "client hello, adding renegotiation extension" \ 4267 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ 4268 -s "found renegotiation extension" \ 4269 -s "server hello, secure renegotiation extension" \ 4270 -c "found renegotiation extension" \ 4271 -s "record counter limit reached: renegotiate" \ 4272 -c "=> renegotiate" \ 4273 -s "=> renegotiate" \ 4274 -s "write hello request" \ 4275 -S "SSL - An unexpected message was received from our peer" \ 4276 -S "failed" 4277 4278requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 4279run_test "Renegotiation: periodic, above period, disabled" \ 4280 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \ 4281 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \ 4282 0 \ 4283 -C "client hello, adding renegotiation extension" \ 4284 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ 4285 -S "found renegotiation extension" \ 4286 -s "server hello, secure renegotiation extension" \ 4287 -c "found renegotiation extension" \ 4288 -S "record counter limit reached: renegotiate" \ 4289 -C "=> renegotiate" \ 4290 -S "=> renegotiate" \ 4291 -S "write hello request" \ 4292 -S "SSL - An unexpected message was received from our peer" \ 4293 -S "failed" 4294 4295requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 4296run_test "Renegotiation: nbio, client-initiated" \ 4297 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \ 4298 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \ 4299 0 \ 4300 -c "client hello, adding renegotiation extension" \ 4301 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ 4302 -s "found renegotiation extension" \ 4303 -s "server hello, secure renegotiation extension" \ 4304 -c "found renegotiation extension" \ 4305 -c "=> renegotiate" \ 4306 -s "=> renegotiate" \ 4307 -S "write hello request" 4308 4309requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 4310run_test "Renegotiation: nbio, server-initiated" \ 4311 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \ 4312 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \ 4313 0 \ 4314 -c "client hello, adding renegotiation extension" \ 4315 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ 4316 -s "found renegotiation extension" \ 4317 -s "server hello, secure renegotiation extension" \ 4318 -c "found renegotiation extension" \ 4319 -c "=> renegotiate" \ 4320 -s "=> renegotiate" \ 4321 -s "write hello request" 4322 4323requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 4324run_test "Renegotiation: openssl server, client-initiated" \ 4325 "$O_SRV -www" \ 4326 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \ 4327 0 \ 4328 -c "client hello, adding renegotiation extension" \ 4329 -c "found renegotiation extension" \ 4330 -c "=> renegotiate" \ 4331 -C "ssl_hanshake() returned" \ 4332 -C "error" \ 4333 -c "HTTP/1.0 200 [Oo][Kk]" 4334 4335requires_gnutls 4336requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 4337run_test "Renegotiation: gnutls server strict, client-initiated" \ 4338 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \ 4339 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \ 4340 0 \ 4341 -c "client hello, adding renegotiation extension" \ 4342 -c "found renegotiation extension" \ 4343 -c "=> renegotiate" \ 4344 -C "ssl_hanshake() returned" \ 4345 -C "error" \ 4346 -c "HTTP/1.0 200 [Oo][Kk]" 4347 4348requires_gnutls 4349requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 4350run_test "Renegotiation: gnutls server unsafe, client-initiated default" \ 4351 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \ 4352 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \ 4353 1 \ 4354 -c "client hello, adding renegotiation extension" \ 4355 -C "found renegotiation extension" \ 4356 -c "=> renegotiate" \ 4357 -c "mbedtls_ssl_handshake() returned" \ 4358 -c "error" \ 4359 -C "HTTP/1.0 200 [Oo][Kk]" 4360 4361requires_gnutls 4362requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 4363run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \ 4364 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \ 4365 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \ 4366 allow_legacy=0" \ 4367 1 \ 4368 -c "client hello, adding renegotiation extension" \ 4369 -C "found renegotiation extension" \ 4370 -c "=> renegotiate" \ 4371 -c "mbedtls_ssl_handshake() returned" \ 4372 -c "error" \ 4373 -C "HTTP/1.0 200 [Oo][Kk]" 4374 4375requires_gnutls 4376requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 4377run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \ 4378 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \ 4379 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \ 4380 allow_legacy=1" \ 4381 0 \ 4382 -c "client hello, adding renegotiation extension" \ 4383 -C "found renegotiation extension" \ 4384 -c "=> renegotiate" \ 4385 -C "ssl_hanshake() returned" \ 4386 -C "error" \ 4387 -c "HTTP/1.0 200 [Oo][Kk]" 4388 4389requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 4390run_test "Renegotiation: DTLS, client-initiated" \ 4391 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \ 4392 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \ 4393 0 \ 4394 -c "client hello, adding renegotiation extension" \ 4395 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ 4396 -s "found renegotiation extension" \ 4397 -s "server hello, secure renegotiation extension" \ 4398 -c "found renegotiation extension" \ 4399 -c "=> renegotiate" \ 4400 -s "=> renegotiate" \ 4401 -S "write hello request" 4402 4403requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 4404run_test "Renegotiation: DTLS, server-initiated" \ 4405 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \ 4406 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \ 4407 read_timeout=1000 max_resend=2" \ 4408 0 \ 4409 -c "client hello, adding renegotiation extension" \ 4410 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ 4411 -s "found renegotiation extension" \ 4412 -s "server hello, secure renegotiation extension" \ 4413 -c "found renegotiation extension" \ 4414 -c "=> renegotiate" \ 4415 -s "=> renegotiate" \ 4416 -s "write hello request" 4417 4418requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 4419run_test "Renegotiation: DTLS, renego_period overflow" \ 4420 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \ 4421 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \ 4422 0 \ 4423 -c "client hello, adding renegotiation extension" \ 4424 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ 4425 -s "found renegotiation extension" \ 4426 -s "server hello, secure renegotiation extension" \ 4427 -s "record counter limit reached: renegotiate" \ 4428 -c "=> renegotiate" \ 4429 -s "=> renegotiate" \ 4430 -s "write hello request" 4431 4432requires_gnutls 4433requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 4434run_test "Renegotiation: DTLS, gnutls server, client-initiated" \ 4435 "$G_SRV -u --mtu 4096" \ 4436 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \ 4437 0 \ 4438 -c "client hello, adding renegotiation extension" \ 4439 -c "found renegotiation extension" \ 4440 -c "=> renegotiate" \ 4441 -C "mbedtls_ssl_handshake returned" \ 4442 -C "error" \ 4443 -s "Extra-header:" 4444 4445# Test for the "secure renegotiation" extension only (no actual renegotiation) 4446 4447requires_gnutls 4448run_test "Renego ext: gnutls server strict, client default" \ 4449 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \ 4450 "$P_CLI debug_level=3" \ 4451 0 \ 4452 -c "found renegotiation extension" \ 4453 -C "error" \ 4454 -c "HTTP/1.0 200 [Oo][Kk]" 4455 4456requires_gnutls 4457run_test "Renego ext: gnutls server unsafe, client default" \ 4458 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \ 4459 "$P_CLI debug_level=3" \ 4460 0 \ 4461 -C "found renegotiation extension" \ 4462 -C "error" \ 4463 -c "HTTP/1.0 200 [Oo][Kk]" 4464 4465requires_gnutls 4466run_test "Renego ext: gnutls server unsafe, client break legacy" \ 4467 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \ 4468 "$P_CLI debug_level=3 allow_legacy=-1" \ 4469 1 \ 4470 -C "found renegotiation extension" \ 4471 -c "error" \ 4472 -C "HTTP/1.0 200 [Oo][Kk]" 4473 4474requires_gnutls 4475run_test "Renego ext: gnutls client strict, server default" \ 4476 "$P_SRV debug_level=3" \ 4477 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \ 4478 0 \ 4479 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \ 4480 -s "server hello, secure renegotiation extension" 4481 4482requires_gnutls 4483run_test "Renego ext: gnutls client unsafe, server default" \ 4484 "$P_SRV debug_level=3" \ 4485 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \ 4486 0 \ 4487 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \ 4488 -S "server hello, secure renegotiation extension" 4489 4490requires_gnutls 4491run_test "Renego ext: gnutls client unsafe, server break legacy" \ 4492 "$P_SRV debug_level=3 allow_legacy=-1" \ 4493 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \ 4494 1 \ 4495 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \ 4496 -S "server hello, secure renegotiation extension" 4497 4498# Tests for silently dropping trailing extra bytes in .der certificates 4499 4500requires_gnutls 4501run_test "DER format: no trailing bytes" \ 4502 "$P_SRV crt_file=data_files/server5-der0.crt \ 4503 key_file=data_files/server5.key" \ 4504 "$G_CLI localhost" \ 4505 0 \ 4506 -c "Handshake was completed" \ 4507 4508requires_gnutls 4509run_test "DER format: with a trailing zero byte" \ 4510 "$P_SRV crt_file=data_files/server5-der1a.crt \ 4511 key_file=data_files/server5.key" \ 4512 "$G_CLI localhost" \ 4513 0 \ 4514 -c "Handshake was completed" \ 4515 4516requires_gnutls 4517run_test "DER format: with a trailing random byte" \ 4518 "$P_SRV crt_file=data_files/server5-der1b.crt \ 4519 key_file=data_files/server5.key" \ 4520 "$G_CLI localhost" \ 4521 0 \ 4522 -c "Handshake was completed" \ 4523 4524requires_gnutls 4525run_test "DER format: with 2 trailing random bytes" \ 4526 "$P_SRV crt_file=data_files/server5-der2.crt \ 4527 key_file=data_files/server5.key" \ 4528 "$G_CLI localhost" \ 4529 0 \ 4530 -c "Handshake was completed" \ 4531 4532requires_gnutls 4533run_test "DER format: with 4 trailing random bytes" \ 4534 "$P_SRV crt_file=data_files/server5-der4.crt \ 4535 key_file=data_files/server5.key" \ 4536 "$G_CLI localhost" \ 4537 0 \ 4538 -c "Handshake was completed" \ 4539 4540requires_gnutls 4541run_test "DER format: with 8 trailing random bytes" \ 4542 "$P_SRV crt_file=data_files/server5-der8.crt \ 4543 key_file=data_files/server5.key" \ 4544 "$G_CLI localhost" \ 4545 0 \ 4546 -c "Handshake was completed" \ 4547 4548requires_gnutls 4549run_test "DER format: with 9 trailing random bytes" \ 4550 "$P_SRV crt_file=data_files/server5-der9.crt \ 4551 key_file=data_files/server5.key" \ 4552 "$G_CLI localhost" \ 4553 0 \ 4554 -c "Handshake was completed" \ 4555 4556# Tests for auth_mode, there are duplicated tests using ca callback for authentication 4557# When updating these tests, modify the matching authentication tests accordingly 4558 4559run_test "Authentication: server badcert, client required" \ 4560 "$P_SRV crt_file=data_files/server5-badsign.crt \ 4561 key_file=data_files/server5.key" \ 4562 "$P_CLI debug_level=1 auth_mode=required" \ 4563 1 \ 4564 -c "x509_verify_cert() returned" \ 4565 -c "! The certificate is not correctly signed by the trusted CA" \ 4566 -c "! mbedtls_ssl_handshake returned" \ 4567 -c "X509 - Certificate verification failed" 4568 4569run_test "Authentication: server badcert, client optional" \ 4570 "$P_SRV crt_file=data_files/server5-badsign.crt \ 4571 key_file=data_files/server5.key" \ 4572 "$P_CLI debug_level=1 auth_mode=optional" \ 4573 0 \ 4574 -c "x509_verify_cert() returned" \ 4575 -c "! The certificate is not correctly signed by the trusted CA" \ 4576 -C "! mbedtls_ssl_handshake returned" \ 4577 -C "X509 - Certificate verification failed" 4578 4579run_test "Authentication: server goodcert, client optional, no trusted CA" \ 4580 "$P_SRV" \ 4581 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \ 4582 0 \ 4583 -c "x509_verify_cert() returned" \ 4584 -c "! The certificate is not correctly signed by the trusted CA" \ 4585 -c "! Certificate verification flags"\ 4586 -C "! mbedtls_ssl_handshake returned" \ 4587 -C "X509 - Certificate verification failed" \ 4588 -C "SSL - No CA Chain is set, but required to operate" 4589 4590run_test "Authentication: server goodcert, client required, no trusted CA" \ 4591 "$P_SRV" \ 4592 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \ 4593 1 \ 4594 -c "x509_verify_cert() returned" \ 4595 -c "! The certificate is not correctly signed by the trusted CA" \ 4596 -c "! Certificate verification flags"\ 4597 -c "! mbedtls_ssl_handshake returned" \ 4598 -c "SSL - No CA Chain is set, but required to operate" 4599 4600# The purpose of the next two tests is to test the client's behaviour when receiving a server 4601# certificate with an unsupported elliptic curve. This should usually not happen because 4602# the client informs the server about the supported curves - it does, though, in the 4603# corner case of a static ECDH suite, because the server doesn't check the curve on that 4604# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a 4605# different means to have the server ignoring the client's supported curve list. 4606 4607requires_config_enabled MBEDTLS_ECP_C 4608run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \ 4609 "$P_SRV debug_level=1 key_file=data_files/server5.key \ 4610 crt_file=data_files/server5.ku-ka.crt" \ 4611 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \ 4612 1 \ 4613 -c "bad certificate (EC key curve)"\ 4614 -c "! Certificate verification flags"\ 4615 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage 4616 4617requires_config_enabled MBEDTLS_ECP_C 4618run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \ 4619 "$P_SRV debug_level=1 key_file=data_files/server5.key \ 4620 crt_file=data_files/server5.ku-ka.crt" \ 4621 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \ 4622 1 \ 4623 -c "bad certificate (EC key curve)"\ 4624 -c "! Certificate verification flags"\ 4625 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check 4626 4627run_test "Authentication: server badcert, client none" \ 4628 "$P_SRV crt_file=data_files/server5-badsign.crt \ 4629 key_file=data_files/server5.key" \ 4630 "$P_CLI debug_level=1 auth_mode=none" \ 4631 0 \ 4632 -C "x509_verify_cert() returned" \ 4633 -C "! The certificate is not correctly signed by the trusted CA" \ 4634 -C "! mbedtls_ssl_handshake returned" \ 4635 -C "X509 - Certificate verification failed" 4636 4637run_test "Authentication: client SHA256, server required" \ 4638 "$P_SRV auth_mode=required" \ 4639 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \ 4640 key_file=data_files/server6.key \ 4641 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \ 4642 0 \ 4643 -c "Supported Signature Algorithm found: 4," \ 4644 -c "Supported Signature Algorithm found: 5," 4645 4646run_test "Authentication: client SHA384, server required" \ 4647 "$P_SRV auth_mode=required" \ 4648 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \ 4649 key_file=data_files/server6.key \ 4650 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \ 4651 0 \ 4652 -c "Supported Signature Algorithm found: 4," \ 4653 -c "Supported Signature Algorithm found: 5," 4654 4655run_test "Authentication: client has no cert, server required (SSLv3)" \ 4656 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \ 4657 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \ 4658 key_file=data_files/server5.key" \ 4659 1 \ 4660 -S "skip write certificate request" \ 4661 -C "skip parse certificate request" \ 4662 -c "got a certificate request" \ 4663 -c "got no certificate to send" \ 4664 -S "x509_verify_cert() returned" \ 4665 -s "client has no certificate" \ 4666 -s "! mbedtls_ssl_handshake returned" \ 4667 -c "! mbedtls_ssl_handshake returned" \ 4668 -s "No client certification received from the client, but required by the authentication mode" 4669 4670run_test "Authentication: client has no cert, server required (TLS)" \ 4671 "$P_SRV debug_level=3 auth_mode=required" \ 4672 "$P_CLI debug_level=3 crt_file=none \ 4673 key_file=data_files/server5.key" \ 4674 1 \ 4675 -S "skip write certificate request" \ 4676 -C "skip parse certificate request" \ 4677 -c "got a certificate request" \ 4678 -c "= write certificate$" \ 4679 -C "skip write certificate$" \ 4680 -S "x509_verify_cert() returned" \ 4681 -s "client has no certificate" \ 4682 -s "! mbedtls_ssl_handshake returned" \ 4683 -c "! mbedtls_ssl_handshake returned" \ 4684 -s "No client certification received from the client, but required by the authentication mode" 4685 4686run_test "Authentication: client badcert, server required" \ 4687 "$P_SRV debug_level=3 auth_mode=required" \ 4688 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \ 4689 key_file=data_files/server5.key" \ 4690 1 \ 4691 -S "skip write certificate request" \ 4692 -C "skip parse certificate request" \ 4693 -c "got a certificate request" \ 4694 -C "skip write certificate" \ 4695 -C "skip write certificate verify" \ 4696 -S "skip parse certificate verify" \ 4697 -s "x509_verify_cert() returned" \ 4698 -s "! The certificate is not correctly signed by the trusted CA" \ 4699 -s "! mbedtls_ssl_handshake returned" \ 4700 -s "send alert level=2 message=48" \ 4701 -c "! mbedtls_ssl_handshake returned" \ 4702 -s "X509 - Certificate verification failed" 4703# We don't check that the client receives the alert because it might 4704# detect that its write end of the connection is closed and abort 4705# before reading the alert message. 4706 4707run_test "Authentication: client cert self-signed and trusted, server required" \ 4708 "$P_SRV debug_level=3 auth_mode=required ca_file=data_files/server5-selfsigned.crt" \ 4709 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \ 4710 key_file=data_files/server5.key" \ 4711 0 \ 4712 -S "skip write certificate request" \ 4713 -C "skip parse certificate request" \ 4714 -c "got a certificate request" \ 4715 -C "skip write certificate" \ 4716 -C "skip write certificate verify" \ 4717 -S "skip parse certificate verify" \ 4718 -S "x509_verify_cert() returned" \ 4719 -S "! The certificate is not correctly signed" \ 4720 -S "X509 - Certificate verification failed" 4721 4722run_test "Authentication: client cert not trusted, server required" \ 4723 "$P_SRV debug_level=3 auth_mode=required" \ 4724 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \ 4725 key_file=data_files/server5.key" \ 4726 1 \ 4727 -S "skip write certificate request" \ 4728 -C "skip parse certificate request" \ 4729 -c "got a certificate request" \ 4730 -C "skip write certificate" \ 4731 -C "skip write certificate verify" \ 4732 -S "skip parse certificate verify" \ 4733 -s "x509_verify_cert() returned" \ 4734 -s "! The certificate is not correctly signed by the trusted CA" \ 4735 -s "! mbedtls_ssl_handshake returned" \ 4736 -c "! mbedtls_ssl_handshake returned" \ 4737 -s "X509 - Certificate verification failed" 4738 4739run_test "Authentication: client badcert, server optional" \ 4740 "$P_SRV debug_level=3 auth_mode=optional" \ 4741 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \ 4742 key_file=data_files/server5.key" \ 4743 0 \ 4744 -S "skip write certificate request" \ 4745 -C "skip parse certificate request" \ 4746 -c "got a certificate request" \ 4747 -C "skip write certificate" \ 4748 -C "skip write certificate verify" \ 4749 -S "skip parse certificate verify" \ 4750 -s "x509_verify_cert() returned" \ 4751 -s "! The certificate is not correctly signed by the trusted CA" \ 4752 -S "! mbedtls_ssl_handshake returned" \ 4753 -C "! mbedtls_ssl_handshake returned" \ 4754 -S "X509 - Certificate verification failed" 4755 4756run_test "Authentication: client badcert, server none" \ 4757 "$P_SRV debug_level=3 auth_mode=none" \ 4758 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \ 4759 key_file=data_files/server5.key" \ 4760 0 \ 4761 -s "skip write certificate request" \ 4762 -C "skip parse certificate request" \ 4763 -c "got no certificate request" \ 4764 -c "skip write certificate" \ 4765 -c "skip write certificate verify" \ 4766 -s "skip parse certificate verify" \ 4767 -S "x509_verify_cert() returned" \ 4768 -S "! The certificate is not correctly signed by the trusted CA" \ 4769 -S "! mbedtls_ssl_handshake returned" \ 4770 -C "! mbedtls_ssl_handshake returned" \ 4771 -S "X509 - Certificate verification failed" 4772 4773run_test "Authentication: client no cert, server optional" \ 4774 "$P_SRV debug_level=3 auth_mode=optional" \ 4775 "$P_CLI debug_level=3 crt_file=none key_file=none" \ 4776 0 \ 4777 -S "skip write certificate request" \ 4778 -C "skip parse certificate request" \ 4779 -c "got a certificate request" \ 4780 -C "skip write certificate$" \ 4781 -C "got no certificate to send" \ 4782 -S "SSLv3 client has no certificate" \ 4783 -c "skip write certificate verify" \ 4784 -s "skip parse certificate verify" \ 4785 -s "! Certificate was missing" \ 4786 -S "! mbedtls_ssl_handshake returned" \ 4787 -C "! mbedtls_ssl_handshake returned" \ 4788 -S "X509 - Certificate verification failed" 4789 4790run_test "Authentication: openssl client no cert, server optional" \ 4791 "$P_SRV debug_level=3 auth_mode=optional" \ 4792 "$O_CLI" \ 4793 0 \ 4794 -S "skip write certificate request" \ 4795 -s "skip parse certificate verify" \ 4796 -s "! Certificate was missing" \ 4797 -S "! mbedtls_ssl_handshake returned" \ 4798 -S "X509 - Certificate verification failed" 4799 4800run_test "Authentication: client no cert, openssl server optional" \ 4801 "$O_SRV -verify 10" \ 4802 "$P_CLI debug_level=3 crt_file=none key_file=none" \ 4803 0 \ 4804 -C "skip parse certificate request" \ 4805 -c "got a certificate request" \ 4806 -C "skip write certificate$" \ 4807 -c "skip write certificate verify" \ 4808 -C "! mbedtls_ssl_handshake returned" 4809 4810run_test "Authentication: client no cert, openssl server required" \ 4811 "$O_SRV -Verify 10" \ 4812 "$P_CLI debug_level=3 crt_file=none key_file=none" \ 4813 1 \ 4814 -C "skip parse certificate request" \ 4815 -c "got a certificate request" \ 4816 -C "skip write certificate$" \ 4817 -c "skip write certificate verify" \ 4818 -c "! mbedtls_ssl_handshake returned" 4819 4820run_test "Authentication: client no cert, ssl3" \ 4821 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \ 4822 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \ 4823 0 \ 4824 -S "skip write certificate request" \ 4825 -C "skip parse certificate request" \ 4826 -c "got a certificate request" \ 4827 -C "skip write certificate$" \ 4828 -c "skip write certificate verify" \ 4829 -c "got no certificate to send" \ 4830 -s "SSLv3 client has no certificate" \ 4831 -s "skip parse certificate verify" \ 4832 -s "! Certificate was missing" \ 4833 -S "! mbedtls_ssl_handshake returned" \ 4834 -C "! mbedtls_ssl_handshake returned" \ 4835 -S "X509 - Certificate verification failed" 4836 4837# This script assumes that MBEDTLS_X509_MAX_INTERMEDIATE_CA has its default 4838# value, defined here as MAX_IM_CA. Some test cases will be skipped if the 4839# library is configured with a different value. 4840 4841MAX_IM_CA='8' 4842 4843# The tests for the max_int tests can pass with any number higher than MAX_IM_CA 4844# because only a chain of MAX_IM_CA length is tested. Equally, the max_int+1 4845# tests can pass with any number less than MAX_IM_CA. However, stricter preconditions 4846# are in place so that the semantics are consistent with the test description. 4847requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA 4848requires_full_size_output_buffer 4849run_test "Authentication: server max_int chain, client default" \ 4850 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \ 4851 key_file=data_files/dir-maxpath/09.key" \ 4852 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \ 4853 0 \ 4854 -C "X509 - A fatal error occurred" 4855 4856requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA 4857requires_full_size_output_buffer 4858run_test "Authentication: server max_int+1 chain, client default" \ 4859 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \ 4860 key_file=data_files/dir-maxpath/10.key" \ 4861 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \ 4862 1 \ 4863 -c "X509 - A fatal error occurred" 4864 4865requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA 4866requires_full_size_output_buffer 4867run_test "Authentication: server max_int+1 chain, client optional" \ 4868 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \ 4869 key_file=data_files/dir-maxpath/10.key" \ 4870 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \ 4871 auth_mode=optional" \ 4872 1 \ 4873 -c "X509 - A fatal error occurred" 4874 4875requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA 4876requires_full_size_output_buffer 4877run_test "Authentication: server max_int+1 chain, client none" \ 4878 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \ 4879 key_file=data_files/dir-maxpath/10.key" \ 4880 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \ 4881 auth_mode=none" \ 4882 0 \ 4883 -C "X509 - A fatal error occurred" 4884 4885requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA 4886requires_full_size_output_buffer 4887run_test "Authentication: client max_int+1 chain, server default" \ 4888 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \ 4889 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \ 4890 key_file=data_files/dir-maxpath/10.key" \ 4891 0 \ 4892 -S "X509 - A fatal error occurred" 4893 4894requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA 4895requires_full_size_output_buffer 4896run_test "Authentication: client max_int+1 chain, server optional" \ 4897 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \ 4898 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \ 4899 key_file=data_files/dir-maxpath/10.key" \ 4900 1 \ 4901 -s "X509 - A fatal error occurred" 4902 4903requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA 4904requires_full_size_output_buffer 4905run_test "Authentication: client max_int+1 chain, server required" \ 4906 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \ 4907 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \ 4908 key_file=data_files/dir-maxpath/10.key" \ 4909 1 \ 4910 -s "X509 - A fatal error occurred" 4911 4912requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA 4913requires_full_size_output_buffer 4914run_test "Authentication: client max_int chain, server required" \ 4915 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \ 4916 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \ 4917 key_file=data_files/dir-maxpath/09.key" \ 4918 0 \ 4919 -S "X509 - A fatal error occurred" 4920 4921# Tests for CA list in CertificateRequest messages 4922 4923run_test "Authentication: send CA list in CertificateRequest (default)" \ 4924 "$P_SRV debug_level=3 auth_mode=required" \ 4925 "$P_CLI crt_file=data_files/server6.crt \ 4926 key_file=data_files/server6.key" \ 4927 0 \ 4928 -s "requested DN" 4929 4930run_test "Authentication: do not send CA list in CertificateRequest" \ 4931 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \ 4932 "$P_CLI crt_file=data_files/server6.crt \ 4933 key_file=data_files/server6.key" \ 4934 0 \ 4935 -S "requested DN" 4936 4937run_test "Authentication: send CA list in CertificateRequest, client self signed" \ 4938 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \ 4939 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \ 4940 key_file=data_files/server5.key" \ 4941 1 \ 4942 -S "requested DN" \ 4943 -s "x509_verify_cert() returned" \ 4944 -s "! The certificate is not correctly signed by the trusted CA" \ 4945 -s "! mbedtls_ssl_handshake returned" \ 4946 -c "! mbedtls_ssl_handshake returned" \ 4947 -s "X509 - Certificate verification failed" 4948 4949# Tests for auth_mode, using CA callback, these are duplicated from the authentication tests 4950# When updating these tests, modify the matching authentication tests accordingly 4951 4952requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK 4953run_test "Authentication, CA callback: server badcert, client required" \ 4954 "$P_SRV crt_file=data_files/server5-badsign.crt \ 4955 key_file=data_files/server5.key" \ 4956 "$P_CLI ca_callback=1 debug_level=3 auth_mode=required" \ 4957 1 \ 4958 -c "use CA callback for X.509 CRT verification" \ 4959 -c "x509_verify_cert() returned" \ 4960 -c "! The certificate is not correctly signed by the trusted CA" \ 4961 -c "! mbedtls_ssl_handshake returned" \ 4962 -c "X509 - Certificate verification failed" 4963 4964requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK 4965run_test "Authentication, CA callback: server badcert, client optional" \ 4966 "$P_SRV crt_file=data_files/server5-badsign.crt \ 4967 key_file=data_files/server5.key" \ 4968 "$P_CLI ca_callback=1 debug_level=3 auth_mode=optional" \ 4969 0 \ 4970 -c "use CA callback for X.509 CRT verification" \ 4971 -c "x509_verify_cert() returned" \ 4972 -c "! The certificate is not correctly signed by the trusted CA" \ 4973 -C "! mbedtls_ssl_handshake returned" \ 4974 -C "X509 - Certificate verification failed" 4975 4976# The purpose of the next two tests is to test the client's behaviour when receiving a server 4977# certificate with an unsupported elliptic curve. This should usually not happen because 4978# the client informs the server about the supported curves - it does, though, in the 4979# corner case of a static ECDH suite, because the server doesn't check the curve on that 4980# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a 4981# different means to have the server ignoring the client's supported curve list. 4982 4983requires_config_enabled MBEDTLS_ECP_C 4984requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK 4985run_test "Authentication, CA callback: server ECDH p256v1, client required, p256v1 unsupported" \ 4986 "$P_SRV debug_level=1 key_file=data_files/server5.key \ 4987 crt_file=data_files/server5.ku-ka.crt" \ 4988 "$P_CLI ca_callback=1 debug_level=3 auth_mode=required curves=secp521r1" \ 4989 1 \ 4990 -c "use CA callback for X.509 CRT verification" \ 4991 -c "bad certificate (EC key curve)" \ 4992 -c "! Certificate verification flags" \ 4993 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage 4994 4995requires_config_enabled MBEDTLS_ECP_C 4996requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK 4997run_test "Authentication, CA callback: server ECDH p256v1, client optional, p256v1 unsupported" \ 4998 "$P_SRV debug_level=1 key_file=data_files/server5.key \ 4999 crt_file=data_files/server5.ku-ka.crt" \ 5000 "$P_CLI ca_callback=1 debug_level=3 auth_mode=optional curves=secp521r1" \ 5001 1 \ 5002 -c "use CA callback for X.509 CRT verification" \ 5003 -c "bad certificate (EC key curve)"\ 5004 -c "! Certificate verification flags"\ 5005 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check 5006 5007requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK 5008run_test "Authentication, CA callback: client SHA256, server required" \ 5009 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \ 5010 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \ 5011 key_file=data_files/server6.key \ 5012 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \ 5013 0 \ 5014 -s "use CA callback for X.509 CRT verification" \ 5015 -c "Supported Signature Algorithm found: 4," \ 5016 -c "Supported Signature Algorithm found: 5," 5017 5018requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK 5019run_test "Authentication, CA callback: client SHA384, server required" \ 5020 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \ 5021 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \ 5022 key_file=data_files/server6.key \ 5023 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \ 5024 0 \ 5025 -s "use CA callback for X.509 CRT verification" \ 5026 -c "Supported Signature Algorithm found: 4," \ 5027 -c "Supported Signature Algorithm found: 5," 5028 5029requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK 5030run_test "Authentication, CA callback: client badcert, server required" \ 5031 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \ 5032 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \ 5033 key_file=data_files/server5.key" \ 5034 1 \ 5035 -s "use CA callback for X.509 CRT verification" \ 5036 -S "skip write certificate request" \ 5037 -C "skip parse certificate request" \ 5038 -c "got a certificate request" \ 5039 -C "skip write certificate" \ 5040 -C "skip write certificate verify" \ 5041 -S "skip parse certificate verify" \ 5042 -s "x509_verify_cert() returned" \ 5043 -s "! The certificate is not correctly signed by the trusted CA" \ 5044 -s "! mbedtls_ssl_handshake returned" \ 5045 -s "send alert level=2 message=48" \ 5046 -c "! mbedtls_ssl_handshake returned" \ 5047 -s "X509 - Certificate verification failed" 5048# We don't check that the client receives the alert because it might 5049# detect that its write end of the connection is closed and abort 5050# before reading the alert message. 5051 5052requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK 5053run_test "Authentication, CA callback: client cert not trusted, server required" \ 5054 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \ 5055 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \ 5056 key_file=data_files/server5.key" \ 5057 1 \ 5058 -s "use CA callback for X.509 CRT verification" \ 5059 -S "skip write certificate request" \ 5060 -C "skip parse certificate request" \ 5061 -c "got a certificate request" \ 5062 -C "skip write certificate" \ 5063 -C "skip write certificate verify" \ 5064 -S "skip parse certificate verify" \ 5065 -s "x509_verify_cert() returned" \ 5066 -s "! The certificate is not correctly signed by the trusted CA" \ 5067 -s "! mbedtls_ssl_handshake returned" \ 5068 -c "! mbedtls_ssl_handshake returned" \ 5069 -s "X509 - Certificate verification failed" 5070 5071requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK 5072run_test "Authentication, CA callback: client badcert, server optional" \ 5073 "$P_SRV ca_callback=1 debug_level=3 auth_mode=optional" \ 5074 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \ 5075 key_file=data_files/server5.key" \ 5076 0 \ 5077 -s "use CA callback for X.509 CRT verification" \ 5078 -S "skip write certificate request" \ 5079 -C "skip parse certificate request" \ 5080 -c "got a certificate request" \ 5081 -C "skip write certificate" \ 5082 -C "skip write certificate verify" \ 5083 -S "skip parse certificate verify" \ 5084 -s "x509_verify_cert() returned" \ 5085 -s "! The certificate is not correctly signed by the trusted CA" \ 5086 -S "! mbedtls_ssl_handshake returned" \ 5087 -C "! mbedtls_ssl_handshake returned" \ 5088 -S "X509 - Certificate verification failed" 5089 5090requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA 5091requires_full_size_output_buffer 5092requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK 5093run_test "Authentication, CA callback: server max_int chain, client default" \ 5094 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \ 5095 key_file=data_files/dir-maxpath/09.key" \ 5096 "$P_CLI ca_callback=1 debug_level=3 server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \ 5097 0 \ 5098 -c "use CA callback for X.509 CRT verification" \ 5099 -C "X509 - A fatal error occurred" 5100 5101requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA 5102requires_full_size_output_buffer 5103requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK 5104run_test "Authentication, CA callback: server max_int+1 chain, client default" \ 5105 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \ 5106 key_file=data_files/dir-maxpath/10.key" \ 5107 "$P_CLI debug_level=3 ca_callback=1 server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \ 5108 1 \ 5109 -c "use CA callback for X.509 CRT verification" \ 5110 -c "X509 - A fatal error occurred" 5111 5112requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA 5113requires_full_size_output_buffer 5114requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK 5115run_test "Authentication, CA callback: server max_int+1 chain, client optional" \ 5116 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \ 5117 key_file=data_files/dir-maxpath/10.key" \ 5118 "$P_CLI ca_callback=1 server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \ 5119 debug_level=3 auth_mode=optional" \ 5120 1 \ 5121 -c "use CA callback for X.509 CRT verification" \ 5122 -c "X509 - A fatal error occurred" 5123 5124requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA 5125requires_full_size_output_buffer 5126requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK 5127run_test "Authentication, CA callback: client max_int+1 chain, server optional" \ 5128 "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \ 5129 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \ 5130 key_file=data_files/dir-maxpath/10.key" \ 5131 1 \ 5132 -s "use CA callback for X.509 CRT verification" \ 5133 -s "X509 - A fatal error occurred" 5134 5135requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA 5136requires_full_size_output_buffer 5137requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK 5138run_test "Authentication, CA callback: client max_int+1 chain, server required" \ 5139 "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \ 5140 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \ 5141 key_file=data_files/dir-maxpath/10.key" \ 5142 1 \ 5143 -s "use CA callback for X.509 CRT verification" \ 5144 -s "X509 - A fatal error occurred" 5145 5146requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA 5147requires_full_size_output_buffer 5148requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK 5149run_test "Authentication, CA callback: client max_int chain, server required" \ 5150 "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \ 5151 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \ 5152 key_file=data_files/dir-maxpath/09.key" \ 5153 0 \ 5154 -s "use CA callback for X.509 CRT verification" \ 5155 -S "X509 - A fatal error occurred" 5156 5157# Tests for certificate selection based on SHA version 5158 5159run_test "Certificate hash: client TLS 1.2 -> SHA-2" \ 5160 "$P_SRV crt_file=data_files/server5.crt \ 5161 key_file=data_files/server5.key \ 5162 crt_file2=data_files/server5-sha1.crt \ 5163 key_file2=data_files/server5.key" \ 5164 "$P_CLI force_version=tls12" \ 5165 0 \ 5166 -c "signed using.*ECDSA with SHA256" \ 5167 -C "signed using.*ECDSA with SHA1" 5168 5169run_test "Certificate hash: client TLS 1.1 -> SHA-1" \ 5170 "$P_SRV crt_file=data_files/server5.crt \ 5171 key_file=data_files/server5.key \ 5172 crt_file2=data_files/server5-sha1.crt \ 5173 key_file2=data_files/server5.key" \ 5174 "$P_CLI force_version=tls1_1" \ 5175 0 \ 5176 -C "signed using.*ECDSA with SHA256" \ 5177 -c "signed using.*ECDSA with SHA1" 5178 5179run_test "Certificate hash: client TLS 1.0 -> SHA-1" \ 5180 "$P_SRV crt_file=data_files/server5.crt \ 5181 key_file=data_files/server5.key \ 5182 crt_file2=data_files/server5-sha1.crt \ 5183 key_file2=data_files/server5.key" \ 5184 "$P_CLI force_version=tls1" \ 5185 0 \ 5186 -C "signed using.*ECDSA with SHA256" \ 5187 -c "signed using.*ECDSA with SHA1" 5188 5189run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \ 5190 "$P_SRV crt_file=data_files/server5.crt \ 5191 key_file=data_files/server5.key \ 5192 crt_file2=data_files/server6.crt \ 5193 key_file2=data_files/server6.key" \ 5194 "$P_CLI force_version=tls1_1" \ 5195 0 \ 5196 -c "serial number.*09" \ 5197 -c "signed using.*ECDSA with SHA256" \ 5198 -C "signed using.*ECDSA with SHA1" 5199 5200run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \ 5201 "$P_SRV crt_file=data_files/server6.crt \ 5202 key_file=data_files/server6.key \ 5203 crt_file2=data_files/server5.crt \ 5204 key_file2=data_files/server5.key" \ 5205 "$P_CLI force_version=tls1_1" \ 5206 0 \ 5207 -c "serial number.*0A" \ 5208 -c "signed using.*ECDSA with SHA256" \ 5209 -C "signed using.*ECDSA with SHA1" 5210 5211# tests for SNI 5212 5213run_test "SNI: no SNI callback" \ 5214 "$P_SRV debug_level=3 \ 5215 crt_file=data_files/server5.crt key_file=data_files/server5.key" \ 5216 "$P_CLI server_name=localhost" \ 5217 0 \ 5218 -S "parse ServerName extension" \ 5219 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \ 5220 -c "subject name *: C=NL, O=PolarSSL, CN=localhost" 5221 5222run_test "SNI: matching cert 1" \ 5223 "$P_SRV debug_level=3 \ 5224 crt_file=data_files/server5.crt key_file=data_files/server5.key \ 5225 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \ 5226 "$P_CLI server_name=localhost" \ 5227 0 \ 5228 -s "parse ServerName extension" \ 5229 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \ 5230 -c "subject name *: C=NL, O=PolarSSL, CN=localhost" 5231 5232run_test "SNI: matching cert 2" \ 5233 "$P_SRV debug_level=3 \ 5234 crt_file=data_files/server5.crt key_file=data_files/server5.key \ 5235 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \ 5236 "$P_CLI server_name=polarssl.example" \ 5237 0 \ 5238 -s "parse ServerName extension" \ 5239 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \ 5240 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example" 5241 5242run_test "SNI: no matching cert" \ 5243 "$P_SRV debug_level=3 \ 5244 crt_file=data_files/server5.crt key_file=data_files/server5.key \ 5245 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \ 5246 "$P_CLI server_name=nonesuch.example" \ 5247 1 \ 5248 -s "parse ServerName extension" \ 5249 -s "ssl_sni_wrapper() returned" \ 5250 -s "mbedtls_ssl_handshake returned" \ 5251 -c "mbedtls_ssl_handshake returned" \ 5252 -c "SSL - A fatal alert message was received from our peer" 5253 5254run_test "SNI: client auth no override: optional" \ 5255 "$P_SRV debug_level=3 auth_mode=optional \ 5256 crt_file=data_files/server5.crt key_file=data_files/server5.key \ 5257 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \ 5258 "$P_CLI debug_level=3 server_name=localhost" \ 5259 0 \ 5260 -S "skip write certificate request" \ 5261 -C "skip parse certificate request" \ 5262 -c "got a certificate request" \ 5263 -C "skip write certificate" \ 5264 -C "skip write certificate verify" \ 5265 -S "skip parse certificate verify" 5266 5267run_test "SNI: client auth override: none -> optional" \ 5268 "$P_SRV debug_level=3 auth_mode=none \ 5269 crt_file=data_files/server5.crt key_file=data_files/server5.key \ 5270 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \ 5271 "$P_CLI debug_level=3 server_name=localhost" \ 5272 0 \ 5273 -S "skip write certificate request" \ 5274 -C "skip parse certificate request" \ 5275 -c "got a certificate request" \ 5276 -C "skip write certificate" \ 5277 -C "skip write certificate verify" \ 5278 -S "skip parse certificate verify" 5279 5280run_test "SNI: client auth override: optional -> none" \ 5281 "$P_SRV debug_level=3 auth_mode=optional \ 5282 crt_file=data_files/server5.crt key_file=data_files/server5.key \ 5283 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \ 5284 "$P_CLI debug_level=3 server_name=localhost" \ 5285 0 \ 5286 -s "skip write certificate request" \ 5287 -C "skip parse certificate request" \ 5288 -c "got no certificate request" \ 5289 -c "skip write certificate" \ 5290 -c "skip write certificate verify" \ 5291 -s "skip parse certificate verify" 5292 5293run_test "SNI: CA no override" \ 5294 "$P_SRV debug_level=3 auth_mode=optional \ 5295 crt_file=data_files/server5.crt key_file=data_files/server5.key \ 5296 ca_file=data_files/test-ca.crt \ 5297 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \ 5298 "$P_CLI debug_level=3 server_name=localhost \ 5299 crt_file=data_files/server6.crt key_file=data_files/server6.key" \ 5300 1 \ 5301 -S "skip write certificate request" \ 5302 -C "skip parse certificate request" \ 5303 -c "got a certificate request" \ 5304 -C "skip write certificate" \ 5305 -C "skip write certificate verify" \ 5306 -S "skip parse certificate verify" \ 5307 -s "x509_verify_cert() returned" \ 5308 -s "! The certificate is not correctly signed by the trusted CA" \ 5309 -S "The certificate has been revoked (is on a CRL)" 5310 5311run_test "SNI: CA override" \ 5312 "$P_SRV debug_level=3 auth_mode=optional \ 5313 crt_file=data_files/server5.crt key_file=data_files/server5.key \ 5314 ca_file=data_files/test-ca.crt \ 5315 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \ 5316 "$P_CLI debug_level=3 server_name=localhost \ 5317 crt_file=data_files/server6.crt key_file=data_files/server6.key" \ 5318 0 \ 5319 -S "skip write certificate request" \ 5320 -C "skip parse certificate request" \ 5321 -c "got a certificate request" \ 5322 -C "skip write certificate" \ 5323 -C "skip write certificate verify" \ 5324 -S "skip parse certificate verify" \ 5325 -S "x509_verify_cert() returned" \ 5326 -S "! The certificate is not correctly signed by the trusted CA" \ 5327 -S "The certificate has been revoked (is on a CRL)" 5328 5329run_test "SNI: CA override with CRL" \ 5330 "$P_SRV debug_level=3 auth_mode=optional \ 5331 crt_file=data_files/server5.crt key_file=data_files/server5.key \ 5332 ca_file=data_files/test-ca.crt \ 5333 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \ 5334 "$P_CLI debug_level=3 server_name=localhost \ 5335 crt_file=data_files/server6.crt key_file=data_files/server6.key" \ 5336 1 \ 5337 -S "skip write certificate request" \ 5338 -C "skip parse certificate request" \ 5339 -c "got a certificate request" \ 5340 -C "skip write certificate" \ 5341 -C "skip write certificate verify" \ 5342 -S "skip parse certificate verify" \ 5343 -s "x509_verify_cert() returned" \ 5344 -S "! The certificate is not correctly signed by the trusted CA" \ 5345 -s "The certificate has been revoked (is on a CRL)" 5346 5347# Tests for SNI and DTLS 5348 5349run_test "SNI: DTLS, no SNI callback" \ 5350 "$P_SRV debug_level=3 dtls=1 \ 5351 crt_file=data_files/server5.crt key_file=data_files/server5.key" \ 5352 "$P_CLI server_name=localhost dtls=1" \ 5353 0 \ 5354 -S "parse ServerName extension" \ 5355 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \ 5356 -c "subject name *: C=NL, O=PolarSSL, CN=localhost" 5357 5358run_test "SNI: DTLS, matching cert 1" \ 5359 "$P_SRV debug_level=3 dtls=1 \ 5360 crt_file=data_files/server5.crt key_file=data_files/server5.key \ 5361 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \ 5362 "$P_CLI server_name=localhost dtls=1" \ 5363 0 \ 5364 -s "parse ServerName extension" \ 5365 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \ 5366 -c "subject name *: C=NL, O=PolarSSL, CN=localhost" 5367 5368run_test "SNI: DTLS, matching cert 2" \ 5369 "$P_SRV debug_level=3 dtls=1 \ 5370 crt_file=data_files/server5.crt key_file=data_files/server5.key \ 5371 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \ 5372 "$P_CLI server_name=polarssl.example dtls=1" \ 5373 0 \ 5374 -s "parse ServerName extension" \ 5375 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \ 5376 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example" 5377 5378run_test "SNI: DTLS, no matching cert" \ 5379 "$P_SRV debug_level=3 dtls=1 \ 5380 crt_file=data_files/server5.crt key_file=data_files/server5.key \ 5381 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \ 5382 "$P_CLI server_name=nonesuch.example dtls=1" \ 5383 1 \ 5384 -s "parse ServerName extension" \ 5385 -s "ssl_sni_wrapper() returned" \ 5386 -s "mbedtls_ssl_handshake returned" \ 5387 -c "mbedtls_ssl_handshake returned" \ 5388 -c "SSL - A fatal alert message was received from our peer" 5389 5390run_test "SNI: DTLS, client auth no override: optional" \ 5391 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \ 5392 crt_file=data_files/server5.crt key_file=data_files/server5.key \ 5393 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \ 5394 "$P_CLI debug_level=3 server_name=localhost dtls=1" \ 5395 0 \ 5396 -S "skip write certificate request" \ 5397 -C "skip parse certificate request" \ 5398 -c "got a certificate request" \ 5399 -C "skip write certificate" \ 5400 -C "skip write certificate verify" \ 5401 -S "skip parse certificate verify" 5402 5403run_test "SNI: DTLS, client auth override: none -> optional" \ 5404 "$P_SRV debug_level=3 auth_mode=none dtls=1 \ 5405 crt_file=data_files/server5.crt key_file=data_files/server5.key \ 5406 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \ 5407 "$P_CLI debug_level=3 server_name=localhost dtls=1" \ 5408 0 \ 5409 -S "skip write certificate request" \ 5410 -C "skip parse certificate request" \ 5411 -c "got a certificate request" \ 5412 -C "skip write certificate" \ 5413 -C "skip write certificate verify" \ 5414 -S "skip parse certificate verify" 5415 5416run_test "SNI: DTLS, client auth override: optional -> none" \ 5417 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \ 5418 crt_file=data_files/server5.crt key_file=data_files/server5.key \ 5419 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \ 5420 "$P_CLI debug_level=3 server_name=localhost dtls=1" \ 5421 0 \ 5422 -s "skip write certificate request" \ 5423 -C "skip parse certificate request" \ 5424 -c "got no certificate request" \ 5425 -c "skip write certificate" \ 5426 -c "skip write certificate verify" \ 5427 -s "skip parse certificate verify" 5428 5429run_test "SNI: DTLS, CA no override" \ 5430 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \ 5431 crt_file=data_files/server5.crt key_file=data_files/server5.key \ 5432 ca_file=data_files/test-ca.crt \ 5433 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \ 5434 "$P_CLI debug_level=3 server_name=localhost dtls=1 \ 5435 crt_file=data_files/server6.crt key_file=data_files/server6.key" \ 5436 1 \ 5437 -S "skip write certificate request" \ 5438 -C "skip parse certificate request" \ 5439 -c "got a certificate request" \ 5440 -C "skip write certificate" \ 5441 -C "skip write certificate verify" \ 5442 -S "skip parse certificate verify" \ 5443 -s "x509_verify_cert() returned" \ 5444 -s "! The certificate is not correctly signed by the trusted CA" \ 5445 -S "The certificate has been revoked (is on a CRL)" 5446 5447run_test "SNI: DTLS, CA override" \ 5448 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \ 5449 crt_file=data_files/server5.crt key_file=data_files/server5.key \ 5450 ca_file=data_files/test-ca.crt \ 5451 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \ 5452 "$P_CLI debug_level=3 server_name=localhost dtls=1 \ 5453 crt_file=data_files/server6.crt key_file=data_files/server6.key" \ 5454 0 \ 5455 -S "skip write certificate request" \ 5456 -C "skip parse certificate request" \ 5457 -c "got a certificate request" \ 5458 -C "skip write certificate" \ 5459 -C "skip write certificate verify" \ 5460 -S "skip parse certificate verify" \ 5461 -S "x509_verify_cert() returned" \ 5462 -S "! The certificate is not correctly signed by the trusted CA" \ 5463 -S "The certificate has been revoked (is on a CRL)" 5464 5465run_test "SNI: DTLS, CA override with CRL" \ 5466 "$P_SRV debug_level=3 auth_mode=optional \ 5467 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \ 5468 ca_file=data_files/test-ca.crt \ 5469 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \ 5470 "$P_CLI debug_level=3 server_name=localhost dtls=1 \ 5471 crt_file=data_files/server6.crt key_file=data_files/server6.key" \ 5472 1 \ 5473 -S "skip write certificate request" \ 5474 -C "skip parse certificate request" \ 5475 -c "got a certificate request" \ 5476 -C "skip write certificate" \ 5477 -C "skip write certificate verify" \ 5478 -S "skip parse certificate verify" \ 5479 -s "x509_verify_cert() returned" \ 5480 -S "! The certificate is not correctly signed by the trusted CA" \ 5481 -s "The certificate has been revoked (is on a CRL)" 5482 5483# Tests for non-blocking I/O: exercise a variety of handshake flows 5484 5485run_test "Non-blocking I/O: basic handshake" \ 5486 "$P_SRV nbio=2 tickets=0 auth_mode=none" \ 5487 "$P_CLI nbio=2 tickets=0" \ 5488 0 \ 5489 -S "mbedtls_ssl_handshake returned" \ 5490 -C "mbedtls_ssl_handshake returned" \ 5491 -c "Read from server: .* bytes read" 5492 5493run_test "Non-blocking I/O: client auth" \ 5494 "$P_SRV nbio=2 tickets=0 auth_mode=required" \ 5495 "$P_CLI nbio=2 tickets=0" \ 5496 0 \ 5497 -S "mbedtls_ssl_handshake returned" \ 5498 -C "mbedtls_ssl_handshake returned" \ 5499 -c "Read from server: .* bytes read" 5500 5501run_test "Non-blocking I/O: ticket" \ 5502 "$P_SRV nbio=2 tickets=1 auth_mode=none" \ 5503 "$P_CLI nbio=2 tickets=1" \ 5504 0 \ 5505 -S "mbedtls_ssl_handshake returned" \ 5506 -C "mbedtls_ssl_handshake returned" \ 5507 -c "Read from server: .* bytes read" 5508 5509run_test "Non-blocking I/O: ticket + client auth" \ 5510 "$P_SRV nbio=2 tickets=1 auth_mode=required" \ 5511 "$P_CLI nbio=2 tickets=1" \ 5512 0 \ 5513 -S "mbedtls_ssl_handshake returned" \ 5514 -C "mbedtls_ssl_handshake returned" \ 5515 -c "Read from server: .* bytes read" 5516 5517run_test "Non-blocking I/O: ticket + client auth + resume" \ 5518 "$P_SRV nbio=2 tickets=1 auth_mode=required" \ 5519 "$P_CLI nbio=2 tickets=1 reconnect=1" \ 5520 0 \ 5521 -S "mbedtls_ssl_handshake returned" \ 5522 -C "mbedtls_ssl_handshake returned" \ 5523 -c "Read from server: .* bytes read" 5524 5525run_test "Non-blocking I/O: ticket + resume" \ 5526 "$P_SRV nbio=2 tickets=1 auth_mode=none" \ 5527 "$P_CLI nbio=2 tickets=1 reconnect=1" \ 5528 0 \ 5529 -S "mbedtls_ssl_handshake returned" \ 5530 -C "mbedtls_ssl_handshake returned" \ 5531 -c "Read from server: .* bytes read" 5532 5533run_test "Non-blocking I/O: session-id resume" \ 5534 "$P_SRV nbio=2 tickets=0 auth_mode=none" \ 5535 "$P_CLI nbio=2 tickets=0 reconnect=1" \ 5536 0 \ 5537 -S "mbedtls_ssl_handshake returned" \ 5538 -C "mbedtls_ssl_handshake returned" \ 5539 -c "Read from server: .* bytes read" 5540 5541# Tests for event-driven I/O: exercise a variety of handshake flows 5542 5543run_test "Event-driven I/O: basic handshake" \ 5544 "$P_SRV event=1 tickets=0 auth_mode=none" \ 5545 "$P_CLI event=1 tickets=0" \ 5546 0 \ 5547 -S "mbedtls_ssl_handshake returned" \ 5548 -C "mbedtls_ssl_handshake returned" \ 5549 -c "Read from server: .* bytes read" 5550 5551run_test "Event-driven I/O: client auth" \ 5552 "$P_SRV event=1 tickets=0 auth_mode=required" \ 5553 "$P_CLI event=1 tickets=0" \ 5554 0 \ 5555 -S "mbedtls_ssl_handshake returned" \ 5556 -C "mbedtls_ssl_handshake returned" \ 5557 -c "Read from server: .* bytes read" 5558 5559run_test "Event-driven I/O: ticket" \ 5560 "$P_SRV event=1 tickets=1 auth_mode=none" \ 5561 "$P_CLI event=1 tickets=1" \ 5562 0 \ 5563 -S "mbedtls_ssl_handshake returned" \ 5564 -C "mbedtls_ssl_handshake returned" \ 5565 -c "Read from server: .* bytes read" 5566 5567run_test "Event-driven I/O: ticket + client auth" \ 5568 "$P_SRV event=1 tickets=1 auth_mode=required" \ 5569 "$P_CLI event=1 tickets=1" \ 5570 0 \ 5571 -S "mbedtls_ssl_handshake returned" \ 5572 -C "mbedtls_ssl_handshake returned" \ 5573 -c "Read from server: .* bytes read" 5574 5575run_test "Event-driven I/O: ticket + client auth + resume" \ 5576 "$P_SRV event=1 tickets=1 auth_mode=required" \ 5577 "$P_CLI event=1 tickets=1 reconnect=1" \ 5578 0 \ 5579 -S "mbedtls_ssl_handshake returned" \ 5580 -C "mbedtls_ssl_handshake returned" \ 5581 -c "Read from server: .* bytes read" 5582 5583run_test "Event-driven I/O: ticket + resume" \ 5584 "$P_SRV event=1 tickets=1 auth_mode=none" \ 5585 "$P_CLI event=1 tickets=1 reconnect=1" \ 5586 0 \ 5587 -S "mbedtls_ssl_handshake returned" \ 5588 -C "mbedtls_ssl_handshake returned" \ 5589 -c "Read from server: .* bytes read" 5590 5591run_test "Event-driven I/O: session-id resume" \ 5592 "$P_SRV event=1 tickets=0 auth_mode=none" \ 5593 "$P_CLI event=1 tickets=0 reconnect=1" \ 5594 0 \ 5595 -S "mbedtls_ssl_handshake returned" \ 5596 -C "mbedtls_ssl_handshake returned" \ 5597 -c "Read from server: .* bytes read" 5598 5599run_test "Event-driven I/O, DTLS: basic handshake" \ 5600 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \ 5601 "$P_CLI dtls=1 event=1 tickets=0" \ 5602 0 \ 5603 -c "Read from server: .* bytes read" 5604 5605run_test "Event-driven I/O, DTLS: client auth" \ 5606 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \ 5607 "$P_CLI dtls=1 event=1 tickets=0" \ 5608 0 \ 5609 -c "Read from server: .* bytes read" 5610 5611run_test "Event-driven I/O, DTLS: ticket" \ 5612 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \ 5613 "$P_CLI dtls=1 event=1 tickets=1" \ 5614 0 \ 5615 -c "Read from server: .* bytes read" 5616 5617run_test "Event-driven I/O, DTLS: ticket + client auth" \ 5618 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \ 5619 "$P_CLI dtls=1 event=1 tickets=1" \ 5620 0 \ 5621 -c "Read from server: .* bytes read" 5622 5623run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \ 5624 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \ 5625 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \ 5626 0 \ 5627 -c "Read from server: .* bytes read" 5628 5629run_test "Event-driven I/O, DTLS: ticket + resume" \ 5630 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \ 5631 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \ 5632 0 \ 5633 -c "Read from server: .* bytes read" 5634 5635run_test "Event-driven I/O, DTLS: session-id resume" \ 5636 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \ 5637 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \ 5638 0 \ 5639 -c "Read from server: .* bytes read" 5640 5641# This test demonstrates the need for the mbedtls_ssl_check_pending function. 5642# During session resumption, the client will send its ApplicationData record 5643# within the same datagram as the Finished messages. In this situation, the 5644# server MUST NOT idle on the underlying transport after handshake completion, 5645# because the ApplicationData request has already been queued internally. 5646run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \ 5647 -p "$P_PXY pack=50" \ 5648 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \ 5649 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \ 5650 0 \ 5651 -c "Read from server: .* bytes read" 5652 5653# Tests for version negotiation 5654 5655requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2 5656run_test "Version check: all -> 1.2" \ 5657 "$P_SRV" \ 5658 "$P_CLI" \ 5659 0 \ 5660 -S "mbedtls_ssl_handshake returned" \ 5661 -C "mbedtls_ssl_handshake returned" \ 5662 -s "Protocol is TLSv1.2" \ 5663 -c "Protocol is TLSv1.2" 5664 5665requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1 5666run_test "Version check: cli max 1.1 -> 1.1" \ 5667 "$P_SRV" \ 5668 "$P_CLI max_version=tls1_1" \ 5669 0 \ 5670 -S "mbedtls_ssl_handshake returned" \ 5671 -C "mbedtls_ssl_handshake returned" \ 5672 -s "Protocol is TLSv1.1" \ 5673 -c "Protocol is TLSv1.1" 5674 5675requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1 5676run_test "Version check: srv max 1.1 -> 1.1" \ 5677 "$P_SRV max_version=tls1_1" \ 5678 "$P_CLI" \ 5679 0 \ 5680 -S "mbedtls_ssl_handshake returned" \ 5681 -C "mbedtls_ssl_handshake returned" \ 5682 -s "Protocol is TLSv1.1" \ 5683 -c "Protocol is TLSv1.1" 5684 5685requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1 5686run_test "Version check: cli+srv max 1.1 -> 1.1" \ 5687 "$P_SRV max_version=tls1_1" \ 5688 "$P_CLI max_version=tls1_1" \ 5689 0 \ 5690 -S "mbedtls_ssl_handshake returned" \ 5691 -C "mbedtls_ssl_handshake returned" \ 5692 -s "Protocol is TLSv1.1" \ 5693 -c "Protocol is TLSv1.1" 5694 5695requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1 5696run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \ 5697 "$P_SRV min_version=tls1_1" \ 5698 "$P_CLI max_version=tls1_1" \ 5699 0 \ 5700 -S "mbedtls_ssl_handshake returned" \ 5701 -C "mbedtls_ssl_handshake returned" \ 5702 -s "Protocol is TLSv1.1" \ 5703 -c "Protocol is TLSv1.1" 5704 5705requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1 5706run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \ 5707 "$P_SRV max_version=tls1_1" \ 5708 "$P_CLI min_version=tls1_1" \ 5709 0 \ 5710 -S "mbedtls_ssl_handshake returned" \ 5711 -C "mbedtls_ssl_handshake returned" \ 5712 -s "Protocol is TLSv1.1" \ 5713 -c "Protocol is TLSv1.1" 5714 5715requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1 5716requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2 5717run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \ 5718 "$P_SRV max_version=tls1_1" \ 5719 "$P_CLI min_version=tls12" \ 5720 1 \ 5721 -s "mbedtls_ssl_handshake returned" \ 5722 -c "mbedtls_ssl_handshake returned" \ 5723 -c "SSL - Handshake protocol not within min/max boundaries" 5724 5725requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1 5726requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2 5727run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \ 5728 "$P_SRV min_version=tls12" \ 5729 "$P_CLI max_version=tls1_1" \ 5730 1 \ 5731 -s "mbedtls_ssl_handshake returned" \ 5732 -c "mbedtls_ssl_handshake returned" \ 5733 -s "SSL - Handshake protocol not within min/max boundaries" 5734 5735# Tests for ALPN extension 5736 5737run_test "ALPN: none" \ 5738 "$P_SRV debug_level=3" \ 5739 "$P_CLI debug_level=3" \ 5740 0 \ 5741 -C "client hello, adding alpn extension" \ 5742 -S "found alpn extension" \ 5743 -C "got an alert message, type: \\[2:120]" \ 5744 -S "server hello, adding alpn extension" \ 5745 -C "found alpn extension " \ 5746 -C "Application Layer Protocol is" \ 5747 -S "Application Layer Protocol is" 5748 5749run_test "ALPN: client only" \ 5750 "$P_SRV debug_level=3" \ 5751 "$P_CLI debug_level=3 alpn=abc,1234" \ 5752 0 \ 5753 -c "client hello, adding alpn extension" \ 5754 -s "found alpn extension" \ 5755 -C "got an alert message, type: \\[2:120]" \ 5756 -S "server hello, adding alpn extension" \ 5757 -C "found alpn extension " \ 5758 -c "Application Layer Protocol is (none)" \ 5759 -S "Application Layer Protocol is" 5760 5761run_test "ALPN: server only" \ 5762 "$P_SRV debug_level=3 alpn=abc,1234" \ 5763 "$P_CLI debug_level=3" \ 5764 0 \ 5765 -C "client hello, adding alpn extension" \ 5766 -S "found alpn extension" \ 5767 -C "got an alert message, type: \\[2:120]" \ 5768 -S "server hello, adding alpn extension" \ 5769 -C "found alpn extension " \ 5770 -C "Application Layer Protocol is" \ 5771 -s "Application Layer Protocol is (none)" 5772 5773run_test "ALPN: both, common cli1-srv1" \ 5774 "$P_SRV debug_level=3 alpn=abc,1234" \ 5775 "$P_CLI debug_level=3 alpn=abc,1234" \ 5776 0 \ 5777 -c "client hello, adding alpn extension" \ 5778 -s "found alpn extension" \ 5779 -C "got an alert message, type: \\[2:120]" \ 5780 -s "server hello, adding alpn extension" \ 5781 -c "found alpn extension" \ 5782 -c "Application Layer Protocol is abc" \ 5783 -s "Application Layer Protocol is abc" 5784 5785run_test "ALPN: both, common cli2-srv1" \ 5786 "$P_SRV debug_level=3 alpn=abc,1234" \ 5787 "$P_CLI debug_level=3 alpn=1234,abc" \ 5788 0 \ 5789 -c "client hello, adding alpn extension" \ 5790 -s "found alpn extension" \ 5791 -C "got an alert message, type: \\[2:120]" \ 5792 -s "server hello, adding alpn extension" \ 5793 -c "found alpn extension" \ 5794 -c "Application Layer Protocol is abc" \ 5795 -s "Application Layer Protocol is abc" 5796 5797run_test "ALPN: both, common cli1-srv2" \ 5798 "$P_SRV debug_level=3 alpn=abc,1234" \ 5799 "$P_CLI debug_level=3 alpn=1234,abcde" \ 5800 0 \ 5801 -c "client hello, adding alpn extension" \ 5802 -s "found alpn extension" \ 5803 -C "got an alert message, type: \\[2:120]" \ 5804 -s "server hello, adding alpn extension" \ 5805 -c "found alpn extension" \ 5806 -c "Application Layer Protocol is 1234" \ 5807 -s "Application Layer Protocol is 1234" 5808 5809run_test "ALPN: both, no common" \ 5810 "$P_SRV debug_level=3 alpn=abc,123" \ 5811 "$P_CLI debug_level=3 alpn=1234,abcde" \ 5812 1 \ 5813 -c "client hello, adding alpn extension" \ 5814 -s "found alpn extension" \ 5815 -c "got an alert message, type: \\[2:120]" \ 5816 -S "server hello, adding alpn extension" \ 5817 -C "found alpn extension" \ 5818 -C "Application Layer Protocol is 1234" \ 5819 -S "Application Layer Protocol is 1234" 5820 5821 5822# Tests for keyUsage in leaf certificates, part 1: 5823# server-side certificate/suite selection 5824 5825run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \ 5826 "$P_SRV key_file=data_files/server2.key \ 5827 crt_file=data_files/server2.ku-ds.crt" \ 5828 "$P_CLI" \ 5829 0 \ 5830 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-" 5831 5832 5833run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \ 5834 "$P_SRV key_file=data_files/server2.key \ 5835 crt_file=data_files/server2.ku-ke.crt" \ 5836 "$P_CLI" \ 5837 0 \ 5838 -c "Ciphersuite is TLS-RSA-WITH-" 5839 5840run_test "keyUsage srv: RSA, keyAgreement -> fail" \ 5841 "$P_SRV key_file=data_files/server2.key \ 5842 crt_file=data_files/server2.ku-ka.crt" \ 5843 "$P_CLI" \ 5844 1 \ 5845 -C "Ciphersuite is " 5846 5847run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \ 5848 "$P_SRV key_file=data_files/server5.key \ 5849 crt_file=data_files/server5.ku-ds.crt" \ 5850 "$P_CLI" \ 5851 0 \ 5852 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-" 5853 5854 5855run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \ 5856 "$P_SRV key_file=data_files/server5.key \ 5857 crt_file=data_files/server5.ku-ka.crt" \ 5858 "$P_CLI" \ 5859 0 \ 5860 -c "Ciphersuite is TLS-ECDH-" 5861 5862run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \ 5863 "$P_SRV key_file=data_files/server5.key \ 5864 crt_file=data_files/server5.ku-ke.crt" \ 5865 "$P_CLI" \ 5866 1 \ 5867 -C "Ciphersuite is " 5868 5869# Tests for keyUsage in leaf certificates, part 2: 5870# client-side checking of server cert 5871 5872run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \ 5873 "$O_SRV -key data_files/server2.key \ 5874 -cert data_files/server2.ku-ds_ke.crt" \ 5875 "$P_CLI debug_level=1 \ 5876 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ 5877 0 \ 5878 -C "bad certificate (usage extensions)" \ 5879 -C "Processing of the Certificate handshake message failed" \ 5880 -c "Ciphersuite is TLS-" 5881 5882run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \ 5883 "$O_SRV -key data_files/server2.key \ 5884 -cert data_files/server2.ku-ds_ke.crt" \ 5885 "$P_CLI debug_level=1 \ 5886 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \ 5887 0 \ 5888 -C "bad certificate (usage extensions)" \ 5889 -C "Processing of the Certificate handshake message failed" \ 5890 -c "Ciphersuite is TLS-" 5891 5892run_test "keyUsage cli: KeyEncipherment, RSA: OK" \ 5893 "$O_SRV -key data_files/server2.key \ 5894 -cert data_files/server2.ku-ke.crt" \ 5895 "$P_CLI debug_level=1 \ 5896 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ 5897 0 \ 5898 -C "bad certificate (usage extensions)" \ 5899 -C "Processing of the Certificate handshake message failed" \ 5900 -c "Ciphersuite is TLS-" 5901 5902run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \ 5903 "$O_SRV -key data_files/server2.key \ 5904 -cert data_files/server2.ku-ke.crt" \ 5905 "$P_CLI debug_level=1 \ 5906 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \ 5907 1 \ 5908 -c "bad certificate (usage extensions)" \ 5909 -c "Processing of the Certificate handshake message failed" \ 5910 -C "Ciphersuite is TLS-" 5911 5912run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \ 5913 "$O_SRV -key data_files/server2.key \ 5914 -cert data_files/server2.ku-ke.crt" \ 5915 "$P_CLI debug_level=1 auth_mode=optional \ 5916 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \ 5917 0 \ 5918 -c "bad certificate (usage extensions)" \ 5919 -C "Processing of the Certificate handshake message failed" \ 5920 -c "Ciphersuite is TLS-" \ 5921 -c "! Usage does not match the keyUsage extension" 5922 5923run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \ 5924 "$O_SRV -key data_files/server2.key \ 5925 -cert data_files/server2.ku-ds.crt" \ 5926 "$P_CLI debug_level=1 \ 5927 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \ 5928 0 \ 5929 -C "bad certificate (usage extensions)" \ 5930 -C "Processing of the Certificate handshake message failed" \ 5931 -c "Ciphersuite is TLS-" 5932 5933run_test "keyUsage cli: DigitalSignature, RSA: fail" \ 5934 "$O_SRV -key data_files/server2.key \ 5935 -cert data_files/server2.ku-ds.crt" \ 5936 "$P_CLI debug_level=1 \ 5937 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ 5938 1 \ 5939 -c "bad certificate (usage extensions)" \ 5940 -c "Processing of the Certificate handshake message failed" \ 5941 -C "Ciphersuite is TLS-" 5942 5943run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \ 5944 "$O_SRV -key data_files/server2.key \ 5945 -cert data_files/server2.ku-ds.crt" \ 5946 "$P_CLI debug_level=1 auth_mode=optional \ 5947 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ 5948 0 \ 5949 -c "bad certificate (usage extensions)" \ 5950 -C "Processing of the Certificate handshake message failed" \ 5951 -c "Ciphersuite is TLS-" \ 5952 -c "! Usage does not match the keyUsage extension" 5953 5954# Tests for keyUsage in leaf certificates, part 3: 5955# server-side checking of client cert 5956 5957run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \ 5958 "$P_SRV debug_level=1 auth_mode=optional" \ 5959 "$O_CLI -key data_files/server2.key \ 5960 -cert data_files/server2.ku-ds.crt" \ 5961 0 \ 5962 -S "bad certificate (usage extensions)" \ 5963 -S "Processing of the Certificate handshake message failed" 5964 5965run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \ 5966 "$P_SRV debug_level=1 auth_mode=optional" \ 5967 "$O_CLI -key data_files/server2.key \ 5968 -cert data_files/server2.ku-ke.crt" \ 5969 0 \ 5970 -s "bad certificate (usage extensions)" \ 5971 -S "Processing of the Certificate handshake message failed" 5972 5973run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \ 5974 "$P_SRV debug_level=1 auth_mode=required" \ 5975 "$O_CLI -key data_files/server2.key \ 5976 -cert data_files/server2.ku-ke.crt" \ 5977 1 \ 5978 -s "bad certificate (usage extensions)" \ 5979 -s "Processing of the Certificate handshake message failed" 5980 5981run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \ 5982 "$P_SRV debug_level=1 auth_mode=optional" \ 5983 "$O_CLI -key data_files/server5.key \ 5984 -cert data_files/server5.ku-ds.crt" \ 5985 0 \ 5986 -S "bad certificate (usage extensions)" \ 5987 -S "Processing of the Certificate handshake message failed" 5988 5989run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \ 5990 "$P_SRV debug_level=1 auth_mode=optional" \ 5991 "$O_CLI -key data_files/server5.key \ 5992 -cert data_files/server5.ku-ka.crt" \ 5993 0 \ 5994 -s "bad certificate (usage extensions)" \ 5995 -S "Processing of the Certificate handshake message failed" 5996 5997# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection 5998 5999run_test "extKeyUsage srv: serverAuth -> OK" \ 6000 "$P_SRV key_file=data_files/server5.key \ 6001 crt_file=data_files/server5.eku-srv.crt" \ 6002 "$P_CLI" \ 6003 0 6004 6005run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \ 6006 "$P_SRV key_file=data_files/server5.key \ 6007 crt_file=data_files/server5.eku-srv.crt" \ 6008 "$P_CLI" \ 6009 0 6010 6011run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \ 6012 "$P_SRV key_file=data_files/server5.key \ 6013 crt_file=data_files/server5.eku-cs_any.crt" \ 6014 "$P_CLI" \ 6015 0 6016 6017run_test "extKeyUsage srv: codeSign -> fail" \ 6018 "$P_SRV key_file=data_files/server5.key \ 6019 crt_file=data_files/server5.eku-cli.crt" \ 6020 "$P_CLI" \ 6021 1 6022 6023# Tests for extendedKeyUsage, part 2: client-side checking of server cert 6024 6025run_test "extKeyUsage cli: serverAuth -> OK" \ 6026 "$O_SRV -key data_files/server5.key \ 6027 -cert data_files/server5.eku-srv.crt" \ 6028 "$P_CLI debug_level=1" \ 6029 0 \ 6030 -C "bad certificate (usage extensions)" \ 6031 -C "Processing of the Certificate handshake message failed" \ 6032 -c "Ciphersuite is TLS-" 6033 6034run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \ 6035 "$O_SRV -key data_files/server5.key \ 6036 -cert data_files/server5.eku-srv_cli.crt" \ 6037 "$P_CLI debug_level=1" \ 6038 0 \ 6039 -C "bad certificate (usage extensions)" \ 6040 -C "Processing of the Certificate handshake message failed" \ 6041 -c "Ciphersuite is TLS-" 6042 6043run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \ 6044 "$O_SRV -key data_files/server5.key \ 6045 -cert data_files/server5.eku-cs_any.crt" \ 6046 "$P_CLI debug_level=1" \ 6047 0 \ 6048 -C "bad certificate (usage extensions)" \ 6049 -C "Processing of the Certificate handshake message failed" \ 6050 -c "Ciphersuite is TLS-" 6051 6052run_test "extKeyUsage cli: codeSign -> fail" \ 6053 "$O_SRV -key data_files/server5.key \ 6054 -cert data_files/server5.eku-cs.crt" \ 6055 "$P_CLI debug_level=1" \ 6056 1 \ 6057 -c "bad certificate (usage extensions)" \ 6058 -c "Processing of the Certificate handshake message failed" \ 6059 -C "Ciphersuite is TLS-" 6060 6061# Tests for extendedKeyUsage, part 3: server-side checking of client cert 6062 6063run_test "extKeyUsage cli-auth: clientAuth -> OK" \ 6064 "$P_SRV debug_level=1 auth_mode=optional" \ 6065 "$O_CLI -key data_files/server5.key \ 6066 -cert data_files/server5.eku-cli.crt" \ 6067 0 \ 6068 -S "bad certificate (usage extensions)" \ 6069 -S "Processing of the Certificate handshake message failed" 6070 6071run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \ 6072 "$P_SRV debug_level=1 auth_mode=optional" \ 6073 "$O_CLI -key data_files/server5.key \ 6074 -cert data_files/server5.eku-srv_cli.crt" \ 6075 0 \ 6076 -S "bad certificate (usage extensions)" \ 6077 -S "Processing of the Certificate handshake message failed" 6078 6079run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \ 6080 "$P_SRV debug_level=1 auth_mode=optional" \ 6081 "$O_CLI -key data_files/server5.key \ 6082 -cert data_files/server5.eku-cs_any.crt" \ 6083 0 \ 6084 -S "bad certificate (usage extensions)" \ 6085 -S "Processing of the Certificate handshake message failed" 6086 6087run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \ 6088 "$P_SRV debug_level=1 auth_mode=optional" \ 6089 "$O_CLI -key data_files/server5.key \ 6090 -cert data_files/server5.eku-cs.crt" \ 6091 0 \ 6092 -s "bad certificate (usage extensions)" \ 6093 -S "Processing of the Certificate handshake message failed" 6094 6095run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \ 6096 "$P_SRV debug_level=1 auth_mode=required" \ 6097 "$O_CLI -key data_files/server5.key \ 6098 -cert data_files/server5.eku-cs.crt" \ 6099 1 \ 6100 -s "bad certificate (usage extensions)" \ 6101 -s "Processing of the Certificate handshake message failed" 6102 6103# Tests for DHM parameters loading 6104 6105run_test "DHM parameters: reference" \ 6106 "$P_SRV" \ 6107 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \ 6108 debug_level=3" \ 6109 0 \ 6110 -c "value of 'DHM: P ' (2048 bits)" \ 6111 -c "value of 'DHM: G ' (2 bits)" 6112 6113run_test "DHM parameters: other parameters" \ 6114 "$P_SRV dhm_file=data_files/dhparams.pem" \ 6115 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \ 6116 debug_level=3" \ 6117 0 \ 6118 -c "value of 'DHM: P ' (1024 bits)" \ 6119 -c "value of 'DHM: G ' (2 bits)" 6120 6121# Tests for DHM client-side size checking 6122 6123run_test "DHM size: server default, client default, OK" \ 6124 "$P_SRV" \ 6125 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \ 6126 debug_level=1" \ 6127 0 \ 6128 -C "DHM prime too short:" 6129 6130run_test "DHM size: server default, client 2048, OK" \ 6131 "$P_SRV" \ 6132 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \ 6133 debug_level=1 dhmlen=2048" \ 6134 0 \ 6135 -C "DHM prime too short:" 6136 6137run_test "DHM size: server 1024, client default, OK" \ 6138 "$P_SRV dhm_file=data_files/dhparams.pem" \ 6139 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \ 6140 debug_level=1" \ 6141 0 \ 6142 -C "DHM prime too short:" 6143 6144run_test "DHM size: server 999, client 999, OK" \ 6145 "$P_SRV dhm_file=data_files/dh.999.pem" \ 6146 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \ 6147 debug_level=1 dhmlen=999" \ 6148 0 \ 6149 -C "DHM prime too short:" 6150 6151run_test "DHM size: server 1000, client 1000, OK" \ 6152 "$P_SRV dhm_file=data_files/dh.1000.pem" \ 6153 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \ 6154 debug_level=1 dhmlen=1000" \ 6155 0 \ 6156 -C "DHM prime too short:" 6157 6158run_test "DHM size: server 1000, client default, rejected" \ 6159 "$P_SRV dhm_file=data_files/dh.1000.pem" \ 6160 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \ 6161 debug_level=1" \ 6162 1 \ 6163 -c "DHM prime too short:" 6164 6165run_test "DHM size: server 1000, client 1001, rejected" \ 6166 "$P_SRV dhm_file=data_files/dh.1000.pem" \ 6167 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \ 6168 debug_level=1 dhmlen=1001" \ 6169 1 \ 6170 -c "DHM prime too short:" 6171 6172run_test "DHM size: server 999, client 1000, rejected" \ 6173 "$P_SRV dhm_file=data_files/dh.999.pem" \ 6174 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \ 6175 debug_level=1 dhmlen=1000" \ 6176 1 \ 6177 -c "DHM prime too short:" 6178 6179run_test "DHM size: server 998, client 999, rejected" \ 6180 "$P_SRV dhm_file=data_files/dh.998.pem" \ 6181 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \ 6182 debug_level=1 dhmlen=999" \ 6183 1 \ 6184 -c "DHM prime too short:" 6185 6186run_test "DHM size: server default, client 2049, rejected" \ 6187 "$P_SRV" \ 6188 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \ 6189 debug_level=1 dhmlen=2049" \ 6190 1 \ 6191 -c "DHM prime too short:" 6192 6193# Tests for PSK callback 6194 6195run_test "PSK callback: psk, no callback" \ 6196 "$P_SRV psk=abc123 psk_identity=foo" \ 6197 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \ 6198 psk_identity=foo psk=abc123" \ 6199 0 \ 6200 -S "SSL - None of the common ciphersuites is usable" \ 6201 -S "SSL - Unknown identity received" \ 6202 -S "SSL - Verification of the message MAC failed" 6203 6204requires_config_enabled MBEDTLS_USE_PSA_CRYPTO 6205run_test "PSK callback: opaque psk on client, no callback" \ 6206 "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo" \ 6207 "$P_CLI extended_ms=0 debug_level=1 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \ 6208 psk_identity=foo psk=abc123 psk_opaque=1" \ 6209 0 \ 6210 -c "skip PMS generation for opaque PSK"\ 6211 -S "skip PMS generation for opaque PSK"\ 6212 -C "session hash for extended master secret"\ 6213 -S "session hash for extended master secret"\ 6214 -S "SSL - None of the common ciphersuites is usable" \ 6215 -S "SSL - Unknown identity received" \ 6216 -S "SSL - Verification of the message MAC failed" 6217 6218requires_config_enabled MBEDTLS_USE_PSA_CRYPTO 6219run_test "PSK callback: opaque psk on client, no callback, SHA-384" \ 6220 "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo" \ 6221 "$P_CLI extended_ms=0 debug_level=1 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \ 6222 psk_identity=foo psk=abc123 psk_opaque=1" \ 6223 0 \ 6224 -c "skip PMS generation for opaque PSK"\ 6225 -S "skip PMS generation for opaque PSK"\ 6226 -C "session hash for extended master secret"\ 6227 -S "session hash for extended master secret"\ 6228 -S "SSL - None of the common ciphersuites is usable" \ 6229 -S "SSL - Unknown identity received" \ 6230 -S "SSL - Verification of the message MAC failed" 6231 6232requires_config_enabled MBEDTLS_USE_PSA_CRYPTO 6233run_test "PSK callback: opaque psk on client, no callback, EMS" \ 6234 "$P_SRV extended_ms=1 debug_level=3 psk=abc123 psk_identity=foo" \ 6235 "$P_CLI extended_ms=1 debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \ 6236 psk_identity=foo psk=abc123 psk_opaque=1" \ 6237 0 \ 6238 -c "skip PMS generation for opaque PSK"\ 6239 -S "skip PMS generation for opaque PSK"\ 6240 -c "session hash for extended master secret"\ 6241 -s "session hash for extended master secret"\ 6242 -S "SSL - None of the common ciphersuites is usable" \ 6243 -S "SSL - Unknown identity received" \ 6244 -S "SSL - Verification of the message MAC failed" 6245 6246requires_config_enabled MBEDTLS_USE_PSA_CRYPTO 6247run_test "PSK callback: opaque psk on client, no callback, SHA-384, EMS" \ 6248 "$P_SRV extended_ms=1 debug_level=3 psk=abc123 psk_identity=foo" \ 6249 "$P_CLI extended_ms=1 debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \ 6250 psk_identity=foo psk=abc123 psk_opaque=1" \ 6251 0 \ 6252 -c "skip PMS generation for opaque PSK"\ 6253 -S "skip PMS generation for opaque PSK"\ 6254 -c "session hash for extended master secret"\ 6255 -s "session hash for extended master secret"\ 6256 -S "SSL - None of the common ciphersuites is usable" \ 6257 -S "SSL - Unknown identity received" \ 6258 -S "SSL - Verification of the message MAC failed" 6259 6260requires_config_enabled MBEDTLS_USE_PSA_CRYPTO 6261run_test "PSK callback: raw psk on client, static opaque on server, no callback" \ 6262 "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \ 6263 "$P_CLI extended_ms=0 debug_level=1 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \ 6264 psk_identity=foo psk=abc123" \ 6265 0 \ 6266 -C "skip PMS generation for opaque PSK"\ 6267 -s "skip PMS generation for opaque PSK"\ 6268 -C "session hash for extended master secret"\ 6269 -S "session hash for extended master secret"\ 6270 -S "SSL - None of the common ciphersuites is usable" \ 6271 -S "SSL - Unknown identity received" \ 6272 -S "SSL - Verification of the message MAC failed" 6273 6274requires_config_enabled MBEDTLS_USE_PSA_CRYPTO 6275run_test "PSK callback: raw psk on client, static opaque on server, no callback, SHA-384" \ 6276 "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384" \ 6277 "$P_CLI extended_ms=0 debug_level=1 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \ 6278 psk_identity=foo psk=abc123" \ 6279 0 \ 6280 -C "skip PMS generation for opaque PSK"\ 6281 -s "skip PMS generation for opaque PSK"\ 6282 -C "session hash for extended master secret"\ 6283 -S "session hash for extended master secret"\ 6284 -S "SSL - None of the common ciphersuites is usable" \ 6285 -S "SSL - Unknown identity received" \ 6286 -S "SSL - Verification of the message MAC failed" 6287 6288requires_config_enabled MBEDTLS_USE_PSA_CRYPTO 6289run_test "PSK callback: raw psk on client, static opaque on server, no callback, EMS" \ 6290 "$P_SRV debug_level=3 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls12 \ 6291 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA extended_ms=1" \ 6292 "$P_CLI debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \ 6293 psk_identity=foo psk=abc123 extended_ms=1" \ 6294 0 \ 6295 -c "session hash for extended master secret"\ 6296 -s "session hash for extended master secret"\ 6297 -C "skip PMS generation for opaque PSK"\ 6298 -s "skip PMS generation for opaque PSK"\ 6299 -S "SSL - None of the common ciphersuites is usable" \ 6300 -S "SSL - Unknown identity received" \ 6301 -S "SSL - Verification of the message MAC failed" 6302 6303requires_config_enabled MBEDTLS_USE_PSA_CRYPTO 6304run_test "PSK callback: raw psk on client, static opaque on server, no callback, EMS, SHA384" \ 6305 "$P_SRV debug_level=3 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls12 \ 6306 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 extended_ms=1" \ 6307 "$P_CLI debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \ 6308 psk_identity=foo psk=abc123 extended_ms=1" \ 6309 0 \ 6310 -c "session hash for extended master secret"\ 6311 -s "session hash for extended master secret"\ 6312 -C "skip PMS generation for opaque PSK"\ 6313 -s "skip PMS generation for opaque PSK"\ 6314 -S "SSL - None of the common ciphersuites is usable" \ 6315 -S "SSL - Unknown identity received" \ 6316 -S "SSL - Verification of the message MAC failed" 6317 6318requires_config_enabled MBEDTLS_USE_PSA_CRYPTO 6319run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback" \ 6320 "$P_SRV extended_ms=0 debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \ 6321 "$P_CLI extended_ms=0 debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \ 6322 psk_identity=def psk=beef" \ 6323 0 \ 6324 -C "skip PMS generation for opaque PSK"\ 6325 -s "skip PMS generation for opaque PSK"\ 6326 -C "session hash for extended master secret"\ 6327 -S "session hash for extended master secret"\ 6328 -S "SSL - None of the common ciphersuites is usable" \ 6329 -S "SSL - Unknown identity received" \ 6330 -S "SSL - Verification of the message MAC failed" 6331 6332requires_config_enabled MBEDTLS_USE_PSA_CRYPTO 6333run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback, SHA-384" \ 6334 "$P_SRV extended_ms=0 debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384" \ 6335 "$P_CLI extended_ms=0 debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \ 6336 psk_identity=def psk=beef" \ 6337 0 \ 6338 -C "skip PMS generation for opaque PSK"\ 6339 -s "skip PMS generation for opaque PSK"\ 6340 -C "session hash for extended master secret"\ 6341 -S "session hash for extended master secret"\ 6342 -S "SSL - None of the common ciphersuites is usable" \ 6343 -S "SSL - Unknown identity received" \ 6344 -S "SSL - Verification of the message MAC failed" 6345 6346requires_config_enabled MBEDTLS_USE_PSA_CRYPTO 6347run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback, EMS" \ 6348 "$P_SRV debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls12 \ 6349 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA extended_ms=1" \ 6350 "$P_CLI debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \ 6351 psk_identity=abc psk=dead extended_ms=1" \ 6352 0 \ 6353 -c "session hash for extended master secret"\ 6354 -s "session hash for extended master secret"\ 6355 -C "skip PMS generation for opaque PSK"\ 6356 -s "skip PMS generation for opaque PSK"\ 6357 -S "SSL - None of the common ciphersuites is usable" \ 6358 -S "SSL - Unknown identity received" \ 6359 -S "SSL - Verification of the message MAC failed" 6360 6361requires_config_enabled MBEDTLS_USE_PSA_CRYPTO 6362run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback, EMS, SHA384" \ 6363 "$P_SRV debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls12 \ 6364 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 extended_ms=1" \ 6365 "$P_CLI debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \ 6366 psk_identity=abc psk=dead extended_ms=1" \ 6367 0 \ 6368 -c "session hash for extended master secret"\ 6369 -s "session hash for extended master secret"\ 6370 -C "skip PMS generation for opaque PSK"\ 6371 -s "skip PMS generation for opaque PSK"\ 6372 -S "SSL - None of the common ciphersuites is usable" \ 6373 -S "SSL - Unknown identity received" \ 6374 -S "SSL - Verification of the message MAC failed" 6375 6376requires_config_enabled MBEDTLS_USE_PSA_CRYPTO 6377run_test "PSK callback: raw psk on client, mismatching static raw PSK on server, opaque PSK from callback" \ 6378 "$P_SRV extended_ms=0 psk_identity=foo psk=abc123 debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \ 6379 "$P_CLI extended_ms=0 debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \ 6380 psk_identity=def psk=beef" \ 6381 0 \ 6382 -C "skip PMS generation for opaque PSK"\ 6383 -s "skip PMS generation for opaque PSK"\ 6384 -C "session hash for extended master secret"\ 6385 -S "session hash for extended master secret"\ 6386 -S "SSL - None of the common ciphersuites is usable" \ 6387 -S "SSL - Unknown identity received" \ 6388 -S "SSL - Verification of the message MAC failed" 6389 6390requires_config_enabled MBEDTLS_USE_PSA_CRYPTO 6391run_test "PSK callback: raw psk on client, mismatching static opaque PSK on server, opaque PSK from callback" \ 6392 "$P_SRV extended_ms=0 psk_opaque=1 psk_identity=foo psk=abc123 debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \ 6393 "$P_CLI extended_ms=0 debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \ 6394 psk_identity=def psk=beef" \ 6395 0 \ 6396 -C "skip PMS generation for opaque PSK"\ 6397 -s "skip PMS generation for opaque PSK"\ 6398 -C "session hash for extended master secret"\ 6399 -S "session hash for extended master secret"\ 6400 -S "SSL - None of the common ciphersuites is usable" \ 6401 -S "SSL - Unknown identity received" \ 6402 -S "SSL - Verification of the message MAC failed" 6403 6404requires_config_enabled MBEDTLS_USE_PSA_CRYPTO 6405run_test "PSK callback: raw psk on client, mismatching static opaque PSK on server, raw PSK from callback" \ 6406 "$P_SRV extended_ms=0 psk_opaque=1 psk_identity=foo psk=abc123 debug_level=3 psk_list=abc,dead,def,beef min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \ 6407 "$P_CLI extended_ms=0 debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \ 6408 psk_identity=def psk=beef" \ 6409 0 \ 6410 -C "skip PMS generation for opaque PSK"\ 6411 -C "session hash for extended master secret"\ 6412 -S "session hash for extended master secret"\ 6413 -S "SSL - None of the common ciphersuites is usable" \ 6414 -S "SSL - Unknown identity received" \ 6415 -S "SSL - Verification of the message MAC failed" 6416 6417requires_config_enabled MBEDTLS_USE_PSA_CRYPTO 6418run_test "PSK callback: raw psk on client, id-matching but wrong raw PSK on server, opaque PSK from callback" \ 6419 "$P_SRV extended_ms=0 psk_opaque=1 psk_identity=def psk=abc123 debug_level=3 psk_list=abc,dead,def,beef min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \ 6420 "$P_CLI extended_ms=0 debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \ 6421 psk_identity=def psk=beef" \ 6422 0 \ 6423 -C "skip PMS generation for opaque PSK"\ 6424 -C "session hash for extended master secret"\ 6425 -S "session hash for extended master secret"\ 6426 -S "SSL - None of the common ciphersuites is usable" \ 6427 -S "SSL - Unknown identity received" \ 6428 -S "SSL - Verification of the message MAC failed" 6429 6430requires_config_enabled MBEDTLS_USE_PSA_CRYPTO 6431run_test "PSK callback: raw psk on client, matching opaque PSK on server, wrong opaque PSK from callback" \ 6432 "$P_SRV extended_ms=0 psk_opaque=1 psk_identity=def psk=beef debug_level=3 psk_list=abc,dead,def,abc123 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \ 6433 "$P_CLI extended_ms=0 debug_level=3 min_version=tls12 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \ 6434 psk_identity=def psk=beef" \ 6435 1 \ 6436 -s "SSL - Verification of the message MAC failed" 6437 6438run_test "PSK callback: no psk, no callback" \ 6439 "$P_SRV" \ 6440 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \ 6441 psk_identity=foo psk=abc123" \ 6442 1 \ 6443 -s "SSL - None of the common ciphersuites is usable" \ 6444 -S "SSL - Unknown identity received" \ 6445 -S "SSL - Verification of the message MAC failed" 6446 6447run_test "PSK callback: callback overrides other settings" \ 6448 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \ 6449 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \ 6450 psk_identity=foo psk=abc123" \ 6451 1 \ 6452 -S "SSL - None of the common ciphersuites is usable" \ 6453 -s "SSL - Unknown identity received" \ 6454 -S "SSL - Verification of the message MAC failed" 6455 6456run_test "PSK callback: first id matches" \ 6457 "$P_SRV psk_list=abc,dead,def,beef" \ 6458 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \ 6459 psk_identity=abc psk=dead" \ 6460 0 \ 6461 -S "SSL - None of the common ciphersuites is usable" \ 6462 -S "SSL - Unknown identity received" \ 6463 -S "SSL - Verification of the message MAC failed" 6464 6465run_test "PSK callback: second id matches" \ 6466 "$P_SRV psk_list=abc,dead,def,beef" \ 6467 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \ 6468 psk_identity=def psk=beef" \ 6469 0 \ 6470 -S "SSL - None of the common ciphersuites is usable" \ 6471 -S "SSL - Unknown identity received" \ 6472 -S "SSL - Verification of the message MAC failed" 6473 6474run_test "PSK callback: no match" \ 6475 "$P_SRV psk_list=abc,dead,def,beef" \ 6476 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \ 6477 psk_identity=ghi psk=beef" \ 6478 1 \ 6479 -S "SSL - None of the common ciphersuites is usable" \ 6480 -s "SSL - Unknown identity received" \ 6481 -S "SSL - Verification of the message MAC failed" 6482 6483run_test "PSK callback: wrong key" \ 6484 "$P_SRV psk_list=abc,dead,def,beef" \ 6485 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \ 6486 psk_identity=abc psk=beef" \ 6487 1 \ 6488 -S "SSL - None of the common ciphersuites is usable" \ 6489 -S "SSL - Unknown identity received" \ 6490 -s "SSL - Verification of the message MAC failed" 6491 6492# Tests for EC J-PAKE 6493 6494requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED 6495run_test "ECJPAKE: client not configured" \ 6496 "$P_SRV debug_level=3" \ 6497 "$P_CLI debug_level=3" \ 6498 0 \ 6499 -C "add ciphersuite: 0xc0ff" \ 6500 -C "adding ecjpake_kkpp extension" \ 6501 -S "found ecjpake kkpp extension" \ 6502 -S "skip ecjpake kkpp extension" \ 6503 -S "ciphersuite mismatch: ecjpake not configured" \ 6504 -S "server hello, ecjpake kkpp extension" \ 6505 -C "found ecjpake_kkpp extension" \ 6506 -S "None of the common ciphersuites is usable" 6507 6508requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED 6509run_test "ECJPAKE: server not configured" \ 6510 "$P_SRV debug_level=3" \ 6511 "$P_CLI debug_level=3 ecjpake_pw=bla \ 6512 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \ 6513 1 \ 6514 -c "add ciphersuite: 0xc0ff" \ 6515 -c "adding ecjpake_kkpp extension" \ 6516 -s "found ecjpake kkpp extension" \ 6517 -s "skip ecjpake kkpp extension" \ 6518 -s "ciphersuite mismatch: ecjpake not configured" \ 6519 -S "server hello, ecjpake kkpp extension" \ 6520 -C "found ecjpake_kkpp extension" \ 6521 -s "None of the common ciphersuites is usable" 6522 6523requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED 6524run_test "ECJPAKE: working, TLS" \ 6525 "$P_SRV debug_level=3 ecjpake_pw=bla" \ 6526 "$P_CLI debug_level=3 ecjpake_pw=bla \ 6527 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \ 6528 0 \ 6529 -c "add ciphersuite: 0xc0ff" \ 6530 -c "adding ecjpake_kkpp extension" \ 6531 -C "re-using cached ecjpake parameters" \ 6532 -s "found ecjpake kkpp extension" \ 6533 -S "skip ecjpake kkpp extension" \ 6534 -S "ciphersuite mismatch: ecjpake not configured" \ 6535 -s "server hello, ecjpake kkpp extension" \ 6536 -c "found ecjpake_kkpp extension" \ 6537 -S "None of the common ciphersuites is usable" \ 6538 -S "SSL - Verification of the message MAC failed" 6539 6540server_needs_more_time 1 6541requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED 6542run_test "ECJPAKE: password mismatch, TLS" \ 6543 "$P_SRV debug_level=3 ecjpake_pw=bla" \ 6544 "$P_CLI debug_level=3 ecjpake_pw=bad \ 6545 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \ 6546 1 \ 6547 -C "re-using cached ecjpake parameters" \ 6548 -s "SSL - Verification of the message MAC failed" 6549 6550requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED 6551run_test "ECJPAKE: working, DTLS" \ 6552 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \ 6553 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \ 6554 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \ 6555 0 \ 6556 -c "re-using cached ecjpake parameters" \ 6557 -S "SSL - Verification of the message MAC failed" 6558 6559requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED 6560run_test "ECJPAKE: working, DTLS, no cookie" \ 6561 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \ 6562 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \ 6563 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \ 6564 0 \ 6565 -C "re-using cached ecjpake parameters" \ 6566 -S "SSL - Verification of the message MAC failed" 6567 6568server_needs_more_time 1 6569requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED 6570run_test "ECJPAKE: password mismatch, DTLS" \ 6571 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \ 6572 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \ 6573 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \ 6574 1 \ 6575 -c "re-using cached ecjpake parameters" \ 6576 -s "SSL - Verification of the message MAC failed" 6577 6578# for tests with configs/config-thread.h 6579requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED 6580run_test "ECJPAKE: working, DTLS, nolog" \ 6581 "$P_SRV dtls=1 ecjpake_pw=bla" \ 6582 "$P_CLI dtls=1 ecjpake_pw=bla \ 6583 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \ 6584 0 6585 6586# Tests for ciphersuites per version 6587 6588requires_config_enabled MBEDTLS_CAMELLIA_C 6589requires_config_enabled MBEDTLS_AES_C 6590run_test "Per-version suites: SSL3" \ 6591 "$P_SRV min_version=ssl3 version_suites=TLS-RSA-WITH-CAMELLIA-128-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \ 6592 "$P_CLI force_version=ssl3" \ 6593 0 \ 6594 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA" 6595 6596requires_config_enabled MBEDTLS_CAMELLIA_C 6597requires_config_enabled MBEDTLS_AES_C 6598run_test "Per-version suites: TLS 1.0" \ 6599 "$P_SRV version_suites=TLS-RSA-WITH-CAMELLIA-128-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \ 6600 "$P_CLI force_version=tls1 arc4=1" \ 6601 0 \ 6602 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA" 6603 6604requires_config_enabled MBEDTLS_CAMELLIA_C 6605requires_config_enabled MBEDTLS_AES_C 6606run_test "Per-version suites: TLS 1.1" \ 6607 "$P_SRV version_suites=TLS-RSA-WITH-CAMELLIA-128-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \ 6608 "$P_CLI force_version=tls1_1" \ 6609 0 \ 6610 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA" 6611 6612requires_config_enabled MBEDTLS_CAMELLIA_C 6613requires_config_enabled MBEDTLS_AES_C 6614requires_config_enabled MBEDTLS_GCM_C 6615run_test "Per-version suites: TLS 1.2" \ 6616 "$P_SRV version_suites=TLS-RSA-WITH-CAMELLIA-128-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \ 6617 "$P_CLI force_version=tls12" \ 6618 0 \ 6619 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256" 6620 6621# Test for ClientHello without extensions 6622 6623requires_gnutls 6624run_test "ClientHello without extensions" \ 6625 "$P_SRV debug_level=3" \ 6626 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \ 6627 0 \ 6628 -s "dumping 'client hello extensions' (0 bytes)" 6629 6630# Tests for mbedtls_ssl_get_bytes_avail() 6631 6632# The server first reads buffer_size-1 bytes, then reads the remainder. 6633run_test "mbedtls_ssl_get_bytes_avail: no extra data" \ 6634 "$P_SRV buffer_size=100" \ 6635 "$P_CLI request_size=100" \ 6636 0 \ 6637 -s "Read from client: 100 bytes read$" 6638 6639run_test "mbedtls_ssl_get_bytes_avail: extra data (+1)" \ 6640 "$P_SRV buffer_size=100" \ 6641 "$P_CLI request_size=101" \ 6642 0 \ 6643 -s "Read from client: 101 bytes read (100 + 1)" 6644 6645requires_max_content_len 200 6646run_test "mbedtls_ssl_get_bytes_avail: extra data (*2)" \ 6647 "$P_SRV buffer_size=100" \ 6648 "$P_CLI request_size=200" \ 6649 0 \ 6650 -s "Read from client: 200 bytes read (100 + 100)" 6651 6652run_test "mbedtls_ssl_get_bytes_avail: extra data (max)" \ 6653 "$P_SRV buffer_size=100" \ 6654 "$P_CLI request_size=$MAX_CONTENT_LEN" \ 6655 0 \ 6656 -s "Read from client: $MAX_CONTENT_LEN bytes read (100 + $((MAX_CONTENT_LEN - 100)))" 6657 6658# Tests for small client packets 6659 6660run_test "Small client packet SSLv3 BlockCipher" \ 6661 "$P_SRV min_version=ssl3" \ 6662 "$P_CLI request_size=1 force_version=ssl3 \ 6663 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 6664 0 \ 6665 -s "Read from client: 1 bytes read" 6666 6667run_test "Small client packet SSLv3 StreamCipher" \ 6668 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 6669 "$P_CLI request_size=1 force_version=ssl3 \ 6670 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 6671 0 \ 6672 -s "Read from client: 1 bytes read" 6673 6674run_test "Small client packet TLS 1.0 BlockCipher" \ 6675 "$P_SRV" \ 6676 "$P_CLI request_size=1 force_version=tls1 \ 6677 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 6678 0 \ 6679 -s "Read from client: 1 bytes read" 6680 6681run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \ 6682 "$P_SRV" \ 6683 "$P_CLI request_size=1 force_version=tls1 etm=0 \ 6684 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 6685 0 \ 6686 -s "Read from client: 1 bytes read" 6687 6688requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 6689run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \ 6690 "$P_SRV trunc_hmac=1" \ 6691 "$P_CLI request_size=1 force_version=tls1 \ 6692 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \ 6693 0 \ 6694 -s "Read from client: 1 bytes read" 6695 6696requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 6697run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \ 6698 "$P_SRV trunc_hmac=1" \ 6699 "$P_CLI request_size=1 force_version=tls1 \ 6700 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \ 6701 0 \ 6702 -s "Read from client: 1 bytes read" 6703 6704run_test "Small client packet TLS 1.0 StreamCipher" \ 6705 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 6706 "$P_CLI request_size=1 force_version=tls1 \ 6707 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 6708 0 \ 6709 -s "Read from client: 1 bytes read" 6710 6711run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \ 6712 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 6713 "$P_CLI request_size=1 force_version=tls1 \ 6714 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \ 6715 0 \ 6716 -s "Read from client: 1 bytes read" 6717 6718requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 6719run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \ 6720 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 6721 "$P_CLI request_size=1 force_version=tls1 \ 6722 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 6723 0 \ 6724 -s "Read from client: 1 bytes read" 6725 6726requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 6727run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \ 6728 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 6729 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \ 6730 trunc_hmac=1 etm=0" \ 6731 0 \ 6732 -s "Read from client: 1 bytes read" 6733 6734run_test "Small client packet TLS 1.1 BlockCipher" \ 6735 "$P_SRV" \ 6736 "$P_CLI request_size=1 force_version=tls1_1 \ 6737 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 6738 0 \ 6739 -s "Read from client: 1 bytes read" 6740 6741run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \ 6742 "$P_SRV" \ 6743 "$P_CLI request_size=1 force_version=tls1_1 \ 6744 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \ 6745 0 \ 6746 -s "Read from client: 1 bytes read" 6747 6748requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 6749run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \ 6750 "$P_SRV trunc_hmac=1" \ 6751 "$P_CLI request_size=1 force_version=tls1_1 \ 6752 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \ 6753 0 \ 6754 -s "Read from client: 1 bytes read" 6755 6756requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 6757run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \ 6758 "$P_SRV trunc_hmac=1" \ 6759 "$P_CLI request_size=1 force_version=tls1_1 \ 6760 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \ 6761 0 \ 6762 -s "Read from client: 1 bytes read" 6763 6764run_test "Small client packet TLS 1.1 StreamCipher" \ 6765 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 6766 "$P_CLI request_size=1 force_version=tls1_1 \ 6767 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 6768 0 \ 6769 -s "Read from client: 1 bytes read" 6770 6771run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \ 6772 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 6773 "$P_CLI request_size=1 force_version=tls1_1 \ 6774 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \ 6775 0 \ 6776 -s "Read from client: 1 bytes read" 6777 6778requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 6779run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \ 6780 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 6781 "$P_CLI request_size=1 force_version=tls1_1 \ 6782 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 6783 0 \ 6784 -s "Read from client: 1 bytes read" 6785 6786requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 6787run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \ 6788 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 6789 "$P_CLI request_size=1 force_version=tls1_1 \ 6790 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \ 6791 0 \ 6792 -s "Read from client: 1 bytes read" 6793 6794run_test "Small client packet TLS 1.2 BlockCipher" \ 6795 "$P_SRV" \ 6796 "$P_CLI request_size=1 force_version=tls12 \ 6797 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 6798 0 \ 6799 -s "Read from client: 1 bytes read" 6800 6801run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \ 6802 "$P_SRV" \ 6803 "$P_CLI request_size=1 force_version=tls12 \ 6804 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \ 6805 0 \ 6806 -s "Read from client: 1 bytes read" 6807 6808run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \ 6809 "$P_SRV" \ 6810 "$P_CLI request_size=1 force_version=tls12 \ 6811 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \ 6812 0 \ 6813 -s "Read from client: 1 bytes read" 6814 6815requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 6816run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \ 6817 "$P_SRV trunc_hmac=1" \ 6818 "$P_CLI request_size=1 force_version=tls12 \ 6819 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \ 6820 0 \ 6821 -s "Read from client: 1 bytes read" 6822 6823requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 6824run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \ 6825 "$P_SRV trunc_hmac=1" \ 6826 "$P_CLI request_size=1 force_version=tls12 \ 6827 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \ 6828 0 \ 6829 -s "Read from client: 1 bytes read" 6830 6831run_test "Small client packet TLS 1.2 StreamCipher" \ 6832 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 6833 "$P_CLI request_size=1 force_version=tls12 \ 6834 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 6835 0 \ 6836 -s "Read from client: 1 bytes read" 6837 6838run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \ 6839 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 6840 "$P_CLI request_size=1 force_version=tls12 \ 6841 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \ 6842 0 \ 6843 -s "Read from client: 1 bytes read" 6844 6845requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 6846run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \ 6847 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 6848 "$P_CLI request_size=1 force_version=tls12 \ 6849 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 6850 0 \ 6851 -s "Read from client: 1 bytes read" 6852 6853requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 6854run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \ 6855 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 6856 "$P_CLI request_size=1 force_version=tls12 \ 6857 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \ 6858 0 \ 6859 -s "Read from client: 1 bytes read" 6860 6861run_test "Small client packet TLS 1.2 AEAD" \ 6862 "$P_SRV" \ 6863 "$P_CLI request_size=1 force_version=tls12 \ 6864 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \ 6865 0 \ 6866 -s "Read from client: 1 bytes read" 6867 6868run_test "Small client packet TLS 1.2 AEAD shorter tag" \ 6869 "$P_SRV" \ 6870 "$P_CLI request_size=1 force_version=tls12 \ 6871 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \ 6872 0 \ 6873 -s "Read from client: 1 bytes read" 6874 6875# Tests for small client packets in DTLS 6876 6877requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 6878run_test "Small client packet DTLS 1.0" \ 6879 "$P_SRV dtls=1 force_version=dtls1" \ 6880 "$P_CLI dtls=1 request_size=1 \ 6881 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 6882 0 \ 6883 -s "Read from client: 1 bytes read" 6884 6885requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 6886run_test "Small client packet DTLS 1.0, without EtM" \ 6887 "$P_SRV dtls=1 force_version=dtls1 etm=0" \ 6888 "$P_CLI dtls=1 request_size=1 \ 6889 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 6890 0 \ 6891 -s "Read from client: 1 bytes read" 6892 6893requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 6894requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 6895run_test "Small client packet DTLS 1.0, truncated hmac" \ 6896 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \ 6897 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \ 6898 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 6899 0 \ 6900 -s "Read from client: 1 bytes read" 6901 6902requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 6903requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 6904run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \ 6905 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \ 6906 "$P_CLI dtls=1 request_size=1 \ 6907 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\ 6908 0 \ 6909 -s "Read from client: 1 bytes read" 6910 6911requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 6912run_test "Small client packet DTLS 1.2" \ 6913 "$P_SRV dtls=1 force_version=dtls12" \ 6914 "$P_CLI dtls=1 request_size=1 \ 6915 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 6916 0 \ 6917 -s "Read from client: 1 bytes read" 6918 6919requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 6920run_test "Small client packet DTLS 1.2, without EtM" \ 6921 "$P_SRV dtls=1 force_version=dtls12 etm=0" \ 6922 "$P_CLI dtls=1 request_size=1 \ 6923 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 6924 0 \ 6925 -s "Read from client: 1 bytes read" 6926 6927requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 6928requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 6929run_test "Small client packet DTLS 1.2, truncated hmac" \ 6930 "$P_SRV dtls=1 force_version=dtls12 trunc_hmac=1" \ 6931 "$P_CLI dtls=1 request_size=1 \ 6932 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \ 6933 0 \ 6934 -s "Read from client: 1 bytes read" 6935 6936requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 6937requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 6938run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \ 6939 "$P_SRV dtls=1 force_version=dtls12 trunc_hmac=1 etm=0" \ 6940 "$P_CLI dtls=1 request_size=1 \ 6941 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\ 6942 0 \ 6943 -s "Read from client: 1 bytes read" 6944 6945# Tests for small server packets 6946 6947run_test "Small server packet SSLv3 BlockCipher" \ 6948 "$P_SRV response_size=1 min_version=ssl3" \ 6949 "$P_CLI force_version=ssl3 \ 6950 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 6951 0 \ 6952 -c "Read from server: 1 bytes read" 6953 6954run_test "Small server packet SSLv3 StreamCipher" \ 6955 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 6956 "$P_CLI force_version=ssl3 \ 6957 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 6958 0 \ 6959 -c "Read from server: 1 bytes read" 6960 6961run_test "Small server packet TLS 1.0 BlockCipher" \ 6962 "$P_SRV response_size=1" \ 6963 "$P_CLI force_version=tls1 \ 6964 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 6965 0 \ 6966 -c "Read from server: 1 bytes read" 6967 6968run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \ 6969 "$P_SRV response_size=1" \ 6970 "$P_CLI force_version=tls1 etm=0 \ 6971 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 6972 0 \ 6973 -c "Read from server: 1 bytes read" 6974 6975requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 6976run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \ 6977 "$P_SRV response_size=1 trunc_hmac=1" \ 6978 "$P_CLI force_version=tls1 \ 6979 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \ 6980 0 \ 6981 -c "Read from server: 1 bytes read" 6982 6983requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 6984run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \ 6985 "$P_SRV response_size=1 trunc_hmac=1" \ 6986 "$P_CLI force_version=tls1 \ 6987 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \ 6988 0 \ 6989 -c "Read from server: 1 bytes read" 6990 6991run_test "Small server packet TLS 1.0 StreamCipher" \ 6992 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 6993 "$P_CLI force_version=tls1 \ 6994 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 6995 0 \ 6996 -c "Read from server: 1 bytes read" 6997 6998run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \ 6999 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 7000 "$P_CLI force_version=tls1 \ 7001 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \ 7002 0 \ 7003 -c "Read from server: 1 bytes read" 7004 7005requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7006run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \ 7007 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 7008 "$P_CLI force_version=tls1 \ 7009 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 7010 0 \ 7011 -c "Read from server: 1 bytes read" 7012 7013requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7014run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \ 7015 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 7016 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \ 7017 trunc_hmac=1 etm=0" \ 7018 0 \ 7019 -c "Read from server: 1 bytes read" 7020 7021run_test "Small server packet TLS 1.1 BlockCipher" \ 7022 "$P_SRV response_size=1" \ 7023 "$P_CLI force_version=tls1_1 \ 7024 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 7025 0 \ 7026 -c "Read from server: 1 bytes read" 7027 7028run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \ 7029 "$P_SRV response_size=1" \ 7030 "$P_CLI force_version=tls1_1 \ 7031 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \ 7032 0 \ 7033 -c "Read from server: 1 bytes read" 7034 7035requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7036run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \ 7037 "$P_SRV response_size=1 trunc_hmac=1" \ 7038 "$P_CLI force_version=tls1_1 \ 7039 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \ 7040 0 \ 7041 -c "Read from server: 1 bytes read" 7042 7043requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7044run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \ 7045 "$P_SRV response_size=1 trunc_hmac=1" \ 7046 "$P_CLI force_version=tls1_1 \ 7047 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \ 7048 0 \ 7049 -c "Read from server: 1 bytes read" 7050 7051run_test "Small server packet TLS 1.1 StreamCipher" \ 7052 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 7053 "$P_CLI force_version=tls1_1 \ 7054 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 7055 0 \ 7056 -c "Read from server: 1 bytes read" 7057 7058run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \ 7059 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 7060 "$P_CLI force_version=tls1_1 \ 7061 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \ 7062 0 \ 7063 -c "Read from server: 1 bytes read" 7064 7065requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7066run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \ 7067 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 7068 "$P_CLI force_version=tls1_1 \ 7069 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 7070 0 \ 7071 -c "Read from server: 1 bytes read" 7072 7073requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7074run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \ 7075 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 7076 "$P_CLI force_version=tls1_1 \ 7077 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \ 7078 0 \ 7079 -c "Read from server: 1 bytes read" 7080 7081run_test "Small server packet TLS 1.2 BlockCipher" \ 7082 "$P_SRV response_size=1" \ 7083 "$P_CLI force_version=tls12 \ 7084 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 7085 0 \ 7086 -c "Read from server: 1 bytes read" 7087 7088run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \ 7089 "$P_SRV response_size=1" \ 7090 "$P_CLI force_version=tls12 \ 7091 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \ 7092 0 \ 7093 -c "Read from server: 1 bytes read" 7094 7095run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \ 7096 "$P_SRV response_size=1" \ 7097 "$P_CLI force_version=tls12 \ 7098 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \ 7099 0 \ 7100 -c "Read from server: 1 bytes read" 7101 7102requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7103run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \ 7104 "$P_SRV response_size=1 trunc_hmac=1" \ 7105 "$P_CLI force_version=tls12 \ 7106 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \ 7107 0 \ 7108 -c "Read from server: 1 bytes read" 7109 7110requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7111run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \ 7112 "$P_SRV response_size=1 trunc_hmac=1" \ 7113 "$P_CLI force_version=tls12 \ 7114 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \ 7115 0 \ 7116 -c "Read from server: 1 bytes read" 7117 7118run_test "Small server packet TLS 1.2 StreamCipher" \ 7119 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 7120 "$P_CLI force_version=tls12 \ 7121 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 7122 0 \ 7123 -c "Read from server: 1 bytes read" 7124 7125run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \ 7126 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 7127 "$P_CLI force_version=tls12 \ 7128 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \ 7129 0 \ 7130 -c "Read from server: 1 bytes read" 7131 7132requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7133run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \ 7134 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 7135 "$P_CLI force_version=tls12 \ 7136 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 7137 0 \ 7138 -c "Read from server: 1 bytes read" 7139 7140requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7141run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \ 7142 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 7143 "$P_CLI force_version=tls12 \ 7144 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \ 7145 0 \ 7146 -c "Read from server: 1 bytes read" 7147 7148run_test "Small server packet TLS 1.2 AEAD" \ 7149 "$P_SRV response_size=1" \ 7150 "$P_CLI force_version=tls12 \ 7151 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \ 7152 0 \ 7153 -c "Read from server: 1 bytes read" 7154 7155run_test "Small server packet TLS 1.2 AEAD shorter tag" \ 7156 "$P_SRV response_size=1" \ 7157 "$P_CLI force_version=tls12 \ 7158 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \ 7159 0 \ 7160 -c "Read from server: 1 bytes read" 7161 7162# Tests for small server packets in DTLS 7163 7164requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 7165run_test "Small server packet DTLS 1.0" \ 7166 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \ 7167 "$P_CLI dtls=1 \ 7168 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 7169 0 \ 7170 -c "Read from server: 1 bytes read" 7171 7172requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 7173run_test "Small server packet DTLS 1.0, without EtM" \ 7174 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \ 7175 "$P_CLI dtls=1 \ 7176 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 7177 0 \ 7178 -c "Read from server: 1 bytes read" 7179 7180requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 7181requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7182run_test "Small server packet DTLS 1.0, truncated hmac" \ 7183 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \ 7184 "$P_CLI dtls=1 trunc_hmac=1 \ 7185 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 7186 0 \ 7187 -c "Read from server: 1 bytes read" 7188 7189requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 7190requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7191run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \ 7192 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \ 7193 "$P_CLI dtls=1 \ 7194 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\ 7195 0 \ 7196 -c "Read from server: 1 bytes read" 7197 7198requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 7199run_test "Small server packet DTLS 1.2" \ 7200 "$P_SRV dtls=1 response_size=1 force_version=dtls12" \ 7201 "$P_CLI dtls=1 \ 7202 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 7203 0 \ 7204 -c "Read from server: 1 bytes read" 7205 7206requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 7207run_test "Small server packet DTLS 1.2, without EtM" \ 7208 "$P_SRV dtls=1 response_size=1 force_version=dtls12 etm=0" \ 7209 "$P_CLI dtls=1 \ 7210 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 7211 0 \ 7212 -c "Read from server: 1 bytes read" 7213 7214requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 7215requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7216run_test "Small server packet DTLS 1.2, truncated hmac" \ 7217 "$P_SRV dtls=1 response_size=1 force_version=dtls12 trunc_hmac=1" \ 7218 "$P_CLI dtls=1 \ 7219 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \ 7220 0 \ 7221 -c "Read from server: 1 bytes read" 7222 7223requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 7224requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7225run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \ 7226 "$P_SRV dtls=1 response_size=1 force_version=dtls12 trunc_hmac=1 etm=0" \ 7227 "$P_CLI dtls=1 \ 7228 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\ 7229 0 \ 7230 -c "Read from server: 1 bytes read" 7231 7232# A test for extensions in SSLv3 7233requires_max_content_len 4096 7234run_test "SSLv3 with extensions, server side" \ 7235 "$P_SRV min_version=ssl3 debug_level=3" \ 7236 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \ 7237 0 \ 7238 -S "dumping 'client hello extensions'" \ 7239 -S "server hello, total extension length:" 7240 7241# Test for large client packets 7242 7243# How many fragments do we expect to write $1 bytes? 7244fragments_for_write() { 7245 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))" 7246} 7247 7248run_test "Large client packet SSLv3 BlockCipher" \ 7249 "$P_SRV min_version=ssl3" \ 7250 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \ 7251 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 7252 0 \ 7253 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \ 7254 -s "Read from client: $MAX_CONTENT_LEN bytes read" 7255 7256run_test "Large client packet SSLv3 StreamCipher" \ 7257 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 7258 "$P_CLI request_size=16384 force_version=ssl3 \ 7259 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 7260 0 \ 7261 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \ 7262 -s "Read from client: $MAX_CONTENT_LEN bytes read" 7263 7264run_test "Large client packet TLS 1.0 BlockCipher" \ 7265 "$P_SRV" \ 7266 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \ 7267 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 7268 0 \ 7269 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \ 7270 -s "Read from client: $MAX_CONTENT_LEN bytes read" 7271 7272run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \ 7273 "$P_SRV" \ 7274 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \ 7275 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 7276 0 \ 7277 -s "Read from client: $MAX_CONTENT_LEN bytes read" 7278 7279requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7280run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \ 7281 "$P_SRV trunc_hmac=1" \ 7282 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \ 7283 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \ 7284 0 \ 7285 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \ 7286 -s "Read from client: $MAX_CONTENT_LEN bytes read" 7287 7288requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7289run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \ 7290 "$P_SRV trunc_hmac=1" \ 7291 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \ 7292 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \ 7293 0 \ 7294 -s "Read from client: $MAX_CONTENT_LEN bytes read" 7295 7296run_test "Large client packet TLS 1.0 StreamCipher" \ 7297 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 7298 "$P_CLI request_size=16384 force_version=tls1 \ 7299 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 7300 0 \ 7301 -s "Read from client: $MAX_CONTENT_LEN bytes read" 7302 7303run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \ 7304 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 7305 "$P_CLI request_size=16384 force_version=tls1 \ 7306 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \ 7307 0 \ 7308 -s "Read from client: $MAX_CONTENT_LEN bytes read" 7309 7310requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7311run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \ 7312 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 7313 "$P_CLI request_size=16384 force_version=tls1 \ 7314 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 7315 0 \ 7316 -s "Read from client: $MAX_CONTENT_LEN bytes read" 7317 7318requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7319run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \ 7320 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 7321 "$P_CLI request_size=16384 force_version=tls1 \ 7322 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \ 7323 0 \ 7324 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \ 7325 -s "Read from client: $MAX_CONTENT_LEN bytes read" 7326 7327run_test "Large client packet TLS 1.1 BlockCipher" \ 7328 "$P_SRV" \ 7329 "$P_CLI request_size=16384 force_version=tls1_1 \ 7330 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 7331 0 \ 7332 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \ 7333 -s "Read from client: $MAX_CONTENT_LEN bytes read" 7334 7335run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \ 7336 "$P_SRV" \ 7337 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \ 7338 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 7339 0 \ 7340 -s "Read from client: $MAX_CONTENT_LEN bytes read" 7341 7342requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7343run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \ 7344 "$P_SRV trunc_hmac=1" \ 7345 "$P_CLI request_size=16384 force_version=tls1_1 \ 7346 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \ 7347 0 \ 7348 -s "Read from client: $MAX_CONTENT_LEN bytes read" 7349 7350requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7351run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \ 7352 "$P_SRV trunc_hmac=1" \ 7353 "$P_CLI request_size=16384 force_version=tls1_1 \ 7354 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \ 7355 0 \ 7356 -s "Read from client: $MAX_CONTENT_LEN bytes read" 7357 7358run_test "Large client packet TLS 1.1 StreamCipher" \ 7359 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 7360 "$P_CLI request_size=16384 force_version=tls1_1 \ 7361 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 7362 0 \ 7363 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \ 7364 -s "Read from client: $MAX_CONTENT_LEN bytes read" 7365 7366run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \ 7367 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 7368 "$P_CLI request_size=16384 force_version=tls1_1 \ 7369 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \ 7370 0 \ 7371 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \ 7372 -s "Read from client: $MAX_CONTENT_LEN bytes read" 7373 7374requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7375run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \ 7376 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 7377 "$P_CLI request_size=16384 force_version=tls1_1 \ 7378 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 7379 0 \ 7380 -s "Read from client: $MAX_CONTENT_LEN bytes read" 7381 7382requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7383run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \ 7384 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 7385 "$P_CLI request_size=16384 force_version=tls1_1 \ 7386 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \ 7387 0 \ 7388 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \ 7389 -s "Read from client: $MAX_CONTENT_LEN bytes read" 7390 7391run_test "Large client packet TLS 1.2 BlockCipher" \ 7392 "$P_SRV" \ 7393 "$P_CLI request_size=16384 force_version=tls12 \ 7394 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 7395 0 \ 7396 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \ 7397 -s "Read from client: $MAX_CONTENT_LEN bytes read" 7398 7399run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \ 7400 "$P_SRV" \ 7401 "$P_CLI request_size=16384 force_version=tls12 etm=0 \ 7402 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 7403 0 \ 7404 -s "Read from client: $MAX_CONTENT_LEN bytes read" 7405 7406run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \ 7407 "$P_SRV" \ 7408 "$P_CLI request_size=16384 force_version=tls12 \ 7409 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \ 7410 0 \ 7411 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \ 7412 -s "Read from client: $MAX_CONTENT_LEN bytes read" 7413 7414requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7415run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \ 7416 "$P_SRV trunc_hmac=1" \ 7417 "$P_CLI request_size=16384 force_version=tls12 \ 7418 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \ 7419 0 \ 7420 -s "Read from client: $MAX_CONTENT_LEN bytes read" 7421 7422requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7423run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \ 7424 "$P_SRV trunc_hmac=1" \ 7425 "$P_CLI request_size=16384 force_version=tls12 \ 7426 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \ 7427 0 \ 7428 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \ 7429 -s "Read from client: $MAX_CONTENT_LEN bytes read" 7430 7431run_test "Large client packet TLS 1.2 StreamCipher" \ 7432 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 7433 "$P_CLI request_size=16384 force_version=tls12 \ 7434 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 7435 0 \ 7436 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \ 7437 -s "Read from client: $MAX_CONTENT_LEN bytes read" 7438 7439run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \ 7440 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 7441 "$P_CLI request_size=16384 force_version=tls12 \ 7442 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \ 7443 0 \ 7444 -s "Read from client: $MAX_CONTENT_LEN bytes read" 7445 7446requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7447run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \ 7448 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 7449 "$P_CLI request_size=16384 force_version=tls12 \ 7450 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 7451 0 \ 7452 -s "Read from client: $MAX_CONTENT_LEN bytes read" 7453 7454requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7455run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \ 7456 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 7457 "$P_CLI request_size=16384 force_version=tls12 \ 7458 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \ 7459 0 \ 7460 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \ 7461 -s "Read from client: $MAX_CONTENT_LEN bytes read" 7462 7463run_test "Large client packet TLS 1.2 AEAD" \ 7464 "$P_SRV" \ 7465 "$P_CLI request_size=16384 force_version=tls12 \ 7466 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \ 7467 0 \ 7468 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \ 7469 -s "Read from client: $MAX_CONTENT_LEN bytes read" 7470 7471run_test "Large client packet TLS 1.2 AEAD shorter tag" \ 7472 "$P_SRV" \ 7473 "$P_CLI request_size=16384 force_version=tls12 \ 7474 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \ 7475 0 \ 7476 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \ 7477 -s "Read from client: $MAX_CONTENT_LEN bytes read" 7478 7479# Test for large server packets 7480# The tests below fail when the server's OUT_CONTENT_LEN is less than 16384. 7481run_test "Large server packet SSLv3 StreamCipher" \ 7482 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 7483 "$P_CLI force_version=ssl3 \ 7484 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 7485 0 \ 7486 -c "Read from server: 16384 bytes read" 7487 7488# Checking next 4 tests logs for 1n-1 split against BEAST too 7489run_test "Large server packet SSLv3 BlockCipher" \ 7490 "$P_SRV response_size=16384 min_version=ssl3" \ 7491 "$P_CLI force_version=ssl3 recsplit=0 \ 7492 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 7493 0 \ 7494 -c "Read from server: 1 bytes read"\ 7495 -c "16383 bytes read"\ 7496 -C "Read from server: 16384 bytes read" 7497 7498run_test "Large server packet TLS 1.0 BlockCipher" \ 7499 "$P_SRV response_size=16384" \ 7500 "$P_CLI force_version=tls1 recsplit=0 \ 7501 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 7502 0 \ 7503 -c "Read from server: 1 bytes read"\ 7504 -c "16383 bytes read"\ 7505 -C "Read from server: 16384 bytes read" 7506 7507run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \ 7508 "$P_SRV response_size=16384" \ 7509 "$P_CLI force_version=tls1 etm=0 recsplit=0 \ 7510 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 7511 0 \ 7512 -c "Read from server: 1 bytes read"\ 7513 -c "16383 bytes read"\ 7514 -C "Read from server: 16384 bytes read" 7515 7516requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7517run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \ 7518 "$P_SRV response_size=16384" \ 7519 "$P_CLI force_version=tls1 recsplit=0 \ 7520 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \ 7521 trunc_hmac=1" \ 7522 0 \ 7523 -c "Read from server: 1 bytes read"\ 7524 -c "16383 bytes read"\ 7525 -C "Read from server: 16384 bytes read" 7526 7527requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7528run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \ 7529 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 7530 "$P_CLI force_version=tls1 \ 7531 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \ 7532 trunc_hmac=1" \ 7533 0 \ 7534 -s "16384 bytes written in 1 fragments" \ 7535 -c "Read from server: 16384 bytes read" 7536 7537run_test "Large server packet TLS 1.0 StreamCipher" \ 7538 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 7539 "$P_CLI force_version=tls1 \ 7540 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 7541 0 \ 7542 -s "16384 bytes written in 1 fragments" \ 7543 -c "Read from server: 16384 bytes read" 7544 7545run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \ 7546 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 7547 "$P_CLI force_version=tls1 \ 7548 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \ 7549 0 \ 7550 -s "16384 bytes written in 1 fragments" \ 7551 -c "Read from server: 16384 bytes read" 7552 7553requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7554run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \ 7555 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 7556 "$P_CLI force_version=tls1 \ 7557 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 7558 0 \ 7559 -s "16384 bytes written in 1 fragments" \ 7560 -c "Read from server: 16384 bytes read" 7561 7562requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7563run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \ 7564 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 7565 "$P_CLI force_version=tls1 \ 7566 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \ 7567 0 \ 7568 -s "16384 bytes written in 1 fragments" \ 7569 -c "Read from server: 16384 bytes read" 7570 7571run_test "Large server packet TLS 1.1 BlockCipher" \ 7572 "$P_SRV response_size=16384" \ 7573 "$P_CLI force_version=tls1_1 \ 7574 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 7575 0 \ 7576 -c "Read from server: 16384 bytes read" 7577 7578run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \ 7579 "$P_SRV response_size=16384" \ 7580 "$P_CLI force_version=tls1_1 etm=0 \ 7581 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 7582 0 \ 7583 -s "16384 bytes written in 1 fragments" \ 7584 -c "Read from server: 16384 bytes read" 7585 7586requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7587run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \ 7588 "$P_SRV response_size=16384" \ 7589 "$P_CLI force_version=tls1_1 \ 7590 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \ 7591 trunc_hmac=1" \ 7592 0 \ 7593 -c "Read from server: 16384 bytes read" 7594 7595requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7596run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \ 7597 "$P_SRV response_size=16384 trunc_hmac=1" \ 7598 "$P_CLI force_version=tls1_1 \ 7599 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \ 7600 0 \ 7601 -s "16384 bytes written in 1 fragments" \ 7602 -c "Read from server: 16384 bytes read" 7603 7604run_test "Large server packet TLS 1.1 StreamCipher" \ 7605 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 7606 "$P_CLI force_version=tls1_1 \ 7607 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 7608 0 \ 7609 -c "Read from server: 16384 bytes read" 7610 7611run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \ 7612 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 7613 "$P_CLI force_version=tls1_1 \ 7614 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \ 7615 0 \ 7616 -s "16384 bytes written in 1 fragments" \ 7617 -c "Read from server: 16384 bytes read" 7618 7619requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7620run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \ 7621 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 7622 "$P_CLI force_version=tls1_1 \ 7623 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \ 7624 trunc_hmac=1" \ 7625 0 \ 7626 -c "Read from server: 16384 bytes read" 7627 7628run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \ 7629 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 7630 "$P_CLI force_version=tls1_1 \ 7631 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \ 7632 0 \ 7633 -s "16384 bytes written in 1 fragments" \ 7634 -c "Read from server: 16384 bytes read" 7635 7636run_test "Large server packet TLS 1.2 BlockCipher" \ 7637 "$P_SRV response_size=16384" \ 7638 "$P_CLI force_version=tls12 \ 7639 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 7640 0 \ 7641 -c "Read from server: 16384 bytes read" 7642 7643run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \ 7644 "$P_SRV response_size=16384" \ 7645 "$P_CLI force_version=tls12 etm=0 \ 7646 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 7647 0 \ 7648 -s "16384 bytes written in 1 fragments" \ 7649 -c "Read from server: 16384 bytes read" 7650 7651run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \ 7652 "$P_SRV response_size=16384" \ 7653 "$P_CLI force_version=tls12 \ 7654 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \ 7655 0 \ 7656 -c "Read from server: 16384 bytes read" 7657 7658requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7659run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \ 7660 "$P_SRV response_size=16384" \ 7661 "$P_CLI force_version=tls12 \ 7662 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \ 7663 trunc_hmac=1" \ 7664 0 \ 7665 -c "Read from server: 16384 bytes read" 7666 7667run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \ 7668 "$P_SRV response_size=16384 trunc_hmac=1" \ 7669 "$P_CLI force_version=tls12 \ 7670 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \ 7671 0 \ 7672 -s "16384 bytes written in 1 fragments" \ 7673 -c "Read from server: 16384 bytes read" 7674 7675run_test "Large server packet TLS 1.2 StreamCipher" \ 7676 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 7677 "$P_CLI force_version=tls12 \ 7678 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 7679 0 \ 7680 -s "16384 bytes written in 1 fragments" \ 7681 -c "Read from server: 16384 bytes read" 7682 7683run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \ 7684 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 7685 "$P_CLI force_version=tls12 \ 7686 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \ 7687 0 \ 7688 -s "16384 bytes written in 1 fragments" \ 7689 -c "Read from server: 16384 bytes read" 7690 7691requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7692run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \ 7693 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 7694 "$P_CLI force_version=tls12 \ 7695 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \ 7696 trunc_hmac=1" \ 7697 0 \ 7698 -c "Read from server: 16384 bytes read" 7699 7700requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC 7701run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \ 7702 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 7703 "$P_CLI force_version=tls12 \ 7704 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \ 7705 0 \ 7706 -s "16384 bytes written in 1 fragments" \ 7707 -c "Read from server: 16384 bytes read" 7708 7709run_test "Large server packet TLS 1.2 AEAD" \ 7710 "$P_SRV response_size=16384" \ 7711 "$P_CLI force_version=tls12 \ 7712 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \ 7713 0 \ 7714 -c "Read from server: 16384 bytes read" 7715 7716run_test "Large server packet TLS 1.2 AEAD shorter tag" \ 7717 "$P_SRV response_size=16384" \ 7718 "$P_CLI force_version=tls12 \ 7719 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \ 7720 0 \ 7721 -c "Read from server: 16384 bytes read" 7722 7723# Tests for restartable ECC 7724 7725requires_config_enabled MBEDTLS_ECP_DP_SECP256R1_ENABLED 7726requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2 7727requires_config_enabled MBEDTLS_ECP_RESTARTABLE 7728run_test "EC restart: TLS, default" \ 7729 "$P_SRV auth_mode=required" \ 7730 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ 7731 key_file=data_files/server5.key crt_file=data_files/server5.crt \ 7732 debug_level=1" \ 7733 0 \ 7734 -C "x509_verify_cert.*4b00" \ 7735 -C "mbedtls_pk_verify.*4b00" \ 7736 -C "mbedtls_ecdh_make_public.*4b00" \ 7737 -C "mbedtls_pk_sign.*4b00" 7738 7739requires_config_enabled MBEDTLS_ECP_DP_SECP256R1_ENABLED 7740requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2 7741requires_config_enabled MBEDTLS_ECP_RESTARTABLE 7742run_test "EC restart: TLS, max_ops=0" \ 7743 "$P_SRV auth_mode=required" \ 7744 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ 7745 key_file=data_files/server5.key crt_file=data_files/server5.crt \ 7746 debug_level=1 ec_max_ops=0" \ 7747 0 \ 7748 -C "x509_verify_cert.*4b00" \ 7749 -C "mbedtls_pk_verify.*4b00" \ 7750 -C "mbedtls_ecdh_make_public.*4b00" \ 7751 -C "mbedtls_pk_sign.*4b00" 7752 7753requires_config_enabled MBEDTLS_ECP_DP_SECP256R1_ENABLED 7754requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2 7755requires_config_enabled MBEDTLS_ECP_RESTARTABLE 7756run_test "EC restart: TLS, max_ops=65535" \ 7757 "$P_SRV auth_mode=required" \ 7758 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ 7759 key_file=data_files/server5.key crt_file=data_files/server5.crt \ 7760 debug_level=1 ec_max_ops=65535" \ 7761 0 \ 7762 -C "x509_verify_cert.*4b00" \ 7763 -C "mbedtls_pk_verify.*4b00" \ 7764 -C "mbedtls_ecdh_make_public.*4b00" \ 7765 -C "mbedtls_pk_sign.*4b00" 7766 7767requires_config_enabled MBEDTLS_ECP_DP_SECP256R1_ENABLED 7768requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2 7769requires_config_enabled MBEDTLS_ECP_RESTARTABLE 7770run_test "EC restart: TLS, max_ops=1000" \ 7771 "$P_SRV auth_mode=required" \ 7772 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ 7773 key_file=data_files/server5.key crt_file=data_files/server5.crt \ 7774 debug_level=1 ec_max_ops=1000" \ 7775 0 \ 7776 -c "x509_verify_cert.*4b00" \ 7777 -c "mbedtls_pk_verify.*4b00" \ 7778 -c "mbedtls_ecdh_make_public.*4b00" \ 7779 -c "mbedtls_pk_sign.*4b00" 7780 7781requires_config_enabled MBEDTLS_ECP_DP_SECP256R1_ENABLED 7782requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2 7783requires_config_enabled MBEDTLS_ECP_RESTARTABLE 7784run_test "EC restart: TLS, max_ops=1000, badsign" \ 7785 "$P_SRV auth_mode=required \ 7786 crt_file=data_files/server5-badsign.crt \ 7787 key_file=data_files/server5.key" \ 7788 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ 7789 key_file=data_files/server5.key crt_file=data_files/server5.crt \ 7790 debug_level=1 ec_max_ops=1000" \ 7791 1 \ 7792 -c "x509_verify_cert.*4b00" \ 7793 -C "mbedtls_pk_verify.*4b00" \ 7794 -C "mbedtls_ecdh_make_public.*4b00" \ 7795 -C "mbedtls_pk_sign.*4b00" \ 7796 -c "! The certificate is not correctly signed by the trusted CA" \ 7797 -c "! mbedtls_ssl_handshake returned" \ 7798 -c "X509 - Certificate verification failed" 7799 7800requires_config_enabled MBEDTLS_ECP_DP_SECP256R1_ENABLED 7801requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2 7802requires_config_enabled MBEDTLS_ECP_RESTARTABLE 7803run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \ 7804 "$P_SRV auth_mode=required \ 7805 crt_file=data_files/server5-badsign.crt \ 7806 key_file=data_files/server5.key" \ 7807 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ 7808 key_file=data_files/server5.key crt_file=data_files/server5.crt \ 7809 debug_level=1 ec_max_ops=1000 auth_mode=optional" \ 7810 0 \ 7811 -c "x509_verify_cert.*4b00" \ 7812 -c "mbedtls_pk_verify.*4b00" \ 7813 -c "mbedtls_ecdh_make_public.*4b00" \ 7814 -c "mbedtls_pk_sign.*4b00" \ 7815 -c "! The certificate is not correctly signed by the trusted CA" \ 7816 -C "! mbedtls_ssl_handshake returned" \ 7817 -C "X509 - Certificate verification failed" 7818 7819requires_config_enabled MBEDTLS_ECP_DP_SECP256R1_ENABLED 7820requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2 7821requires_config_enabled MBEDTLS_ECP_RESTARTABLE 7822run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \ 7823 "$P_SRV auth_mode=required \ 7824 crt_file=data_files/server5-badsign.crt \ 7825 key_file=data_files/server5.key" \ 7826 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ 7827 key_file=data_files/server5.key crt_file=data_files/server5.crt \ 7828 debug_level=1 ec_max_ops=1000 auth_mode=none" \ 7829 0 \ 7830 -C "x509_verify_cert.*4b00" \ 7831 -c "mbedtls_pk_verify.*4b00" \ 7832 -c "mbedtls_ecdh_make_public.*4b00" \ 7833 -c "mbedtls_pk_sign.*4b00" \ 7834 -C "! The certificate is not correctly signed by the trusted CA" \ 7835 -C "! mbedtls_ssl_handshake returned" \ 7836 -C "X509 - Certificate verification failed" 7837 7838requires_config_enabled MBEDTLS_ECP_DP_SECP256R1_ENABLED 7839requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2 7840requires_config_enabled MBEDTLS_ECP_RESTARTABLE 7841run_test "EC restart: DTLS, max_ops=1000" \ 7842 "$P_SRV auth_mode=required dtls=1" \ 7843 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ 7844 key_file=data_files/server5.key crt_file=data_files/server5.crt \ 7845 dtls=1 debug_level=1 ec_max_ops=1000" \ 7846 0 \ 7847 -c "x509_verify_cert.*4b00" \ 7848 -c "mbedtls_pk_verify.*4b00" \ 7849 -c "mbedtls_ecdh_make_public.*4b00" \ 7850 -c "mbedtls_pk_sign.*4b00" 7851 7852requires_config_enabled MBEDTLS_ECP_DP_SECP256R1_ENABLED 7853requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2 7854requires_config_enabled MBEDTLS_ECP_RESTARTABLE 7855run_test "EC restart: TLS, max_ops=1000 no client auth" \ 7856 "$P_SRV" \ 7857 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ 7858 debug_level=1 ec_max_ops=1000" \ 7859 0 \ 7860 -c "x509_verify_cert.*4b00" \ 7861 -c "mbedtls_pk_verify.*4b00" \ 7862 -c "mbedtls_ecdh_make_public.*4b00" \ 7863 -C "mbedtls_pk_sign.*4b00" 7864 7865 7866# Restartable is only for ECDHE-ECDSA, with another ciphersuite we expect no 7867# restartable behaviour at all (not even client auth). 7868# This is the same as "EC restart: TLS, max_ops=1000" except with ECDHE-RSA, 7869# and all 4 assertions negated. 7870requires_config_enabled MBEDTLS_ECP_RESTARTABLE 7871requires_config_enabled MBEDTLS_ECP_DP_SECP256R1_ENABLED 7872requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2 7873run_test "EC restart: TLS, max_ops=1000, ECDHE-RSA" \ 7874 "$P_SRV curves=secp256r1 auth_mode=required" \ 7875 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256 \ 7876 key_file=data_files/server5.key crt_file=data_files/server5.crt \ 7877 debug_level=1 ec_max_ops=1000" \ 7878 0 \ 7879 -C "x509_verify_cert.*4b00" \ 7880 -C "mbedtls_pk_verify.*4b00" \ 7881 -C "mbedtls_ecdh_make_public.*4b00" \ 7882 -C "mbedtls_pk_sign.*4b00" 7883 7884# Tests of asynchronous private key support in SSL 7885 7886requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE 7887run_test "SSL async private: sign, delay=0" \ 7888 "$P_SRV \ 7889 async_operations=s async_private_delay1=0 async_private_delay2=0" \ 7890 "$P_CLI" \ 7891 0 \ 7892 -s "Async sign callback: using key slot " \ 7893 -s "Async resume (slot [0-9]): sign done, status=0" 7894 7895requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE 7896run_test "SSL async private: sign, delay=1" \ 7897 "$P_SRV \ 7898 async_operations=s async_private_delay1=1 async_private_delay2=1" \ 7899 "$P_CLI" \ 7900 0 \ 7901 -s "Async sign callback: using key slot " \ 7902 -s "Async resume (slot [0-9]): call 0 more times." \ 7903 -s "Async resume (slot [0-9]): sign done, status=0" 7904 7905requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE 7906run_test "SSL async private: sign, delay=2" \ 7907 "$P_SRV \ 7908 async_operations=s async_private_delay1=2 async_private_delay2=2" \ 7909 "$P_CLI" \ 7910 0 \ 7911 -s "Async sign callback: using key slot " \ 7912 -U "Async sign callback: using key slot " \ 7913 -s "Async resume (slot [0-9]): call 1 more times." \ 7914 -s "Async resume (slot [0-9]): call 0 more times." \ 7915 -s "Async resume (slot [0-9]): sign done, status=0" 7916 7917# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1 7918# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1. 7919requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE 7920run_test "SSL async private: sign, RSA, TLS 1.1" \ 7921 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \ 7922 async_operations=s async_private_delay1=0 async_private_delay2=0" \ 7923 "$P_CLI force_version=tls1_1" \ 7924 0 \ 7925 -s "Async sign callback: using key slot " \ 7926 -s "Async resume (slot [0-9]): sign done, status=0" 7927 7928requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE 7929run_test "SSL async private: sign, SNI" \ 7930 "$P_SRV debug_level=3 \ 7931 async_operations=s async_private_delay1=0 async_private_delay2=0 \ 7932 crt_file=data_files/server5.crt key_file=data_files/server5.key \ 7933 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \ 7934 "$P_CLI server_name=polarssl.example" \ 7935 0 \ 7936 -s "Async sign callback: using key slot " \ 7937 -s "Async resume (slot [0-9]): sign done, status=0" \ 7938 -s "parse ServerName extension" \ 7939 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \ 7940 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example" 7941 7942requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE 7943run_test "SSL async private: decrypt, delay=0" \ 7944 "$P_SRV \ 7945 async_operations=d async_private_delay1=0 async_private_delay2=0" \ 7946 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ 7947 0 \ 7948 -s "Async decrypt callback: using key slot " \ 7949 -s "Async resume (slot [0-9]): decrypt done, status=0" 7950 7951requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE 7952run_test "SSL async private: decrypt, delay=1" \ 7953 "$P_SRV \ 7954 async_operations=d async_private_delay1=1 async_private_delay2=1" \ 7955 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ 7956 0 \ 7957 -s "Async decrypt callback: using key slot " \ 7958 -s "Async resume (slot [0-9]): call 0 more times." \ 7959 -s "Async resume (slot [0-9]): decrypt done, status=0" 7960 7961requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE 7962run_test "SSL async private: decrypt RSA-PSK, delay=0" \ 7963 "$P_SRV psk=abc123 \ 7964 async_operations=d async_private_delay1=0 async_private_delay2=0" \ 7965 "$P_CLI psk=abc123 \ 7966 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \ 7967 0 \ 7968 -s "Async decrypt callback: using key slot " \ 7969 -s "Async resume (slot [0-9]): decrypt done, status=0" 7970 7971requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE 7972run_test "SSL async private: decrypt RSA-PSK, delay=1" \ 7973 "$P_SRV psk=abc123 \ 7974 async_operations=d async_private_delay1=1 async_private_delay2=1" \ 7975 "$P_CLI psk=abc123 \ 7976 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \ 7977 0 \ 7978 -s "Async decrypt callback: using key slot " \ 7979 -s "Async resume (slot [0-9]): call 0 more times." \ 7980 -s "Async resume (slot [0-9]): decrypt done, status=0" 7981 7982requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE 7983run_test "SSL async private: sign callback not present" \ 7984 "$P_SRV \ 7985 async_operations=d async_private_delay1=1 async_private_delay2=1" \ 7986 "$P_CLI; [ \$? -eq 1 ] && 7987 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ 7988 0 \ 7989 -S "Async sign callback" \ 7990 -s "! mbedtls_ssl_handshake returned" \ 7991 -s "The own private key or pre-shared key is not set, but needed" \ 7992 -s "Async resume (slot [0-9]): decrypt done, status=0" \ 7993 -s "Successful connection" 7994 7995requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE 7996run_test "SSL async private: decrypt callback not present" \ 7997 "$P_SRV debug_level=1 \ 7998 async_operations=s async_private_delay1=1 async_private_delay2=1" \ 7999 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA; 8000 [ \$? -eq 1 ] && $P_CLI" \ 8001 0 \ 8002 -S "Async decrypt callback" \ 8003 -s "! mbedtls_ssl_handshake returned" \ 8004 -s "got no RSA private key" \ 8005 -s "Async resume (slot [0-9]): sign done, status=0" \ 8006 -s "Successful connection" 8007 8008# key1: ECDSA, key2: RSA; use key1 from slot 0 8009requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE 8010run_test "SSL async private: slot 0 used with key1" \ 8011 "$P_SRV \ 8012 async_operations=s async_private_delay1=1 \ 8013 key_file=data_files/server5.key crt_file=data_files/server5.crt \ 8014 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \ 8015 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \ 8016 0 \ 8017 -s "Async sign callback: using key slot 0," \ 8018 -s "Async resume (slot 0): call 0 more times." \ 8019 -s "Async resume (slot 0): sign done, status=0" 8020 8021# key1: ECDSA, key2: RSA; use key2 from slot 0 8022requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE 8023run_test "SSL async private: slot 0 used with key2" \ 8024 "$P_SRV \ 8025 async_operations=s async_private_delay2=1 \ 8026 key_file=data_files/server5.key crt_file=data_files/server5.crt \ 8027 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \ 8028 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \ 8029 0 \ 8030 -s "Async sign callback: using key slot 0," \ 8031 -s "Async resume (slot 0): call 0 more times." \ 8032 -s "Async resume (slot 0): sign done, status=0" 8033 8034# key1: ECDSA, key2: RSA; use key2 from slot 1 8035requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE 8036run_test "SSL async private: slot 1 used with key2" \ 8037 "$P_SRV \ 8038 async_operations=s async_private_delay1=1 async_private_delay2=1 \ 8039 key_file=data_files/server5.key crt_file=data_files/server5.crt \ 8040 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \ 8041 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \ 8042 0 \ 8043 -s "Async sign callback: using key slot 1," \ 8044 -s "Async resume (slot 1): call 0 more times." \ 8045 -s "Async resume (slot 1): sign done, status=0" 8046 8047# key1: ECDSA, key2: RSA; use key2 directly 8048requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE 8049run_test "SSL async private: fall back to transparent key" \ 8050 "$P_SRV \ 8051 async_operations=s async_private_delay1=1 \ 8052 key_file=data_files/server5.key crt_file=data_files/server5.crt \ 8053 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \ 8054 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \ 8055 0 \ 8056 -s "Async sign callback: no key matches this certificate." 8057 8058requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE 8059run_test "SSL async private: sign, error in start" \ 8060 "$P_SRV \ 8061 async_operations=s async_private_delay1=1 async_private_delay2=1 \ 8062 async_private_error=1" \ 8063 "$P_CLI" \ 8064 1 \ 8065 -s "Async sign callback: injected error" \ 8066 -S "Async resume" \ 8067 -S "Async cancel" \ 8068 -s "! mbedtls_ssl_handshake returned" 8069 8070requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE 8071run_test "SSL async private: sign, cancel after start" \ 8072 "$P_SRV \ 8073 async_operations=s async_private_delay1=1 async_private_delay2=1 \ 8074 async_private_error=2" \ 8075 "$P_CLI" \ 8076 1 \ 8077 -s "Async sign callback: using key slot " \ 8078 -S "Async resume" \ 8079 -s "Async cancel" 8080 8081requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE 8082run_test "SSL async private: sign, error in resume" \ 8083 "$P_SRV \ 8084 async_operations=s async_private_delay1=1 async_private_delay2=1 \ 8085 async_private_error=3" \ 8086 "$P_CLI" \ 8087 1 \ 8088 -s "Async sign callback: using key slot " \ 8089 -s "Async resume callback: sign done but injected error" \ 8090 -S "Async cancel" \ 8091 -s "! mbedtls_ssl_handshake returned" 8092 8093requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE 8094run_test "SSL async private: decrypt, error in start" \ 8095 "$P_SRV \ 8096 async_operations=d async_private_delay1=1 async_private_delay2=1 \ 8097 async_private_error=1" \ 8098 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ 8099 1 \ 8100 -s "Async decrypt callback: injected error" \ 8101 -S "Async resume" \ 8102 -S "Async cancel" \ 8103 -s "! mbedtls_ssl_handshake returned" 8104 8105requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE 8106run_test "SSL async private: decrypt, cancel after start" \ 8107 "$P_SRV \ 8108 async_operations=d async_private_delay1=1 async_private_delay2=1 \ 8109 async_private_error=2" \ 8110 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ 8111 1 \ 8112 -s "Async decrypt callback: using key slot " \ 8113 -S "Async resume" \ 8114 -s "Async cancel" 8115 8116requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE 8117run_test "SSL async private: decrypt, error in resume" \ 8118 "$P_SRV \ 8119 async_operations=d async_private_delay1=1 async_private_delay2=1 \ 8120 async_private_error=3" \ 8121 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ 8122 1 \ 8123 -s "Async decrypt callback: using key slot " \ 8124 -s "Async resume callback: decrypt done but injected error" \ 8125 -S "Async cancel" \ 8126 -s "! mbedtls_ssl_handshake returned" 8127 8128requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE 8129run_test "SSL async private: cancel after start then operate correctly" \ 8130 "$P_SRV \ 8131 async_operations=s async_private_delay1=1 async_private_delay2=1 \ 8132 async_private_error=-2" \ 8133 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \ 8134 0 \ 8135 -s "Async cancel" \ 8136 -s "! mbedtls_ssl_handshake returned" \ 8137 -s "Async resume" \ 8138 -s "Successful connection" 8139 8140requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE 8141run_test "SSL async private: error in resume then operate correctly" \ 8142 "$P_SRV \ 8143 async_operations=s async_private_delay1=1 async_private_delay2=1 \ 8144 async_private_error=-3" \ 8145 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \ 8146 0 \ 8147 -s "! mbedtls_ssl_handshake returned" \ 8148 -s "Async resume" \ 8149 -s "Successful connection" 8150 8151# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly 8152requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE 8153run_test "SSL async private: cancel after start then fall back to transparent key" \ 8154 "$P_SRV \ 8155 async_operations=s async_private_delay1=1 async_private_error=-2 \ 8156 key_file=data_files/server5.key crt_file=data_files/server5.crt \ 8157 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \ 8158 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256; 8159 [ \$? -eq 1 ] && 8160 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \ 8161 0 \ 8162 -s "Async sign callback: using key slot 0" \ 8163 -S "Async resume" \ 8164 -s "Async cancel" \ 8165 -s "! mbedtls_ssl_handshake returned" \ 8166 -s "Async sign callback: no key matches this certificate." \ 8167 -s "Successful connection" 8168 8169# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly 8170requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE 8171run_test "SSL async private: sign, error in resume then fall back to transparent key" \ 8172 "$P_SRV \ 8173 async_operations=s async_private_delay1=1 async_private_error=-3 \ 8174 key_file=data_files/server5.key crt_file=data_files/server5.crt \ 8175 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \ 8176 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256; 8177 [ \$? -eq 1 ] && 8178 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \ 8179 0 \ 8180 -s "Async resume" \ 8181 -s "! mbedtls_ssl_handshake returned" \ 8182 -s "Async sign callback: no key matches this certificate." \ 8183 -s "Successful connection" 8184 8185requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE 8186requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 8187run_test "SSL async private: renegotiation: client-initiated, sign" \ 8188 "$P_SRV \ 8189 async_operations=s async_private_delay1=1 async_private_delay2=1 \ 8190 exchanges=2 renegotiation=1" \ 8191 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \ 8192 0 \ 8193 -s "Async sign callback: using key slot " \ 8194 -s "Async resume (slot [0-9]): sign done, status=0" 8195 8196requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE 8197requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 8198run_test "SSL async private: renegotiation: server-initiated, sign" \ 8199 "$P_SRV \ 8200 async_operations=s async_private_delay1=1 async_private_delay2=1 \ 8201 exchanges=2 renegotiation=1 renegotiate=1" \ 8202 "$P_CLI exchanges=2 renegotiation=1" \ 8203 0 \ 8204 -s "Async sign callback: using key slot " \ 8205 -s "Async resume (slot [0-9]): sign done, status=0" 8206 8207requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE 8208requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 8209run_test "SSL async private: renegotiation: client-initiated, decrypt" \ 8210 "$P_SRV \ 8211 async_operations=d async_private_delay1=1 async_private_delay2=1 \ 8212 exchanges=2 renegotiation=1" \ 8213 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \ 8214 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ 8215 0 \ 8216 -s "Async decrypt callback: using key slot " \ 8217 -s "Async resume (slot [0-9]): decrypt done, status=0" 8218 8219requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE 8220requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 8221run_test "SSL async private: renegotiation: server-initiated, decrypt" \ 8222 "$P_SRV \ 8223 async_operations=d async_private_delay1=1 async_private_delay2=1 \ 8224 exchanges=2 renegotiation=1 renegotiate=1" \ 8225 "$P_CLI exchanges=2 renegotiation=1 \ 8226 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ 8227 0 \ 8228 -s "Async decrypt callback: using key slot " \ 8229 -s "Async resume (slot [0-9]): decrypt done, status=0" 8230 8231# Tests for ECC extensions (rfc 4492) 8232 8233requires_config_enabled MBEDTLS_AES_C 8234requires_config_enabled MBEDTLS_CIPHER_MODE_CBC 8235requires_config_enabled MBEDTLS_SHA256_C 8236requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED 8237run_test "Force a non ECC ciphersuite in the client side" \ 8238 "$P_SRV debug_level=3" \ 8239 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \ 8240 0 \ 8241 -C "client hello, adding supported_elliptic_curves extension" \ 8242 -C "client hello, adding supported_point_formats extension" \ 8243 -S "found supported elliptic curves extension" \ 8244 -S "found supported point formats extension" 8245 8246requires_config_enabled MBEDTLS_AES_C 8247requires_config_enabled MBEDTLS_CIPHER_MODE_CBC 8248requires_config_enabled MBEDTLS_SHA256_C 8249requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED 8250run_test "Force a non ECC ciphersuite in the server side" \ 8251 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \ 8252 "$P_CLI debug_level=3" \ 8253 0 \ 8254 -C "found supported_point_formats extension" \ 8255 -S "server hello, supported_point_formats extension" 8256 8257requires_config_enabled MBEDTLS_AES_C 8258requires_config_enabled MBEDTLS_CIPHER_MODE_CBC 8259requires_config_enabled MBEDTLS_SHA256_C 8260requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED 8261run_test "Force an ECC ciphersuite in the client side" \ 8262 "$P_SRV debug_level=3" \ 8263 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \ 8264 0 \ 8265 -c "client hello, adding supported_elliptic_curves extension" \ 8266 -c "client hello, adding supported_point_formats extension" \ 8267 -s "found supported elliptic curves extension" \ 8268 -s "found supported point formats extension" 8269 8270requires_config_enabled MBEDTLS_AES_C 8271requires_config_enabled MBEDTLS_CIPHER_MODE_CBC 8272requires_config_enabled MBEDTLS_SHA256_C 8273requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED 8274run_test "Force an ECC ciphersuite in the server side" \ 8275 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \ 8276 "$P_CLI debug_level=3" \ 8277 0 \ 8278 -c "found supported_point_formats extension" \ 8279 -s "server hello, supported_point_formats extension" 8280 8281# Tests for DTLS HelloVerifyRequest 8282 8283run_test "DTLS cookie: enabled" \ 8284 "$P_SRV dtls=1 debug_level=2" \ 8285 "$P_CLI dtls=1 debug_level=2" \ 8286 0 \ 8287 -s "cookie verification failed" \ 8288 -s "cookie verification passed" \ 8289 -S "cookie verification skipped" \ 8290 -c "received hello verify request" \ 8291 -s "hello verification requested" \ 8292 -S "SSL - The requested feature is not available" 8293 8294run_test "DTLS cookie: disabled" \ 8295 "$P_SRV dtls=1 debug_level=2 cookies=0" \ 8296 "$P_CLI dtls=1 debug_level=2" \ 8297 0 \ 8298 -S "cookie verification failed" \ 8299 -S "cookie verification passed" \ 8300 -s "cookie verification skipped" \ 8301 -C "received hello verify request" \ 8302 -S "hello verification requested" \ 8303 -S "SSL - The requested feature is not available" 8304 8305run_test "DTLS cookie: default (failing)" \ 8306 "$P_SRV dtls=1 debug_level=2 cookies=-1" \ 8307 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \ 8308 1 \ 8309 -s "cookie verification failed" \ 8310 -S "cookie verification passed" \ 8311 -S "cookie verification skipped" \ 8312 -C "received hello verify request" \ 8313 -S "hello verification requested" \ 8314 -s "SSL - The requested feature is not available" 8315 8316requires_ipv6 8317run_test "DTLS cookie: enabled, IPv6" \ 8318 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \ 8319 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \ 8320 0 \ 8321 -s "cookie verification failed" \ 8322 -s "cookie verification passed" \ 8323 -S "cookie verification skipped" \ 8324 -c "received hello verify request" \ 8325 -s "hello verification requested" \ 8326 -S "SSL - The requested feature is not available" 8327 8328run_test "DTLS cookie: enabled, nbio" \ 8329 "$P_SRV dtls=1 nbio=2 debug_level=2" \ 8330 "$P_CLI dtls=1 nbio=2 debug_level=2" \ 8331 0 \ 8332 -s "cookie verification failed" \ 8333 -s "cookie verification passed" \ 8334 -S "cookie verification skipped" \ 8335 -c "received hello verify request" \ 8336 -s "hello verification requested" \ 8337 -S "SSL - The requested feature is not available" 8338 8339# Tests for client reconnecting from the same port with DTLS 8340 8341not_with_valgrind # spurious resend 8342run_test "DTLS client reconnect from same port: reference" \ 8343 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \ 8344 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \ 8345 0 \ 8346 -C "resend" \ 8347 -S "The operation timed out" \ 8348 -S "Client initiated reconnection from same port" 8349 8350not_with_valgrind # spurious resend 8351run_test "DTLS client reconnect from same port: reconnect" \ 8352 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \ 8353 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000 reconnect_hard=1" \ 8354 0 \ 8355 -C "resend" \ 8356 -S "The operation timed out" \ 8357 -s "Client initiated reconnection from same port" 8358 8359not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts) 8360run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \ 8361 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \ 8362 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000 reconnect_hard=1" \ 8363 0 \ 8364 -S "The operation timed out" \ 8365 -s "Client initiated reconnection from same port" 8366 8367only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout 8368run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \ 8369 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \ 8370 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \ 8371 0 \ 8372 -S "The operation timed out" \ 8373 -s "Client initiated reconnection from same port" 8374 8375run_test "DTLS client reconnect from same port: no cookies" \ 8376 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \ 8377 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \ 8378 0 \ 8379 -s "The operation timed out" \ 8380 -S "Client initiated reconnection from same port" 8381 8382run_test "DTLS client reconnect from same port: attacker-injected" \ 8383 -p "$P_PXY inject_clihlo=1" \ 8384 "$P_SRV dtls=1 exchanges=2 debug_level=1" \ 8385 "$P_CLI dtls=1 exchanges=2" \ 8386 0 \ 8387 -s "possible client reconnect from the same port" \ 8388 -S "Client initiated reconnection from same port" 8389 8390# Tests for various cases of client authentication with DTLS 8391# (focused on handshake flows and message parsing) 8392 8393run_test "DTLS client auth: required" \ 8394 "$P_SRV dtls=1 auth_mode=required" \ 8395 "$P_CLI dtls=1" \ 8396 0 \ 8397 -s "Verifying peer X.509 certificate... ok" 8398 8399run_test "DTLS client auth: optional, client has no cert" \ 8400 "$P_SRV dtls=1 auth_mode=optional" \ 8401 "$P_CLI dtls=1 crt_file=none key_file=none" \ 8402 0 \ 8403 -s "! Certificate was missing" 8404 8405run_test "DTLS client auth: none, client has no cert" \ 8406 "$P_SRV dtls=1 auth_mode=none" \ 8407 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \ 8408 0 \ 8409 -c "skip write certificate$" \ 8410 -s "! Certificate verification was skipped" 8411 8412run_test "DTLS wrong PSK: badmac alert" \ 8413 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \ 8414 "$P_CLI dtls=1 psk=abc124" \ 8415 1 \ 8416 -s "SSL - Verification of the message MAC failed" \ 8417 -c "SSL - A fatal alert message was received from our peer" 8418 8419# Tests for receiving fragmented handshake messages with DTLS 8420 8421requires_gnutls 8422run_test "DTLS reassembly: no fragmentation (gnutls server)" \ 8423 "$G_SRV -u --mtu 2048 -a" \ 8424 "$P_CLI dtls=1 debug_level=2" \ 8425 0 \ 8426 -C "found fragmented DTLS handshake message" \ 8427 -C "error" 8428 8429requires_gnutls 8430run_test "DTLS reassembly: some fragmentation (gnutls server)" \ 8431 "$G_SRV -u --mtu 512" \ 8432 "$P_CLI dtls=1 debug_level=2" \ 8433 0 \ 8434 -c "found fragmented DTLS handshake message" \ 8435 -C "error" 8436 8437requires_gnutls 8438run_test "DTLS reassembly: more fragmentation (gnutls server)" \ 8439 "$G_SRV -u --mtu 128" \ 8440 "$P_CLI dtls=1 debug_level=2" \ 8441 0 \ 8442 -c "found fragmented DTLS handshake message" \ 8443 -C "error" 8444 8445requires_gnutls 8446run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \ 8447 "$G_SRV -u --mtu 128" \ 8448 "$P_CLI dtls=1 nbio=2 debug_level=2" \ 8449 0 \ 8450 -c "found fragmented DTLS handshake message" \ 8451 -C "error" 8452 8453requires_gnutls 8454requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 8455run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \ 8456 "$G_SRV -u --mtu 256" \ 8457 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \ 8458 0 \ 8459 -c "found fragmented DTLS handshake message" \ 8460 -c "client hello, adding renegotiation extension" \ 8461 -c "found renegotiation extension" \ 8462 -c "=> renegotiate" \ 8463 -C "mbedtls_ssl_handshake returned" \ 8464 -C "error" \ 8465 -s "Extra-header:" 8466 8467requires_gnutls 8468requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 8469run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \ 8470 "$G_SRV -u --mtu 256" \ 8471 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \ 8472 0 \ 8473 -c "found fragmented DTLS handshake message" \ 8474 -c "client hello, adding renegotiation extension" \ 8475 -c "found renegotiation extension" \ 8476 -c "=> renegotiate" \ 8477 -C "mbedtls_ssl_handshake returned" \ 8478 -C "error" \ 8479 -s "Extra-header:" 8480 8481run_test "DTLS reassembly: no fragmentation (openssl server)" \ 8482 "$O_SRV -dtls1 -mtu 2048" \ 8483 "$P_CLI dtls=1 debug_level=2" \ 8484 0 \ 8485 -C "found fragmented DTLS handshake message" \ 8486 -C "error" 8487 8488run_test "DTLS reassembly: some fragmentation (openssl server)" \ 8489 "$O_SRV -dtls1 -mtu 768" \ 8490 "$P_CLI dtls=1 debug_level=2" \ 8491 0 \ 8492 -c "found fragmented DTLS handshake message" \ 8493 -C "error" 8494 8495run_test "DTLS reassembly: more fragmentation (openssl server)" \ 8496 "$O_SRV -dtls1 -mtu 256" \ 8497 "$P_CLI dtls=1 debug_level=2" \ 8498 0 \ 8499 -c "found fragmented DTLS handshake message" \ 8500 -C "error" 8501 8502run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \ 8503 "$O_SRV -dtls1 -mtu 256" \ 8504 "$P_CLI dtls=1 nbio=2 debug_level=2" \ 8505 0 \ 8506 -c "found fragmented DTLS handshake message" \ 8507 -C "error" 8508 8509# Tests for sending fragmented handshake messages with DTLS 8510# 8511# Use client auth when we need the client to send large messages, 8512# and use large cert chains on both sides too (the long chains we have all use 8513# both RSA and ECDSA, but ideally we should have long chains with either). 8514# Sizes reached (UDP payload): 8515# - 2037B for server certificate 8516# - 1542B for client certificate 8517# - 1013B for newsessionticket 8518# - all others below 512B 8519# All those tests assume MAX_CONTENT_LEN is at least 2048 8520 8521requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 8522requires_config_enabled MBEDTLS_RSA_C 8523requires_config_enabled MBEDTLS_ECDSA_C 8524requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 8525requires_max_content_len 4096 8526run_test "DTLS fragmenting: none (for reference)" \ 8527 "$P_SRV dtls=1 debug_level=2 auth_mode=required \ 8528 crt_file=data_files/server7_int-ca.crt \ 8529 key_file=data_files/server7.key \ 8530 hs_timeout=2500-60000 \ 8531 max_frag_len=4096" \ 8532 "$P_CLI dtls=1 debug_level=2 \ 8533 crt_file=data_files/server8_int-ca2.crt \ 8534 key_file=data_files/server8.key \ 8535 hs_timeout=2500-60000 \ 8536 max_frag_len=4096" \ 8537 0 \ 8538 -S "found fragmented DTLS handshake message" \ 8539 -C "found fragmented DTLS handshake message" \ 8540 -C "error" 8541 8542requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 8543requires_config_enabled MBEDTLS_RSA_C 8544requires_config_enabled MBEDTLS_ECDSA_C 8545requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 8546requires_max_content_len 2048 8547run_test "DTLS fragmenting: server only (max_frag_len)" \ 8548 "$P_SRV dtls=1 debug_level=2 auth_mode=required \ 8549 crt_file=data_files/server7_int-ca.crt \ 8550 key_file=data_files/server7.key \ 8551 hs_timeout=2500-60000 \ 8552 max_frag_len=1024" \ 8553 "$P_CLI dtls=1 debug_level=2 \ 8554 crt_file=data_files/server8_int-ca2.crt \ 8555 key_file=data_files/server8.key \ 8556 hs_timeout=2500-60000 \ 8557 max_frag_len=2048" \ 8558 0 \ 8559 -S "found fragmented DTLS handshake message" \ 8560 -c "found fragmented DTLS handshake message" \ 8561 -C "error" 8562 8563# With the MFL extension, the server has no way of forcing 8564# the client to not exceed a certain MTU; hence, the following 8565# test can't be replicated with an MTU proxy such as the one 8566# `client-initiated, server only (max_frag_len)` below. 8567requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 8568requires_config_enabled MBEDTLS_RSA_C 8569requires_config_enabled MBEDTLS_ECDSA_C 8570requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 8571requires_max_content_len 4096 8572run_test "DTLS fragmenting: server only (more) (max_frag_len)" \ 8573 "$P_SRV dtls=1 debug_level=2 auth_mode=required \ 8574 crt_file=data_files/server7_int-ca.crt \ 8575 key_file=data_files/server7.key \ 8576 hs_timeout=2500-60000 \ 8577 max_frag_len=512" \ 8578 "$P_CLI dtls=1 debug_level=2 \ 8579 crt_file=data_files/server8_int-ca2.crt \ 8580 key_file=data_files/server8.key \ 8581 hs_timeout=2500-60000 \ 8582 max_frag_len=4096" \ 8583 0 \ 8584 -S "found fragmented DTLS handshake message" \ 8585 -c "found fragmented DTLS handshake message" \ 8586 -C "error" 8587 8588requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 8589requires_config_enabled MBEDTLS_RSA_C 8590requires_config_enabled MBEDTLS_ECDSA_C 8591requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 8592requires_max_content_len 2048 8593run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \ 8594 "$P_SRV dtls=1 debug_level=2 auth_mode=none \ 8595 crt_file=data_files/server7_int-ca.crt \ 8596 key_file=data_files/server7.key \ 8597 hs_timeout=2500-60000 \ 8598 max_frag_len=2048" \ 8599 "$P_CLI dtls=1 debug_level=2 \ 8600 crt_file=data_files/server8_int-ca2.crt \ 8601 key_file=data_files/server8.key \ 8602 hs_timeout=2500-60000 \ 8603 max_frag_len=1024" \ 8604 0 \ 8605 -S "found fragmented DTLS handshake message" \ 8606 -c "found fragmented DTLS handshake message" \ 8607 -C "error" 8608 8609# While not required by the standard defining the MFL extension 8610# (according to which it only applies to records, not to datagrams), 8611# Mbed TLS will never send datagrams larger than MFL + { Max record expansion }, 8612# as otherwise there wouldn't be any means to communicate MTU restrictions 8613# to the peer. 8614# The next test checks that no datagrams significantly larger than the 8615# negotiated MFL are sent. 8616requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 8617requires_config_enabled MBEDTLS_RSA_C 8618requires_config_enabled MBEDTLS_ECDSA_C 8619requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 8620requires_max_content_len 2048 8621run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \ 8622 -p "$P_PXY mtu=1110" \ 8623 "$P_SRV dtls=1 debug_level=2 auth_mode=none \ 8624 crt_file=data_files/server7_int-ca.crt \ 8625 key_file=data_files/server7.key \ 8626 hs_timeout=2500-60000 \ 8627 max_frag_len=2048" \ 8628 "$P_CLI dtls=1 debug_level=2 \ 8629 crt_file=data_files/server8_int-ca2.crt \ 8630 key_file=data_files/server8.key \ 8631 hs_timeout=2500-60000 \ 8632 max_frag_len=1024" \ 8633 0 \ 8634 -S "found fragmented DTLS handshake message" \ 8635 -c "found fragmented DTLS handshake message" \ 8636 -C "error" 8637 8638requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 8639requires_config_enabled MBEDTLS_RSA_C 8640requires_config_enabled MBEDTLS_ECDSA_C 8641requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 8642requires_max_content_len 2048 8643run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \ 8644 "$P_SRV dtls=1 debug_level=2 auth_mode=required \ 8645 crt_file=data_files/server7_int-ca.crt \ 8646 key_file=data_files/server7.key \ 8647 hs_timeout=2500-60000 \ 8648 max_frag_len=2048" \ 8649 "$P_CLI dtls=1 debug_level=2 \ 8650 crt_file=data_files/server8_int-ca2.crt \ 8651 key_file=data_files/server8.key \ 8652 hs_timeout=2500-60000 \ 8653 max_frag_len=1024" \ 8654 0 \ 8655 -s "found fragmented DTLS handshake message" \ 8656 -c "found fragmented DTLS handshake message" \ 8657 -C "error" 8658 8659# While not required by the standard defining the MFL extension 8660# (according to which it only applies to records, not to datagrams), 8661# Mbed TLS will never send datagrams larger than MFL + { Max record expansion }, 8662# as otherwise there wouldn't be any means to communicate MTU restrictions 8663# to the peer. 8664# The next test checks that no datagrams significantly larger than the 8665# negotiated MFL are sent. 8666requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 8667requires_config_enabled MBEDTLS_RSA_C 8668requires_config_enabled MBEDTLS_ECDSA_C 8669requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 8670requires_max_content_len 2048 8671run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \ 8672 -p "$P_PXY mtu=1110" \ 8673 "$P_SRV dtls=1 debug_level=2 auth_mode=required \ 8674 crt_file=data_files/server7_int-ca.crt \ 8675 key_file=data_files/server7.key \ 8676 hs_timeout=2500-60000 \ 8677 max_frag_len=2048" \ 8678 "$P_CLI dtls=1 debug_level=2 \ 8679 crt_file=data_files/server8_int-ca2.crt \ 8680 key_file=data_files/server8.key \ 8681 hs_timeout=2500-60000 \ 8682 max_frag_len=1024" \ 8683 0 \ 8684 -s "found fragmented DTLS handshake message" \ 8685 -c "found fragmented DTLS handshake message" \ 8686 -C "error" 8687 8688requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 8689requires_config_enabled MBEDTLS_RSA_C 8690requires_config_enabled MBEDTLS_ECDSA_C 8691requires_max_content_len 4096 8692run_test "DTLS fragmenting: none (for reference) (MTU)" \ 8693 "$P_SRV dtls=1 debug_level=2 auth_mode=required \ 8694 crt_file=data_files/server7_int-ca.crt \ 8695 key_file=data_files/server7.key \ 8696 hs_timeout=2500-60000 \ 8697 mtu=4096" \ 8698 "$P_CLI dtls=1 debug_level=2 \ 8699 crt_file=data_files/server8_int-ca2.crt \ 8700 key_file=data_files/server8.key \ 8701 hs_timeout=2500-60000 \ 8702 mtu=4096" \ 8703 0 \ 8704 -S "found fragmented DTLS handshake message" \ 8705 -C "found fragmented DTLS handshake message" \ 8706 -C "error" 8707 8708requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 8709requires_config_enabled MBEDTLS_RSA_C 8710requires_config_enabled MBEDTLS_ECDSA_C 8711requires_max_content_len 4096 8712run_test "DTLS fragmenting: client (MTU)" \ 8713 "$P_SRV dtls=1 debug_level=2 auth_mode=required \ 8714 crt_file=data_files/server7_int-ca.crt \ 8715 key_file=data_files/server7.key \ 8716 hs_timeout=3500-60000 \ 8717 mtu=4096" \ 8718 "$P_CLI dtls=1 debug_level=2 \ 8719 crt_file=data_files/server8_int-ca2.crt \ 8720 key_file=data_files/server8.key \ 8721 hs_timeout=3500-60000 \ 8722 mtu=1024" \ 8723 0 \ 8724 -s "found fragmented DTLS handshake message" \ 8725 -C "found fragmented DTLS handshake message" \ 8726 -C "error" 8727 8728requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 8729requires_config_enabled MBEDTLS_RSA_C 8730requires_config_enabled MBEDTLS_ECDSA_C 8731requires_max_content_len 2048 8732run_test "DTLS fragmenting: server (MTU)" \ 8733 "$P_SRV dtls=1 debug_level=2 auth_mode=required \ 8734 crt_file=data_files/server7_int-ca.crt \ 8735 key_file=data_files/server7.key \ 8736 hs_timeout=2500-60000 \ 8737 mtu=512" \ 8738 "$P_CLI dtls=1 debug_level=2 \ 8739 crt_file=data_files/server8_int-ca2.crt \ 8740 key_file=data_files/server8.key \ 8741 hs_timeout=2500-60000 \ 8742 mtu=2048" \ 8743 0 \ 8744 -S "found fragmented DTLS handshake message" \ 8745 -c "found fragmented DTLS handshake message" \ 8746 -C "error" 8747 8748requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 8749requires_config_enabled MBEDTLS_RSA_C 8750requires_config_enabled MBEDTLS_ECDSA_C 8751requires_max_content_len 2048 8752run_test "DTLS fragmenting: both (MTU=1024)" \ 8753 -p "$P_PXY mtu=1024" \ 8754 "$P_SRV dtls=1 debug_level=2 auth_mode=required \ 8755 crt_file=data_files/server7_int-ca.crt \ 8756 key_file=data_files/server7.key \ 8757 hs_timeout=2500-60000 \ 8758 mtu=1024" \ 8759 "$P_CLI dtls=1 debug_level=2 \ 8760 crt_file=data_files/server8_int-ca2.crt \ 8761 key_file=data_files/server8.key \ 8762 hs_timeout=2500-60000 \ 8763 mtu=1024" \ 8764 0 \ 8765 -s "found fragmented DTLS handshake message" \ 8766 -c "found fragmented DTLS handshake message" \ 8767 -C "error" 8768 8769# Forcing ciphersuite for this test to fit the MTU of 512 with full config. 8770requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 8771requires_config_enabled MBEDTLS_RSA_C 8772requires_config_enabled MBEDTLS_ECDSA_C 8773requires_config_enabled MBEDTLS_SHA256_C 8774requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED 8775requires_config_enabled MBEDTLS_AES_C 8776requires_config_enabled MBEDTLS_GCM_C 8777requires_max_content_len 2048 8778run_test "DTLS fragmenting: both (MTU=512)" \ 8779 -p "$P_PXY mtu=512" \ 8780 "$P_SRV dtls=1 debug_level=2 auth_mode=required \ 8781 crt_file=data_files/server7_int-ca.crt \ 8782 key_file=data_files/server7.key \ 8783 hs_timeout=2500-60000 \ 8784 mtu=512" \ 8785 "$P_CLI dtls=1 debug_level=2 \ 8786 crt_file=data_files/server8_int-ca2.crt \ 8787 key_file=data_files/server8.key \ 8788 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ 8789 hs_timeout=2500-60000 \ 8790 mtu=512" \ 8791 0 \ 8792 -s "found fragmented DTLS handshake message" \ 8793 -c "found fragmented DTLS handshake message" \ 8794 -C "error" 8795 8796# Test for automatic MTU reduction on repeated resend. 8797# Forcing ciphersuite for this test to fit the MTU of 508 with full config. 8798# The ratio of max/min timeout should ideally equal 4 to accept two 8799# retransmissions, but in some cases (like both the server and client using 8800# fragmentation and auto-reduction) an extra retransmission might occur, 8801# hence the ratio of 8. 8802not_with_valgrind 8803requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 8804requires_config_enabled MBEDTLS_RSA_C 8805requires_config_enabled MBEDTLS_ECDSA_C 8806requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED 8807requires_config_enabled MBEDTLS_AES_C 8808requires_config_enabled MBEDTLS_GCM_C 8809requires_max_content_len 2048 8810run_test "DTLS fragmenting: proxy MTU: auto-reduction (not valgrind)" \ 8811 -p "$P_PXY mtu=508" \ 8812 "$P_SRV dtls=1 debug_level=2 auth_mode=required \ 8813 crt_file=data_files/server7_int-ca.crt \ 8814 key_file=data_files/server7.key \ 8815 hs_timeout=400-3200" \ 8816 "$P_CLI dtls=1 debug_level=2 \ 8817 crt_file=data_files/server8_int-ca2.crt \ 8818 key_file=data_files/server8.key \ 8819 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ 8820 hs_timeout=400-3200" \ 8821 0 \ 8822 -s "found fragmented DTLS handshake message" \ 8823 -c "found fragmented DTLS handshake message" \ 8824 -C "error" 8825 8826# Forcing ciphersuite for this test to fit the MTU of 508 with full config. 8827only_with_valgrind 8828requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 8829requires_config_enabled MBEDTLS_RSA_C 8830requires_config_enabled MBEDTLS_ECDSA_C 8831requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED 8832requires_config_enabled MBEDTLS_AES_C 8833requires_config_enabled MBEDTLS_GCM_C 8834requires_max_content_len 2048 8835run_test "DTLS fragmenting: proxy MTU: auto-reduction (with valgrind)" \ 8836 -p "$P_PXY mtu=508" \ 8837 "$P_SRV dtls=1 debug_level=2 auth_mode=required \ 8838 crt_file=data_files/server7_int-ca.crt \ 8839 key_file=data_files/server7.key \ 8840 hs_timeout=250-10000" \ 8841 "$P_CLI dtls=1 debug_level=2 \ 8842 crt_file=data_files/server8_int-ca2.crt \ 8843 key_file=data_files/server8.key \ 8844 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ 8845 hs_timeout=250-10000" \ 8846 0 \ 8847 -s "found fragmented DTLS handshake message" \ 8848 -c "found fragmented DTLS handshake message" \ 8849 -C "error" 8850 8851# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend 8852# OTOH the client might resend if the server is to slow to reset after sending 8853# a HelloVerifyRequest, so only check for no retransmission server-side 8854not_with_valgrind # spurious autoreduction due to timeout 8855requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 8856requires_config_enabled MBEDTLS_RSA_C 8857requires_config_enabled MBEDTLS_ECDSA_C 8858requires_max_content_len 2048 8859run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \ 8860 -p "$P_PXY mtu=1024" \ 8861 "$P_SRV dtls=1 debug_level=2 auth_mode=required \ 8862 crt_file=data_files/server7_int-ca.crt \ 8863 key_file=data_files/server7.key \ 8864 hs_timeout=10000-60000 \ 8865 mtu=1024" \ 8866 "$P_CLI dtls=1 debug_level=2 \ 8867 crt_file=data_files/server8_int-ca2.crt \ 8868 key_file=data_files/server8.key \ 8869 hs_timeout=10000-60000 \ 8870 mtu=1024" \ 8871 0 \ 8872 -S "autoreduction" \ 8873 -s "found fragmented DTLS handshake message" \ 8874 -c "found fragmented DTLS handshake message" \ 8875 -C "error" 8876 8877# Forcing ciphersuite for this test to fit the MTU of 512 with full config. 8878# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend 8879# OTOH the client might resend if the server is to slow to reset after sending 8880# a HelloVerifyRequest, so only check for no retransmission server-side 8881not_with_valgrind # spurious autoreduction due to timeout 8882requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 8883requires_config_enabled MBEDTLS_RSA_C 8884requires_config_enabled MBEDTLS_ECDSA_C 8885requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED 8886requires_config_enabled MBEDTLS_AES_C 8887requires_config_enabled MBEDTLS_GCM_C 8888requires_max_content_len 2048 8889run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \ 8890 -p "$P_PXY mtu=512" \ 8891 "$P_SRV dtls=1 debug_level=2 auth_mode=required \ 8892 crt_file=data_files/server7_int-ca.crt \ 8893 key_file=data_files/server7.key \ 8894 hs_timeout=10000-60000 \ 8895 mtu=512" \ 8896 "$P_CLI dtls=1 debug_level=2 \ 8897 crt_file=data_files/server8_int-ca2.crt \ 8898 key_file=data_files/server8.key \ 8899 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ 8900 hs_timeout=10000-60000 \ 8901 mtu=512" \ 8902 0 \ 8903 -S "autoreduction" \ 8904 -s "found fragmented DTLS handshake message" \ 8905 -c "found fragmented DTLS handshake message" \ 8906 -C "error" 8907 8908not_with_valgrind # spurious autoreduction due to timeout 8909requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 8910requires_config_enabled MBEDTLS_RSA_C 8911requires_config_enabled MBEDTLS_ECDSA_C 8912requires_max_content_len 2048 8913run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \ 8914 -p "$P_PXY mtu=1024" \ 8915 "$P_SRV dtls=1 debug_level=2 auth_mode=required \ 8916 crt_file=data_files/server7_int-ca.crt \ 8917 key_file=data_files/server7.key \ 8918 hs_timeout=10000-60000 \ 8919 mtu=1024 nbio=2" \ 8920 "$P_CLI dtls=1 debug_level=2 \ 8921 crt_file=data_files/server8_int-ca2.crt \ 8922 key_file=data_files/server8.key \ 8923 hs_timeout=10000-60000 \ 8924 mtu=1024 nbio=2" \ 8925 0 \ 8926 -S "autoreduction" \ 8927 -s "found fragmented DTLS handshake message" \ 8928 -c "found fragmented DTLS handshake message" \ 8929 -C "error" 8930 8931# Forcing ciphersuite for this test to fit the MTU of 512 with full config. 8932not_with_valgrind # spurious autoreduction due to timeout 8933requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 8934requires_config_enabled MBEDTLS_RSA_C 8935requires_config_enabled MBEDTLS_ECDSA_C 8936requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED 8937requires_config_enabled MBEDTLS_AES_C 8938requires_config_enabled MBEDTLS_GCM_C 8939requires_max_content_len 2048 8940run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \ 8941 -p "$P_PXY mtu=512" \ 8942 "$P_SRV dtls=1 debug_level=2 auth_mode=required \ 8943 crt_file=data_files/server7_int-ca.crt \ 8944 key_file=data_files/server7.key \ 8945 hs_timeout=10000-60000 \ 8946 mtu=512 nbio=2" \ 8947 "$P_CLI dtls=1 debug_level=2 \ 8948 crt_file=data_files/server8_int-ca2.crt \ 8949 key_file=data_files/server8.key \ 8950 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ 8951 hs_timeout=10000-60000 \ 8952 mtu=512 nbio=2" \ 8953 0 \ 8954 -S "autoreduction" \ 8955 -s "found fragmented DTLS handshake message" \ 8956 -c "found fragmented DTLS handshake message" \ 8957 -C "error" 8958 8959# Forcing ciphersuite for this test to fit the MTU of 1450 with full config. 8960# This ensures things still work after session_reset(). 8961# It also exercises the "resumed handshake" flow. 8962# Since we don't support reading fragmented ClientHello yet, 8963# up the MTU to 1450 (larger than ClientHello with session ticket, 8964# but still smaller than client's Certificate to ensure fragmentation). 8965# An autoreduction on the client-side might happen if the server is 8966# slow to reset, therefore omitting '-C "autoreduction"' below. 8967# reco_delay avoids races where the client reconnects before the server has 8968# resumed listening, which would result in a spurious autoreduction. 8969not_with_valgrind # spurious autoreduction due to timeout 8970requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 8971requires_config_enabled MBEDTLS_RSA_C 8972requires_config_enabled MBEDTLS_ECDSA_C 8973requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED 8974requires_config_enabled MBEDTLS_AES_C 8975requires_config_enabled MBEDTLS_GCM_C 8976requires_max_content_len 2048 8977run_test "DTLS fragmenting: proxy MTU, resumed handshake" \ 8978 -p "$P_PXY mtu=1450" \ 8979 "$P_SRV dtls=1 debug_level=2 auth_mode=required \ 8980 crt_file=data_files/server7_int-ca.crt \ 8981 key_file=data_files/server7.key \ 8982 hs_timeout=10000-60000 \ 8983 mtu=1450" \ 8984 "$P_CLI dtls=1 debug_level=2 \ 8985 crt_file=data_files/server8_int-ca2.crt \ 8986 key_file=data_files/server8.key \ 8987 hs_timeout=10000-60000 \ 8988 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ 8989 mtu=1450 reconnect=1 skip_close_notify=1 reco_delay=1" \ 8990 0 \ 8991 -S "autoreduction" \ 8992 -s "found fragmented DTLS handshake message" \ 8993 -c "found fragmented DTLS handshake message" \ 8994 -C "error" 8995 8996# An autoreduction on the client-side might happen if the server is 8997# slow to reset, therefore omitting '-C "autoreduction"' below. 8998not_with_valgrind # spurious autoreduction due to timeout 8999requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 9000requires_config_enabled MBEDTLS_RSA_C 9001requires_config_enabled MBEDTLS_ECDSA_C 9002requires_config_enabled MBEDTLS_SHA256_C 9003requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED 9004requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 9005requires_config_enabled MBEDTLS_CHACHAPOLY_C 9006requires_max_content_len 2048 9007run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \ 9008 -p "$P_PXY mtu=512" \ 9009 "$P_SRV dtls=1 debug_level=2 auth_mode=required \ 9010 crt_file=data_files/server7_int-ca.crt \ 9011 key_file=data_files/server7.key \ 9012 exchanges=2 renegotiation=1 \ 9013 hs_timeout=10000-60000 \ 9014 mtu=512" \ 9015 "$P_CLI dtls=1 debug_level=2 \ 9016 crt_file=data_files/server8_int-ca2.crt \ 9017 key_file=data_files/server8.key \ 9018 exchanges=2 renegotiation=1 renegotiate=1 \ 9019 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ 9020 hs_timeout=10000-60000 \ 9021 mtu=512" \ 9022 0 \ 9023 -S "autoreduction" \ 9024 -s "found fragmented DTLS handshake message" \ 9025 -c "found fragmented DTLS handshake message" \ 9026 -C "error" 9027 9028# An autoreduction on the client-side might happen if the server is 9029# slow to reset, therefore omitting '-C "autoreduction"' below. 9030not_with_valgrind # spurious autoreduction due to timeout 9031requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 9032requires_config_enabled MBEDTLS_RSA_C 9033requires_config_enabled MBEDTLS_ECDSA_C 9034requires_config_enabled MBEDTLS_SHA256_C 9035requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED 9036requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 9037requires_config_enabled MBEDTLS_AES_C 9038requires_config_enabled MBEDTLS_GCM_C 9039requires_max_content_len 2048 9040run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \ 9041 -p "$P_PXY mtu=512" \ 9042 "$P_SRV dtls=1 debug_level=2 auth_mode=required \ 9043 crt_file=data_files/server7_int-ca.crt \ 9044 key_file=data_files/server7.key \ 9045 exchanges=2 renegotiation=1 \ 9046 hs_timeout=10000-60000 \ 9047 mtu=512" \ 9048 "$P_CLI dtls=1 debug_level=2 \ 9049 crt_file=data_files/server8_int-ca2.crt \ 9050 key_file=data_files/server8.key \ 9051 exchanges=2 renegotiation=1 renegotiate=1 \ 9052 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ 9053 hs_timeout=10000-60000 \ 9054 mtu=512" \ 9055 0 \ 9056 -S "autoreduction" \ 9057 -s "found fragmented DTLS handshake message" \ 9058 -c "found fragmented DTLS handshake message" \ 9059 -C "error" 9060 9061# An autoreduction on the client-side might happen if the server is 9062# slow to reset, therefore omitting '-C "autoreduction"' below. 9063not_with_valgrind # spurious autoreduction due to timeout 9064requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 9065requires_config_enabled MBEDTLS_RSA_C 9066requires_config_enabled MBEDTLS_ECDSA_C 9067requires_config_enabled MBEDTLS_SHA256_C 9068requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED 9069requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 9070requires_config_enabled MBEDTLS_AES_C 9071requires_config_enabled MBEDTLS_CCM_C 9072requires_max_content_len 2048 9073run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \ 9074 -p "$P_PXY mtu=1024" \ 9075 "$P_SRV dtls=1 debug_level=2 auth_mode=required \ 9076 crt_file=data_files/server7_int-ca.crt \ 9077 key_file=data_files/server7.key \ 9078 exchanges=2 renegotiation=1 \ 9079 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \ 9080 hs_timeout=10000-60000 \ 9081 mtu=1024" \ 9082 "$P_CLI dtls=1 debug_level=2 \ 9083 crt_file=data_files/server8_int-ca2.crt \ 9084 key_file=data_files/server8.key \ 9085 exchanges=2 renegotiation=1 renegotiate=1 \ 9086 hs_timeout=10000-60000 \ 9087 mtu=1024" \ 9088 0 \ 9089 -S "autoreduction" \ 9090 -s "found fragmented DTLS handshake message" \ 9091 -c "found fragmented DTLS handshake message" \ 9092 -C "error" 9093 9094# An autoreduction on the client-side might happen if the server is 9095# slow to reset, therefore omitting '-C "autoreduction"' below. 9096not_with_valgrind # spurious autoreduction due to timeout 9097requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 9098requires_config_enabled MBEDTLS_RSA_C 9099requires_config_enabled MBEDTLS_ECDSA_C 9100requires_config_enabled MBEDTLS_SHA256_C 9101requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED 9102requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 9103requires_config_enabled MBEDTLS_AES_C 9104requires_config_enabled MBEDTLS_CIPHER_MODE_CBC 9105requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC 9106requires_max_content_len 2048 9107run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \ 9108 -p "$P_PXY mtu=1024" \ 9109 "$P_SRV dtls=1 debug_level=2 auth_mode=required \ 9110 crt_file=data_files/server7_int-ca.crt \ 9111 key_file=data_files/server7.key \ 9112 exchanges=2 renegotiation=1 \ 9113 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \ 9114 hs_timeout=10000-60000 \ 9115 mtu=1024" \ 9116 "$P_CLI dtls=1 debug_level=2 \ 9117 crt_file=data_files/server8_int-ca2.crt \ 9118 key_file=data_files/server8.key \ 9119 exchanges=2 renegotiation=1 renegotiate=1 \ 9120 hs_timeout=10000-60000 \ 9121 mtu=1024" \ 9122 0 \ 9123 -S "autoreduction" \ 9124 -s "found fragmented DTLS handshake message" \ 9125 -c "found fragmented DTLS handshake message" \ 9126 -C "error" 9127 9128# An autoreduction on the client-side might happen if the server is 9129# slow to reset, therefore omitting '-C "autoreduction"' below. 9130not_with_valgrind # spurious autoreduction due to timeout 9131requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 9132requires_config_enabled MBEDTLS_RSA_C 9133requires_config_enabled MBEDTLS_ECDSA_C 9134requires_config_enabled MBEDTLS_SHA256_C 9135requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED 9136requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 9137requires_config_enabled MBEDTLS_AES_C 9138requires_config_enabled MBEDTLS_CIPHER_MODE_CBC 9139requires_max_content_len 2048 9140run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \ 9141 -p "$P_PXY mtu=1024" \ 9142 "$P_SRV dtls=1 debug_level=2 auth_mode=required \ 9143 crt_file=data_files/server7_int-ca.crt \ 9144 key_file=data_files/server7.key \ 9145 exchanges=2 renegotiation=1 \ 9146 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \ 9147 hs_timeout=10000-60000 \ 9148 mtu=1024" \ 9149 "$P_CLI dtls=1 debug_level=2 \ 9150 crt_file=data_files/server8_int-ca2.crt \ 9151 key_file=data_files/server8.key \ 9152 exchanges=2 renegotiation=1 renegotiate=1 \ 9153 hs_timeout=10000-60000 \ 9154 mtu=1024" \ 9155 0 \ 9156 -S "autoreduction" \ 9157 -s "found fragmented DTLS handshake message" \ 9158 -c "found fragmented DTLS handshake message" \ 9159 -C "error" 9160 9161# Forcing ciphersuite for this test to fit the MTU of 512 with full config. 9162requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 9163requires_config_enabled MBEDTLS_RSA_C 9164requires_config_enabled MBEDTLS_ECDSA_C 9165requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED 9166requires_config_enabled MBEDTLS_AES_C 9167requires_config_enabled MBEDTLS_GCM_C 9168client_needs_more_time 2 9169requires_max_content_len 2048 9170run_test "DTLS fragmenting: proxy MTU + 3d" \ 9171 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \ 9172 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \ 9173 crt_file=data_files/server7_int-ca.crt \ 9174 key_file=data_files/server7.key \ 9175 hs_timeout=250-10000 mtu=512" \ 9176 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \ 9177 crt_file=data_files/server8_int-ca2.crt \ 9178 key_file=data_files/server8.key \ 9179 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ 9180 hs_timeout=250-10000 mtu=512" \ 9181 0 \ 9182 -s "found fragmented DTLS handshake message" \ 9183 -c "found fragmented DTLS handshake message" \ 9184 -C "error" 9185 9186# Forcing ciphersuite for this test to fit the MTU of 512 with full config. 9187requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 9188requires_config_enabled MBEDTLS_RSA_C 9189requires_config_enabled MBEDTLS_ECDSA_C 9190requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED 9191requires_config_enabled MBEDTLS_AES_C 9192requires_config_enabled MBEDTLS_GCM_C 9193client_needs_more_time 2 9194requires_max_content_len 2048 9195run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \ 9196 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \ 9197 "$P_SRV dtls=1 debug_level=2 auth_mode=required \ 9198 crt_file=data_files/server7_int-ca.crt \ 9199 key_file=data_files/server7.key \ 9200 hs_timeout=250-10000 mtu=512 nbio=2" \ 9201 "$P_CLI dtls=1 debug_level=2 \ 9202 crt_file=data_files/server8_int-ca2.crt \ 9203 key_file=data_files/server8.key \ 9204 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ 9205 hs_timeout=250-10000 mtu=512 nbio=2" \ 9206 0 \ 9207 -s "found fragmented DTLS handshake message" \ 9208 -c "found fragmented DTLS handshake message" \ 9209 -C "error" 9210 9211# interop tests for DTLS fragmentating with reliable connection 9212# 9213# here and below we just want to test that the we fragment in a way that 9214# pleases other implementations, so we don't need the peer to fragment 9215requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 9216requires_config_enabled MBEDTLS_RSA_C 9217requires_config_enabled MBEDTLS_ECDSA_C 9218requires_gnutls 9219requires_max_content_len 2048 9220run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \ 9221 "$G_SRV -u" \ 9222 "$P_CLI dtls=1 debug_level=2 \ 9223 crt_file=data_files/server8_int-ca2.crt \ 9224 key_file=data_files/server8.key \ 9225 mtu=512 force_version=dtls12" \ 9226 0 \ 9227 -c "fragmenting handshake message" \ 9228 -C "error" 9229 9230requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 9231requires_config_enabled MBEDTLS_RSA_C 9232requires_config_enabled MBEDTLS_ECDSA_C 9233requires_gnutls 9234requires_max_content_len 2048 9235run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \ 9236 "$G_SRV -u" \ 9237 "$P_CLI dtls=1 debug_level=2 \ 9238 crt_file=data_files/server8_int-ca2.crt \ 9239 key_file=data_files/server8.key \ 9240 mtu=512 force_version=dtls1" \ 9241 0 \ 9242 -c "fragmenting handshake message" \ 9243 -C "error" 9244 9245# We use --insecure for the GnuTLS client because it expects 9246# the hostname / IP it connects to to be the name used in the 9247# certificate obtained from the server. Here, however, it 9248# connects to 127.0.0.1 while our test certificates use 'localhost' 9249# as the server name in the certificate. This will make the 9250# certificate validation fail, but passing --insecure makes 9251# GnuTLS continue the connection nonetheless. 9252requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 9253requires_config_enabled MBEDTLS_RSA_C 9254requires_config_enabled MBEDTLS_ECDSA_C 9255requires_gnutls 9256requires_not_i686 9257requires_max_content_len 2048 9258run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \ 9259 "$P_SRV dtls=1 debug_level=2 \ 9260 crt_file=data_files/server7_int-ca.crt \ 9261 key_file=data_files/server7.key \ 9262 mtu=512 force_version=dtls12" \ 9263 "$G_CLI -u --insecure 127.0.0.1" \ 9264 0 \ 9265 -s "fragmenting handshake message" 9266 9267# See previous test for the reason to use --insecure 9268requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 9269requires_config_enabled MBEDTLS_RSA_C 9270requires_config_enabled MBEDTLS_ECDSA_C 9271requires_gnutls 9272requires_not_i686 9273requires_max_content_len 2048 9274run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \ 9275 "$P_SRV dtls=1 debug_level=2 \ 9276 crt_file=data_files/server7_int-ca.crt \ 9277 key_file=data_files/server7.key \ 9278 mtu=512 force_version=dtls1" \ 9279 "$G_CLI -u --insecure 127.0.0.1" \ 9280 0 \ 9281 -s "fragmenting handshake message" 9282 9283requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 9284requires_config_enabled MBEDTLS_RSA_C 9285requires_config_enabled MBEDTLS_ECDSA_C 9286requires_max_content_len 2048 9287run_test "DTLS fragmenting: openssl server, DTLS 1.2" \ 9288 "$O_SRV -dtls1_2 -verify 10" \ 9289 "$P_CLI dtls=1 debug_level=2 \ 9290 crt_file=data_files/server8_int-ca2.crt \ 9291 key_file=data_files/server8.key \ 9292 mtu=512 force_version=dtls12" \ 9293 0 \ 9294 -c "fragmenting handshake message" \ 9295 -C "error" 9296 9297requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 9298requires_config_enabled MBEDTLS_RSA_C 9299requires_config_enabled MBEDTLS_ECDSA_C 9300requires_max_content_len 2048 9301run_test "DTLS fragmenting: openssl server, DTLS 1.0" \ 9302 "$O_SRV -dtls1 -verify 10" \ 9303 "$P_CLI dtls=1 debug_level=2 \ 9304 crt_file=data_files/server8_int-ca2.crt \ 9305 key_file=data_files/server8.key \ 9306 mtu=512 force_version=dtls1" \ 9307 0 \ 9308 -c "fragmenting handshake message" \ 9309 -C "error" 9310 9311requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 9312requires_config_enabled MBEDTLS_RSA_C 9313requires_config_enabled MBEDTLS_ECDSA_C 9314requires_max_content_len 2048 9315run_test "DTLS fragmenting: openssl client, DTLS 1.2" \ 9316 "$P_SRV dtls=1 debug_level=2 \ 9317 crt_file=data_files/server7_int-ca.crt \ 9318 key_file=data_files/server7.key \ 9319 mtu=512 force_version=dtls12" \ 9320 "$O_CLI -dtls1_2" \ 9321 0 \ 9322 -s "fragmenting handshake message" 9323 9324requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 9325requires_config_enabled MBEDTLS_RSA_C 9326requires_config_enabled MBEDTLS_ECDSA_C 9327requires_max_content_len 2048 9328run_test "DTLS fragmenting: openssl client, DTLS 1.0" \ 9329 "$P_SRV dtls=1 debug_level=2 \ 9330 crt_file=data_files/server7_int-ca.crt \ 9331 key_file=data_files/server7.key \ 9332 mtu=512 force_version=dtls1" \ 9333 "$O_CLI -dtls1" \ 9334 0 \ 9335 -s "fragmenting handshake message" 9336 9337# interop tests for DTLS fragmentating with unreliable connection 9338# 9339# again we just want to test that the we fragment in a way that 9340# pleases other implementations, so we don't need the peer to fragment 9341requires_gnutls_next 9342requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 9343requires_config_enabled MBEDTLS_RSA_C 9344requires_config_enabled MBEDTLS_ECDSA_C 9345client_needs_more_time 4 9346requires_max_content_len 2048 9347run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \ 9348 -p "$P_PXY drop=8 delay=8 duplicate=8" \ 9349 "$G_NEXT_SRV -u" \ 9350 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \ 9351 crt_file=data_files/server8_int-ca2.crt \ 9352 key_file=data_files/server8.key \ 9353 hs_timeout=250-60000 mtu=512 force_version=dtls12" \ 9354 0 \ 9355 -c "fragmenting handshake message" \ 9356 -C "error" 9357 9358requires_gnutls_next 9359requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 9360requires_config_enabled MBEDTLS_RSA_C 9361requires_config_enabled MBEDTLS_ECDSA_C 9362client_needs_more_time 4 9363requires_max_content_len 2048 9364run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \ 9365 -p "$P_PXY drop=8 delay=8 duplicate=8" \ 9366 "$G_NEXT_SRV -u" \ 9367 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \ 9368 crt_file=data_files/server8_int-ca2.crt \ 9369 key_file=data_files/server8.key \ 9370 hs_timeout=250-60000 mtu=512 force_version=dtls1" \ 9371 0 \ 9372 -c "fragmenting handshake message" \ 9373 -C "error" 9374 9375requires_gnutls_next 9376requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 9377requires_config_enabled MBEDTLS_RSA_C 9378requires_config_enabled MBEDTLS_ECDSA_C 9379client_needs_more_time 4 9380requires_max_content_len 2048 9381run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \ 9382 -p "$P_PXY drop=8 delay=8 duplicate=8" \ 9383 "$P_SRV dtls=1 debug_level=2 \ 9384 crt_file=data_files/server7_int-ca.crt \ 9385 key_file=data_files/server7.key \ 9386 hs_timeout=250-60000 mtu=512 force_version=dtls12" \ 9387 "$G_NEXT_CLI -u --insecure 127.0.0.1" \ 9388 0 \ 9389 -s "fragmenting handshake message" 9390 9391requires_gnutls_next 9392requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 9393requires_config_enabled MBEDTLS_RSA_C 9394requires_config_enabled MBEDTLS_ECDSA_C 9395client_needs_more_time 4 9396requires_max_content_len 2048 9397run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \ 9398 -p "$P_PXY drop=8 delay=8 duplicate=8" \ 9399 "$P_SRV dtls=1 debug_level=2 \ 9400 crt_file=data_files/server7_int-ca.crt \ 9401 key_file=data_files/server7.key \ 9402 hs_timeout=250-60000 mtu=512 force_version=dtls1" \ 9403 "$G_NEXT_CLI -u --insecure 127.0.0.1" \ 9404 0 \ 9405 -s "fragmenting handshake message" 9406 9407## The two tests below require 1.1.1a or higher version of openssl, otherwise 9408## it might trigger a bug due to openssl (https://github.com/openssl/openssl/issues/6902) 9409requires_openssl_next 9410requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 9411requires_config_enabled MBEDTLS_RSA_C 9412requires_config_enabled MBEDTLS_ECDSA_C 9413client_needs_more_time 4 9414requires_max_content_len 2048 9415run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \ 9416 -p "$P_PXY drop=8 delay=8 duplicate=8" \ 9417 "$O_NEXT_SRV -dtls1_2 -verify 10" \ 9418 "$P_CLI dtls=1 debug_level=2 \ 9419 crt_file=data_files/server8_int-ca2.crt \ 9420 key_file=data_files/server8.key \ 9421 hs_timeout=250-60000 mtu=512 force_version=dtls12" \ 9422 0 \ 9423 -c "fragmenting handshake message" \ 9424 -C "error" 9425 9426requires_openssl_next 9427requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 9428requires_config_enabled MBEDTLS_RSA_C 9429requires_config_enabled MBEDTLS_ECDSA_C 9430client_needs_more_time 4 9431requires_max_content_len 2048 9432run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \ 9433 -p "$P_PXY drop=8 delay=8 duplicate=8" \ 9434 "$O_NEXT_SRV -dtls1 -verify 10" \ 9435 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \ 9436 crt_file=data_files/server8_int-ca2.crt \ 9437 key_file=data_files/server8.key \ 9438 hs_timeout=250-60000 mtu=512 force_version=dtls1" \ 9439 0 \ 9440 -c "fragmenting handshake message" \ 9441 -C "error" 9442 9443## the two tests below will time out with certain seed. 9444## The cause is an openssl bug (https://github.com/openssl/openssl/issues/18887) 9445skip_next_test 9446requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 9447requires_config_enabled MBEDTLS_RSA_C 9448requires_config_enabled MBEDTLS_ECDSA_C 9449client_needs_more_time 4 9450requires_max_content_len 2048 9451run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \ 9452 -p "$P_PXY drop=8 delay=8 duplicate=8" \ 9453 "$P_SRV dtls=1 debug_level=2 \ 9454 crt_file=data_files/server7_int-ca.crt \ 9455 key_file=data_files/server7.key \ 9456 hs_timeout=250-60000 mtu=512 force_version=dtls12" \ 9457 "$O_CLI -dtls1_2" \ 9458 0 \ 9459 -s "fragmenting handshake message" 9460 9461# -nbio is added to prevent s_client from blocking in case of duplicated 9462# messages at the end of the handshake 9463skip_next_test 9464requires_config_enabled MBEDTLS_SSL_PROTO_DTLS 9465requires_config_enabled MBEDTLS_RSA_C 9466requires_config_enabled MBEDTLS_ECDSA_C 9467client_needs_more_time 4 9468requires_max_content_len 2048 9469run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \ 9470 -p "$P_PXY drop=8 delay=8 duplicate=8" \ 9471 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \ 9472 crt_file=data_files/server7_int-ca.crt \ 9473 key_file=data_files/server7.key \ 9474 hs_timeout=250-60000 mtu=512 force_version=dtls1" \ 9475 "$O_CLI -nbio -dtls1" \ 9476 0 \ 9477 -s "fragmenting handshake message" 9478 9479# Tests for DTLS-SRTP (RFC 5764) 9480requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9481run_test "DTLS-SRTP all profiles supported" \ 9482 "$P_SRV dtls=1 use_srtp=1 debug_level=3" \ 9483 "$P_CLI dtls=1 use_srtp=1 debug_level=3" \ 9484 0 \ 9485 -s "found use_srtp extension" \ 9486 -s "found srtp profile" \ 9487 -s "selected srtp profile" \ 9488 -s "server hello, adding use_srtp extension" \ 9489 -s "DTLS-SRTP key material is"\ 9490 -c "client hello, adding use_srtp extension" \ 9491 -c "found use_srtp extension" \ 9492 -c "found srtp profile" \ 9493 -c "selected srtp profile" \ 9494 -c "DTLS-SRTP key material is"\ 9495 -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\ 9496 -C "error" 9497 9498 9499requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9500run_test "DTLS-SRTP server supports all profiles. Client supports one profile." \ 9501 "$P_SRV dtls=1 use_srtp=1 debug_level=3" \ 9502 "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=5 debug_level=3" \ 9503 0 \ 9504 -s "found use_srtp extension" \ 9505 -s "found srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_80" \ 9506 -s "selected srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_80" \ 9507 -s "server hello, adding use_srtp extension" \ 9508 -s "DTLS-SRTP key material is"\ 9509 -c "client hello, adding use_srtp extension" \ 9510 -c "found use_srtp extension" \ 9511 -c "found srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_80" \ 9512 -c "selected srtp profile" \ 9513 -c "DTLS-SRTP key material is"\ 9514 -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\ 9515 -C "error" 9516 9517requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9518run_test "DTLS-SRTP server supports one profile. Client supports all profiles." \ 9519 "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=6 debug_level=3" \ 9520 "$P_CLI dtls=1 use_srtp=1 debug_level=3" \ 9521 0 \ 9522 -s "found use_srtp extension" \ 9523 -s "found srtp profile" \ 9524 -s "selected srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_32" \ 9525 -s "server hello, adding use_srtp extension" \ 9526 -s "DTLS-SRTP key material is"\ 9527 -c "client hello, adding use_srtp extension" \ 9528 -c "found use_srtp extension" \ 9529 -c "found srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_32" \ 9530 -c "selected srtp profile" \ 9531 -c "DTLS-SRTP key material is"\ 9532 -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\ 9533 -C "error" 9534 9535requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9536run_test "DTLS-SRTP server and Client support only one matching profile." \ 9537 "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \ 9538 "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \ 9539 0 \ 9540 -s "found use_srtp extension" \ 9541 -s "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \ 9542 -s "selected srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \ 9543 -s "server hello, adding use_srtp extension" \ 9544 -s "DTLS-SRTP key material is"\ 9545 -c "client hello, adding use_srtp extension" \ 9546 -c "found use_srtp extension" \ 9547 -c "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \ 9548 -c "selected srtp profile" \ 9549 -c "DTLS-SRTP key material is"\ 9550 -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\ 9551 -C "error" 9552 9553requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9554run_test "DTLS-SRTP server and Client support only one different profile." \ 9555 "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \ 9556 "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=6 debug_level=3" \ 9557 0 \ 9558 -s "found use_srtp extension" \ 9559 -s "found srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_32" \ 9560 -S "selected srtp profile" \ 9561 -S "server hello, adding use_srtp extension" \ 9562 -S "DTLS-SRTP key material is"\ 9563 -c "client hello, adding use_srtp extension" \ 9564 -C "found use_srtp extension" \ 9565 -C "found srtp profile" \ 9566 -C "selected srtp profile" \ 9567 -C "DTLS-SRTP key material is"\ 9568 -C "error" 9569 9570requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9571run_test "DTLS-SRTP server doesn't support use_srtp extension." \ 9572 "$P_SRV dtls=1 debug_level=3" \ 9573 "$P_CLI dtls=1 use_srtp=1 debug_level=3" \ 9574 0 \ 9575 -s "found use_srtp extension" \ 9576 -S "server hello, adding use_srtp extension" \ 9577 -S "DTLS-SRTP key material is"\ 9578 -c "client hello, adding use_srtp extension" \ 9579 -C "found use_srtp extension" \ 9580 -C "found srtp profile" \ 9581 -C "selected srtp profile" \ 9582 -C "DTLS-SRTP key material is"\ 9583 -C "error" 9584 9585requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9586run_test "DTLS-SRTP all profiles supported. mki used" \ 9587 "$P_SRV dtls=1 use_srtp=1 support_mki=1 debug_level=3" \ 9588 "$P_CLI dtls=1 use_srtp=1 mki=542310ab34290481 debug_level=3" \ 9589 0 \ 9590 -s "found use_srtp extension" \ 9591 -s "found srtp profile" \ 9592 -s "selected srtp profile" \ 9593 -s "server hello, adding use_srtp extension" \ 9594 -s "dumping 'using mki' (8 bytes)" \ 9595 -s "DTLS-SRTP key material is"\ 9596 -c "client hello, adding use_srtp extension" \ 9597 -c "found use_srtp extension" \ 9598 -c "found srtp profile" \ 9599 -c "selected srtp profile" \ 9600 -c "dumping 'sending mki' (8 bytes)" \ 9601 -c "dumping 'received mki' (8 bytes)" \ 9602 -c "DTLS-SRTP key material is"\ 9603 -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\ 9604 -g "find_in_both '^ *DTLS-SRTP mki value: [0-9A-F]*$'"\ 9605 -C "error" 9606 9607requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9608run_test "DTLS-SRTP all profiles supported. server doesn't support mki." \ 9609 "$P_SRV dtls=1 use_srtp=1 debug_level=3" \ 9610 "$P_CLI dtls=1 use_srtp=1 mki=542310ab34290481 debug_level=3" \ 9611 0 \ 9612 -s "found use_srtp extension" \ 9613 -s "found srtp profile" \ 9614 -s "selected srtp profile" \ 9615 -s "server hello, adding use_srtp extension" \ 9616 -s "DTLS-SRTP key material is"\ 9617 -s "DTLS-SRTP no mki value negotiated"\ 9618 -S "dumping 'using mki' (8 bytes)" \ 9619 -c "client hello, adding use_srtp extension" \ 9620 -c "found use_srtp extension" \ 9621 -c "found srtp profile" \ 9622 -c "selected srtp profile" \ 9623 -c "DTLS-SRTP key material is"\ 9624 -c "DTLS-SRTP no mki value negotiated"\ 9625 -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\ 9626 -c "dumping 'sending mki' (8 bytes)" \ 9627 -C "dumping 'received mki' (8 bytes)" \ 9628 -C "error" 9629 9630requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9631run_test "DTLS-SRTP all profiles supported. openssl client." \ 9632 "$P_SRV dtls=1 use_srtp=1 debug_level=3" \ 9633 "$O_CLI -dtls1 -use_srtp SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \ 9634 0 \ 9635 -s "found use_srtp extension" \ 9636 -s "found srtp profile" \ 9637 -s "selected srtp profile" \ 9638 -s "server hello, adding use_srtp extension" \ 9639 -s "DTLS-SRTP key material is"\ 9640 -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\ 9641 -c "SRTP Extension negotiated, profile=SRTP_AES128_CM_SHA1_80" 9642 9643requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9644run_test "DTLS-SRTP server supports all profiles. Client supports all profiles, in different order. openssl client." \ 9645 "$P_SRV dtls=1 use_srtp=1 debug_level=3" \ 9646 "$O_CLI -dtls1 -use_srtp SRTP_AES128_CM_SHA1_32:SRTP_AES128_CM_SHA1_80 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \ 9647 0 \ 9648 -s "found use_srtp extension" \ 9649 -s "found srtp profile" \ 9650 -s "selected srtp profile" \ 9651 -s "server hello, adding use_srtp extension" \ 9652 -s "DTLS-SRTP key material is"\ 9653 -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\ 9654 -c "SRTP Extension negotiated, profile=SRTP_AES128_CM_SHA1_32" 9655 9656requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9657run_test "DTLS-SRTP server supports all profiles. Client supports one profile. openssl client." \ 9658 "$P_SRV dtls=1 use_srtp=1 debug_level=3" \ 9659 "$O_CLI -dtls1 -use_srtp SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \ 9660 0 \ 9661 -s "found use_srtp extension" \ 9662 -s "found srtp profile" \ 9663 -s "selected srtp profile" \ 9664 -s "server hello, adding use_srtp extension" \ 9665 -s "DTLS-SRTP key material is"\ 9666 -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\ 9667 -c "SRTP Extension negotiated, profile=SRTP_AES128_CM_SHA1_32" 9668 9669requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9670run_test "DTLS-SRTP server supports one profile. Client supports all profiles. openssl client." \ 9671 "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \ 9672 "$O_CLI -dtls1 -use_srtp SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \ 9673 0 \ 9674 -s "found use_srtp extension" \ 9675 -s "found srtp profile" \ 9676 -s "selected srtp profile" \ 9677 -s "server hello, adding use_srtp extension" \ 9678 -s "DTLS-SRTP key material is"\ 9679 -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\ 9680 -c "SRTP Extension negotiated, profile=SRTP_AES128_CM_SHA1_32" 9681 9682requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9683run_test "DTLS-SRTP server and Client support only one matching profile. openssl client." \ 9684 "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \ 9685 "$O_CLI -dtls1 -use_srtp SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \ 9686 0 \ 9687 -s "found use_srtp extension" \ 9688 -s "found srtp profile" \ 9689 -s "selected srtp profile" \ 9690 -s "server hello, adding use_srtp extension" \ 9691 -s "DTLS-SRTP key material is"\ 9692 -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\ 9693 -c "SRTP Extension negotiated, profile=SRTP_AES128_CM_SHA1_32" 9694 9695requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9696run_test "DTLS-SRTP server and Client support only one different profile. openssl client." \ 9697 "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=1 debug_level=3" \ 9698 "$O_CLI -dtls1 -use_srtp SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \ 9699 0 \ 9700 -s "found use_srtp extension" \ 9701 -s "found srtp profile" \ 9702 -S "selected srtp profile" \ 9703 -S "server hello, adding use_srtp extension" \ 9704 -S "DTLS-SRTP key material is"\ 9705 -C "SRTP Extension negotiated, profile" 9706 9707requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9708run_test "DTLS-SRTP server doesn't support use_srtp extension. openssl client" \ 9709 "$P_SRV dtls=1 debug_level=3" \ 9710 "$O_CLI -dtls1 -use_srtp SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \ 9711 0 \ 9712 -s "found use_srtp extension" \ 9713 -S "server hello, adding use_srtp extension" \ 9714 -S "DTLS-SRTP key material is"\ 9715 -C "SRTP Extension negotiated, profile" 9716 9717requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9718run_test "DTLS-SRTP all profiles supported. openssl server" \ 9719 "$O_SRV -dtls1 -verify 0 -use_srtp SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \ 9720 "$P_CLI dtls=1 use_srtp=1 debug_level=3" \ 9721 0 \ 9722 -c "client hello, adding use_srtp extension" \ 9723 -c "found use_srtp extension" \ 9724 -c "found srtp profile" \ 9725 -c "selected srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_80" \ 9726 -c "DTLS-SRTP key material is"\ 9727 -C "error" 9728 9729requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9730run_test "DTLS-SRTP server supports all profiles. Client supports all profiles, in different order. openssl server." \ 9731 "$O_SRV -dtls1 -verify 0 -use_srtp SRTP_AES128_CM_SHA1_32:SRTP_AES128_CM_SHA1_80 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \ 9732 "$P_CLI dtls=1 use_srtp=1 debug_level=3" \ 9733 0 \ 9734 -c "client hello, adding use_srtp extension" \ 9735 -c "found use_srtp extension" \ 9736 -c "found srtp profile" \ 9737 -c "selected srtp profile" \ 9738 -c "DTLS-SRTP key material is"\ 9739 -C "error" 9740 9741requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9742run_test "DTLS-SRTP server supports all profiles. Client supports one profile. openssl server." \ 9743 "$O_SRV -dtls1 -verify 0 -use_srtp SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \ 9744 "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \ 9745 0 \ 9746 -c "client hello, adding use_srtp extension" \ 9747 -c "found use_srtp extension" \ 9748 -c "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \ 9749 -c "selected srtp profile" \ 9750 -c "DTLS-SRTP key material is"\ 9751 -C "error" 9752 9753requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9754run_test "DTLS-SRTP server supports one profile. Client supports all profiles. openssl server." \ 9755 "$O_SRV -dtls1 -verify 0 -use_srtp SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \ 9756 "$P_CLI dtls=1 use_srtp=1 debug_level=3" \ 9757 0 \ 9758 -c "client hello, adding use_srtp extension" \ 9759 -c "found use_srtp extension" \ 9760 -c "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \ 9761 -c "selected srtp profile" \ 9762 -c "DTLS-SRTP key material is"\ 9763 -C "error" 9764 9765requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9766run_test "DTLS-SRTP server and Client support only one matching profile. openssl server." \ 9767 "$O_SRV -dtls1 -verify 0 -use_srtp SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \ 9768 "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \ 9769 0 \ 9770 -c "client hello, adding use_srtp extension" \ 9771 -c "found use_srtp extension" \ 9772 -c "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \ 9773 -c "selected srtp profile" \ 9774 -c "DTLS-SRTP key material is"\ 9775 -C "error" 9776 9777requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9778run_test "DTLS-SRTP server and Client support only one different profile. openssl server." \ 9779 "$O_SRV -dtls1 -verify 0 -use_srtp SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \ 9780 "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=6 debug_level=3" \ 9781 0 \ 9782 -c "client hello, adding use_srtp extension" \ 9783 -C "found use_srtp extension" \ 9784 -C "found srtp profile" \ 9785 -C "selected srtp profile" \ 9786 -C "DTLS-SRTP key material is"\ 9787 -C "error" 9788 9789requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9790run_test "DTLS-SRTP server doesn't support use_srtp extension. openssl server" \ 9791 "$O_SRV -dtls1" \ 9792 "$P_CLI dtls=1 use_srtp=1 debug_level=3" \ 9793 0 \ 9794 -c "client hello, adding use_srtp extension" \ 9795 -C "found use_srtp extension" \ 9796 -C "found srtp profile" \ 9797 -C "selected srtp profile" \ 9798 -C "DTLS-SRTP key material is"\ 9799 -C "error" 9800 9801requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9802run_test "DTLS-SRTP all profiles supported. server doesn't support mki. openssl server." \ 9803 "$O_SRV -dtls1 -verify 0 -use_srtp SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \ 9804 "$P_CLI dtls=1 use_srtp=1 mki=542310ab34290481 debug_level=3" \ 9805 0 \ 9806 -c "client hello, adding use_srtp extension" \ 9807 -c "found use_srtp extension" \ 9808 -c "found srtp profile" \ 9809 -c "selected srtp profile" \ 9810 -c "DTLS-SRTP key material is"\ 9811 -c "DTLS-SRTP no mki value negotiated"\ 9812 -c "dumping 'sending mki' (8 bytes)" \ 9813 -C "dumping 'received mki' (8 bytes)" \ 9814 -C "error" 9815 9816requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9817requires_gnutls 9818run_test "DTLS-SRTP all profiles supported. gnutls client." \ 9819 "$P_SRV dtls=1 use_srtp=1 debug_level=3" \ 9820 "$G_CLI -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_80:SRTP_AES128_CM_HMAC_SHA1_32:SRTP_NULL_HMAC_SHA1_80:SRTP_NULL_SHA1_32 --insecure 127.0.0.1" \ 9821 0 \ 9822 -s "found use_srtp extension" \ 9823 -s "found srtp profile" \ 9824 -s "selected srtp profile" \ 9825 -s "server hello, adding use_srtp extension" \ 9826 -s "DTLS-SRTP key material is"\ 9827 -c "SRTP profile: SRTP_AES128_CM_HMAC_SHA1_80" 9828 9829requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9830requires_gnutls 9831run_test "DTLS-SRTP server supports all profiles. Client supports all profiles, in different order. gnutls client." \ 9832 "$P_SRV dtls=1 use_srtp=1 debug_level=3" \ 9833 "$G_CLI -u --srtp-profiles=SRTP_NULL_HMAC_SHA1_80:SRTP_AES128_CM_HMAC_SHA1_80:SRTP_NULL_SHA1_32:SRTP_AES128_CM_HMAC_SHA1_32 --insecure 127.0.0.1" \ 9834 0 \ 9835 -s "found use_srtp extension" \ 9836 -s "found srtp profile" \ 9837 -s "selected srtp profile" \ 9838 -s "server hello, adding use_srtp extension" \ 9839 -s "DTLS-SRTP key material is"\ 9840 -c "SRTP profile: SRTP_NULL_HMAC_SHA1_80" 9841 9842requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9843requires_gnutls 9844run_test "DTLS-SRTP server supports all profiles. Client supports one profile. gnutls client." \ 9845 "$P_SRV dtls=1 use_srtp=1 debug_level=3" \ 9846 "$G_CLI -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_32 --insecure 127.0.0.1" \ 9847 0 \ 9848 -s "found use_srtp extension" \ 9849 -s "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \ 9850 -s "selected srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \ 9851 -s "server hello, adding use_srtp extension" \ 9852 -s "DTLS-SRTP key material is"\ 9853 -c "SRTP profile: SRTP_AES128_CM_HMAC_SHA1_32" 9854 9855requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9856requires_gnutls 9857run_test "DTLS-SRTP server supports one profile. Client supports all profiles. gnutls client." \ 9858 "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=6 debug_level=3" \ 9859 "$G_CLI -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_80:SRTP_AES128_CM_HMAC_SHA1_32:SRTP_NULL_HMAC_SHA1_80:SRTP_NULL_SHA1_32 --insecure 127.0.0.1" \ 9860 0 \ 9861 -s "found use_srtp extension" \ 9862 -s "found srtp profile" \ 9863 -s "selected srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_32" \ 9864 -s "server hello, adding use_srtp extension" \ 9865 -s "DTLS-SRTP key material is"\ 9866 -c "SRTP profile: SRTP_NULL_SHA1_32" 9867 9868requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9869requires_gnutls 9870run_test "DTLS-SRTP server and Client support only one matching profile. gnutls client." \ 9871 "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \ 9872 "$G_CLI -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_32 --insecure 127.0.0.1" \ 9873 0 \ 9874 -s "found use_srtp extension" \ 9875 -s "found srtp profile" \ 9876 -s "selected srtp profile" \ 9877 -s "server hello, adding use_srtp extension" \ 9878 -s "DTLS-SRTP key material is"\ 9879 -c "SRTP profile: SRTP_AES128_CM_HMAC_SHA1_32" 9880 9881requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9882requires_gnutls 9883run_test "DTLS-SRTP server and Client support only one different profile. gnutls client." \ 9884 "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=1 debug_level=3" \ 9885 "$G_CLI -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_32 --insecure 127.0.0.1" \ 9886 0 \ 9887 -s "found use_srtp extension" \ 9888 -s "found srtp profile" \ 9889 -S "selected srtp profile" \ 9890 -S "server hello, adding use_srtp extension" \ 9891 -S "DTLS-SRTP key material is"\ 9892 -C "SRTP profile:" 9893 9894requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9895requires_gnutls 9896run_test "DTLS-SRTP server doesn't support use_srtp extension. gnutls client" \ 9897 "$P_SRV dtls=1 debug_level=3" \ 9898 "$G_CLI -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_80:SRTP_AES128_CM_HMAC_SHA1_32:SRTP_NULL_HMAC_SHA1_80:SRTP_NULL_SHA1_32 --insecure 127.0.0.1" \ 9899 0 \ 9900 -s "found use_srtp extension" \ 9901 -S "server hello, adding use_srtp extension" \ 9902 -S "DTLS-SRTP key material is"\ 9903 -C "SRTP profile:" 9904 9905requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9906requires_gnutls 9907run_test "DTLS-SRTP all profiles supported. gnutls server" \ 9908 "$G_SRV -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_80:SRTP_AES128_CM_HMAC_SHA1_32:SRTP_NULL_HMAC_SHA1_80:SRTP_NULL_SHA1_32" \ 9909 "$P_CLI dtls=1 use_srtp=1 debug_level=3" \ 9910 0 \ 9911 -c "client hello, adding use_srtp extension" \ 9912 -c "found use_srtp extension" \ 9913 -c "found srtp profile" \ 9914 -c "selected srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_80" \ 9915 -c "DTLS-SRTP key material is"\ 9916 -C "error" 9917 9918requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9919requires_gnutls 9920run_test "DTLS-SRTP server supports all profiles. Client supports all profiles, in different order. gnutls server." \ 9921 "$G_SRV -u --srtp-profiles=SRTP_NULL_SHA1_32:SRTP_AES128_CM_HMAC_SHA1_32:SRTP_AES128_CM_HMAC_SHA1_80:SRTP_NULL_HMAC_SHA1_80:SRTP_NULL_SHA1_32" \ 9922 "$P_CLI dtls=1 use_srtp=1 debug_level=3" \ 9923 0 \ 9924 -c "client hello, adding use_srtp extension" \ 9925 -c "found use_srtp extension" \ 9926 -c "found srtp profile" \ 9927 -c "selected srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_80" \ 9928 -c "DTLS-SRTP key material is"\ 9929 -C "error" 9930 9931requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9932requires_gnutls 9933run_test "DTLS-SRTP server supports all profiles. Client supports one profile. gnutls server." \ 9934 "$G_SRV -u --srtp-profiles=SRTP_NULL_SHA1_32:SRTP_AES128_CM_HMAC_SHA1_32:SRTP_AES128_CM_HMAC_SHA1_80:SRTP_NULL_HMAC_SHA1_80:SRTP_NULL_SHA1_32" \ 9935 "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \ 9936 0 \ 9937 -c "client hello, adding use_srtp extension" \ 9938 -c "found use_srtp extension" \ 9939 -c "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \ 9940 -c "selected srtp profile" \ 9941 -c "DTLS-SRTP key material is"\ 9942 -C "error" 9943 9944requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9945requires_gnutls 9946run_test "DTLS-SRTP server supports one profile. Client supports all profiles. gnutls server." \ 9947 "$G_SRV -u --srtp-profiles=SRTP_NULL_HMAC_SHA1_80" \ 9948 "$P_CLI dtls=1 use_srtp=1 debug_level=3" \ 9949 0 \ 9950 -c "client hello, adding use_srtp extension" \ 9951 -c "found use_srtp extension" \ 9952 -c "found srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_80" \ 9953 -c "selected srtp profile" \ 9954 -c "DTLS-SRTP key material is"\ 9955 -C "error" 9956 9957requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9958requires_gnutls 9959run_test "DTLS-SRTP server and Client support only one matching profile. gnutls server." \ 9960 "$G_SRV -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_32" \ 9961 "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \ 9962 0 \ 9963 -c "client hello, adding use_srtp extension" \ 9964 -c "found use_srtp extension" \ 9965 -c "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \ 9966 -c "selected srtp profile" \ 9967 -c "DTLS-SRTP key material is"\ 9968 -C "error" 9969 9970requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9971requires_gnutls 9972run_test "DTLS-SRTP server and Client support only one different profile. gnutls server." \ 9973 "$G_SRV -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_32" \ 9974 "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=6 debug_level=3" \ 9975 0 \ 9976 -c "client hello, adding use_srtp extension" \ 9977 -C "found use_srtp extension" \ 9978 -C "found srtp profile" \ 9979 -C "selected srtp profile" \ 9980 -C "DTLS-SRTP key material is"\ 9981 -C "error" 9982 9983requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9984requires_gnutls 9985run_test "DTLS-SRTP server doesn't support use_srtp extension. gnutls server" \ 9986 "$G_SRV -u" \ 9987 "$P_CLI dtls=1 use_srtp=1 debug_level=3" \ 9988 0 \ 9989 -c "client hello, adding use_srtp extension" \ 9990 -C "found use_srtp extension" \ 9991 -C "found srtp profile" \ 9992 -C "selected srtp profile" \ 9993 -C "DTLS-SRTP key material is"\ 9994 -C "error" 9995 9996requires_config_enabled MBEDTLS_SSL_DTLS_SRTP 9997requires_gnutls 9998run_test "DTLS-SRTP all profiles supported. mki used. gnutls server." \ 9999 "$G_SRV -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_80:SRTP_AES128_CM_HMAC_SHA1_32:SRTP_NULL_HMAC_SHA1_80:SRTP_NULL_SHA1_32" \ 10000 "$P_CLI dtls=1 use_srtp=1 mki=542310ab34290481 debug_level=3" \ 10001 0 \ 10002 -c "client hello, adding use_srtp extension" \ 10003 -c "found use_srtp extension" \ 10004 -c "found srtp profile" \ 10005 -c "selected srtp profile" \ 10006 -c "DTLS-SRTP key material is"\ 10007 -c "DTLS-SRTP mki value:"\ 10008 -c "dumping 'sending mki' (8 bytes)" \ 10009 -c "dumping 'received mki' (8 bytes)" \ 10010 -C "error" 10011 10012# Tests for specific things with "unreliable" UDP connection 10013 10014not_with_valgrind # spurious resend due to timeout 10015run_test "DTLS proxy: reference" \ 10016 -p "$P_PXY" \ 10017 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \ 10018 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \ 10019 0 \ 10020 -C "replayed record" \ 10021 -S "replayed record" \ 10022 -C "Buffer record from epoch" \ 10023 -S "Buffer record from epoch" \ 10024 -C "ssl_buffer_message" \ 10025 -S "ssl_buffer_message" \ 10026 -C "discarding invalid record" \ 10027 -S "discarding invalid record" \ 10028 -S "resend" \ 10029 -s "Extra-header:" \ 10030 -c "HTTP/1.0 200 OK" 10031 10032not_with_valgrind # spurious resend due to timeout 10033run_test "DTLS proxy: duplicate every packet" \ 10034 -p "$P_PXY duplicate=1" \ 10035 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \ 10036 "$P_CLI dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \ 10037 0 \ 10038 -c "replayed record" \ 10039 -s "replayed record" \ 10040 -c "record from another epoch" \ 10041 -s "record from another epoch" \ 10042 -S "resend" \ 10043 -s "Extra-header:" \ 10044 -c "HTTP/1.0 200 OK" 10045 10046run_test "DTLS proxy: duplicate every packet, server anti-replay off" \ 10047 -p "$P_PXY duplicate=1" \ 10048 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \ 10049 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \ 10050 0 \ 10051 -c "replayed record" \ 10052 -S "replayed record" \ 10053 -c "record from another epoch" \ 10054 -s "record from another epoch" \ 10055 -c "resend" \ 10056 -s "resend" \ 10057 -s "Extra-header:" \ 10058 -c "HTTP/1.0 200 OK" 10059 10060run_test "DTLS proxy: multiple records in same datagram" \ 10061 -p "$P_PXY pack=50" \ 10062 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \ 10063 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \ 10064 0 \ 10065 -c "next record in same datagram" \ 10066 -s "next record in same datagram" 10067 10068run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \ 10069 -p "$P_PXY pack=50 duplicate=1" \ 10070 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \ 10071 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \ 10072 0 \ 10073 -c "next record in same datagram" \ 10074 -s "next record in same datagram" 10075 10076run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \ 10077 -p "$P_PXY bad_ad=1" \ 10078 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \ 10079 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \ 10080 0 \ 10081 -c "discarding invalid record (mac)" \ 10082 -s "discarding invalid record (mac)" \ 10083 -s "Extra-header:" \ 10084 -c "HTTP/1.0 200 OK" \ 10085 -S "too many records with bad MAC" \ 10086 -S "Verification of the message MAC failed" 10087 10088run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \ 10089 -p "$P_PXY bad_ad=1" \ 10090 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \ 10091 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \ 10092 1 \ 10093 -C "discarding invalid record (mac)" \ 10094 -S "discarding invalid record (mac)" \ 10095 -S "Extra-header:" \ 10096 -C "HTTP/1.0 200 OK" \ 10097 -s "too many records with bad MAC" \ 10098 -s "Verification of the message MAC failed" 10099 10100run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \ 10101 -p "$P_PXY bad_ad=1" \ 10102 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \ 10103 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \ 10104 0 \ 10105 -c "discarding invalid record (mac)" \ 10106 -s "discarding invalid record (mac)" \ 10107 -s "Extra-header:" \ 10108 -c "HTTP/1.0 200 OK" \ 10109 -S "too many records with bad MAC" \ 10110 -S "Verification of the message MAC failed" 10111 10112run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\ 10113 -p "$P_PXY bad_ad=1" \ 10114 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \ 10115 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \ 10116 1 \ 10117 -c "discarding invalid record (mac)" \ 10118 -s "discarding invalid record (mac)" \ 10119 -s "Extra-header:" \ 10120 -c "HTTP/1.0 200 OK" \ 10121 -s "too many records with bad MAC" \ 10122 -s "Verification of the message MAC failed" 10123 10124run_test "DTLS proxy: delay ChangeCipherSpec" \ 10125 -p "$P_PXY delay_ccs=1" \ 10126 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \ 10127 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \ 10128 0 \ 10129 -c "record from another epoch" \ 10130 -s "record from another epoch" \ 10131 -s "Extra-header:" \ 10132 -c "HTTP/1.0 200 OK" 10133 10134# Tests for reordering support with DTLS 10135 10136requires_certificate_authentication 10137run_test "DTLS reordering: Buffer out-of-order handshake message on client" \ 10138 -p "$P_PXY delay_srv=ServerHello" \ 10139 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \ 10140 hs_timeout=2500-60000" \ 10141 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \ 10142 hs_timeout=2500-60000" \ 10143 0 \ 10144 -c "Buffering HS message" \ 10145 -c "Next handshake message has been buffered - load"\ 10146 -S "Buffering HS message" \ 10147 -S "Next handshake message has been buffered - load"\ 10148 -C "Injecting buffered CCS message" \ 10149 -C "Remember CCS message" \ 10150 -S "Injecting buffered CCS message" \ 10151 -S "Remember CCS message" 10152 10153requires_certificate_authentication 10154run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \ 10155 -p "$P_PXY delay_srv=ServerHello" \ 10156 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \ 10157 hs_timeout=2500-60000" \ 10158 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \ 10159 hs_timeout=2500-60000" \ 10160 0 \ 10161 -c "Buffering HS message" \ 10162 -c "found fragmented DTLS handshake message"\ 10163 -c "Next handshake message 1 not or only partially bufffered" \ 10164 -c "Next handshake message has been buffered - load"\ 10165 -S "Buffering HS message" \ 10166 -S "Next handshake message has been buffered - load"\ 10167 -C "Injecting buffered CCS message" \ 10168 -C "Remember CCS message" \ 10169 -S "Injecting buffered CCS message" \ 10170 -S "Remember CCS message" 10171 10172# The client buffers the ServerKeyExchange before receiving the fragmented 10173# Certificate message; at the time of writing, together these are aroudn 1200b 10174# in size, so that the bound below ensures that the certificate can be reassembled 10175# while keeping the ServerKeyExchange. 10176requires_certificate_authentication 10177requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300 10178run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \ 10179 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \ 10180 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \ 10181 hs_timeout=2500-60000" \ 10182 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \ 10183 hs_timeout=2500-60000" \ 10184 0 \ 10185 -c "Buffering HS message" \ 10186 -c "Next handshake message has been buffered - load"\ 10187 -C "attempt to make space by freeing buffered messages" \ 10188 -S "Buffering HS message" \ 10189 -S "Next handshake message has been buffered - load"\ 10190 -C "Injecting buffered CCS message" \ 10191 -C "Remember CCS message" \ 10192 -S "Injecting buffered CCS message" \ 10193 -S "Remember CCS message" 10194 10195# The size constraints ensure that the delayed certificate message can't 10196# be reassembled while keeping the ServerKeyExchange message, but it can 10197# when dropping it first. 10198requires_certificate_authentication 10199requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900 10200requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299 10201run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \ 10202 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \ 10203 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \ 10204 hs_timeout=2500-60000" \ 10205 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \ 10206 hs_timeout=2500-60000" \ 10207 0 \ 10208 -c "Buffering HS message" \ 10209 -c "attempt to make space by freeing buffered future messages" \ 10210 -c "Enough space available after freeing buffered HS messages" \ 10211 -S "Buffering HS message" \ 10212 -S "Next handshake message has been buffered - load"\ 10213 -C "Injecting buffered CCS message" \ 10214 -C "Remember CCS message" \ 10215 -S "Injecting buffered CCS message" \ 10216 -S "Remember CCS message" 10217 10218requires_certificate_authentication 10219run_test "DTLS reordering: Buffer out-of-order handshake message on server" \ 10220 -p "$P_PXY delay_cli=Certificate" \ 10221 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \ 10222 hs_timeout=2500-60000" \ 10223 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \ 10224 hs_timeout=2500-60000" \ 10225 0 \ 10226 -C "Buffering HS message" \ 10227 -C "Next handshake message has been buffered - load"\ 10228 -s "Buffering HS message" \ 10229 -s "Next handshake message has been buffered - load" \ 10230 -C "Injecting buffered CCS message" \ 10231 -C "Remember CCS message" \ 10232 -S "Injecting buffered CCS message" \ 10233 -S "Remember CCS message" 10234 10235requires_certificate_authentication 10236run_test "DTLS reordering: Buffer out-of-order CCS message on client"\ 10237 -p "$P_PXY delay_srv=NewSessionTicket" \ 10238 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \ 10239 hs_timeout=2500-60000" \ 10240 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \ 10241 hs_timeout=2500-60000" \ 10242 0 \ 10243 -C "Buffering HS message" \ 10244 -C "Next handshake message has been buffered - load"\ 10245 -S "Buffering HS message" \ 10246 -S "Next handshake message has been buffered - load" \ 10247 -c "Injecting buffered CCS message" \ 10248 -c "Remember CCS message" \ 10249 -S "Injecting buffered CCS message" \ 10250 -S "Remember CCS message" 10251 10252requires_certificate_authentication 10253run_test "DTLS reordering: Buffer out-of-order CCS message on server"\ 10254 -p "$P_PXY delay_cli=ClientKeyExchange" \ 10255 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \ 10256 hs_timeout=2500-60000" \ 10257 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \ 10258 hs_timeout=2500-60000" \ 10259 0 \ 10260 -C "Buffering HS message" \ 10261 -C "Next handshake message has been buffered - load"\ 10262 -S "Buffering HS message" \ 10263 -S "Next handshake message has been buffered - load" \ 10264 -C "Injecting buffered CCS message" \ 10265 -C "Remember CCS message" \ 10266 -s "Injecting buffered CCS message" \ 10267 -s "Remember CCS message" 10268 10269run_test "DTLS reordering: Buffer encrypted Finished message" \ 10270 -p "$P_PXY delay_ccs=1" \ 10271 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \ 10272 hs_timeout=2500-60000" \ 10273 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \ 10274 hs_timeout=2500-60000" \ 10275 0 \ 10276 -s "Buffer record from epoch 1" \ 10277 -s "Found buffered record from current epoch - load" \ 10278 -c "Buffer record from epoch 1" \ 10279 -c "Found buffered record from current epoch - load" 10280 10281# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec 10282# from the server are delayed, so that the encrypted Finished message 10283# is received and buffered. When the fragmented NewSessionTicket comes 10284# in afterwards, the encrypted Finished message must be freed in order 10285# to make space for the NewSessionTicket to be reassembled. 10286# This works only in very particular circumstances: 10287# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering 10288# of the NewSessionTicket, but small enough to also allow buffering of 10289# the encrypted Finished message. 10290# - The MTU setting on the server must be so small that the NewSessionTicket 10291# needs to be fragmented. 10292# - All messages sent by the server must be small enough to be either sent 10293# without fragmentation or be reassembled within the bounds of 10294# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based 10295# handshake, omitting CRTs. 10296requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 190 10297requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 230 10298run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \ 10299 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \ 10300 "$P_SRV mtu=140 response_size=90 dgram_packing=0 psk=abc123 psk_identity=foo cookies=0 dtls=1 debug_level=2" \ 10301 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \ 10302 0 \ 10303 -s "Buffer record from epoch 1" \ 10304 -s "Found buffered record from current epoch - load" \ 10305 -c "Buffer record from epoch 1" \ 10306 -C "Found buffered record from current epoch - load" \ 10307 -c "Enough space available after freeing future epoch record" 10308 10309# Tests for "randomly unreliable connection": try a variety of flows and peers 10310 10311client_needs_more_time 2 10312run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \ 10313 -p "$P_PXY drop=5 delay=5 duplicate=5" \ 10314 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \ 10315 psk=abc123" \ 10316 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \ 10317 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \ 10318 0 \ 10319 -s "Extra-header:" \ 10320 -c "HTTP/1.0 200 OK" 10321 10322client_needs_more_time 2 10323run_test "DTLS proxy: 3d, \"short\" RSA handshake" \ 10324 -p "$P_PXY drop=5 delay=5 duplicate=5" \ 10325 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \ 10326 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \ 10327 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ 10328 0 \ 10329 -s "Extra-header:" \ 10330 -c "HTTP/1.0 200 OK" 10331 10332client_needs_more_time 2 10333run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \ 10334 -p "$P_PXY drop=5 delay=5 duplicate=5" \ 10335 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \ 10336 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \ 10337 0 \ 10338 -s "Extra-header:" \ 10339 -c "HTTP/1.0 200 OK" 10340 10341client_needs_more_time 2 10342run_test "DTLS proxy: 3d, FS, client auth" \ 10343 -p "$P_PXY drop=5 delay=5 duplicate=5" \ 10344 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \ 10345 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \ 10346 0 \ 10347 -s "Extra-header:" \ 10348 -c "HTTP/1.0 200 OK" 10349 10350client_needs_more_time 2 10351run_test "DTLS proxy: 3d, FS, ticket" \ 10352 -p "$P_PXY drop=5 delay=5 duplicate=5" \ 10353 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \ 10354 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \ 10355 0 \ 10356 -s "Extra-header:" \ 10357 -c "HTTP/1.0 200 OK" 10358 10359client_needs_more_time 2 10360run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \ 10361 -p "$P_PXY drop=5 delay=5 duplicate=5" \ 10362 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \ 10363 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \ 10364 0 \ 10365 -s "Extra-header:" \ 10366 -c "HTTP/1.0 200 OK" 10367 10368client_needs_more_time 2 10369run_test "DTLS proxy: 3d, max handshake, nbio" \ 10370 -p "$P_PXY drop=5 delay=5 duplicate=5" \ 10371 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \ 10372 auth_mode=required" \ 10373 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \ 10374 0 \ 10375 -s "Extra-header:" \ 10376 -c "HTTP/1.0 200 OK" 10377 10378client_needs_more_time 4 10379requires_config_enabled MBEDTLS_SSL_CACHE_C 10380run_test "DTLS proxy: 3d, min handshake, resumption" \ 10381 -p "$P_PXY drop=5 delay=5 duplicate=5" \ 10382 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \ 10383 psk=abc123 debug_level=3" \ 10384 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \ 10385 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \ 10386 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \ 10387 0 \ 10388 -s "a session has been resumed" \ 10389 -c "a session has been resumed" \ 10390 -s "Extra-header:" \ 10391 -c "HTTP/1.0 200 OK" 10392 10393client_needs_more_time 4 10394requires_config_enabled MBEDTLS_SSL_CACHE_C 10395run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \ 10396 -p "$P_PXY drop=5 delay=5 duplicate=5" \ 10397 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \ 10398 psk=abc123 debug_level=3 nbio=2" \ 10399 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \ 10400 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \ 10401 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \ 10402 0 \ 10403 -s "a session has been resumed" \ 10404 -c "a session has been resumed" \ 10405 -s "Extra-header:" \ 10406 -c "HTTP/1.0 200 OK" 10407 10408client_needs_more_time 4 10409requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 10410run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \ 10411 -p "$P_PXY drop=5 delay=5 duplicate=5" \ 10412 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \ 10413 psk=abc123 renegotiation=1 debug_level=2" \ 10414 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \ 10415 renegotiate=1 debug_level=2 \ 10416 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \ 10417 0 \ 10418 -c "=> renegotiate" \ 10419 -s "=> renegotiate" \ 10420 -s "Extra-header:" \ 10421 -c "HTTP/1.0 200 OK" 10422 10423client_needs_more_time 4 10424requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 10425run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \ 10426 -p "$P_PXY drop=5 delay=5 duplicate=5" \ 10427 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \ 10428 psk=abc123 renegotiation=1 debug_level=2" \ 10429 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \ 10430 renegotiate=1 debug_level=2 \ 10431 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \ 10432 0 \ 10433 -c "=> renegotiate" \ 10434 -s "=> renegotiate" \ 10435 -s "Extra-header:" \ 10436 -c "HTTP/1.0 200 OK" 10437 10438client_needs_more_time 4 10439requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 10440run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \ 10441 -p "$P_PXY drop=5 delay=5 duplicate=5" \ 10442 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \ 10443 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \ 10444 debug_level=2" \ 10445 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \ 10446 renegotiation=1 exchanges=4 debug_level=2 \ 10447 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \ 10448 0 \ 10449 -c "=> renegotiate" \ 10450 -s "=> renegotiate" \ 10451 -s "Extra-header:" \ 10452 -c "HTTP/1.0 200 OK" 10453 10454client_needs_more_time 4 10455requires_config_enabled MBEDTLS_SSL_RENEGOTIATION 10456run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \ 10457 -p "$P_PXY drop=5 delay=5 duplicate=5" \ 10458 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \ 10459 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \ 10460 debug_level=2 nbio=2" \ 10461 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \ 10462 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \ 10463 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \ 10464 0 \ 10465 -c "=> renegotiate" \ 10466 -s "=> renegotiate" \ 10467 -s "Extra-header:" \ 10468 -c "HTTP/1.0 200 OK" 10469 10470## The three tests below require 1.1.1a or higher version of openssl, otherwise 10471## it might trigger a bug due to openssl (https://github.com/openssl/openssl/issues/6902) 10472requires_openssl_next 10473client_needs_more_time 6 10474not_with_valgrind # risk of non-mbedtls peer timing out 10475run_test "DTLS proxy: 3d, openssl server" \ 10476 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \ 10477 "$O_NEXT_SRV -dtls1 -mtu 2048" \ 10478 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \ 10479 0 \ 10480 -c "HTTP/1.0 200 OK" 10481 10482requires_openssl_next 10483client_needs_more_time 8 10484not_with_valgrind # risk of non-mbedtls peer timing out 10485run_test "DTLS proxy: 3d, openssl server, fragmentation" \ 10486 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \ 10487 "$O_NEXT_SRV -dtls1 -mtu 768" \ 10488 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \ 10489 0 \ 10490 -c "HTTP/1.0 200 OK" 10491 10492requires_openssl_next 10493client_needs_more_time 8 10494not_with_valgrind # risk of non-mbedtls peer timing out 10495run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \ 10496 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \ 10497 "$O_NEXT_SRV -dtls1 -mtu 768" \ 10498 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \ 10499 0 \ 10500 -c "HTTP/1.0 200 OK" 10501 10502requires_gnutls 10503client_needs_more_time 6 10504not_with_valgrind # risk of non-mbedtls peer timing out 10505run_test "DTLS proxy: 3d, gnutls server" \ 10506 -p "$P_PXY drop=5 delay=5 duplicate=5" \ 10507 "$G_SRV -u --mtu 2048 -a" \ 10508 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \ 10509 0 \ 10510 -s "Extra-header:" \ 10511 -c "Extra-header:" 10512 10513requires_gnutls_next 10514client_needs_more_time 8 10515not_with_valgrind # risk of non-mbedtls peer timing out 10516run_test "DTLS proxy: 3d, gnutls server, fragmentation" \ 10517 -p "$P_PXY drop=5 delay=5 duplicate=5" \ 10518 "$G_NEXT_SRV -u --mtu 512" \ 10519 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \ 10520 0 \ 10521 -s "Extra-header:" \ 10522 -c "Extra-header:" 10523 10524requires_gnutls_next 10525client_needs_more_time 8 10526not_with_valgrind # risk of non-mbedtls peer timing out 10527run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \ 10528 -p "$P_PXY drop=5 delay=5 duplicate=5" \ 10529 "$G_NEXT_SRV -u --mtu 512" \ 10530 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \ 10531 0 \ 10532 -s "Extra-header:" \ 10533 -c "Extra-header:" 10534 10535requires_config_enabled MBEDTLS_SSL_EXPORT_KEYS 10536run_test "export keys functionality" \ 10537 "$P_SRV eap_tls=1 debug_level=3" \ 10538 "$P_CLI eap_tls=1 debug_level=3" \ 10539 0 \ 10540 -s "exported maclen is " \ 10541 -s "exported keylen is " \ 10542 -s "exported ivlen is " \ 10543 -c "exported maclen is " \ 10544 -c "exported keylen is " \ 10545 -c "exported ivlen is " \ 10546 -c "EAP-TLS key material is:"\ 10547 -s "EAP-TLS key material is:"\ 10548 -c "EAP-TLS IV is:" \ 10549 -s "EAP-TLS IV is:" 10550 10551# Test heap memory usage after handshake 10552requires_config_enabled MBEDTLS_MEMORY_DEBUG 10553requires_config_enabled MBEDTLS_MEMORY_BUFFER_ALLOC_C 10554requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 10555requires_max_content_len 16384 10556run_tests_memory_after_hanshake 10557 10558# Final report 10559 10560echo "------------------------------------------------------------------------" 10561 10562if [ $FAILS = 0 ]; then 10563 printf "PASSED" 10564else 10565 printf "FAILED" 10566fi 10567PASSES=$(( $TESTS - $FAILS )) 10568echo " ($PASSES / $TESTS tests ($SKIPS skipped))" 10569 10570if [ $FAILS -gt 255 ]; then 10571 # Clamp at 255 as caller gets exit code & 0xFF 10572 # (so 256 would be 0, or success, etc) 10573 FAILS=255 10574fi 10575exit $FAILS 10576