Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # Test various options that are not covered by compat.sh |
| 4 | # |
| 5 | # Here the goal is not to cover every ciphersuite/version, but |
| 6 | # rather specific options (max fragment length, truncated hmac, etc) |
| 7 | # or procedures (session resumption from cache or ticket, renego, etc). |
| 8 | # |
| 9 | # Assumes all options are compiled in. |
| 10 | |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 11 | set -u |
| 12 | |
Manuel Pégourié-Gonnard | 913030c | 2014-03-28 10:12:38 +0100 | [diff] [blame] | 13 | # test if it is defined from the environment before assining default |
| 14 | # if yes, assume it means it's a build with all the options we need (SSLv2) |
| 15 | if [ -n "${OPENSSL_CMD:-}" ]; then |
| 16 | OPENSSL_OK=1 |
| 17 | else |
| 18 | OPENSSL_OK=0 |
| 19 | fi |
| 20 | |
Manuel Pégourié-Gonnard | f7a2690 | 2014-02-27 12:25:54 +0100 | [diff] [blame] | 21 | # default values, can be overriden by the environment |
| 22 | : ${P_SRV:=../programs/ssl/ssl_server2} |
| 23 | : ${P_CLI:=../programs/ssl/ssl_client2} |
Manuel Pégourié-Gonnard | 74faf3c | 2014-03-13 18:47:44 +0100 | [diff] [blame] | 24 | : ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 25 | |
Manuel Pégourié-Gonnard | 74faf3c | 2014-03-13 18:47:44 +0100 | [diff] [blame] | 26 | O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key" |
| 27 | O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client" |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 28 | |
Manuel Pégourié-Gonnard | 33a752e | 2014-02-21 09:47:37 +0100 | [diff] [blame] | 29 | TESTS=0 |
| 30 | FAILS=0 |
| 31 | |
Manuel Pégourié-Gonnard | 83d8c73 | 2014-04-07 13:24:21 +0200 | [diff] [blame] | 32 | CONFIG_H='../include/polarssl/config.h' |
| 33 | |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 34 | MEMCHECK=0 |
Manuel Pégourié-Gonnard | 417d46c | 2014-03-13 19:17:53 +0100 | [diff] [blame] | 35 | FILTER='.*' |
Manuel Pégourié-Gonnard | 913030c | 2014-03-28 10:12:38 +0100 | [diff] [blame] | 36 | if [ "$OPENSSL_OK" -gt 0 ]; then |
| 37 | EXCLUDE='^$' |
| 38 | else |
| 39 | EXCLUDE='SSLv2' |
| 40 | fi |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 41 | |
| 42 | print_usage() { |
| 43 | echo "Usage: $0 [options]" |
Manuel Pégourié-Gonnard | 417d46c | 2014-03-13 19:17:53 +0100 | [diff] [blame] | 44 | echo -e " -h|--help\tPrint this help." |
| 45 | echo -e " -m|--memcheck\tCheck memory leaks and errors." |
| 46 | echo -e " -f|--filter\tOnly matching tests are executed (default: '$FILTER')" |
| 47 | echo -e " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')" |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | get_options() { |
| 51 | while [ $# -gt 0 ]; do |
| 52 | case "$1" in |
Manuel Pégourié-Gonnard | 417d46c | 2014-03-13 19:17:53 +0100 | [diff] [blame] | 53 | -f|--filter) |
| 54 | shift; FILTER=$1 |
| 55 | ;; |
| 56 | -e|--exclude) |
| 57 | shift; EXCLUDE=$1 |
| 58 | ;; |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 59 | -m|--memcheck) |
| 60 | MEMCHECK=1 |
| 61 | ;; |
| 62 | -h|--help) |
| 63 | print_usage |
| 64 | exit 0 |
| 65 | ;; |
| 66 | *) |
Paul Bakker | 1ebc0c5 | 2014-05-22 15:47:58 +0200 | [diff] [blame] | 67 | echo "Unknown argument: '$1'" |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 68 | print_usage |
| 69 | exit 1 |
| 70 | ;; |
| 71 | esac |
| 72 | shift |
| 73 | done |
| 74 | } |
| 75 | |
Manuel Pégourié-Gonnard | f8bdbb5 | 2014-02-21 09:20:14 +0100 | [diff] [blame] | 76 | # print_name <name> |
| 77 | print_name() { |
| 78 | echo -n "$1 " |
| 79 | LEN=`echo "$1" | wc -c` |
| 80 | LEN=`echo 72 - $LEN | bc` |
| 81 | for i in `seq 1 $LEN`; do echo -n '.'; done |
| 82 | echo -n ' ' |
Manuel Pégourié-Gonnard | 33a752e | 2014-02-21 09:47:37 +0100 | [diff] [blame] | 83 | |
| 84 | TESTS=`echo $TESTS + 1 | bc` |
Manuel Pégourié-Gonnard | f8bdbb5 | 2014-02-21 09:20:14 +0100 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | # fail <message> |
| 88 | fail() { |
| 89 | echo "FAIL" |
Manuel Pégourié-Gonnard | 3eec604 | 2014-02-27 15:37:24 +0100 | [diff] [blame] | 90 | echo " ! $1" |
Manuel Pégourié-Gonnard | 33a752e | 2014-02-21 09:47:37 +0100 | [diff] [blame] | 91 | |
Manuel Pégourié-Gonnard | bc3b16c | 2014-05-28 23:06:50 +0200 | [diff] [blame] | 92 | cp $SRV_OUT o-srv-${TESTS}.log |
| 93 | cp $CLI_OUT o-cli-${TESTS}.log |
Manuel Pégourié-Gonnard | 3eec604 | 2014-02-27 15:37:24 +0100 | [diff] [blame] | 94 | echo " ! outputs saved to o-srv-${TESTS}.log and o-cli-${TESTS}.log" |
Manuel Pégourié-Gonnard | 33a752e | 2014-02-21 09:47:37 +0100 | [diff] [blame] | 95 | |
| 96 | FAILS=`echo $FAILS + 1 | bc` |
Manuel Pégourié-Gonnard | f8bdbb5 | 2014-02-21 09:20:14 +0100 | [diff] [blame] | 97 | } |
| 98 | |
Manuel Pégourié-Gonnard | 677884d | 2014-02-25 16:42:31 +0100 | [diff] [blame] | 99 | # is_polar <cmd_line> |
| 100 | is_polar() { |
| 101 | echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null |
| 102 | } |
| 103 | |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 104 | # has_mem_err <log_file_name> |
| 105 | has_mem_err() { |
| 106 | if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" && |
| 107 | grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null |
| 108 | then |
| 109 | return 1 # false: does not have errors |
| 110 | else |
| 111 | return 0 # true: has errors |
| 112 | fi |
| 113 | } |
| 114 | |
Manuel Pégourié-Gonnard | 0c1ec47 | 2014-06-20 18:41:11 +0200 | [diff] [blame] | 115 | # wait for server to start: two versions depending on lsof availability |
| 116 | wait_server_start() { |
| 117 | if which lsof >/dev/null; then |
| 118 | # make sure we don't loop forever |
| 119 | ( sleep "$DOG_DELAY"; echo "SERVERSTART TIMEOUT"; kill $MAIN_PID ) & |
| 120 | WATCHDOG_PID=$! |
| 121 | |
| 122 | # make a tight loop, server usually takes less than 1 sec to start |
| 123 | until lsof -nbi TCP:"$PORT" | grep LISTEN >/dev/null; do :; done |
| 124 | |
| 125 | kill $WATCHDOG_PID |
| 126 | wait $WATCHDOG_PID |
| 127 | else |
| 128 | sleep "$START_DELAY" |
| 129 | fi |
| 130 | } |
| 131 | |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 132 | # Usage: run_test name srv_cmd cli_cmd cli_exit [option [...]] |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 133 | # Options: -s pattern pattern that must be present in server output |
| 134 | # -c pattern pattern that must be present in client output |
| 135 | # -S pattern pattern that must be absent in server output |
| 136 | # -C pattern pattern that must be absent in client output |
| 137 | run_test() { |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 138 | NAME="$1" |
| 139 | SRV_CMD="$2" |
| 140 | CLI_CMD="$3" |
| 141 | CLI_EXPECT="$4" |
| 142 | shift 4 |
| 143 | |
Manuel Pégourié-Gonnard | 417d46c | 2014-03-13 19:17:53 +0100 | [diff] [blame] | 144 | if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then : |
| 145 | else |
| 146 | return |
| 147 | fi |
| 148 | |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 149 | print_name "$NAME" |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 150 | |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 151 | # prepend valgrind to our commands if active |
| 152 | if [ "$MEMCHECK" -gt 0 ]; then |
| 153 | if is_polar "$SRV_CMD"; then |
| 154 | SRV_CMD="valgrind --leak-check=full $SRV_CMD" |
| 155 | fi |
| 156 | if is_polar "$CLI_CMD"; then |
| 157 | CLI_CMD="valgrind --leak-check=full $CLI_CMD" |
| 158 | fi |
| 159 | fi |
| 160 | |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 161 | # run the commands |
Manuel Pégourié-Gonnard | bc3b16c | 2014-05-28 23:06:50 +0200 | [diff] [blame] | 162 | echo "$SRV_CMD" > $SRV_OUT |
| 163 | $SRV_CMD >> $SRV_OUT 2>&1 & |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 164 | SRV_PID=$! |
Manuel Pégourié-Gonnard | 0c1ec47 | 2014-06-20 18:41:11 +0200 | [diff] [blame] | 165 | wait_server_start |
Manuel Pégourié-Gonnard | bc3b16c | 2014-05-28 23:06:50 +0200 | [diff] [blame] | 166 | echo "$CLI_CMD" > $CLI_OUT |
| 167 | eval "$CLI_CMD" >> $CLI_OUT 2>&1 |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 168 | CLI_EXIT=$? |
Manuel Pégourié-Gonnard | bc3b16c | 2014-05-28 23:06:50 +0200 | [diff] [blame] | 169 | echo "EXIT: $CLI_EXIT" >> $CLI_OUT |
Manuel Pégourié-Gonnard | e01af4c | 2014-03-25 14:16:44 +0100 | [diff] [blame] | 170 | |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 171 | if is_polar "$SRV_CMD"; then |
Manuel Pégourié-Gonnard | 32f8f4d | 2014-05-29 11:31:20 +0200 | [diff] [blame] | 172 | # start watchdog in case SERVERQUIT fails |
Manuel Pégourié-Gonnard | 0c1ec47 | 2014-06-20 18:41:11 +0200 | [diff] [blame] | 173 | ( sleep "$DOG_DELAY"; echo "SERVERQUIT TIMEOUT"; kill $MAIN_PID ) & |
Manuel Pégourié-Gonnard | 32f8f4d | 2014-05-29 11:31:20 +0200 | [diff] [blame] | 174 | WATCHDOG_PID=$! |
| 175 | |
| 176 | # psk is useful when server only has bad certs |
Manuel Pégourié-Gonnard | 8066b81 | 2014-05-28 22:59:30 +0200 | [diff] [blame] | 177 | $P_CLI request_page=SERVERQUIT tickets=0 auth_mode=none psk=abc123 \ |
Manuel Pégourié-Gonnard | 84fd687 | 2014-03-13 18:35:10 +0100 | [diff] [blame] | 178 | crt_file=data_files/cli2.crt key_file=data_files/cli2.key \ |
| 179 | >/dev/null |
Manuel Pégourié-Gonnard | 32f8f4d | 2014-05-29 11:31:20 +0200 | [diff] [blame] | 180 | |
| 181 | wait $SRV_PID |
| 182 | kill $WATCHDOG_PID |
| 183 | wait $WATCHDOG_PID |
Manuel Pégourié-Gonnard | 677884d | 2014-02-25 16:42:31 +0100 | [diff] [blame] | 184 | else |
| 185 | kill $SRV_PID |
Manuel Pégourié-Gonnard | 32f8f4d | 2014-05-29 11:31:20 +0200 | [diff] [blame] | 186 | wait $SRV_PID |
Manuel Pégourié-Gonnard | 677884d | 2014-02-25 16:42:31 +0100 | [diff] [blame] | 187 | fi |
Manuel Pégourié-Gonnard | 677884d | 2014-02-25 16:42:31 +0100 | [diff] [blame] | 188 | |
| 189 | # check if the client and server went at least to the handshake stage |
Paul Bakker | 1ebc0c5 | 2014-05-22 15:47:58 +0200 | [diff] [blame] | 190 | # (useful to avoid tests with only negative assertions and non-zero |
Manuel Pégourié-Gonnard | 677884d | 2014-02-25 16:42:31 +0100 | [diff] [blame] | 191 | # expected client exit to incorrectly succeed in case of catastrophic |
| 192 | # failure) |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 193 | if is_polar "$SRV_CMD"; then |
Manuel Pégourié-Gonnard | bc3b16c | 2014-05-28 23:06:50 +0200 | [diff] [blame] | 194 | if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :; |
Manuel Pégourié-Gonnard | 677884d | 2014-02-25 16:42:31 +0100 | [diff] [blame] | 195 | else |
| 196 | fail "server failed to start" |
| 197 | return |
| 198 | fi |
| 199 | fi |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 200 | if is_polar "$CLI_CMD"; then |
Manuel Pégourié-Gonnard | bc3b16c | 2014-05-28 23:06:50 +0200 | [diff] [blame] | 201 | if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :; |
Manuel Pégourié-Gonnard | 677884d | 2014-02-25 16:42:31 +0100 | [diff] [blame] | 202 | else |
| 203 | fail "client failed to start" |
| 204 | return |
| 205 | fi |
| 206 | fi |
| 207 | |
Manuel Pégourié-Gonnard | f8bdbb5 | 2014-02-21 09:20:14 +0100 | [diff] [blame] | 208 | # check server exit code |
| 209 | if [ $? != 0 ]; then |
| 210 | fail "server fail" |
| 211 | return |
| 212 | fi |
| 213 | |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 214 | # check client exit code |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 215 | if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \ |
| 216 | \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ] |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 217 | then |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 218 | fail "bad client exit code" |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 219 | return |
| 220 | fi |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 221 | |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 222 | # check other assertions |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 223 | while [ $# -gt 0 ] |
| 224 | do |
| 225 | case $1 in |
| 226 | "-s") |
Manuel Pégourié-Gonnard | bc3b16c | 2014-05-28 23:06:50 +0200 | [diff] [blame] | 227 | if grep "$2" $SRV_OUT >/dev/null; then :; else |
Manuel Pégourié-Gonnard | f8bdbb5 | 2014-02-21 09:20:14 +0100 | [diff] [blame] | 228 | fail "-s $2" |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 229 | return |
| 230 | fi |
| 231 | ;; |
| 232 | |
| 233 | "-c") |
Manuel Pégourié-Gonnard | bc3b16c | 2014-05-28 23:06:50 +0200 | [diff] [blame] | 234 | if grep "$2" $CLI_OUT >/dev/null; then :; else |
Manuel Pégourié-Gonnard | f8bdbb5 | 2014-02-21 09:20:14 +0100 | [diff] [blame] | 235 | fail "-c $2" |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 236 | return |
| 237 | fi |
| 238 | ;; |
| 239 | |
| 240 | "-S") |
Manuel Pégourié-Gonnard | bc3b16c | 2014-05-28 23:06:50 +0200 | [diff] [blame] | 241 | if grep "$2" $SRV_OUT >/dev/null; then |
Manuel Pégourié-Gonnard | f8bdbb5 | 2014-02-21 09:20:14 +0100 | [diff] [blame] | 242 | fail "-S $2" |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 243 | return |
| 244 | fi |
| 245 | ;; |
| 246 | |
| 247 | "-C") |
Manuel Pégourié-Gonnard | bc3b16c | 2014-05-28 23:06:50 +0200 | [diff] [blame] | 248 | if grep "$2" $CLI_OUT >/dev/null; then |
Manuel Pégourié-Gonnard | f8bdbb5 | 2014-02-21 09:20:14 +0100 | [diff] [blame] | 249 | fail "-C $2" |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 250 | return |
| 251 | fi |
| 252 | ;; |
| 253 | |
| 254 | *) |
Paul Bakker | 1ebc0c5 | 2014-05-22 15:47:58 +0200 | [diff] [blame] | 255 | echo "Unknown test: $1" >&2 |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 256 | exit 1 |
| 257 | esac |
| 258 | shift 2 |
| 259 | done |
| 260 | |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 261 | # check valgrind's results |
| 262 | if [ "$MEMCHECK" -gt 0 ]; then |
Manuel Pégourié-Gonnard | bc3b16c | 2014-05-28 23:06:50 +0200 | [diff] [blame] | 263 | if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 264 | fail "Server has memory errors" |
| 265 | return |
| 266 | fi |
Manuel Pégourié-Gonnard | bc3b16c | 2014-05-28 23:06:50 +0200 | [diff] [blame] | 267 | if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 268 | fail "Client has memory errors" |
| 269 | return |
| 270 | fi |
| 271 | fi |
| 272 | |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 273 | # if we're here, everything is ok |
| 274 | echo "PASS" |
Manuel Pégourié-Gonnard | bc3b16c | 2014-05-28 23:06:50 +0200 | [diff] [blame] | 275 | rm -f $SRV_OUT $CLI_OUT |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 276 | } |
| 277 | |
Manuel Pégourié-Gonnard | a9062e9 | 2014-02-25 16:21:22 +0100 | [diff] [blame] | 278 | cleanup() { |
Manuel Pégourié-Gonnard | bc3b16c | 2014-05-28 23:06:50 +0200 | [diff] [blame] | 279 | rm -f $CLI_OUT $SRV_OUT $SESSION |
Manuel Pégourié-Gonnard | 0c1ec47 | 2014-06-20 18:41:11 +0200 | [diff] [blame] | 280 | kill $SRV_PID >/dev/null 2>&1 |
| 281 | kill $WATCHDOG_PID >/dev/null 2>&1 |
Manuel Pégourié-Gonnard | a9062e9 | 2014-02-25 16:21:22 +0100 | [diff] [blame] | 282 | exit 1 |
| 283 | } |
| 284 | |
Manuel Pégourié-Gonnard | 9dea8bd | 2014-02-26 18:21:02 +0100 | [diff] [blame] | 285 | # |
| 286 | # MAIN |
| 287 | # |
| 288 | |
Manuel Pégourié-Gonnard | 913030c | 2014-03-28 10:12:38 +0100 | [diff] [blame] | 289 | get_options "$@" |
| 290 | |
Manuel Pégourié-Gonnard | f7a2690 | 2014-02-27 12:25:54 +0100 | [diff] [blame] | 291 | # sanity checks, avoid an avalanche of errors |
| 292 | if [ ! -x "$P_SRV" ]; then |
| 293 | echo "Command '$P_SRV' is not an executable file" |
| 294 | exit 1 |
| 295 | fi |
| 296 | if [ ! -x "$P_CLI" ]; then |
| 297 | echo "Command '$P_CLI' is not an executable file" |
| 298 | exit 1 |
| 299 | fi |
Manuel Pégourié-Gonnard | 74faf3c | 2014-03-13 18:47:44 +0100 | [diff] [blame] | 300 | if which $OPENSSL_CMD >/dev/null 2>&1; then :; else |
| 301 | echo "Command '$OPENSSL_CMD' not found" |
Manuel Pégourié-Gonnard | f7a2690 | 2014-02-27 12:25:54 +0100 | [diff] [blame] | 302 | exit 1 |
| 303 | fi |
| 304 | |
Manuel Pégourié-Gonnard | 32f8f4d | 2014-05-29 11:31:20 +0200 | [diff] [blame] | 305 | # used by watchdog |
| 306 | MAIN_PID="$$" |
| 307 | |
Manuel Pégourié-Gonnard | 0c1ec47 | 2014-06-20 18:41:11 +0200 | [diff] [blame] | 308 | # be more patient with valgrind |
| 309 | if [ "$MEMCHECK" -gt 0 ]; then |
| 310 | START_DELAY=3 |
| 311 | DOG_DELAY=30 |
| 312 | else |
| 313 | START_DELAY=1 |
| 314 | DOG_DELAY=10 |
| 315 | fi |
| 316 | |
Manuel Pégourié-Gonnard | 8066b81 | 2014-05-28 22:59:30 +0200 | [diff] [blame] | 317 | # Pick a "unique" port in the range 10000-19999. |
| 318 | PORT="0000$$" |
Manuel Pégourié-Gonnard | fab2a3c | 2014-06-16 16:54:36 +0200 | [diff] [blame] | 319 | PORT="1$(echo $PORT | tail -c 5)" |
Manuel Pégourié-Gonnard | 8066b81 | 2014-05-28 22:59:30 +0200 | [diff] [blame] | 320 | |
| 321 | # fix commands to use this port |
| 322 | P_SRV="$P_SRV server_port=$PORT" |
| 323 | P_CLI="$P_CLI server_port=$PORT" |
| 324 | O_SRV="$O_SRV -accept $PORT" |
| 325 | O_CLI="$O_CLI -connect localhost:$PORT" |
| 326 | |
Manuel Pégourié-Gonnard | bc3b16c | 2014-05-28 23:06:50 +0200 | [diff] [blame] | 327 | # Also pick a unique name for intermediate files |
| 328 | SRV_OUT="srv_out.$$" |
| 329 | CLI_OUT="cli_out.$$" |
| 330 | SESSION="session.$$" |
| 331 | |
Manuel Pégourié-Gonnard | a9062e9 | 2014-02-25 16:21:22 +0100 | [diff] [blame] | 332 | trap cleanup INT TERM HUP |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 333 | |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 334 | # Test for SSLv2 ClientHello |
| 335 | |
| 336 | run_test "SSLv2 ClientHello #0 (reference)" \ |
| 337 | "$P_SRV debug_level=3" \ |
Manuel Pégourié-Gonnard | a3d808e | 2014-02-26 16:33:03 +0100 | [diff] [blame] | 338 | "$O_CLI -no_ssl2" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 339 | 0 \ |
| 340 | -S "parse client hello v2" \ |
| 341 | -S "ssl_handshake returned" |
| 342 | |
| 343 | # Adding a SSL2-only suite makes OpenSSL client send SSLv2 ClientHello |
| 344 | run_test "SSLv2 ClientHello #1 (actual test)" \ |
| 345 | "$P_SRV debug_level=3" \ |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 346 | "$O_CLI -cipher 'DES-CBC-MD5:ALL'" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 347 | 0 \ |
| 348 | -s "parse client hello v2" \ |
| 349 | -S "ssl_handshake returned" |
| 350 | |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 351 | # Tests for Truncated HMAC extension |
| 352 | |
| 353 | run_test "Truncated HMAC #0" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 354 | "$P_SRV debug_level=5" \ |
| 355 | "$P_CLI trunc_hmac=0 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 356 | 0 \ |
| 357 | -s "dumping 'computed mac' (20 bytes)" |
| 358 | |
| 359 | run_test "Truncated HMAC #1" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 360 | "$P_SRV debug_level=5" \ |
| 361 | "$P_CLI trunc_hmac=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 362 | 0 \ |
Manuel Pégourié-Gonnard | f7c5201 | 2014-02-20 11:43:46 +0100 | [diff] [blame] | 363 | -s "dumping 'computed mac' (10 bytes)" |
| 364 | |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 365 | # Tests for Session Tickets |
| 366 | |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 367 | run_test "Session resume using tickets #1 (basic)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 368 | "$P_SRV debug_level=4 tickets=1" \ |
| 369 | "$P_CLI debug_level=4 tickets=1 reconnect=1" \ |
Manuel Pégourié-Gonnard | f7c5201 | 2014-02-20 11:43:46 +0100 | [diff] [blame] | 370 | 0 \ |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 371 | -c "client hello, adding session ticket extension" \ |
| 372 | -s "found session ticket extension" \ |
| 373 | -s "server hello, adding session ticket extension" \ |
| 374 | -c "found session_ticket extension" \ |
| 375 | -c "parse new session ticket" \ |
Manuel Pégourié-Gonnard | f7c5201 | 2014-02-20 11:43:46 +0100 | [diff] [blame] | 376 | -S "session successfully restored from cache" \ |
| 377 | -s "session successfully restored from ticket" \ |
| 378 | -s "a session has been resumed" \ |
| 379 | -c "a session has been resumed" |
| 380 | |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 381 | run_test "Session resume using tickets #2 (cache disabled)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 382 | "$P_SRV debug_level=4 tickets=1 cache_max=0" \ |
| 383 | "$P_CLI debug_level=4 tickets=1 reconnect=1" \ |
Manuel Pégourié-Gonnard | dbe1ee1 | 2014-02-21 09:18:13 +0100 | [diff] [blame] | 384 | 0 \ |
| 385 | -c "client hello, adding session ticket extension" \ |
| 386 | -s "found session ticket extension" \ |
| 387 | -s "server hello, adding session ticket extension" \ |
| 388 | -c "found session_ticket extension" \ |
| 389 | -c "parse new session ticket" \ |
| 390 | -S "session successfully restored from cache" \ |
| 391 | -s "session successfully restored from ticket" \ |
| 392 | -s "a session has been resumed" \ |
| 393 | -c "a session has been resumed" |
| 394 | |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 395 | run_test "Session resume using tickets #3 (timeout)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 396 | "$P_SRV debug_level=4 tickets=1 cache_max=0 ticket_timeout=1" \ |
| 397 | "$P_CLI debug_level=4 tickets=1 reconnect=1 reco_delay=2" \ |
Manuel Pégourié-Gonnard | dbe1ee1 | 2014-02-21 09:18:13 +0100 | [diff] [blame] | 398 | 0 \ |
| 399 | -c "client hello, adding session ticket extension" \ |
| 400 | -s "found session ticket extension" \ |
| 401 | -s "server hello, adding session ticket extension" \ |
| 402 | -c "found session_ticket extension" \ |
| 403 | -c "parse new session ticket" \ |
| 404 | -S "session successfully restored from cache" \ |
| 405 | -S "session successfully restored from ticket" \ |
| 406 | -S "a session has been resumed" \ |
| 407 | -C "a session has been resumed" |
| 408 | |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 409 | run_test "Session resume using tickets #4 (openssl server)" \ |
Manuel Pégourié-Gonnard | f7a2690 | 2014-02-27 12:25:54 +0100 | [diff] [blame] | 410 | "$O_SRV" \ |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 411 | "$P_CLI debug_level=4 tickets=1 reconnect=1" \ |
| 412 | 0 \ |
| 413 | -c "client hello, adding session ticket extension" \ |
| 414 | -c "found session_ticket extension" \ |
| 415 | -c "parse new session ticket" \ |
| 416 | -c "a session has been resumed" |
| 417 | |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 418 | run_test "Session resume using tickets #5 (openssl client)" \ |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 419 | "$P_SRV debug_level=4 tickets=1" \ |
Manuel Pégourié-Gonnard | bc3b16c | 2014-05-28 23:06:50 +0200 | [diff] [blame] | 420 | "( $O_CLI -sess_out $SESSION; \ |
| 421 | $O_CLI -sess_in $SESSION; \ |
| 422 | rm -f $SESSION )" \ |
Manuel Pégourié-Gonnard | fccd325 | 2014-02-25 17:14:15 +0100 | [diff] [blame] | 423 | 0 \ |
| 424 | -s "found session ticket extension" \ |
| 425 | -s "server hello, adding session ticket extension" \ |
| 426 | -S "session successfully restored from cache" \ |
| 427 | -s "session successfully restored from ticket" \ |
| 428 | -s "a session has been resumed" |
| 429 | |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 430 | # Tests for Session Resume based on session-ID and cache |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 431 | |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 432 | run_test "Session resume using cache #1 (tickets enabled on client)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 433 | "$P_SRV debug_level=4 tickets=0" \ |
| 434 | "$P_CLI debug_level=4 tickets=1 reconnect=1" \ |
Manuel Pégourié-Gonnard | f7c5201 | 2014-02-20 11:43:46 +0100 | [diff] [blame] | 435 | 0 \ |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 436 | -c "client hello, adding session ticket extension" \ |
| 437 | -s "found session ticket extension" \ |
| 438 | -S "server hello, adding session ticket extension" \ |
| 439 | -C "found session_ticket extension" \ |
| 440 | -C "parse new session ticket" \ |
Manuel Pégourié-Gonnard | f7c5201 | 2014-02-20 11:43:46 +0100 | [diff] [blame] | 441 | -s "session successfully restored from cache" \ |
| 442 | -S "session successfully restored from ticket" \ |
| 443 | -s "a session has been resumed" \ |
| 444 | -c "a session has been resumed" |
| 445 | |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 446 | run_test "Session resume using cache #2 (tickets enabled on server)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 447 | "$P_SRV debug_level=4 tickets=1" \ |
| 448 | "$P_CLI debug_level=4 tickets=0 reconnect=1" \ |
Manuel Pégourié-Gonnard | f7c5201 | 2014-02-20 11:43:46 +0100 | [diff] [blame] | 449 | 0 \ |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 450 | -C "client hello, adding session ticket extension" \ |
| 451 | -S "found session ticket extension" \ |
| 452 | -S "server hello, adding session ticket extension" \ |
| 453 | -C "found session_ticket extension" \ |
| 454 | -C "parse new session ticket" \ |
Manuel Pégourié-Gonnard | f7c5201 | 2014-02-20 11:43:46 +0100 | [diff] [blame] | 455 | -s "session successfully restored from cache" \ |
| 456 | -S "session successfully restored from ticket" \ |
| 457 | -s "a session has been resumed" \ |
| 458 | -c "a session has been resumed" |
Manuel Pégourié-Gonnard | de14378 | 2014-02-20 14:50:42 +0100 | [diff] [blame] | 459 | |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 460 | run_test "Session resume using cache #3 (cache_max=0)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 461 | "$P_SRV debug_level=4 tickets=0 cache_max=0" \ |
| 462 | "$P_CLI debug_level=4 tickets=0 reconnect=1" \ |
Manuel Pégourié-Gonnard | 4c88345 | 2014-02-20 21:32:41 +0100 | [diff] [blame] | 463 | 0 \ |
| 464 | -S "session successfully restored from cache" \ |
| 465 | -S "session successfully restored from ticket" \ |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 466 | -S "a session has been resumed" \ |
| 467 | -C "a session has been resumed" |
Manuel Pégourié-Gonnard | 4c88345 | 2014-02-20 21:32:41 +0100 | [diff] [blame] | 468 | |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 469 | run_test "Session resume using cache #4 (cache_max=1)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 470 | "$P_SRV debug_level=4 tickets=0 cache_max=1" \ |
| 471 | "$P_CLI debug_level=4 tickets=0 reconnect=1" \ |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 472 | 0 \ |
| 473 | -s "session successfully restored from cache" \ |
| 474 | -S "session successfully restored from ticket" \ |
| 475 | -s "a session has been resumed" \ |
| 476 | -c "a session has been resumed" |
| 477 | |
| 478 | run_test "Session resume using cache #5 (timemout > delay)" \ |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 479 | "$P_SRV debug_level=4 tickets=0" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 480 | "$P_CLI debug_level=4 tickets=0 reconnect=1 reco_delay=0" \ |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 481 | 0 \ |
| 482 | -s "session successfully restored from cache" \ |
| 483 | -S "session successfully restored from ticket" \ |
| 484 | -s "a session has been resumed" \ |
| 485 | -c "a session has been resumed" |
| 486 | |
| 487 | run_test "Session resume using cache #6 (timeout < delay)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 488 | "$P_SRV debug_level=4 tickets=0 cache_timeout=1" \ |
| 489 | "$P_CLI debug_level=4 tickets=0 reconnect=1 reco_delay=2" \ |
Manuel Pégourié-Gonnard | c55a5b7 | 2014-02-20 22:50:56 +0100 | [diff] [blame] | 490 | 0 \ |
| 491 | -S "session successfully restored from cache" \ |
| 492 | -S "session successfully restored from ticket" \ |
| 493 | -S "a session has been resumed" \ |
| 494 | -C "a session has been resumed" |
| 495 | |
| 496 | run_test "Session resume using cache #7 (no timeout)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 497 | "$P_SRV debug_level=4 tickets=0 cache_timeout=0" \ |
| 498 | "$P_CLI debug_level=4 tickets=0 reconnect=1 reco_delay=2" \ |
Manuel Pégourié-Gonnard | 4c88345 | 2014-02-20 21:32:41 +0100 | [diff] [blame] | 499 | 0 \ |
| 500 | -s "session successfully restored from cache" \ |
| 501 | -S "session successfully restored from ticket" \ |
| 502 | -s "a session has been resumed" \ |
| 503 | -c "a session has been resumed" |
| 504 | |
Manuel Pégourié-Gonnard | db735f6 | 2014-02-25 17:57:59 +0100 | [diff] [blame] | 505 | run_test "Session resume using cache #8 (openssl client)" \ |
| 506 | "$P_SRV debug_level=4 tickets=0" \ |
Manuel Pégourié-Gonnard | bc3b16c | 2014-05-28 23:06:50 +0200 | [diff] [blame] | 507 | "( $O_CLI -sess_out $SESSION; \ |
| 508 | $O_CLI -sess_in $SESSION; \ |
| 509 | rm -f $SESSION )" \ |
Manuel Pégourié-Gonnard | db735f6 | 2014-02-25 17:57:59 +0100 | [diff] [blame] | 510 | 0 \ |
| 511 | -s "found session ticket extension" \ |
| 512 | -S "server hello, adding session ticket extension" \ |
| 513 | -s "session successfully restored from cache" \ |
| 514 | -S "session successfully restored from ticket" \ |
| 515 | -s "a session has been resumed" |
| 516 | |
| 517 | run_test "Session resume using cache #9 (openssl server)" \ |
Manuel Pégourié-Gonnard | f7a2690 | 2014-02-27 12:25:54 +0100 | [diff] [blame] | 518 | "$O_SRV" \ |
Manuel Pégourié-Gonnard | db735f6 | 2014-02-25 17:57:59 +0100 | [diff] [blame] | 519 | "$P_CLI debug_level=4 tickets=0 reconnect=1" \ |
| 520 | 0 \ |
| 521 | -C "found session_ticket extension" \ |
| 522 | -C "parse new session ticket" \ |
| 523 | -c "a session has been resumed" |
| 524 | |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 525 | # Tests for Max Fragment Length extension |
| 526 | |
Manuel Pégourié-Gonnard | de14378 | 2014-02-20 14:50:42 +0100 | [diff] [blame] | 527 | run_test "Max fragment length #1" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 528 | "$P_SRV debug_level=4" \ |
| 529 | "$P_CLI debug_level=4" \ |
Manuel Pégourié-Gonnard | de14378 | 2014-02-20 14:50:42 +0100 | [diff] [blame] | 530 | 0 \ |
| 531 | -C "client hello, adding max_fragment_length extension" \ |
| 532 | -S "found max fragment length extension" \ |
| 533 | -S "server hello, max_fragment_length extension" \ |
| 534 | -C "found max_fragment_length extension" |
| 535 | |
| 536 | run_test "Max fragment length #2" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 537 | "$P_SRV debug_level=4" \ |
| 538 | "$P_CLI debug_level=4 max_frag_len=4096" \ |
Manuel Pégourié-Gonnard | de14378 | 2014-02-20 14:50:42 +0100 | [diff] [blame] | 539 | 0 \ |
| 540 | -c "client hello, adding max_fragment_length extension" \ |
| 541 | -s "found max fragment length extension" \ |
| 542 | -s "server hello, max_fragment_length extension" \ |
| 543 | -c "found max_fragment_length extension" |
| 544 | |
| 545 | run_test "Max fragment length #3" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 546 | "$P_SRV debug_level=4 max_frag_len=4096" \ |
| 547 | "$P_CLI debug_level=4" \ |
Manuel Pégourié-Gonnard | de14378 | 2014-02-20 14:50:42 +0100 | [diff] [blame] | 548 | 0 \ |
| 549 | -C "client hello, adding max_fragment_length extension" \ |
| 550 | -S "found max fragment length extension" \ |
| 551 | -S "server hello, max_fragment_length extension" \ |
| 552 | -C "found max_fragment_length extension" |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 553 | |
| 554 | # Tests for renegotiation |
| 555 | |
| 556 | run_test "Renegotiation #0 (none)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 557 | "$P_SRV debug_level=4" \ |
| 558 | "$P_CLI debug_level=4" \ |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 559 | 0 \ |
| 560 | -C "client hello, adding renegotiation extension" \ |
| 561 | -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ |
| 562 | -S "found renegotiation extension" \ |
| 563 | -s "server hello, secure renegotiation extension" \ |
| 564 | -c "found renegotiation extension" \ |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 565 | -C "=> renegotiate" \ |
| 566 | -S "=> renegotiate" \ |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 567 | -S "write hello request" |
| 568 | |
| 569 | run_test "Renegotiation #1 (enabled, client-initiated)" \ |
Manuel Pégourié-Gonnard | 00d538f | 2014-03-31 10:44:40 +0200 | [diff] [blame] | 570 | "$P_SRV debug_level=4 renegotiation=1" \ |
| 571 | "$P_CLI debug_level=4 renegotiation=1 renegotiate=1" \ |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 572 | 0 \ |
| 573 | -c "client hello, adding renegotiation extension" \ |
| 574 | -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ |
| 575 | -s "found renegotiation extension" \ |
| 576 | -s "server hello, secure renegotiation extension" \ |
| 577 | -c "found renegotiation extension" \ |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 578 | -c "=> renegotiate" \ |
| 579 | -s "=> renegotiate" \ |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 580 | -S "write hello request" |
| 581 | |
| 582 | run_test "Renegotiation #2 (enabled, server-initiated)" \ |
Manuel Pégourié-Gonnard | 00d538f | 2014-03-31 10:44:40 +0200 | [diff] [blame] | 583 | "$P_SRV debug_level=4 renegotiation=1 renegotiate=1" \ |
| 584 | "$P_CLI debug_level=4 renegotiation=1" \ |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 585 | 0 \ |
| 586 | -c "client hello, adding renegotiation extension" \ |
| 587 | -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ |
| 588 | -s "found renegotiation extension" \ |
| 589 | -s "server hello, secure renegotiation extension" \ |
| 590 | -c "found renegotiation extension" \ |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 591 | -c "=> renegotiate" \ |
| 592 | -s "=> renegotiate" \ |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 593 | -s "write hello request" |
| 594 | |
| 595 | run_test "Renegotiation #3 (enabled, double)" \ |
Manuel Pégourié-Gonnard | 00d538f | 2014-03-31 10:44:40 +0200 | [diff] [blame] | 596 | "$P_SRV debug_level=4 renegotiation=1 renegotiate=1" \ |
| 597 | "$P_CLI debug_level=4 renegotiation=1 renegotiate=1" \ |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 598 | 0 \ |
| 599 | -c "client hello, adding renegotiation extension" \ |
| 600 | -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ |
| 601 | -s "found renegotiation extension" \ |
| 602 | -s "server hello, secure renegotiation extension" \ |
| 603 | -c "found renegotiation extension" \ |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 604 | -c "=> renegotiate" \ |
| 605 | -s "=> renegotiate" \ |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 606 | -s "write hello request" |
| 607 | |
| 608 | run_test "Renegotiation #4 (client-initiated, server-rejected)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 609 | "$P_SRV debug_level=4 renegotiation=0" \ |
Manuel Pégourié-Gonnard | 00d538f | 2014-03-31 10:44:40 +0200 | [diff] [blame] | 610 | "$P_CLI debug_level=4 renegotiation=1 renegotiate=1" \ |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 611 | 1 \ |
| 612 | -c "client hello, adding renegotiation extension" \ |
| 613 | -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ |
| 614 | -S "found renegotiation extension" \ |
| 615 | -s "server hello, secure renegotiation extension" \ |
| 616 | -c "found renegotiation extension" \ |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 617 | -c "=> renegotiate" \ |
| 618 | -S "=> renegotiate" \ |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 619 | -S "write hello request" |
| 620 | |
| 621 | run_test "Renegotiation #5 (server-initiated, client-rejected)" \ |
Manuel Pégourié-Gonnard | 00d538f | 2014-03-31 10:44:40 +0200 | [diff] [blame] | 622 | "$P_SRV debug_level=4 renegotiation=1 renegotiate=1" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 623 | "$P_CLI debug_level=4 renegotiation=0" \ |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 624 | 0 \ |
| 625 | -C "client hello, adding renegotiation extension" \ |
| 626 | -s "received TLS_EMPTY_RENEGOTIATION_INFO" \ |
| 627 | -S "found renegotiation extension" \ |
| 628 | -s "server hello, secure renegotiation extension" \ |
| 629 | -c "found renegotiation extension" \ |
Manuel Pégourié-Gonnard | c73339f | 2014-02-26 16:35:27 +0100 | [diff] [blame] | 630 | -C "=> renegotiate" \ |
| 631 | -S "=> renegotiate" \ |
Manuel Pégourié-Gonnard | 780d671 | 2014-02-20 17:19:59 +0100 | [diff] [blame] | 632 | -s "write hello request" \ |
| 633 | -s "SSL - An unexpected message was received from our peer" \ |
| 634 | -s "failed" |
Manuel Pégourié-Gonnard | 33a752e | 2014-02-21 09:47:37 +0100 | [diff] [blame] | 635 | |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 636 | # Tests for auth_mode |
| 637 | |
| 638 | run_test "Authentication #1 (server badcert, client required)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 639 | "$P_SRV crt_file=data_files/server5-badsign.crt \ |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 640 | key_file=data_files/server5.key" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 641 | "$P_CLI debug_level=2 auth_mode=required" \ |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 642 | 1 \ |
| 643 | -c "x509_verify_cert() returned" \ |
| 644 | -c "! self-signed or not signed by a trusted CA" \ |
| 645 | -c "! ssl_handshake returned" \ |
| 646 | -c "X509 - Certificate verification failed" |
| 647 | |
| 648 | run_test "Authentication #2 (server badcert, client optional)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 649 | "$P_SRV crt_file=data_files/server5-badsign.crt \ |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 650 | key_file=data_files/server5.key" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 651 | "$P_CLI debug_level=2 auth_mode=optional" \ |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 652 | 0 \ |
| 653 | -c "x509_verify_cert() returned" \ |
| 654 | -c "! self-signed or not signed by a trusted CA" \ |
| 655 | -C "! ssl_handshake returned" \ |
| 656 | -C "X509 - Certificate verification failed" |
| 657 | |
| 658 | run_test "Authentication #3 (server badcert, client none)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 659 | "$P_SRV crt_file=data_files/server5-badsign.crt \ |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 660 | key_file=data_files/server5.key" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 661 | "$P_CLI debug_level=2 auth_mode=none" \ |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 662 | 0 \ |
| 663 | -C "x509_verify_cert() returned" \ |
| 664 | -C "! self-signed or not signed by a trusted CA" \ |
| 665 | -C "! ssl_handshake returned" \ |
| 666 | -C "X509 - Certificate verification failed" |
| 667 | |
| 668 | run_test "Authentication #4 (client badcert, server required)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 669 | "$P_SRV debug_level=4 auth_mode=required" \ |
| 670 | "$P_CLI debug_level=4 crt_file=data_files/server5-badsign.crt \ |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 671 | key_file=data_files/server5.key" \ |
| 672 | 1 \ |
| 673 | -S "skip write certificate request" \ |
| 674 | -C "skip parse certificate request" \ |
| 675 | -c "got a certificate request" \ |
| 676 | -C "skip write certificate" \ |
| 677 | -C "skip write certificate verify" \ |
| 678 | -S "skip parse certificate verify" \ |
| 679 | -s "x509_verify_cert() returned" \ |
| 680 | -S "! self-signed or not signed by a trusted CA" \ |
| 681 | -s "! ssl_handshake returned" \ |
| 682 | -c "! ssl_handshake returned" \ |
| 683 | -s "X509 - Certificate verification failed" |
| 684 | |
| 685 | run_test "Authentication #5 (client badcert, server optional)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 686 | "$P_SRV debug_level=4 auth_mode=optional" \ |
| 687 | "$P_CLI debug_level=4 crt_file=data_files/server5-badsign.crt \ |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 688 | key_file=data_files/server5.key" \ |
| 689 | 0 \ |
| 690 | -S "skip write certificate request" \ |
| 691 | -C "skip parse certificate request" \ |
| 692 | -c "got a certificate request" \ |
| 693 | -C "skip write certificate" \ |
| 694 | -C "skip write certificate verify" \ |
| 695 | -S "skip parse certificate verify" \ |
| 696 | -s "x509_verify_cert() returned" \ |
| 697 | -s "! self-signed or not signed by a trusted CA" \ |
| 698 | -S "! ssl_handshake returned" \ |
| 699 | -C "! ssl_handshake returned" \ |
| 700 | -S "X509 - Certificate verification failed" |
| 701 | |
| 702 | run_test "Authentication #6 (client badcert, server none)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 703 | "$P_SRV debug_level=4 auth_mode=none" \ |
| 704 | "$P_CLI debug_level=4 crt_file=data_files/server5-badsign.crt \ |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 705 | key_file=data_files/server5.key" \ |
| 706 | 0 \ |
| 707 | -s "skip write certificate request" \ |
| 708 | -C "skip parse certificate request" \ |
| 709 | -c "got no certificate request" \ |
| 710 | -c "skip write certificate" \ |
| 711 | -c "skip write certificate verify" \ |
| 712 | -s "skip parse certificate verify" \ |
| 713 | -S "x509_verify_cert() returned" \ |
| 714 | -S "! self-signed or not signed by a trusted CA" \ |
| 715 | -S "! ssl_handshake returned" \ |
| 716 | -C "! ssl_handshake returned" \ |
| 717 | -S "X509 - Certificate verification failed" |
| 718 | |
Manuel Pégourié-Gonnard | de515cc | 2014-02-27 14:58:26 +0100 | [diff] [blame] | 719 | run_test "Authentication #7 (client no cert, server optional)" \ |
| 720 | "$P_SRV debug_level=4 auth_mode=optional" \ |
| 721 | "$P_CLI debug_level=4 crt_file=none key_file=none" \ |
| 722 | 0 \ |
| 723 | -S "skip write certificate request" \ |
| 724 | -C "skip parse certificate request" \ |
| 725 | -c "got a certificate request" \ |
| 726 | -C "skip write certificate$" \ |
| 727 | -C "got no certificate to send" \ |
| 728 | -S "SSLv3 client has no certificate" \ |
| 729 | -c "skip write certificate verify" \ |
| 730 | -s "skip parse certificate verify" \ |
| 731 | -s "! no client certificate sent" \ |
| 732 | -S "! ssl_handshake returned" \ |
| 733 | -C "! ssl_handshake returned" \ |
| 734 | -S "X509 - Certificate verification failed" |
| 735 | |
| 736 | run_test "Authentication #8 (openssl client no cert, server optional)" \ |
| 737 | "$P_SRV debug_level=4 auth_mode=optional" \ |
| 738 | "$O_CLI" \ |
| 739 | 0 \ |
| 740 | -S "skip write certificate request" \ |
| 741 | -s "skip parse certificate verify" \ |
| 742 | -s "! no client certificate sent" \ |
| 743 | -S "! ssl_handshake returned" \ |
| 744 | -S "X509 - Certificate verification failed" |
| 745 | |
| 746 | run_test "Authentication #9 (client no cert, openssl server optional)" \ |
| 747 | "$O_SRV -verify 10" \ |
| 748 | "$P_CLI debug_level=4 crt_file=none key_file=none" \ |
| 749 | 0 \ |
| 750 | -C "skip parse certificate request" \ |
| 751 | -c "got a certificate request" \ |
| 752 | -C "skip write certificate$" \ |
| 753 | -c "skip write certificate verify" \ |
| 754 | -C "! ssl_handshake returned" |
| 755 | |
| 756 | run_test "Authentication #10 (client no cert, ssl3)" \ |
| 757 | "$P_SRV debug_level=4 auth_mode=optional force_version=ssl3" \ |
| 758 | "$P_CLI debug_level=4 crt_file=none key_file=none" \ |
| 759 | 0 \ |
| 760 | -S "skip write certificate request" \ |
| 761 | -C "skip parse certificate request" \ |
| 762 | -c "got a certificate request" \ |
| 763 | -C "skip write certificate$" \ |
| 764 | -c "skip write certificate verify" \ |
| 765 | -c "got no certificate to send" \ |
| 766 | -s "SSLv3 client has no certificate" \ |
| 767 | -s "skip parse certificate verify" \ |
| 768 | -s "! no client certificate sent" \ |
| 769 | -S "! ssl_handshake returned" \ |
| 770 | -C "! ssl_handshake returned" \ |
| 771 | -S "X509 - Certificate verification failed" |
| 772 | |
Manuel Pégourié-Gonnard | 96ea2f2 | 2014-02-25 12:26:29 +0100 | [diff] [blame] | 773 | # tests for SNI |
| 774 | |
| 775 | run_test "SNI #0 (no SNI callback)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 776 | "$P_SRV debug_level=4 server_addr=127.0.0.1 \ |
Manuel Pégourié-Gonnard | 96ea2f2 | 2014-02-25 12:26:29 +0100 | [diff] [blame] | 777 | crt_file=data_files/server5.crt key_file=data_files/server5.key" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 778 | "$P_CLI debug_level=0 server_addr=127.0.0.1 \ |
Manuel Pégourié-Gonnard | 96ea2f2 | 2014-02-25 12:26:29 +0100 | [diff] [blame] | 779 | server_name=localhost" \ |
| 780 | 0 \ |
| 781 | -S "parse ServerName extension" \ |
| 782 | -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \ |
| 783 | -c "subject name *: C=NL, O=PolarSSL, CN=localhost" |
| 784 | |
| 785 | run_test "SNI #1 (matching cert 1)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 786 | "$P_SRV debug_level=4 server_addr=127.0.0.1 \ |
Manuel Pégourié-Gonnard | 96ea2f2 | 2014-02-25 12:26:29 +0100 | [diff] [blame] | 787 | crt_file=data_files/server5.crt key_file=data_files/server5.key \ |
Manuel Pégourié-Gonnard | 76b8ab7 | 2014-03-26 09:31:35 +0100 | [diff] [blame] | 788 | sni=localhost,data_files/server2.crt,data_files/server2.key,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 789 | "$P_CLI debug_level=0 server_addr=127.0.0.1 \ |
Manuel Pégourié-Gonnard | 96ea2f2 | 2014-02-25 12:26:29 +0100 | [diff] [blame] | 790 | server_name=localhost" \ |
| 791 | 0 \ |
| 792 | -s "parse ServerName extension" \ |
| 793 | -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \ |
| 794 | -c "subject name *: C=NL, O=PolarSSL, CN=localhost" |
| 795 | |
| 796 | run_test "SNI #2 (matching cert 2)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 797 | "$P_SRV debug_level=4 server_addr=127.0.0.1 \ |
Manuel Pégourié-Gonnard | 96ea2f2 | 2014-02-25 12:26:29 +0100 | [diff] [blame] | 798 | crt_file=data_files/server5.crt key_file=data_files/server5.key \ |
Manuel Pégourié-Gonnard | 76b8ab7 | 2014-03-26 09:31:35 +0100 | [diff] [blame] | 799 | sni=localhost,data_files/server2.crt,data_files/server2.key,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 800 | "$P_CLI debug_level=0 server_addr=127.0.0.1 \ |
Manuel Pégourié-Gonnard | 76b8ab7 | 2014-03-26 09:31:35 +0100 | [diff] [blame] | 801 | server_name=polarssl.example" \ |
Manuel Pégourié-Gonnard | 96ea2f2 | 2014-02-25 12:26:29 +0100 | [diff] [blame] | 802 | 0 \ |
| 803 | -s "parse ServerName extension" \ |
| 804 | -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \ |
Manuel Pégourié-Gonnard | 76b8ab7 | 2014-03-26 09:31:35 +0100 | [diff] [blame] | 805 | -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example" |
Manuel Pégourié-Gonnard | 96ea2f2 | 2014-02-25 12:26:29 +0100 | [diff] [blame] | 806 | |
| 807 | run_test "SNI #3 (no matching cert)" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 808 | "$P_SRV debug_level=4 server_addr=127.0.0.1 \ |
Manuel Pégourié-Gonnard | 96ea2f2 | 2014-02-25 12:26:29 +0100 | [diff] [blame] | 809 | crt_file=data_files/server5.crt key_file=data_files/server5.key \ |
Manuel Pégourié-Gonnard | 76b8ab7 | 2014-03-26 09:31:35 +0100 | [diff] [blame] | 810 | sni=localhost,data_files/server2.crt,data_files/server2.key,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key" \ |
Manuel Pégourié-Gonnard | c1da664 | 2014-02-25 14:18:30 +0100 | [diff] [blame] | 811 | "$P_CLI debug_level=0 server_addr=127.0.0.1 \ |
Manuel Pégourié-Gonnard | 76b8ab7 | 2014-03-26 09:31:35 +0100 | [diff] [blame] | 812 | server_name=nonesuch.example" \ |
Manuel Pégourié-Gonnard | 96ea2f2 | 2014-02-25 12:26:29 +0100 | [diff] [blame] | 813 | 1 \ |
| 814 | -s "parse ServerName extension" \ |
| 815 | -s "ssl_sni_wrapper() returned" \ |
| 816 | -s "ssl_handshake returned" \ |
| 817 | -c "ssl_handshake returned" \ |
| 818 | -c "SSL - A fatal alert message was received from our peer" |
| 819 | |
Manuel Pégourié-Gonnard | 0b6609b | 2014-02-26 14:45:12 +0100 | [diff] [blame] | 820 | # Tests for non-blocking I/O: exercise a variety of handshake flows |
| 821 | |
| 822 | run_test "Non-blocking I/O #1 (basic handshake)" \ |
| 823 | "$P_SRV nbio=2 tickets=0 auth_mode=none" \ |
| 824 | "$P_CLI nbio=2 tickets=0" \ |
| 825 | 0 \ |
| 826 | -S "ssl_handshake returned" \ |
| 827 | -C "ssl_handshake returned" \ |
| 828 | -c "Read from server: .* bytes read" |
| 829 | |
| 830 | run_test "Non-blocking I/O #2 (client auth)" \ |
| 831 | "$P_SRV nbio=2 tickets=0 auth_mode=required" \ |
| 832 | "$P_CLI nbio=2 tickets=0" \ |
| 833 | 0 \ |
| 834 | -S "ssl_handshake returned" \ |
| 835 | -C "ssl_handshake returned" \ |
| 836 | -c "Read from server: .* bytes read" |
| 837 | |
| 838 | run_test "Non-blocking I/O #3 (ticket)" \ |
| 839 | "$P_SRV nbio=2 tickets=1 auth_mode=none" \ |
| 840 | "$P_CLI nbio=2 tickets=1" \ |
| 841 | 0 \ |
| 842 | -S "ssl_handshake returned" \ |
| 843 | -C "ssl_handshake returned" \ |
| 844 | -c "Read from server: .* bytes read" |
| 845 | |
| 846 | run_test "Non-blocking I/O #4 (ticket + client auth)" \ |
| 847 | "$P_SRV nbio=2 tickets=1 auth_mode=required" \ |
| 848 | "$P_CLI nbio=2 tickets=1" \ |
| 849 | 0 \ |
| 850 | -S "ssl_handshake returned" \ |
| 851 | -C "ssl_handshake returned" \ |
| 852 | -c "Read from server: .* bytes read" |
| 853 | |
| 854 | run_test "Non-blocking I/O #5 (ticket + client auth + resume)" \ |
| 855 | "$P_SRV nbio=2 tickets=1 auth_mode=required" \ |
| 856 | "$P_CLI nbio=2 tickets=1 reconnect=1" \ |
| 857 | 0 \ |
| 858 | -S "ssl_handshake returned" \ |
| 859 | -C "ssl_handshake returned" \ |
| 860 | -c "Read from server: .* bytes read" |
| 861 | |
| 862 | run_test "Non-blocking I/O #6 (ticket + resume)" \ |
| 863 | "$P_SRV nbio=2 tickets=1 auth_mode=none" \ |
| 864 | "$P_CLI nbio=2 tickets=1 reconnect=1" \ |
| 865 | 0 \ |
| 866 | -S "ssl_handshake returned" \ |
| 867 | -C "ssl_handshake returned" \ |
| 868 | -c "Read from server: .* bytes read" |
| 869 | |
| 870 | run_test "Non-blocking I/O #7 (session-id resume)" \ |
| 871 | "$P_SRV nbio=2 tickets=0 auth_mode=none" \ |
| 872 | "$P_CLI nbio=2 tickets=0 reconnect=1" \ |
| 873 | 0 \ |
| 874 | -S "ssl_handshake returned" \ |
| 875 | -C "ssl_handshake returned" \ |
| 876 | -c "Read from server: .* bytes read" |
| 877 | |
Manuel Pégourié-Gonnard | f6521de | 2014-04-07 12:42:04 +0200 | [diff] [blame] | 878 | # Tests for version negotiation |
| 879 | |
Manuel Pégourié-Gonnard | a3d808e | 2014-02-26 16:33:03 +0100 | [diff] [blame] | 880 | run_test "Version check #1 (all -> 1.2)" \ |
| 881 | "$P_SRV" \ |
| 882 | "$P_CLI" \ |
| 883 | 0 \ |
| 884 | -S "ssl_handshake returned" \ |
| 885 | -C "ssl_handshake returned" \ |
| 886 | -s "Protocol is TLSv1.2" \ |
| 887 | -c "Protocol is TLSv1.2" |
| 888 | |
| 889 | run_test "Version check #2 (cli max 1.1 -> 1.1)" \ |
| 890 | "$P_SRV" \ |
| 891 | "$P_CLI max_version=tls1_1" \ |
| 892 | 0 \ |
| 893 | -S "ssl_handshake returned" \ |
| 894 | -C "ssl_handshake returned" \ |
| 895 | -s "Protocol is TLSv1.1" \ |
| 896 | -c "Protocol is TLSv1.1" |
| 897 | |
| 898 | run_test "Version check #3 (srv max 1.1 -> 1.1)" \ |
| 899 | "$P_SRV max_version=tls1_1" \ |
| 900 | "$P_CLI" \ |
| 901 | 0 \ |
| 902 | -S "ssl_handshake returned" \ |
| 903 | -C "ssl_handshake returned" \ |
| 904 | -s "Protocol is TLSv1.1" \ |
| 905 | -c "Protocol is TLSv1.1" |
| 906 | |
| 907 | run_test "Version check #4 (cli+srv max 1.1 -> 1.1)" \ |
| 908 | "$P_SRV max_version=tls1_1" \ |
| 909 | "$P_CLI max_version=tls1_1" \ |
| 910 | 0 \ |
| 911 | -S "ssl_handshake returned" \ |
| 912 | -C "ssl_handshake returned" \ |
| 913 | -s "Protocol is TLSv1.1" \ |
| 914 | -c "Protocol is TLSv1.1" |
| 915 | |
| 916 | run_test "Version check #5 (cli max 1.1, srv min 1.1 -> 1.1)" \ |
| 917 | "$P_SRV min_version=tls1_1" \ |
| 918 | "$P_CLI max_version=tls1_1" \ |
| 919 | 0 \ |
| 920 | -S "ssl_handshake returned" \ |
| 921 | -C "ssl_handshake returned" \ |
| 922 | -s "Protocol is TLSv1.1" \ |
| 923 | -c "Protocol is TLSv1.1" |
| 924 | |
| 925 | run_test "Version check #6 (cli min 1.1, srv max 1.1 -> 1.1)" \ |
| 926 | "$P_SRV max_version=tls1_1" \ |
| 927 | "$P_CLI min_version=tls1_1" \ |
| 928 | 0 \ |
| 929 | -S "ssl_handshake returned" \ |
| 930 | -C "ssl_handshake returned" \ |
| 931 | -s "Protocol is TLSv1.1" \ |
| 932 | -c "Protocol is TLSv1.1" |
| 933 | |
| 934 | run_test "Version check #7 (cli min 1.2, srv max 1.1 -> fail)" \ |
| 935 | "$P_SRV max_version=tls1_1" \ |
| 936 | "$P_CLI min_version=tls1_2" \ |
| 937 | 1 \ |
| 938 | -s "ssl_handshake returned" \ |
| 939 | -c "ssl_handshake returned" \ |
| 940 | -c "SSL - Handshake protocol not within min/max boundaries" |
| 941 | |
| 942 | run_test "Version check #8 (srv min 1.2, cli max 1.1 -> fail)" \ |
| 943 | "$P_SRV min_version=tls1_2" \ |
| 944 | "$P_CLI max_version=tls1_1" \ |
| 945 | 1 \ |
| 946 | -s "ssl_handshake returned" \ |
| 947 | -c "ssl_handshake returned" \ |
| 948 | -s "SSL - Handshake protocol not within min/max boundaries" |
| 949 | |
Manuel Pégourié-Gonnard | f6521de | 2014-04-07 12:42:04 +0200 | [diff] [blame] | 950 | # Tests for ALPN extension |
| 951 | |
Manuel Pégourié-Gonnard | 83d8c73 | 2014-04-07 13:24:21 +0200 | [diff] [blame] | 952 | if grep '^#define POLARSSL_SSL_ALPN' $CONFIG_H >/dev/null; then |
| 953 | |
Manuel Pégourié-Gonnard | f6521de | 2014-04-07 12:42:04 +0200 | [diff] [blame] | 954 | run_test "ALPN #0 (none)" \ |
| 955 | "$P_SRV debug_level=4" \ |
| 956 | "$P_CLI debug_level=4" \ |
| 957 | 0 \ |
| 958 | -C "client hello, adding alpn extension" \ |
| 959 | -S "found alpn extension" \ |
| 960 | -C "got an alert message, type: \\[2:120]" \ |
| 961 | -S "server hello, adding alpn extension" \ |
| 962 | -C "found alpn extension " \ |
| 963 | -C "Application Layer Protocol is" \ |
| 964 | -S "Application Layer Protocol is" |
| 965 | |
| 966 | run_test "ALPN #1 (client only)" \ |
| 967 | "$P_SRV debug_level=4" \ |
| 968 | "$P_CLI debug_level=4 alpn=abc,1234" \ |
| 969 | 0 \ |
| 970 | -c "client hello, adding alpn extension" \ |
| 971 | -s "found alpn extension" \ |
| 972 | -C "got an alert message, type: \\[2:120]" \ |
| 973 | -S "server hello, adding alpn extension" \ |
| 974 | -C "found alpn extension " \ |
| 975 | -c "Application Layer Protocol is (none)" \ |
| 976 | -S "Application Layer Protocol is" |
| 977 | |
| 978 | run_test "ALPN #2 (server only)" \ |
| 979 | "$P_SRV debug_level=4 alpn=abc,1234" \ |
| 980 | "$P_CLI debug_level=4" \ |
| 981 | 0 \ |
| 982 | -C "client hello, adding alpn extension" \ |
| 983 | -S "found alpn extension" \ |
| 984 | -C "got an alert message, type: \\[2:120]" \ |
| 985 | -S "server hello, adding alpn extension" \ |
| 986 | -C "found alpn extension " \ |
| 987 | -C "Application Layer Protocol is" \ |
| 988 | -s "Application Layer Protocol is (none)" |
| 989 | |
| 990 | run_test "ALPN #3 (both, common cli1-srv1)" \ |
| 991 | "$P_SRV debug_level=4 alpn=abc,1234" \ |
| 992 | "$P_CLI debug_level=4 alpn=abc,1234" \ |
| 993 | 0 \ |
| 994 | -c "client hello, adding alpn extension" \ |
| 995 | -s "found alpn extension" \ |
| 996 | -C "got an alert message, type: \\[2:120]" \ |
| 997 | -s "server hello, adding alpn extension" \ |
| 998 | -c "found alpn extension" \ |
| 999 | -c "Application Layer Protocol is abc" \ |
| 1000 | -s "Application Layer Protocol is abc" |
| 1001 | |
| 1002 | run_test "ALPN #4 (both, common cli2-srv1)" \ |
| 1003 | "$P_SRV debug_level=4 alpn=abc,1234" \ |
| 1004 | "$P_CLI debug_level=4 alpn=1234,abc" \ |
| 1005 | 0 \ |
| 1006 | -c "client hello, adding alpn extension" \ |
| 1007 | -s "found alpn extension" \ |
| 1008 | -C "got an alert message, type: \\[2:120]" \ |
| 1009 | -s "server hello, adding alpn extension" \ |
| 1010 | -c "found alpn extension" \ |
| 1011 | -c "Application Layer Protocol is abc" \ |
| 1012 | -s "Application Layer Protocol is abc" |
| 1013 | |
| 1014 | run_test "ALPN #5 (both, common cli1-srv2)" \ |
| 1015 | "$P_SRV debug_level=4 alpn=abc,1234" \ |
| 1016 | "$P_CLI debug_level=4 alpn=1234,abcde" \ |
| 1017 | 0 \ |
| 1018 | -c "client hello, adding alpn extension" \ |
| 1019 | -s "found alpn extension" \ |
| 1020 | -C "got an alert message, type: \\[2:120]" \ |
| 1021 | -s "server hello, adding alpn extension" \ |
| 1022 | -c "found alpn extension" \ |
| 1023 | -c "Application Layer Protocol is 1234" \ |
| 1024 | -s "Application Layer Protocol is 1234" |
| 1025 | |
| 1026 | run_test "ALPN #6 (both, no common)" \ |
| 1027 | "$P_SRV debug_level=4 alpn=abc,123" \ |
| 1028 | "$P_CLI debug_level=4 alpn=1234,abcde" \ |
| 1029 | 1 \ |
| 1030 | -c "client hello, adding alpn extension" \ |
| 1031 | -s "found alpn extension" \ |
| 1032 | -c "got an alert message, type: \\[2:120]" \ |
| 1033 | -S "server hello, adding alpn extension" \ |
| 1034 | -C "found alpn extension" \ |
| 1035 | -C "Application Layer Protocol is 1234" \ |
| 1036 | -S "Application Layer Protocol is 1234" |
| 1037 | |
Manuel Pégourié-Gonnard | 83d8c73 | 2014-04-07 13:24:21 +0200 | [diff] [blame] | 1038 | fi |
| 1039 | |
Manuel Pégourié-Gonnard | 7f2a07d | 2014-04-09 09:50:57 +0200 | [diff] [blame] | 1040 | # Tests for keyUsage in leaf certificates, part 1: |
| 1041 | # server-side certificate/suite selection |
| 1042 | |
Manuel Pégourié-Gonnard | 17cde5f | 2014-05-22 14:42:39 +0200 | [diff] [blame] | 1043 | run_test "keyUsage srv #1 (RSA, digitalSignature -> (EC)DHE-RSA)" \ |
Manuel Pégourié-Gonnard | 7f2a07d | 2014-04-09 09:50:57 +0200 | [diff] [blame] | 1044 | "$P_SRV key_file=data_files/server2.key \ |
| 1045 | crt_file=data_files/server2.ku-ds.crt" \ |
| 1046 | "$P_CLI" \ |
| 1047 | 0 \ |
Manuel Pégourié-Gonnard | 17cde5f | 2014-05-22 14:42:39 +0200 | [diff] [blame] | 1048 | -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-" |
Manuel Pégourié-Gonnard | 7f2a07d | 2014-04-09 09:50:57 +0200 | [diff] [blame] | 1049 | |
| 1050 | |
| 1051 | run_test "keyUsage srv #2 (RSA, keyEncipherment -> RSA)" \ |
| 1052 | "$P_SRV key_file=data_files/server2.key \ |
| 1053 | crt_file=data_files/server2.ku-ke.crt" \ |
| 1054 | "$P_CLI" \ |
| 1055 | 0 \ |
| 1056 | -c "Ciphersuite is TLS-RSA-WITH-" |
| 1057 | |
| 1058 | # add psk to leave an option for client to send SERVERQUIT |
| 1059 | run_test "keyUsage srv #3 (RSA, keyAgreement -> fail)" \ |
| 1060 | "$P_SRV psk=abc123 key_file=data_files/server2.key \ |
| 1061 | crt_file=data_files/server2.ku-ka.crt" \ |
| 1062 | "$P_CLI psk=badbad" \ |
| 1063 | 1 \ |
| 1064 | -C "Ciphersuite is " |
| 1065 | |
| 1066 | run_test "keyUsage srv #4 (ECDSA, digitalSignature -> ECDHE-ECDSA)" \ |
| 1067 | "$P_SRV key_file=data_files/server5.key \ |
| 1068 | crt_file=data_files/server5.ku-ds.crt" \ |
| 1069 | "$P_CLI" \ |
| 1070 | 0 \ |
| 1071 | -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-" |
| 1072 | |
| 1073 | |
| 1074 | run_test "keyUsage srv #5 (ECDSA, keyAgreement -> ECDH-)" \ |
| 1075 | "$P_SRV key_file=data_files/server5.key \ |
| 1076 | crt_file=data_files/server5.ku-ka.crt" \ |
| 1077 | "$P_CLI" \ |
| 1078 | 0 \ |
| 1079 | -c "Ciphersuite is TLS-ECDH-" |
| 1080 | |
| 1081 | # add psk to leave an option for client to send SERVERQUIT |
| 1082 | run_test "keyUsage srv #6 (ECDSA, keyEncipherment -> fail)" \ |
| 1083 | "$P_SRV psk=abc123 key_file=data_files/server5.key \ |
| 1084 | crt_file=data_files/server5.ku-ke.crt" \ |
| 1085 | "$P_CLI psk=badbad" \ |
| 1086 | 1 \ |
| 1087 | -C "Ciphersuite is " |
| 1088 | |
| 1089 | # Tests for keyUsage in leaf certificates, part 2: |
Manuel Pégourié-Gonnard | a9db85d | 2014-04-09 14:53:05 +0200 | [diff] [blame] | 1090 | # client-side checking of server cert |
Manuel Pégourié-Gonnard | 7f2a07d | 2014-04-09 09:50:57 +0200 | [diff] [blame] | 1091 | |
| 1092 | run_test "keyUsage cli #1 (DigitalSignature+KeyEncipherment, RSA: OK)" \ |
| 1093 | "$O_SRV -key data_files/server2.key \ |
| 1094 | -cert data_files/server2.ku-ds_ke.crt" \ |
| 1095 | "$P_CLI debug_level=2 \ |
| 1096 | force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ |
| 1097 | 0 \ |
Manuel Pégourié-Gonnard | a9db85d | 2014-04-09 14:53:05 +0200 | [diff] [blame] | 1098 | -C "bad certificate (usage extensions)" \ |
Manuel Pégourié-Gonnard | 7f2a07d | 2014-04-09 09:50:57 +0200 | [diff] [blame] | 1099 | -C "Processing of the Certificate handshake message failed" \ |
| 1100 | -c "Ciphersuite is TLS-" |
| 1101 | |
| 1102 | run_test "keyUsage cli #2 (DigitalSignature+KeyEncipherment, DHE-RSA: OK)" \ |
| 1103 | "$O_SRV -key data_files/server2.key \ |
| 1104 | -cert data_files/server2.ku-ds_ke.crt" \ |
| 1105 | "$P_CLI debug_level=2 \ |
| 1106 | force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \ |
| 1107 | 0 \ |
Manuel Pégourié-Gonnard | a9db85d | 2014-04-09 14:53:05 +0200 | [diff] [blame] | 1108 | -C "bad certificate (usage extensions)" \ |
Manuel Pégourié-Gonnard | 7f2a07d | 2014-04-09 09:50:57 +0200 | [diff] [blame] | 1109 | -C "Processing of the Certificate handshake message failed" \ |
| 1110 | -c "Ciphersuite is TLS-" |
| 1111 | |
| 1112 | run_test "keyUsage cli #3 (KeyEncipherment, RSA: OK)" \ |
| 1113 | "$O_SRV -key data_files/server2.key \ |
| 1114 | -cert data_files/server2.ku-ke.crt" \ |
| 1115 | "$P_CLI debug_level=2 \ |
| 1116 | force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ |
| 1117 | 0 \ |
Manuel Pégourié-Gonnard | a9db85d | 2014-04-09 14:53:05 +0200 | [diff] [blame] | 1118 | -C "bad certificate (usage extensions)" \ |
Manuel Pégourié-Gonnard | 7f2a07d | 2014-04-09 09:50:57 +0200 | [diff] [blame] | 1119 | -C "Processing of the Certificate handshake message failed" \ |
| 1120 | -c "Ciphersuite is TLS-" |
| 1121 | |
| 1122 | run_test "keyUsage cli #4 (KeyEncipherment, DHE-RSA: fail)" \ |
| 1123 | "$O_SRV -key data_files/server2.key \ |
| 1124 | -cert data_files/server2.ku-ke.crt" \ |
| 1125 | "$P_CLI debug_level=2 \ |
| 1126 | force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \ |
| 1127 | 1 \ |
Manuel Pégourié-Gonnard | a9db85d | 2014-04-09 14:53:05 +0200 | [diff] [blame] | 1128 | -c "bad certificate (usage extensions)" \ |
Manuel Pégourié-Gonnard | 7f2a07d | 2014-04-09 09:50:57 +0200 | [diff] [blame] | 1129 | -c "Processing of the Certificate handshake message failed" \ |
| 1130 | -C "Ciphersuite is TLS-" |
| 1131 | |
| 1132 | run_test "keyUsage cli #5 (DigitalSignature, DHE-RSA: OK)" \ |
| 1133 | "$O_SRV -key data_files/server2.key \ |
| 1134 | -cert data_files/server2.ku-ds.crt" \ |
| 1135 | "$P_CLI debug_level=2 \ |
| 1136 | force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \ |
| 1137 | 0 \ |
Manuel Pégourié-Gonnard | a9db85d | 2014-04-09 14:53:05 +0200 | [diff] [blame] | 1138 | -C "bad certificate (usage extensions)" \ |
Manuel Pégourié-Gonnard | 7f2a07d | 2014-04-09 09:50:57 +0200 | [diff] [blame] | 1139 | -C "Processing of the Certificate handshake message failed" \ |
| 1140 | -c "Ciphersuite is TLS-" |
| 1141 | |
| 1142 | run_test "keyUsage cli #5 (DigitalSignature, RSA: fail)" \ |
| 1143 | "$O_SRV -key data_files/server2.key \ |
| 1144 | -cert data_files/server2.ku-ds.crt" \ |
| 1145 | "$P_CLI debug_level=2 \ |
| 1146 | force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ |
| 1147 | 1 \ |
Manuel Pégourié-Gonnard | a9db85d | 2014-04-09 14:53:05 +0200 | [diff] [blame] | 1148 | -c "bad certificate (usage extensions)" \ |
Manuel Pégourié-Gonnard | 7f2a07d | 2014-04-09 09:50:57 +0200 | [diff] [blame] | 1149 | -c "Processing of the Certificate handshake message failed" \ |
| 1150 | -C "Ciphersuite is TLS-" |
| 1151 | |
Manuel Pégourié-Gonnard | a9db85d | 2014-04-09 14:53:05 +0200 | [diff] [blame] | 1152 | # Tests for keyUsage in leaf certificates, part 3: |
| 1153 | # server-side checking of client cert |
| 1154 | |
| 1155 | run_test "keyUsage cli-auth #1 (RSA, DigitalSignature: OK)" \ |
| 1156 | "$P_SRV debug_level=2 auth_mode=optional" \ |
| 1157 | "$O_CLI -key data_files/server2.key \ |
| 1158 | -cert data_files/server2.ku-ds.crt" \ |
| 1159 | 0 \ |
| 1160 | -S "bad certificate (usage extensions)" \ |
| 1161 | -S "Processing of the Certificate handshake message failed" |
| 1162 | |
| 1163 | run_test "keyUsage cli-auth #2 (RSA, KeyEncipherment: fail (soft))" \ |
| 1164 | "$P_SRV debug_level=2 auth_mode=optional" \ |
| 1165 | "$O_CLI -key data_files/server2.key \ |
| 1166 | -cert data_files/server2.ku-ke.crt" \ |
| 1167 | 0 \ |
| 1168 | -s "bad certificate (usage extensions)" \ |
| 1169 | -S "Processing of the Certificate handshake message failed" |
| 1170 | |
| 1171 | run_test "keyUsage cli-auth #3 (RSA, KeyEncipherment: fail (hard))" \ |
| 1172 | "$P_SRV debug_level=2 auth_mode=required" \ |
| 1173 | "$O_CLI -key data_files/server2.key \ |
| 1174 | -cert data_files/server2.ku-ke.crt" \ |
| 1175 | 1 \ |
| 1176 | -s "bad certificate (usage extensions)" \ |
| 1177 | -s "Processing of the Certificate handshake message failed" |
| 1178 | |
| 1179 | run_test "keyUsage cli-auth #4 (ECDSA, DigitalSignature: OK)" \ |
| 1180 | "$P_SRV debug_level=2 auth_mode=optional" \ |
| 1181 | "$O_CLI -key data_files/server5.key \ |
| 1182 | -cert data_files/server5.ku-ds.crt" \ |
| 1183 | 0 \ |
| 1184 | -S "bad certificate (usage extensions)" \ |
| 1185 | -S "Processing of the Certificate handshake message failed" |
| 1186 | |
| 1187 | run_test "keyUsage cli-auth #5 (ECDSA, KeyAgreement: fail (soft))" \ |
| 1188 | "$P_SRV debug_level=2 auth_mode=optional" \ |
| 1189 | "$O_CLI -key data_files/server5.key \ |
| 1190 | -cert data_files/server5.ku-ka.crt" \ |
| 1191 | 0 \ |
| 1192 | -s "bad certificate (usage extensions)" \ |
| 1193 | -S "Processing of the Certificate handshake message failed" |
| 1194 | |
Manuel Pégourié-Gonnard | 0408fd1 | 2014-04-11 11:06:22 +0200 | [diff] [blame] | 1195 | # Tests for extendedKeyUsage, part 1: server-side certificate/suite selection |
| 1196 | |
| 1197 | run_test "extKeyUsage srv #1 (serverAuth -> OK)" \ |
| 1198 | "$P_SRV key_file=data_files/server5.key \ |
| 1199 | crt_file=data_files/server5.eku-srv.crt" \ |
| 1200 | "$P_CLI" \ |
| 1201 | 0 |
| 1202 | |
| 1203 | run_test "extKeyUsage srv #2 (serverAuth,clientAuth -> OK)" \ |
| 1204 | "$P_SRV key_file=data_files/server5.key \ |
| 1205 | crt_file=data_files/server5.eku-srv.crt" \ |
| 1206 | "$P_CLI" \ |
| 1207 | 0 |
| 1208 | |
| 1209 | run_test "extKeyUsage srv #3 (codeSign,anyEKU -> OK)" \ |
| 1210 | "$P_SRV key_file=data_files/server5.key \ |
| 1211 | crt_file=data_files/server5.eku-cs_any.crt" \ |
| 1212 | "$P_CLI" \ |
| 1213 | 0 |
| 1214 | |
| 1215 | # add psk to leave an option for client to send SERVERQUIT |
| 1216 | run_test "extKeyUsage srv #4 (codeSign -> fail)" \ |
| 1217 | "$P_SRV psk=abc123 key_file=data_files/server5.key \ |
| 1218 | crt_file=data_files/server5.eku-cli.crt" \ |
| 1219 | "$P_CLI psk=badbad" \ |
| 1220 | 1 |
| 1221 | |
| 1222 | # Tests for extendedKeyUsage, part 2: client-side checking of server cert |
| 1223 | |
| 1224 | run_test "extKeyUsage cli #1 (serverAuth -> OK)" \ |
| 1225 | "$O_SRV -key data_files/server5.key \ |
| 1226 | -cert data_files/server5.eku-srv.crt" \ |
| 1227 | "$P_CLI debug_level=2" \ |
| 1228 | 0 \ |
| 1229 | -C "bad certificate (usage extensions)" \ |
| 1230 | -C "Processing of the Certificate handshake message failed" \ |
| 1231 | -c "Ciphersuite is TLS-" |
| 1232 | |
| 1233 | run_test "extKeyUsage cli #2 (serverAuth,clientAuth -> OK)" \ |
| 1234 | "$O_SRV -key data_files/server5.key \ |
| 1235 | -cert data_files/server5.eku-srv_cli.crt" \ |
| 1236 | "$P_CLI debug_level=2" \ |
| 1237 | 0 \ |
| 1238 | -C "bad certificate (usage extensions)" \ |
| 1239 | -C "Processing of the Certificate handshake message failed" \ |
| 1240 | -c "Ciphersuite is TLS-" |
| 1241 | |
| 1242 | run_test "extKeyUsage cli #3 (codeSign,anyEKU -> OK)" \ |
| 1243 | "$O_SRV -key data_files/server5.key \ |
| 1244 | -cert data_files/server5.eku-cs_any.crt" \ |
| 1245 | "$P_CLI debug_level=2" \ |
| 1246 | 0 \ |
| 1247 | -C "bad certificate (usage extensions)" \ |
| 1248 | -C "Processing of the Certificate handshake message failed" \ |
| 1249 | -c "Ciphersuite is TLS-" |
| 1250 | |
| 1251 | run_test "extKeyUsage cli #4 (codeSign -> fail)" \ |
| 1252 | "$O_SRV -key data_files/server5.key \ |
| 1253 | -cert data_files/server5.eku-cs.crt" \ |
| 1254 | "$P_CLI debug_level=2" \ |
| 1255 | 1 \ |
| 1256 | -c "bad certificate (usage extensions)" \ |
| 1257 | -c "Processing of the Certificate handshake message failed" \ |
| 1258 | -C "Ciphersuite is TLS-" |
| 1259 | |
| 1260 | # Tests for extendedKeyUsage, part 3: server-side checking of client cert |
| 1261 | |
| 1262 | run_test "extKeyUsage cli-auth #1 (clientAuth -> OK)" \ |
| 1263 | "$P_SRV debug_level=2 auth_mode=optional" \ |
| 1264 | "$O_CLI -key data_files/server5.key \ |
| 1265 | -cert data_files/server5.eku-cli.crt" \ |
| 1266 | 0 \ |
| 1267 | -S "bad certificate (usage extensions)" \ |
| 1268 | -S "Processing of the Certificate handshake message failed" |
| 1269 | |
| 1270 | run_test "extKeyUsage cli-auth #2 (serverAuth,clientAuth -> OK)" \ |
| 1271 | "$P_SRV debug_level=2 auth_mode=optional" \ |
| 1272 | "$O_CLI -key data_files/server5.key \ |
| 1273 | -cert data_files/server5.eku-srv_cli.crt" \ |
| 1274 | 0 \ |
| 1275 | -S "bad certificate (usage extensions)" \ |
| 1276 | -S "Processing of the Certificate handshake message failed" |
| 1277 | |
| 1278 | run_test "extKeyUsage cli-auth #3 (codeSign,anyEKU -> OK)" \ |
| 1279 | "$P_SRV debug_level=2 auth_mode=optional" \ |
| 1280 | "$O_CLI -key data_files/server5.key \ |
| 1281 | -cert data_files/server5.eku-cs_any.crt" \ |
| 1282 | 0 \ |
| 1283 | -S "bad certificate (usage extensions)" \ |
| 1284 | -S "Processing of the Certificate handshake message failed" |
| 1285 | |
| 1286 | run_test "extKeyUsage cli-auth #4 (codeSign -> fail (soft))" \ |
| 1287 | "$P_SRV debug_level=2 auth_mode=optional" \ |
| 1288 | "$O_CLI -key data_files/server5.key \ |
| 1289 | -cert data_files/server5.eku-cs.crt" \ |
| 1290 | 0 \ |
| 1291 | -s "bad certificate (usage extensions)" \ |
| 1292 | -S "Processing of the Certificate handshake message failed" |
| 1293 | |
| 1294 | run_test "extKeyUsage cli-auth #4b (codeSign -> fail (hard))" \ |
| 1295 | "$P_SRV debug_level=2 auth_mode=required" \ |
| 1296 | "$O_CLI -key data_files/server5.key \ |
| 1297 | -cert data_files/server5.eku-cs.crt" \ |
| 1298 | 1 \ |
| 1299 | -s "bad certificate (usage extensions)" \ |
| 1300 | -s "Processing of the Certificate handshake message failed" |
| 1301 | |
Manuel Pégourié-Gonnard | 0cc7e31 | 2014-06-09 11:36:47 +0200 | [diff] [blame] | 1302 | # Tests for DHM parameters loading |
| 1303 | |
| 1304 | run_test "DHM parameters #0 (reference)" \ |
| 1305 | "$P_SRV" \ |
| 1306 | "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \ |
| 1307 | debug_level=3" \ |
| 1308 | 0 \ |
| 1309 | -c "value of 'DHM: P ' (2048 bits)" \ |
| 1310 | -c "value of 'DHM: G ' (2048 bits)" |
| 1311 | |
| 1312 | run_test "DHM parameters #1 (other parameters)" \ |
| 1313 | "$P_SRV dhm_file=data_files/dhparams.pem" \ |
| 1314 | "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \ |
| 1315 | debug_level=3" \ |
| 1316 | 0 \ |
| 1317 | -c "value of 'DHM: P ' (1024 bits)" \ |
| 1318 | -c "value of 'DHM: G ' (2 bits)" |
| 1319 | |
Manuel Pégourié-Gonnard | a6781c9 | 2014-06-10 15:00:46 +0200 | [diff] [blame] | 1320 | # Tests for PSK callback |
| 1321 | |
Manuel Pégourié-Gonnard | 10c3c9f | 2014-06-10 15:28:52 +0200 | [diff] [blame] | 1322 | run_test "PSK callback #0a (psk, no callback)" \ |
Manuel Pégourié-Gonnard | a6781c9 | 2014-06-10 15:00:46 +0200 | [diff] [blame] | 1323 | "$P_SRV psk=abc123 psk_identity=foo" \ |
| 1324 | "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \ |
| 1325 | psk_identity=foo psk=abc123" \ |
| 1326 | 0 \ |
Manuel Pégourié-Gonnard | 10c3c9f | 2014-06-10 15:28:52 +0200 | [diff] [blame] | 1327 | -S "SSL - The server has no ciphersuites in common" \ |
| 1328 | -S "SSL - Unknown identity received" \ |
| 1329 | -S "SSL - Verification of the message MAC failed" |
| 1330 | |
| 1331 | run_test "PSK callback #0b (no psk, no callback)" \ |
| 1332 | "$P_SRV" \ |
| 1333 | "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \ |
| 1334 | psk_identity=foo psk=abc123" \ |
| 1335 | 1 \ |
| 1336 | -s "SSL - The server has no ciphersuites in common" \ |
Manuel Pégourié-Gonnard | a6781c9 | 2014-06-10 15:00:46 +0200 | [diff] [blame] | 1337 | -S "SSL - Unknown identity received" \ |
| 1338 | -S "SSL - Verification of the message MAC failed" |
| 1339 | |
| 1340 | run_test "PSK callback #1 (callback overrides other settings)" \ |
| 1341 | "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \ |
| 1342 | "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \ |
| 1343 | psk_identity=foo psk=abc123" \ |
| 1344 | 1 \ |
Manuel Pégourié-Gonnard | 10c3c9f | 2014-06-10 15:28:52 +0200 | [diff] [blame] | 1345 | -S "SSL - The server has no ciphersuites in common" \ |
Manuel Pégourié-Gonnard | a6781c9 | 2014-06-10 15:00:46 +0200 | [diff] [blame] | 1346 | -s "SSL - Unknown identity received" \ |
| 1347 | -S "SSL - Verification of the message MAC failed" |
| 1348 | |
| 1349 | run_test "PSK callback #2 (first id matches)" \ |
| 1350 | "$P_SRV psk_list=abc,dead,def,beef" \ |
| 1351 | "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \ |
| 1352 | psk_identity=abc psk=dead" \ |
| 1353 | 0 \ |
Manuel Pégourié-Gonnard | 10c3c9f | 2014-06-10 15:28:52 +0200 | [diff] [blame] | 1354 | -S "SSL - The server has no ciphersuites in common" \ |
Manuel Pégourié-Gonnard | a6781c9 | 2014-06-10 15:00:46 +0200 | [diff] [blame] | 1355 | -S "SSL - Unknown identity received" \ |
| 1356 | -S "SSL - Verification of the message MAC failed" |
| 1357 | |
| 1358 | run_test "PSK callback #3 (second id matches)" \ |
| 1359 | "$P_SRV psk_list=abc,dead,def,beef" \ |
| 1360 | "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \ |
| 1361 | psk_identity=def psk=beef" \ |
| 1362 | 0 \ |
Manuel Pégourié-Gonnard | 10c3c9f | 2014-06-10 15:28:52 +0200 | [diff] [blame] | 1363 | -S "SSL - The server has no ciphersuites in common" \ |
Manuel Pégourié-Gonnard | a6781c9 | 2014-06-10 15:00:46 +0200 | [diff] [blame] | 1364 | -S "SSL - Unknown identity received" \ |
| 1365 | -S "SSL - Verification of the message MAC failed" |
| 1366 | |
| 1367 | run_test "PSK callback #4 (no match)" \ |
| 1368 | "$P_SRV psk_list=abc,dead,def,beef" \ |
| 1369 | "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \ |
| 1370 | psk_identity=ghi psk=beef" \ |
| 1371 | 1 \ |
Manuel Pégourié-Gonnard | 10c3c9f | 2014-06-10 15:28:52 +0200 | [diff] [blame] | 1372 | -S "SSL - The server has no ciphersuites in common" \ |
Manuel Pégourié-Gonnard | a6781c9 | 2014-06-10 15:00:46 +0200 | [diff] [blame] | 1373 | -s "SSL - Unknown identity received" \ |
| 1374 | -S "SSL - Verification of the message MAC failed" |
| 1375 | |
| 1376 | run_test "PSK callback #5 (wrong key)" \ |
| 1377 | "$P_SRV psk_list=abc,dead,def,beef" \ |
| 1378 | "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \ |
| 1379 | psk_identity=abc psk=beef" \ |
| 1380 | 1 \ |
Manuel Pégourié-Gonnard | 10c3c9f | 2014-06-10 15:28:52 +0200 | [diff] [blame] | 1381 | -S "SSL - The server has no ciphersuites in common" \ |
Manuel Pégourié-Gonnard | a6781c9 | 2014-06-10 15:00:46 +0200 | [diff] [blame] | 1382 | -S "SSL - Unknown identity received" \ |
| 1383 | -s "SSL - Verification of the message MAC failed" |
Manuel Pégourié-Gonnard | 0cc7e31 | 2014-06-09 11:36:47 +0200 | [diff] [blame] | 1384 | |
Manuel Pégourié-Gonnard | 90805a8 | 2014-06-11 14:06:01 +0200 | [diff] [blame] | 1385 | # Tests for ciphersuites per version |
| 1386 | |
| 1387 | run_test "Per-version suites #1" \ |
| 1388 | "$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-RC4-128-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \ |
| 1389 | "$P_CLI force_version=ssl3" \ |
| 1390 | 0 \ |
| 1391 | -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA" |
| 1392 | |
| 1393 | run_test "Per-version suites #2" \ |
| 1394 | "$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-RC4-128-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \ |
| 1395 | "$P_CLI force_version=tls1" \ |
| 1396 | 0 \ |
| 1397 | -c "Ciphersuite is TLS-RSA-WITH-RC4-128-SHA" |
| 1398 | |
| 1399 | run_test "Per-version suites #3" \ |
| 1400 | "$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-RC4-128-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \ |
| 1401 | "$P_CLI force_version=tls1_1" \ |
| 1402 | 0 \ |
| 1403 | -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA" |
| 1404 | |
| 1405 | run_test "Per-version suites #4" \ |
| 1406 | "$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-RC4-128-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \ |
| 1407 | "$P_CLI force_version=tls1_2" \ |
| 1408 | 0 \ |
| 1409 | -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256" |
| 1410 | |
Manuel Pégourié-Gonnard | 95c0a63 | 2014-06-11 18:32:36 +0200 | [diff] [blame] | 1411 | # Tests for ssl_get_bytes_avail() |
| 1412 | |
| 1413 | run_test "ssl_get_bytes_avail #1 (no extra data)" \ |
| 1414 | "$P_SRV" \ |
| 1415 | "$P_CLI request_size=100" \ |
| 1416 | 0 \ |
| 1417 | -s "Read from client: 100 bytes read$" |
| 1418 | |
| 1419 | run_test "ssl_get_bytes_avail #2 (extra data)" \ |
| 1420 | "$P_SRV" \ |
| 1421 | "$P_CLI request_size=500" \ |
| 1422 | 0 \ |
| 1423 | -s "Read from client: 500 bytes read (.*+.*)" |
Manuel Pégourié-Gonnard | 90805a8 | 2014-06-11 14:06:01 +0200 | [diff] [blame] | 1424 | |
Manuel Pégourié-Gonnard | 8520dac | 2014-02-21 12:12:23 +0100 | [diff] [blame] | 1425 | # Final report |
| 1426 | |
Manuel Pégourié-Gonnard | 33a752e | 2014-02-21 09:47:37 +0100 | [diff] [blame] | 1427 | echo "------------------------------------------------------------------------" |
| 1428 | |
| 1429 | if [ $FAILS = 0 ]; then |
| 1430 | echo -n "PASSED" |
| 1431 | else |
| 1432 | echo -n "FAILED" |
| 1433 | fi |
| 1434 | PASSES=`echo $TESTS - $FAILS | bc` |
Manuel Pégourié-Gonnard | 4145b89 | 2014-02-24 13:20:14 +0100 | [diff] [blame] | 1435 | echo " ($PASSES / $TESTS tests)" |
Manuel Pégourié-Gonnard | 33a752e | 2014-02-21 09:47:37 +0100 | [diff] [blame] | 1436 | |
| 1437 | exit $FAILS |