Manuel Pégourié-Gonnard | 72e51ee | 2014-08-31 10:22:11 +0200 | [diff] [blame] | 1 | #!/bin/sh |
Paul Bakker | accd4eb | 2013-07-19 13:41:51 +0200 | [diff] [blame] | 2 | |
Simon Butcher | ac22d11 | 2016-09-04 22:31:09 +0100 | [diff] [blame] | 3 | # compat.sh |
| 4 | # |
Bence Szépkúti | 1e14827 | 2020-08-07 13:07:28 +0200 | [diff] [blame] | 5 | # Copyright The Mbed TLS Contributors |
Bence Szépkúti | c7da1fe | 2020-05-26 01:54:15 +0200 | [diff] [blame] | 6 | # SPDX-License-Identifier: Apache-2.0 |
| 7 | # |
| 8 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 9 | # not use this file except in compliance with the License. |
| 10 | # You may obtain a copy of the License at |
| 11 | # |
| 12 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | # |
| 14 | # Unless required by applicable law or agreed to in writing, software |
| 15 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 16 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | # See the License for the specific language governing permissions and |
| 18 | # limitations under the License. |
| 19 | # |
Simon Butcher | ac22d11 | 2016-09-04 22:31:09 +0100 | [diff] [blame] | 20 | # Purpose |
| 21 | # |
| 22 | # Test interoperbility with OpenSSL, GnuTLS as well as itself. |
Manuel Pégourié-Gonnard | 12b8472 | 2014-03-25 19:07:28 +0100 | [diff] [blame] | 23 | # |
| 24 | # Check each common ciphersuite, with each version, both ways (client/server), |
| 25 | # with and without client authentication. |
Manuel Pégourié-Gonnard | eaadc50 | 2014-02-20 11:01:30 +0100 | [diff] [blame] | 26 | |
Manuel Pégourié-Gonnard | 913030c | 2014-03-28 10:12:38 +0100 | [diff] [blame] | 27 | set -u |
| 28 | |
Jaeden Amero | 6e70eb2 | 2019-07-03 13:51:04 +0100 | [diff] [blame] | 29 | # Limit the size of each log to 10 GiB, in case of failures with this script |
| 30 | # where it may output seemingly unlimited length error logs. |
| 31 | ulimit -f 20971520 |
| 32 | |
Manuel Pégourié-Gonnard | a1a9f9a | 2014-03-25 18:04:59 +0100 | [diff] [blame] | 33 | # initialise counters |
Manuel Pégourié-Gonnard | 72e51ee | 2014-08-31 10:22:11 +0200 | [diff] [blame] | 34 | TESTS=0 |
| 35 | FAILED=0 |
| 36 | SKIPPED=0 |
| 37 | SRVMEM=0 |
Manuel Pégourié-Gonnard | 70064fd | 2013-08-27 22:00:47 +0200 | [diff] [blame] | 38 | |
Antonin Décimo | 36e89b5 | 2019-01-23 15:24:37 +0100 | [diff] [blame] | 39 | # default commands, can be overridden by the environment |
Simon Butcher | ac22d11 | 2016-09-04 22:31:09 +0100 | [diff] [blame] | 40 | : ${M_SRV:=../programs/ssl/ssl_server2} |
| 41 | : ${M_CLI:=../programs/ssl/ssl_client2} |
Manuel Pégourié-Gonnard | 74faf3c | 2014-03-13 18:47:44 +0100 | [diff] [blame] | 42 | : ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system |
| 43 | : ${GNUTLS_CLI:=gnutls-cli} |
| 44 | : ${GNUTLS_SERV:=gnutls-serv} |
Manuel Pégourié-Gonnard | f7a2690 | 2014-02-27 12:25:54 +0100 | [diff] [blame] | 45 | |
Manuel Pégourié-Gonnard | 1287f11 | 2014-08-31 16:20:58 +0200 | [diff] [blame] | 46 | # do we have a recent enough GnuTLS? |
Manuel Pégourié-Gonnard | 03db6b0 | 2015-06-26 15:45:30 +0200 | [diff] [blame] | 47 | if ( which $GNUTLS_CLI && which $GNUTLS_SERV ) >/dev/null 2>&1; then |
Manuel Pégourié-Gonnard | dd45927 | 2014-10-24 12:57:37 +0200 | [diff] [blame] | 48 | G_VER="$( $GNUTLS_CLI --version | head -n1 )" |
| 49 | if echo "$G_VER" | grep '@VERSION@' > /dev/null; then # git version |
Manuel Pégourié-Gonnard | 1287f11 | 2014-08-31 16:20:58 +0200 | [diff] [blame] | 50 | PEER_GNUTLS=" GnuTLS" |
Manuel Pégourié-Gonnard | dd45927 | 2014-10-24 12:57:37 +0200 | [diff] [blame] | 51 | else |
| 52 | eval $( echo $G_VER | sed 's/.* \([0-9]*\)\.\([0-9]\)*\.\([0-9]*\)$/MAJOR="\1" MINOR="\2" PATCH="\3"/' ) |
| 53 | if [ $MAJOR -lt 3 -o \ |
| 54 | \( $MAJOR -eq 3 -a $MINOR -lt 2 \) -o \ |
| 55 | \( $MAJOR -eq 3 -a $MINOR -eq 2 -a $PATCH -lt 15 \) ] |
| 56 | then |
| 57 | PEER_GNUTLS="" |
| 58 | else |
| 59 | PEER_GNUTLS=" GnuTLS" |
Manuel Pégourié-Gonnard | c36b432 | 2018-06-14 13:14:29 +0200 | [diff] [blame] | 60 | if [ $MINOR -lt 4 ]; then |
| 61 | GNUTLS_MINOR_LT_FOUR='x' |
| 62 | fi |
Manuel Pégourié-Gonnard | dd45927 | 2014-10-24 12:57:37 +0200 | [diff] [blame] | 63 | fi |
Manuel Pégourié-Gonnard | 1287f11 | 2014-08-31 16:20:58 +0200 | [diff] [blame] | 64 | fi |
| 65 | else |
| 66 | PEER_GNUTLS="" |
| 67 | fi |
| 68 | |
Manuel Pégourié-Gonnard | a1a9f9a | 2014-03-25 18:04:59 +0100 | [diff] [blame] | 69 | # default values for options |
Xiaofei Bai | 8b5c382 | 2021-12-02 08:43:35 +0000 | [diff] [blame] | 70 | MODES="tls12 dtls12" |
Paul Bakker | 1eeceae | 2012-11-23 14:25:34 +0100 | [diff] [blame] | 71 | VERIFIES="NO YES" |
Manuel Pégourié-Gonnard | 7ebaf37 | 2013-08-27 21:03:33 +0200 | [diff] [blame] | 72 | TYPES="ECDSA RSA PSK" |
Paul Bakker | accd4eb | 2013-07-19 13:41:51 +0200 | [diff] [blame] | 73 | FILTER="" |
Manuel Pégourié-Gonnard | 7299dfd | 2018-02-15 11:43:55 +0100 | [diff] [blame] | 74 | # exclude: |
| 75 | # - NULL: excluded from our default config |
Manuel Pégourié-Gonnard | 7299dfd | 2018-02-15 11:43:55 +0100 | [diff] [blame] | 76 | # avoid plain DES but keep 3DES-EDE-CBC (mbedTLS), DES-CBC3 (OpenSSL) |
Bence Szépkúti | bb0cfeb | 2021-05-28 09:42:25 +0200 | [diff] [blame] | 77 | # - ARIA: not in default mbedtls_config.h + requires OpenSSL >= 1.1.1 |
Manuel Pégourié-Gonnard | 9fece7e | 2018-06-18 11:38:22 +0200 | [diff] [blame] | 78 | # - ChachaPoly: requires OpenSSL >= 1.1.0 |
Andres Amaya Garcia | bdfba79 | 2019-02-11 21:47:30 +0000 | [diff] [blame] | 79 | # - 3DES: not in default config |
Mateusz Starzyk | 5224e29 | 2021-02-22 14:36:29 +0100 | [diff] [blame] | 80 | EXCLUDE='NULL\|DES\|ARIA\|CHACHA20-POLY1305' |
Paul Bakker | accd4eb | 2013-07-19 13:41:51 +0200 | [diff] [blame] | 81 | VERBOSE="" |
Manuel Pégourié-Gonnard | 3eec604 | 2014-02-27 15:37:24 +0100 | [diff] [blame] | 82 | MEMCHECK=0 |
Manuel Pégourié-Gonnard | e4f6edc | 2015-01-22 16:43:54 +0000 | [diff] [blame] | 83 | PEERS="OpenSSL$PEER_GNUTLS mbedTLS" |
Paul Bakker | accd4eb | 2013-07-19 13:41:51 +0200 | [diff] [blame] | 84 | |
Manuel Pégourié-Gonnard | 39e2ca9 | 2015-08-04 16:43:37 +0200 | [diff] [blame] | 85 | # hidden option: skip DTLS with OpenSSL |
| 86 | # (travis CI has a version that doesn't work for us) |
| 87 | : ${OSSL_NO_DTLS:=0} |
| 88 | |
Manuel Pégourié-Gonnard | 9dea8bd | 2014-02-26 18:21:02 +0100 | [diff] [blame] | 89 | print_usage() { |
| 90 | echo "Usage: $0" |
Manuel Pégourié-Gonnard | f46f128 | 2014-12-11 11:51:28 +0100 | [diff] [blame] | 91 | printf " -h|--help\tPrint this help.\n" |
Gilles Peskine | 231befa | 2020-08-26 20:05:11 +0200 | [diff] [blame] | 92 | printf " -f|--filter\tOnly matching ciphersuites are tested (Default: '%s')\n" "$FILTER" |
| 93 | printf " -e|--exclude\tMatching ciphersuites are excluded (Default: '%s')\n" "$EXCLUDE" |
| 94 | printf " -m|--modes\tWhich modes to perform (Default: '%s')\n" "$MODES" |
| 95 | printf " -t|--types\tWhich key exchange type to perform (Default: '%s')\n" "$TYPES" |
| 96 | printf " -V|--verify\tWhich verification modes to perform (Default: '%s')\n" "$VERIFIES" |
| 97 | printf " -p|--peers\tWhich peers to use (Default: '%s')\n" "$PEERS" |
Manuel Pégourié-Gonnard | f46f128 | 2014-12-11 11:51:28 +0100 | [diff] [blame] | 98 | printf " \tAlso available: GnuTLS (needs v3.2.15 or higher)\n" |
| 99 | printf " -M|--memcheck\tCheck memory leaks and errors.\n" |
| 100 | printf " -v|--verbose\tSet verbose output.\n" |
Manuel Pégourié-Gonnard | 9dea8bd | 2014-02-26 18:21:02 +0100 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | get_options() { |
| 104 | while [ $# -gt 0 ]; do |
| 105 | case "$1" in |
| 106 | -f|--filter) |
| 107 | shift; FILTER=$1 |
| 108 | ;; |
Manuel Pégourié-Gonnard | 9edba77 | 2014-03-13 17:45:35 +0100 | [diff] [blame] | 109 | -e|--exclude) |
| 110 | shift; EXCLUDE=$1 |
| 111 | ;; |
Manuel Pégourié-Gonnard | 9dea8bd | 2014-02-26 18:21:02 +0100 | [diff] [blame] | 112 | -m|--modes) |
| 113 | shift; MODES=$1 |
| 114 | ;; |
| 115 | -t|--types) |
| 116 | shift; TYPES=$1 |
| 117 | ;; |
| 118 | -V|--verify) |
| 119 | shift; VERIFIES=$1 |
| 120 | ;; |
Manuel Pégourié-Gonnard | 9edba77 | 2014-03-13 17:45:35 +0100 | [diff] [blame] | 121 | -p|--peers) |
| 122 | shift; PEERS=$1 |
| 123 | ;; |
Manuel Pégourié-Gonnard | 9dea8bd | 2014-02-26 18:21:02 +0100 | [diff] [blame] | 124 | -v|--verbose) |
| 125 | VERBOSE=1 |
| 126 | ;; |
Manuel Pégourié-Gonnard | 3eec604 | 2014-02-27 15:37:24 +0100 | [diff] [blame] | 127 | -M|--memcheck) |
| 128 | MEMCHECK=1 |
| 129 | ;; |
Manuel Pégourié-Gonnard | 9dea8bd | 2014-02-26 18:21:02 +0100 | [diff] [blame] | 130 | -h|--help) |
| 131 | print_usage |
| 132 | exit 0 |
| 133 | ;; |
| 134 | *) |
| 135 | echo "Unknown argument: '$1'" |
| 136 | print_usage |
| 137 | exit 1 |
| 138 | ;; |
| 139 | esac |
| 140 | shift |
| 141 | done |
Manuel Pégourié-Gonnard | 85a4178 | 2014-10-24 12:47:26 +0200 | [diff] [blame] | 142 | |
| 143 | # sanitize some options (modes checked later) |
| 144 | VERIFIES="$( echo $VERIFIES | tr [a-z] [A-Z] )" |
| 145 | TYPES="$( echo $TYPES | tr [a-z] [A-Z] )" |
Manuel Pégourié-Gonnard | 9dea8bd | 2014-02-26 18:21:02 +0100 | [diff] [blame] | 146 | } |
Paul Bakker | accd4eb | 2013-07-19 13:41:51 +0200 | [diff] [blame] | 147 | |
Manuel Pégourié-Gonnard | 9595771 | 2014-02-19 15:29:38 +0100 | [diff] [blame] | 148 | log() { |
Paul Bakker | accd4eb | 2013-07-19 13:41:51 +0200 | [diff] [blame] | 149 | if [ "X" != "X$VERBOSE" ]; then |
Manuel Pégourié-Gonnard | 3025b6c | 2014-03-26 15:30:16 +0100 | [diff] [blame] | 150 | echo "" |
Paul Bakker | accd4eb | 2013-07-19 13:41:51 +0200 | [diff] [blame] | 151 | echo "$@" |
| 152 | fi |
| 153 | } |
Paul Bakker | 10cd225 | 2012-04-12 21:26:34 +0000 | [diff] [blame] | 154 | |
Manuel Pégourié-Gonnard | 3025b6c | 2014-03-26 15:30:16 +0100 | [diff] [blame] | 155 | # is_dtls <mode> |
| 156 | is_dtls() |
| 157 | { |
Xiaofei Bai | 8b5c382 | 2021-12-02 08:43:35 +0000 | [diff] [blame] | 158 | test "$1" = "dtls12" |
Manuel Pégourié-Gonnard | 3025b6c | 2014-03-26 15:30:16 +0100 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | # minor_ver <mode> |
| 162 | minor_ver() |
| 163 | { |
| 164 | case "$1" in |
Xiaofei Bai | 8b5c382 | 2021-12-02 08:43:35 +0000 | [diff] [blame] | 165 | tls12|dtls12) |
Manuel Pégourié-Gonnard | 3025b6c | 2014-03-26 15:30:16 +0100 | [diff] [blame] | 166 | echo 3 |
| 167 | ;; |
| 168 | *) |
| 169 | echo "error: invalid mode: $MODE" >&2 |
| 170 | # exiting is no good here, typically called in a subshell |
| 171 | echo -1 |
| 172 | esac |
| 173 | } |
| 174 | |
Manuel Pégourié-Gonnard | dfc8d5a | 2013-08-27 20:48:40 +0200 | [diff] [blame] | 175 | filter() |
| 176 | { |
Manuel Pégourié-Gonnard | 9edba77 | 2014-03-13 17:45:35 +0100 | [diff] [blame] | 177 | LIST="$1" |
Manuel Pégourié-Gonnard | dfc8d5a | 2013-08-27 20:48:40 +0200 | [diff] [blame] | 178 | NEW_LIST="" |
| 179 | |
Mateusz Starzyk | 5224e29 | 2021-02-22 14:36:29 +0100 | [diff] [blame] | 180 | EXCLMODE="$EXCLUDE" |
Manuel Pégourié-Gonnard | 3025b6c | 2014-03-26 15:30:16 +0100 | [diff] [blame] | 181 | |
Manuel Pégourié-Gonnard | dfc8d5a | 2013-08-27 20:48:40 +0200 | [diff] [blame] | 182 | for i in $LIST; |
| 183 | do |
Manuel Pégourié-Gonnard | 3025b6c | 2014-03-26 15:30:16 +0100 | [diff] [blame] | 184 | NEW_LIST="$NEW_LIST $( echo "$i" | grep "$FILTER" | grep -v "$EXCLMODE" )" |
Manuel Pégourié-Gonnard | dfc8d5a | 2013-08-27 20:48:40 +0200 | [diff] [blame] | 185 | done |
| 186 | |
Manuel Pégourié-Gonnard | 911622d | 2014-02-27 11:50:40 +0100 | [diff] [blame] | 187 | # normalize whitespace |
Manuel Pégourié-Gonnard | f46f128 | 2014-12-11 11:51:28 +0100 | [diff] [blame] | 188 | echo "$NEW_LIST" | sed -e 's/[[:space:]][[:space:]]*/ /g' -e 's/^ //' -e 's/ $//' |
Manuel Pégourié-Gonnard | dfc8d5a | 2013-08-27 20:48:40 +0200 | [diff] [blame] | 189 | } |
| 190 | |
Manuel Pégourié-Gonnard | 53aef81 | 2014-07-11 17:41:24 +0200 | [diff] [blame] | 191 | # OpenSSL 1.0.1h with -Verify wants a ClientCertificate message even for |
| 192 | # PSK ciphersuites with DTLS, which is incorrect, so disable them for now |
| 193 | check_openssl_server_bug() |
| 194 | { |
| 195 | if test "X$VERIFY" = "XYES" && is_dtls "$MODE" && \ |
| 196 | echo "$1" | grep "^TLS-PSK" >/dev/null; |
| 197 | then |
| 198 | SKIP_NEXT="YES" |
| 199 | fi |
| 200 | } |
| 201 | |
Manuel Pégourié-Gonnard | 5b2d776 | 2014-02-28 12:42:57 +0100 | [diff] [blame] | 202 | filter_ciphersuites() |
| 203 | { |
Manuel Pégourié-Gonnard | 9edba77 | 2014-03-13 17:45:35 +0100 | [diff] [blame] | 204 | if [ "X" != "X$FILTER" -o "X" != "X$EXCLUDE" ]; |
Manuel Pégourié-Gonnard | 5b2d776 | 2014-02-28 12:42:57 +0100 | [diff] [blame] | 205 | then |
Simon Butcher | ac22d11 | 2016-09-04 22:31:09 +0100 | [diff] [blame] | 206 | # Ciphersuite for mbed TLS |
| 207 | M_CIPHERS=$( filter "$M_CIPHERS" ) |
| 208 | |
| 209 | # Ciphersuite for OpenSSL |
Manuel Pégourié-Gonnard | 9edba77 | 2014-03-13 17:45:35 +0100 | [diff] [blame] | 210 | O_CIPHERS=$( filter "$O_CIPHERS" ) |
Simon Butcher | ac22d11 | 2016-09-04 22:31:09 +0100 | [diff] [blame] | 211 | |
| 212 | # Ciphersuite for GnuTLS |
Manuel Pégourié-Gonnard | 9edba77 | 2014-03-13 17:45:35 +0100 | [diff] [blame] | 213 | G_CIPHERS=$( filter "$G_CIPHERS" ) |
Manuel Pégourié-Gonnard | 5b2d776 | 2014-02-28 12:42:57 +0100 | [diff] [blame] | 214 | fi |
Manuel Pégourié-Gonnard | 29980b1 | 2014-07-10 20:12:56 +0200 | [diff] [blame] | 215 | |
Manuel Pégourié-Gonnard | dba564b | 2015-01-23 11:33:38 +0000 | [diff] [blame] | 216 | # For GnuTLS client -> mbed TLS server, |
Manuel Pégourié-Gonnard | d1af102 | 2014-07-11 17:01:06 +0200 | [diff] [blame] | 217 | # we need to force IPv4 by connecting to 127.0.0.1 but then auth fails |
Manuel Pégourié-Gonnard | 29980b1 | 2014-07-10 20:12:56 +0200 | [diff] [blame] | 218 | if [ "X$VERIFY" = "XYES" ] && is_dtls "$MODE"; then |
| 219 | G_CIPHERS="" |
| 220 | fi |
Manuel Pégourié-Gonnard | 5b2d776 | 2014-02-28 12:42:57 +0100 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | reset_ciphersuites() |
Manuel Pégourié-Gonnard | 48f196c | 2014-02-19 13:51:58 +0100 | [diff] [blame] | 224 | { |
Simon Butcher | ac22d11 | 2016-09-04 22:31:09 +0100 | [diff] [blame] | 225 | M_CIPHERS="" |
Manuel Pégourié-Gonnard | 48f196c | 2014-02-19 13:51:58 +0100 | [diff] [blame] | 226 | O_CIPHERS="" |
Manuel Pégourié-Gonnard | 5b2d776 | 2014-02-28 12:42:57 +0100 | [diff] [blame] | 227 | G_CIPHERS="" |
| 228 | } |
Manuel Pégourié-Gonnard | 48f196c | 2014-02-19 13:51:58 +0100 | [diff] [blame] | 229 | |
Joe Subbiani | c3610ba | 2021-07-29 11:35:59 +0100 | [diff] [blame] | 230 | check_translation() |
| 231 | { |
Joe Subbiani | 439a696 | 2021-07-29 12:51:09 +0100 | [diff] [blame] | 232 | if [ $1 -ne 0 ]; then |
| 233 | echo "translate_ciphers.py failed with exit code $1" >&2 |
| 234 | echo "$2" >&2 |
Joe Subbiani | c3610ba | 2021-07-29 11:35:59 +0100 | [diff] [blame] | 235 | exit 1 |
| 236 | fi |
| 237 | } |
| 238 | |
Manuel Pégourié-Gonnard | 7299dfd | 2018-02-15 11:43:55 +0100 | [diff] [blame] | 239 | # Ciphersuites that can be used with all peers. |
| 240 | # Since we currently have three possible peers, each ciphersuite should appear |
| 241 | # three times: in each peer's list (with the name that this peer uses). |
Manuel Pégourié-Gonnard | 12b8472 | 2014-03-25 19:07:28 +0100 | [diff] [blame] | 242 | add_common_ciphersuites() |
Manuel Pégourié-Gonnard | 5b2d776 | 2014-02-28 12:42:57 +0100 | [diff] [blame] | 243 | { |
Joe Subbiani | 34d6262 | 2021-07-27 14:55:56 +0100 | [diff] [blame] | 244 | CIPHERS="" |
Manuel Pégourié-Gonnard | 48f196c | 2014-02-19 13:51:58 +0100 | [diff] [blame] | 245 | case $TYPE in |
| 246 | |
| 247 | "ECDSA") |
Joe Subbiani | 9f84761 | 2021-08-10 10:41:13 +0100 | [diff] [blame^] | 248 | CIPHERS="$CIPHERS \ |
| 249 | TLS-ECDHE-ECDSA-WITH-NULL-SHA \ |
| 250 | TLS-ECDHE-ECDSA-WITH-3DES-EDE-CBC-SHA \ |
| 251 | TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA \ |
| 252 | TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA \ |
| 253 | |
| 254 | TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \ |
| 255 | TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384 \ |
| 256 | TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ |
| 257 | TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384 \ |
| 258 | " |
Manuel Pégourié-Gonnard | 48f196c | 2014-02-19 13:51:58 +0100 | [diff] [blame] | 259 | ;; |
| 260 | |
| 261 | "RSA") |
Joe Subbiani | 34d6262 | 2021-07-27 14:55:56 +0100 | [diff] [blame] | 262 | CIPHERS="$CIPHERS \ |
| 263 | TLS-DHE-RSA-WITH-AES-128-CBC-SHA \ |
Manuel Pégourié-Gonnard | 48f196c | 2014-02-19 13:51:58 +0100 | [diff] [blame] | 264 | TLS-DHE-RSA-WITH-AES-256-CBC-SHA \ |
| 265 | TLS-DHE-RSA-WITH-CAMELLIA-128-CBC-SHA \ |
| 266 | TLS-DHE-RSA-WITH-CAMELLIA-256-CBC-SHA \ |
| 267 | TLS-DHE-RSA-WITH-3DES-EDE-CBC-SHA \ |
| 268 | TLS-RSA-WITH-AES-256-CBC-SHA \ |
| 269 | TLS-RSA-WITH-CAMELLIA-256-CBC-SHA \ |
| 270 | TLS-RSA-WITH-AES-128-CBC-SHA \ |
| 271 | TLS-RSA-WITH-CAMELLIA-128-CBC-SHA \ |
| 272 | TLS-RSA-WITH-3DES-EDE-CBC-SHA \ |
Manuel Pégourié-Gonnard | 48f196c | 2014-02-19 13:51:58 +0100 | [diff] [blame] | 273 | TLS-RSA-WITH-NULL-MD5 \ |
| 274 | TLS-RSA-WITH-NULL-SHA \ |
Joe Subbiani | 9f84761 | 2021-08-10 10:41:13 +0100 | [diff] [blame^] | 275 | |
| 276 | TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA \ |
| 277 | TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA \ |
| 278 | TLS-ECDHE-RSA-WITH-3DES-EDE-CBC-SHA \ |
| 279 | TLS-ECDHE-RSA-WITH-NULL-SHA \ |
| 280 | |
| 281 | TLS-RSA-WITH-AES-128-CBC-SHA256 \ |
| 282 | TLS-DHE-RSA-WITH-AES-128-CBC-SHA256 \ |
| 283 | TLS-RSA-WITH-AES-256-CBC-SHA256 \ |
| 284 | TLS-DHE-RSA-WITH-AES-256-CBC-SHA256 \ |
| 285 | TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256 \ |
| 286 | TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384 \ |
| 287 | TLS-RSA-WITH-AES-128-GCM-SHA256 \ |
| 288 | TLS-RSA-WITH-AES-256-GCM-SHA384 \ |
| 289 | TLS-DHE-RSA-WITH-AES-128-GCM-SHA256 \ |
| 290 | TLS-DHE-RSA-WITH-AES-256-GCM-SHA384 \ |
| 291 | TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256 \ |
| 292 | TLS-ECDHE-RSA-WITH-AES-256-GCM-SHA384 \ |
| 293 | |
| 294 | TLS-RSA-WITH-NULL-SHA256 \ |
Manuel Pégourié-Gonnard | 12b8472 | 2014-03-25 19:07:28 +0100 | [diff] [blame] | 295 | " |
Manuel Pégourié-Gonnard | 48f196c | 2014-02-19 13:51:58 +0100 | [diff] [blame] | 296 | ;; |
| 297 | |
| 298 | "PSK") |
Joe Subbiani | 34d6262 | 2021-07-27 14:55:56 +0100 | [diff] [blame] | 299 | CIPHERS="$CIPHERS \ |
| 300 | TLS-PSK-WITH-3DES-EDE-CBC-SHA \ |
Manuel Pégourié-Gonnard | 48f196c | 2014-02-19 13:51:58 +0100 | [diff] [blame] | 301 | TLS-PSK-WITH-AES-128-CBC-SHA \ |
| 302 | TLS-PSK-WITH-AES-256-CBC-SHA \ |
| 303 | " |
Manuel Pégourié-Gonnard | 48f196c | 2014-02-19 13:51:58 +0100 | [diff] [blame] | 304 | ;; |
| 305 | esac |
Joe Subbiani | 34d6262 | 2021-07-27 14:55:56 +0100 | [diff] [blame] | 306 | |
| 307 | M_CIPHERS="$M_CIPHERS $CIPHERS" |
| 308 | |
Joe Subbiani | 918ee79 | 2021-07-30 16:57:04 +0100 | [diff] [blame] | 309 | T=$(./scripts/translate_ciphers.py g $CIPHERS) |
Joe Subbiani | 439a696 | 2021-07-29 12:51:09 +0100 | [diff] [blame] | 310 | check_translation $? "$T" |
Joe Subbiani | c3610ba | 2021-07-29 11:35:59 +0100 | [diff] [blame] | 311 | G_CIPHERS="$G_CIPHERS $T" |
Joe Subbiani | 34d6262 | 2021-07-27 14:55:56 +0100 | [diff] [blame] | 312 | |
Joe Subbiani | 918ee79 | 2021-07-30 16:57:04 +0100 | [diff] [blame] | 313 | T=$(./scripts/translate_ciphers.py o $CIPHERS) |
Joe Subbiani | 439a696 | 2021-07-29 12:51:09 +0100 | [diff] [blame] | 314 | check_translation $? "$T" |
Joe Subbiani | c3610ba | 2021-07-29 11:35:59 +0100 | [diff] [blame] | 315 | O_CIPHERS="$O_CIPHERS $T" |
Manuel Pégourié-Gonnard | 48f196c | 2014-02-19 13:51:58 +0100 | [diff] [blame] | 316 | } |
| 317 | |
Manuel Pégourié-Gonnard | 7299dfd | 2018-02-15 11:43:55 +0100 | [diff] [blame] | 318 | # Ciphersuites usable only with Mbed TLS and OpenSSL |
Joe Subbiani | b0aba9a | 2021-08-25 09:56:57 +0100 | [diff] [blame] | 319 | # A list of ciphersuites in the Mbed TLS convention is compiled and |
| 320 | # appended to the list of Mbed TLS ciphersuites $M_CIPHERS. The same list |
| 321 | # is translated to the OpenSSL naming convention and appended to the list of |
| 322 | # OpenSSL ciphersuites $O_CIPHERS. |
Manuel Pégourié-Gonnard | 7299dfd | 2018-02-15 11:43:55 +0100 | [diff] [blame] | 323 | # |
| 324 | # NOTE: for some reason RSA-PSK doesn't work with OpenSSL, |
Manuel Pégourié-Gonnard | ce5673c | 2018-03-06 09:54:10 +0100 | [diff] [blame] | 325 | # so RSA-PSK ciphersuites need to go in other sections, see |
Dave Rodgman | 017a199 | 2022-03-31 14:07:01 +0100 | [diff] [blame] | 326 | # https://github.com/Mbed-TLS/mbedtls/issues/1419 |
Manuel Pégourié-Gonnard | 9fece7e | 2018-06-18 11:38:22 +0200 | [diff] [blame] | 327 | # |
| 328 | # ChachaPoly suites are here rather than in "common", as they were added in |
| 329 | # GnuTLS in 3.5.0 and the CI only has 3.4.x so far. |
Manuel Pégourié-Gonnard | 12b8472 | 2014-03-25 19:07:28 +0100 | [diff] [blame] | 330 | add_openssl_ciphersuites() |
| 331 | { |
Joe Subbiani | 34d6262 | 2021-07-27 14:55:56 +0100 | [diff] [blame] | 332 | CIPHERS="" |
Manuel Pégourié-Gonnard | 12b8472 | 2014-03-25 19:07:28 +0100 | [diff] [blame] | 333 | case $TYPE in |
| 334 | |
| 335 | "ECDSA") |
Joe Subbiani | 9f84761 | 2021-08-10 10:41:13 +0100 | [diff] [blame^] | 336 | CIPHERS="$CIPHERS \ |
| 337 | TLS-ECDH-ECDSA-WITH-NULL-SHA \ |
| 338 | TLS-ECDH-ECDSA-WITH-3DES-EDE-CBC-SHA \ |
| 339 | TLS-ECDH-ECDSA-WITH-AES-128-CBC-SHA \ |
| 340 | TLS-ECDH-ECDSA-WITH-AES-256-CBC-SHA \ |
| 341 | |
| 342 | TLS-ECDH-ECDSA-WITH-AES-128-CBC-SHA256 \ |
| 343 | TLS-ECDH-ECDSA-WITH-AES-256-CBC-SHA384 \ |
| 344 | TLS-ECDH-ECDSA-WITH-AES-128-GCM-SHA256 \ |
| 345 | TLS-ECDH-ECDSA-WITH-AES-256-GCM-SHA384 \ |
| 346 | TLS-ECDHE-ECDSA-WITH-ARIA-256-GCM-SHA384 \ |
| 347 | TLS-ECDHE-ECDSA-WITH-ARIA-128-GCM-SHA256 \ |
| 348 | TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256 \ |
| 349 | " |
Manuel Pégourié-Gonnard | 12b8472 | 2014-03-25 19:07:28 +0100 | [diff] [blame] | 350 | ;; |
| 351 | |
| 352 | "RSA") |
Joe Subbiani | 34d6262 | 2021-07-27 14:55:56 +0100 | [diff] [blame] | 353 | CIPHERS="$CIPHERS \ |
Joe Subbiani | 9f84761 | 2021-08-10 10:41:13 +0100 | [diff] [blame^] | 354 | TLS-RSA-WITH-DES-CBC-SHA \ |
Manuel Pégourié-Gonnard | 12b8472 | 2014-03-25 19:07:28 +0100 | [diff] [blame] | 355 | TLS-DHE-RSA-WITH-DES-CBC-SHA \ |
Joe Subbiani | 9f84761 | 2021-08-10 10:41:13 +0100 | [diff] [blame^] | 356 | |
| 357 | TLS-ECDHE-RSA-WITH-ARIA-256-GCM-SHA384 \ |
| 358 | TLS-DHE-RSA-WITH-ARIA-256-GCM-SHA384 \ |
| 359 | TLS-RSA-WITH-ARIA-256-GCM-SHA384 \ |
| 360 | TLS-ECDHE-RSA-WITH-ARIA-128-GCM-SHA256 \ |
| 361 | TLS-DHE-RSA-WITH-ARIA-128-GCM-SHA256 \ |
| 362 | TLS-RSA-WITH-ARIA-128-GCM-SHA256 \ |
| 363 | TLS-DHE-RSA-WITH-CHACHA20-POLY1305-SHA256 \ |
| 364 | TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256 \ |
Manuel Pégourié-Gonnard | 12b8472 | 2014-03-25 19:07:28 +0100 | [diff] [blame] | 365 | " |
Manuel Pégourié-Gonnard | 12b8472 | 2014-03-25 19:07:28 +0100 | [diff] [blame] | 366 | ;; |
| 367 | |
| 368 | "PSK") |
Joe Subbiani | 9f84761 | 2021-08-10 10:41:13 +0100 | [diff] [blame^] | 369 | CIPHERS="$CIPHERS \ |
| 370 | TLS-DHE-PSK-WITH-ARIA-256-GCM-SHA384 \ |
| 371 | TLS-DHE-PSK-WITH-ARIA-128-GCM-SHA256 \ |
| 372 | TLS-PSK-WITH-ARIA-256-GCM-SHA384 \ |
| 373 | TLS-PSK-WITH-ARIA-128-GCM-SHA256 \ |
| 374 | TLS-PSK-WITH-CHACHA20-POLY1305-SHA256 \ |
| 375 | TLS-ECDHE-PSK-WITH-CHACHA20-POLY1305-SHA256 \ |
| 376 | TLS-DHE-PSK-WITH-CHACHA20-POLY1305-SHA256 \ |
| 377 | " |
Manuel Pégourié-Gonnard | 12b8472 | 2014-03-25 19:07:28 +0100 | [diff] [blame] | 378 | ;; |
| 379 | esac |
Joe Subbiani | 34d6262 | 2021-07-27 14:55:56 +0100 | [diff] [blame] | 380 | |
| 381 | M_CIPHERS="$M_CIPHERS $CIPHERS" |
| 382 | |
Joe Subbiani | 918ee79 | 2021-07-30 16:57:04 +0100 | [diff] [blame] | 383 | T=$(./scripts/translate_ciphers.py o $CIPHERS) |
Joe Subbiani | 439a696 | 2021-07-29 12:51:09 +0100 | [diff] [blame] | 384 | check_translation $? "$T" |
Joe Subbiani | c3610ba | 2021-07-29 11:35:59 +0100 | [diff] [blame] | 385 | O_CIPHERS="$O_CIPHERS $T" |
Manuel Pégourié-Gonnard | 12b8472 | 2014-03-25 19:07:28 +0100 | [diff] [blame] | 386 | } |
| 387 | |
Manuel Pégourié-Gonnard | 7299dfd | 2018-02-15 11:43:55 +0100 | [diff] [blame] | 388 | # Ciphersuites usable only with Mbed TLS and GnuTLS |
Joe Subbiani | b0aba9a | 2021-08-25 09:56:57 +0100 | [diff] [blame] | 389 | # A list of ciphersuites in the Mbed TLS convention is compiled and |
| 390 | # appended to the list of Mbed TLS ciphersuites $M_CIPHERS. The same list |
| 391 | # is translated to the GnuTLS naming convention and appended to the list of |
| 392 | # GnuTLS ciphersuites $G_CIPHERS. |
Manuel Pégourié-Gonnard | 5b2d776 | 2014-02-28 12:42:57 +0100 | [diff] [blame] | 393 | add_gnutls_ciphersuites() |
Manuel Pégourié-Gonnard | 48f196c | 2014-02-19 13:51:58 +0100 | [diff] [blame] | 394 | { |
Joe Subbiani | 34d6262 | 2021-07-27 14:55:56 +0100 | [diff] [blame] | 395 | CIPHERS="" |
Manuel Pégourié-Gonnard | 48f196c | 2014-02-19 13:51:58 +0100 | [diff] [blame] | 396 | case $TYPE in |
| 397 | |
| 398 | "ECDSA") |
Joe Subbiani | 9f84761 | 2021-08-10 10:41:13 +0100 | [diff] [blame^] | 399 | CIPHERS="$CIPHERS \ |
| 400 | TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-CBC-SHA256 \ |
| 401 | TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-CBC-SHA384 \ |
| 402 | TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-GCM-SHA256 \ |
| 403 | TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-GCM-SHA384 \ |
| 404 | TLS-ECDHE-ECDSA-WITH-AES-128-CCM \ |
| 405 | TLS-ECDHE-ECDSA-WITH-AES-256-CCM \ |
| 406 | TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \ |
| 407 | TLS-ECDHE-ECDSA-WITH-AES-256-CCM-8 \ |
| 408 | " |
Manuel Pégourié-Gonnard | 48f196c | 2014-02-19 13:51:58 +0100 | [diff] [blame] | 409 | ;; |
| 410 | |
| 411 | "RSA") |
Joe Subbiani | 9f84761 | 2021-08-10 10:41:13 +0100 | [diff] [blame^] | 412 | CIPHERS="$CIPHERS \ |
| 413 | TLS-ECDHE-RSA-WITH-CAMELLIA-128-CBC-SHA256 \ |
| 414 | TLS-ECDHE-RSA-WITH-CAMELLIA-256-CBC-SHA384 \ |
| 415 | TLS-RSA-WITH-CAMELLIA-128-CBC-SHA256 \ |
| 416 | TLS-RSA-WITH-CAMELLIA-256-CBC-SHA256 \ |
| 417 | TLS-DHE-RSA-WITH-CAMELLIA-128-CBC-SHA256 \ |
| 418 | TLS-DHE-RSA-WITH-CAMELLIA-256-CBC-SHA256 \ |
| 419 | TLS-ECDHE-RSA-WITH-CAMELLIA-128-GCM-SHA256 \ |
| 420 | TLS-ECDHE-RSA-WITH-CAMELLIA-256-GCM-SHA384 \ |
| 421 | TLS-DHE-RSA-WITH-CAMELLIA-128-GCM-SHA256 \ |
| 422 | TLS-DHE-RSA-WITH-CAMELLIA-256-GCM-SHA384 \ |
| 423 | TLS-RSA-WITH-CAMELLIA-128-GCM-SHA256 \ |
| 424 | TLS-RSA-WITH-CAMELLIA-256-GCM-SHA384 \ |
| 425 | TLS-RSA-WITH-AES-128-CCM \ |
| 426 | TLS-RSA-WITH-AES-256-CCM \ |
| 427 | TLS-DHE-RSA-WITH-AES-128-CCM \ |
| 428 | TLS-DHE-RSA-WITH-AES-256-CCM \ |
| 429 | TLS-RSA-WITH-AES-128-CCM-8 \ |
| 430 | TLS-RSA-WITH-AES-256-CCM-8 \ |
| 431 | TLS-DHE-RSA-WITH-AES-128-CCM-8 \ |
| 432 | TLS-DHE-RSA-WITH-AES-256-CCM-8 \ |
| 433 | " |
Manuel Pégourié-Gonnard | 48f196c | 2014-02-19 13:51:58 +0100 | [diff] [blame] | 434 | ;; |
| 435 | |
| 436 | "PSK") |
Joe Subbiani | 9f84761 | 2021-08-10 10:41:13 +0100 | [diff] [blame^] | 437 | CIPHERS="$CIPHERS \ |
| 438 | TLS-DHE-PSK-WITH-3DES-EDE-CBC-SHA \ |
| 439 | TLS-DHE-PSK-WITH-AES-128-CBC-SHA \ |
| 440 | TLS-DHE-PSK-WITH-AES-256-CBC-SHA \ |
| 441 | |
| 442 | TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA \ |
| 443 | TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA \ |
| 444 | TLS-ECDHE-PSK-WITH-3DES-EDE-CBC-SHA \ |
| 445 | TLS-RSA-PSK-WITH-3DES-EDE-CBC-SHA \ |
| 446 | TLS-RSA-PSK-WITH-AES-256-CBC-SHA \ |
| 447 | TLS-RSA-PSK-WITH-AES-128-CBC-SHA \ |
| 448 | |
| 449 | TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA384 \ |
| 450 | TLS-ECDHE-PSK-WITH-CAMELLIA-256-CBC-SHA384 \ |
| 451 | TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \ |
| 452 | TLS-ECDHE-PSK-WITH-CAMELLIA-128-CBC-SHA256 \ |
| 453 | TLS-ECDHE-PSK-WITH-NULL-SHA384 \ |
| 454 | TLS-ECDHE-PSK-WITH-NULL-SHA256 \ |
| 455 | TLS-PSK-WITH-AES-128-CBC-SHA256 \ |
| 456 | TLS-PSK-WITH-AES-256-CBC-SHA384 \ |
| 457 | TLS-DHE-PSK-WITH-AES-128-CBC-SHA256 \ |
| 458 | TLS-DHE-PSK-WITH-AES-256-CBC-SHA384 \ |
| 459 | TLS-PSK-WITH-NULL-SHA256 \ |
| 460 | TLS-PSK-WITH-NULL-SHA384 \ |
| 461 | TLS-DHE-PSK-WITH-NULL-SHA256 \ |
| 462 | TLS-DHE-PSK-WITH-NULL-SHA384 \ |
| 463 | TLS-RSA-PSK-WITH-AES-256-CBC-SHA384 \ |
| 464 | TLS-RSA-PSK-WITH-AES-128-CBC-SHA256 \ |
| 465 | TLS-RSA-PSK-WITH-NULL-SHA256 \ |
| 466 | TLS-RSA-PSK-WITH-NULL-SHA384 \ |
| 467 | TLS-DHE-PSK-WITH-CAMELLIA-128-CBC-SHA256 \ |
| 468 | TLS-DHE-PSK-WITH-CAMELLIA-256-CBC-SHA384 \ |
| 469 | TLS-PSK-WITH-CAMELLIA-128-CBC-SHA256 \ |
| 470 | TLS-PSK-WITH-CAMELLIA-256-CBC-SHA384 \ |
| 471 | TLS-RSA-PSK-WITH-CAMELLIA-256-CBC-SHA384 \ |
| 472 | TLS-RSA-PSK-WITH-CAMELLIA-128-CBC-SHA256 \ |
| 473 | TLS-PSK-WITH-AES-128-GCM-SHA256 \ |
| 474 | TLS-PSK-WITH-AES-256-GCM-SHA384 \ |
| 475 | TLS-DHE-PSK-WITH-AES-128-GCM-SHA256 \ |
| 476 | TLS-DHE-PSK-WITH-AES-256-GCM-SHA384 \ |
| 477 | TLS-PSK-WITH-AES-128-CCM \ |
| 478 | TLS-PSK-WITH-AES-256-CCM \ |
| 479 | TLS-DHE-PSK-WITH-AES-128-CCM \ |
| 480 | TLS-DHE-PSK-WITH-AES-256-CCM \ |
| 481 | TLS-PSK-WITH-AES-128-CCM-8 \ |
| 482 | TLS-PSK-WITH-AES-256-CCM-8 \ |
| 483 | TLS-DHE-PSK-WITH-AES-128-CCM-8 \ |
| 484 | TLS-DHE-PSK-WITH-AES-256-CCM-8 \ |
| 485 | TLS-RSA-PSK-WITH-CAMELLIA-128-GCM-SHA256 \ |
| 486 | TLS-RSA-PSK-WITH-CAMELLIA-256-GCM-SHA384 \ |
| 487 | TLS-PSK-WITH-CAMELLIA-128-GCM-SHA256 \ |
| 488 | TLS-PSK-WITH-CAMELLIA-256-GCM-SHA384 \ |
| 489 | TLS-DHE-PSK-WITH-CAMELLIA-128-GCM-SHA256 \ |
| 490 | TLS-DHE-PSK-WITH-CAMELLIA-256-GCM-SHA384 \ |
| 491 | TLS-RSA-PSK-WITH-AES-256-GCM-SHA384 \ |
| 492 | TLS-RSA-PSK-WITH-AES-128-GCM-SHA256 \ |
Manuel Pégourié-Gonnard | e46aa5e | 2014-07-13 15:44:19 +0200 | [diff] [blame] | 493 | " |
Manuel Pégourié-Gonnard | 48f196c | 2014-02-19 13:51:58 +0100 | [diff] [blame] | 494 | ;; |
| 495 | esac |
Joe Subbiani | 43592bd | 2021-07-27 16:32:21 +0100 | [diff] [blame] | 496 | |
Joe Subbiani | 34d6262 | 2021-07-27 14:55:56 +0100 | [diff] [blame] | 497 | M_CIPHERS="$M_CIPHERS $CIPHERS" |
| 498 | |
Joe Subbiani | 918ee79 | 2021-07-30 16:57:04 +0100 | [diff] [blame] | 499 | T=$(./scripts/translate_ciphers.py g $CIPHERS) |
Joe Subbiani | 439a696 | 2021-07-29 12:51:09 +0100 | [diff] [blame] | 500 | check_translation $? "$T" |
Joe Subbiani | c3610ba | 2021-07-29 11:35:59 +0100 | [diff] [blame] | 501 | G_CIPHERS="$G_CIPHERS $T" |
Manuel Pégourié-Gonnard | 5b2d776 | 2014-02-28 12:42:57 +0100 | [diff] [blame] | 502 | } |
Manuel Pégourié-Gonnard | 48f196c | 2014-02-19 13:51:58 +0100 | [diff] [blame] | 503 | |
Manuel Pégourié-Gonnard | 7299dfd | 2018-02-15 11:43:55 +0100 | [diff] [blame] | 504 | # Ciphersuites usable only with Mbed TLS (not currently supported by another |
| 505 | # peer usable in this script). This provide only very rudimentaty testing, as |
| 506 | # this is not interop testing, but it's better than nothing. |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 507 | add_mbedtls_ciphersuites() |
Manuel Pégourié-Gonnard | 5b2d776 | 2014-02-28 12:42:57 +0100 | [diff] [blame] | 508 | { |
| 509 | case $TYPE in |
| 510 | |
| 511 | "ECDSA") |
Joe Subbiani | 9f84761 | 2021-08-10 10:41:13 +0100 | [diff] [blame^] | 512 | M_CIPHERS="$M_CIPHERS \ |
| 513 | TLS-ECDH-ECDSA-WITH-CAMELLIA-128-CBC-SHA256 \ |
| 514 | TLS-ECDH-ECDSA-WITH-CAMELLIA-256-CBC-SHA384 \ |
| 515 | |
| 516 | TLS-ECDH-ECDSA-WITH-CAMELLIA-128-GCM-SHA256 \ |
| 517 | TLS-ECDH-ECDSA-WITH-CAMELLIA-256-GCM-SHA384 \ |
| 518 | TLS-ECDHE-ECDSA-WITH-ARIA-256-CBC-SHA384 \ |
| 519 | TLS-ECDHE-ECDSA-WITH-ARIA-128-CBC-SHA256 \ |
| 520 | TLS-ECDH-ECDSA-WITH-ARIA-256-GCM-SHA384 \ |
| 521 | TLS-ECDH-ECDSA-WITH-ARIA-128-GCM-SHA256 \ |
| 522 | TLS-ECDH-ECDSA-WITH-ARIA-256-CBC-SHA384 \ |
| 523 | TLS-ECDH-ECDSA-WITH-ARIA-128-CBC-SHA256 \ |
| 524 | " |
Manuel Pégourié-Gonnard | 5b2d776 | 2014-02-28 12:42:57 +0100 | [diff] [blame] | 525 | ;; |
| 526 | |
| 527 | "RSA") |
Joe Subbiani | 9f84761 | 2021-08-10 10:41:13 +0100 | [diff] [blame^] | 528 | M_CIPHERS="$M_CIPHERS \ |
| 529 | TLS-ECDHE-RSA-WITH-ARIA-256-CBC-SHA384 \ |
| 530 | TLS-DHE-RSA-WITH-ARIA-256-CBC-SHA384 \ |
| 531 | TLS-ECDHE-RSA-WITH-ARIA-128-CBC-SHA256 \ |
| 532 | TLS-DHE-RSA-WITH-ARIA-128-CBC-SHA256 \ |
| 533 | TLS-RSA-WITH-ARIA-256-CBC-SHA384 \ |
| 534 | TLS-RSA-WITH-ARIA-128-CBC-SHA256 \ |
| 535 | " |
Manuel Pégourié-Gonnard | 5b2d776 | 2014-02-28 12:42:57 +0100 | [diff] [blame] | 536 | ;; |
| 537 | |
| 538 | "PSK") |
Manuel Pégourié-Gonnard | 7eb58cb | 2015-07-07 11:54:14 +0200 | [diff] [blame] | 539 | # *PSK-NULL-SHA suites supported by GnuTLS 3.3.5 but not 3.2.15 |
Joe Subbiani | 9f84761 | 2021-08-10 10:41:13 +0100 | [diff] [blame^] | 540 | M_CIPHERS="$M_CIPHERS \ |
| 541 | TLS-PSK-WITH-NULL-SHA \ |
| 542 | TLS-DHE-PSK-WITH-NULL-SHA \ |
| 543 | |
| 544 | TLS-ECDHE-PSK-WITH-NULL-SHA \ |
| 545 | TLS-RSA-PSK-WITH-NULL-SHA \ |
| 546 | |
| 547 | TLS-RSA-PSK-WITH-ARIA-256-CBC-SHA384 \ |
| 548 | TLS-RSA-PSK-WITH-ARIA-128-CBC-SHA256 \ |
| 549 | TLS-PSK-WITH-ARIA-256-CBC-SHA384 \ |
| 550 | TLS-PSK-WITH-ARIA-128-CBC-SHA256 \ |
| 551 | TLS-RSA-PSK-WITH-ARIA-256-GCM-SHA384 \ |
| 552 | TLS-RSA-PSK-WITH-ARIA-128-GCM-SHA256 \ |
| 553 | TLS-ECDHE-PSK-WITH-ARIA-256-CBC-SHA384 \ |
| 554 | TLS-ECDHE-PSK-WITH-ARIA-128-CBC-SHA256 \ |
| 555 | TLS-DHE-PSK-WITH-ARIA-256-CBC-SHA384 \ |
| 556 | TLS-DHE-PSK-WITH-ARIA-128-CBC-SHA256 \ |
| 557 | TLS-RSA-PSK-WITH-CHACHA20-POLY1305-SHA256 \ |
Manuel Pégourié-Gonnard | 5b2d776 | 2014-02-28 12:42:57 +0100 | [diff] [blame] | 558 | " |
Manuel Pégourié-Gonnard | 5b2d776 | 2014-02-28 12:42:57 +0100 | [diff] [blame] | 559 | ;; |
| 560 | esac |
Manuel Pégourié-Gonnard | 48f196c | 2014-02-19 13:51:58 +0100 | [diff] [blame] | 561 | } |
| 562 | |
Manuel Pégourié-Gonnard | d941a79 | 2014-02-19 13:35:52 +0100 | [diff] [blame] | 563 | setup_arguments() |
| 564 | { |
Ronald Cron | 2c74ff6 | 2022-03-11 17:15:23 +0100 | [diff] [blame] | 565 | O_MODE="" |
Manuel Pégourié-Gonnard | 3025b6c | 2014-03-26 15:30:16 +0100 | [diff] [blame] | 566 | G_MODE="" |
| 567 | case "$MODE" in |
Xiaofei Bai | 8b5c382 | 2021-12-02 08:43:35 +0000 | [diff] [blame] | 568 | "tls12") |
Ronald Cron | 2c74ff6 | 2022-03-11 17:15:23 +0100 | [diff] [blame] | 569 | O_MODE="tls1_2" |
Manuel Pégourié-Gonnard | 5b2d776 | 2014-02-28 12:42:57 +0100 | [diff] [blame] | 570 | G_PRIO_MODE="+VERS-TLS1.2" |
Manuel Pégourié-Gonnard | 9ada01a | 2014-02-19 14:24:24 +0100 | [diff] [blame] | 571 | ;; |
Xiaofei Bai | 8b5c382 | 2021-12-02 08:43:35 +0000 | [diff] [blame] | 572 | "dtls12") |
Ronald Cron | 2c74ff6 | 2022-03-11 17:15:23 +0100 | [diff] [blame] | 573 | O_MODE="dtls1_2" |
Manuel Pégourié-Gonnard | 3025b6c | 2014-03-26 15:30:16 +0100 | [diff] [blame] | 574 | G_PRIO_MODE="+VERS-DTLS1.2" |
Manuel Pégourié-Gonnard | 3679519 | 2014-09-26 16:33:45 +0200 | [diff] [blame] | 575 | G_MODE="-u" |
Manuel Pégourié-Gonnard | 3025b6c | 2014-03-26 15:30:16 +0100 | [diff] [blame] | 576 | ;; |
Manuel Pégourié-Gonnard | 9ada01a | 2014-02-19 14:24:24 +0100 | [diff] [blame] | 577 | *) |
| 578 | echo "error: invalid mode: $MODE" >&2 |
| 579 | exit 1; |
| 580 | esac |
| 581 | |
Manuel Pégourié-Gonnard | c36b432 | 2018-06-14 13:14:29 +0200 | [diff] [blame] | 582 | # GnuTLS < 3.4 will choke if we try to allow CCM-8 |
| 583 | if [ -z "${GNUTLS_MINOR_LT_FOUR-}" ]; then |
| 584 | G_PRIO_CCM="+AES-256-CCM-8:+AES-128-CCM-8:" |
| 585 | else |
| 586 | G_PRIO_CCM="" |
| 587 | fi |
| 588 | |
Mateusz Starzyk | 5224e29 | 2021-02-22 14:36:29 +0100 | [diff] [blame] | 589 | M_SERVER_ARGS="server_port=$PORT server_addr=0.0.0.0 force_version=$MODE" |
Ronald Cron | 2c74ff6 | 2022-03-11 17:15:23 +0100 | [diff] [blame] | 590 | O_SERVER_ARGS="-accept $PORT -cipher NULL,ALL -$O_MODE" |
Manuel Pégourié-Gonnard | 3025b6c | 2014-03-26 15:30:16 +0100 | [diff] [blame] | 591 | G_SERVER_ARGS="-p $PORT --http $G_MODE" |
Mateusz Starzyk | 5224e29 | 2021-02-22 14:36:29 +0100 | [diff] [blame] | 592 | G_SERVER_PRIO="NORMAL:${G_PRIO_CCM}+NULL:+MD5:+PSK:+DHE-PSK:+ECDHE-PSK:+SHA256:+SHA384:+RSA-PSK:-VERS-TLS-ALL:$G_PRIO_MODE" |
Manuel Pégourié-Gonnard | 5b2d776 | 2014-02-28 12:42:57 +0100 | [diff] [blame] | 593 | |
Gilles Peskine | 96f5bae | 2021-04-01 14:00:11 +0200 | [diff] [blame] | 594 | # The default prime for `openssl s_server` depends on the version: |
| 595 | # * OpenSSL <= 1.0.2a: 512-bit |
| 596 | # * OpenSSL 1.0.2b to 1.1.1b: 1024-bit |
| 597 | # * OpenSSL >= 1.1.1c: 2048-bit |
| 598 | # Mbed TLS wants >=1024, so force that for older versions. Don't force |
| 599 | # it for newer versions, which reject a 1024-bit prime. Indifferently |
| 600 | # force it or not for intermediate versions. |
| 601 | case $($OPENSSL_CMD version) in |
| 602 | "OpenSSL 1.0"*) |
| 603 | O_SERVER_ARGS="$O_SERVER_ARGS -dhparam data_files/dhparams.pem" |
| 604 | ;; |
| 605 | esac |
| 606 | |
Manuel Pégourié-Gonnard | d1af102 | 2014-07-11 17:01:06 +0200 | [diff] [blame] | 607 | # with OpenSSL 1.0.1h, -www, -WWW and -HTTP break DTLS handshakes |
| 608 | if is_dtls "$MODE"; then |
Manuel Pégourié-Gonnard | 3679519 | 2014-09-26 16:33:45 +0200 | [diff] [blame] | 609 | O_SERVER_ARGS="$O_SERVER_ARGS" |
Manuel Pégourié-Gonnard | d1af102 | 2014-07-11 17:01:06 +0200 | [diff] [blame] | 610 | else |
| 611 | O_SERVER_ARGS="$O_SERVER_ARGS -www" |
| 612 | fi |
| 613 | |
Simon Butcher | ac22d11 | 2016-09-04 22:31:09 +0100 | [diff] [blame] | 614 | M_CLIENT_ARGS="server_port=$PORT server_addr=127.0.0.1 force_version=$MODE" |
Ronald Cron | 2c74ff6 | 2022-03-11 17:15:23 +0100 | [diff] [blame] | 615 | O_CLIENT_ARGS="-connect localhost:$PORT -$O_MODE" |
Manuel Pégourié-Gonnard | 3025b6c | 2014-03-26 15:30:16 +0100 | [diff] [blame] | 616 | G_CLIENT_ARGS="-p $PORT --debug 3 $G_MODE" |
Manuel Pégourié-Gonnard | a437144 | 2014-03-13 16:21:59 +0100 | [diff] [blame] | 617 | G_CLIENT_PRIO="NONE:$G_PRIO_MODE:+COMP-NULL:+CURVE-ALL:+SIGN-ALL" |
Manuel Pégourié-Gonnard | 9ada01a | 2014-02-19 14:24:24 +0100 | [diff] [blame] | 618 | |
Manuel Pégourié-Gonnard | d941a79 | 2014-02-19 13:35:52 +0100 | [diff] [blame] | 619 | if [ "X$VERIFY" = "XYES" ]; |
| 620 | then |
Simon Butcher | ac22d11 | 2016-09-04 22:31:09 +0100 | [diff] [blame] | 621 | M_SERVER_ARGS="$M_SERVER_ARGS ca_file=data_files/test-ca_cat12.crt auth_mode=required" |
Manuel Pégourié-Gonnard | 9ada01a | 2014-02-19 14:24:24 +0100 | [diff] [blame] | 622 | O_SERVER_ARGS="$O_SERVER_ARGS -CAfile data_files/test-ca_cat12.crt -Verify 10" |
Manuel Pégourié-Gonnard | 5b2d776 | 2014-02-28 12:42:57 +0100 | [diff] [blame] | 623 | G_SERVER_ARGS="$G_SERVER_ARGS --x509cafile data_files/test-ca_cat12.crt --require-client-cert" |
| 624 | |
Simon Butcher | ac22d11 | 2016-09-04 22:31:09 +0100 | [diff] [blame] | 625 | M_CLIENT_ARGS="$M_CLIENT_ARGS ca_file=data_files/test-ca_cat12.crt auth_mode=required" |
Manuel Pégourié-Gonnard | da782c9 | 2014-02-21 10:10:20 +0100 | [diff] [blame] | 626 | O_CLIENT_ARGS="$O_CLIENT_ARGS -CAfile data_files/test-ca_cat12.crt -verify 10" |
Manuel Pégourié-Gonnard | a437144 | 2014-03-13 16:21:59 +0100 | [diff] [blame] | 627 | G_CLIENT_ARGS="$G_CLIENT_ARGS --x509cafile data_files/test-ca_cat12.crt" |
Manuel Pégourié-Gonnard | da782c9 | 2014-02-21 10:10:20 +0100 | [diff] [blame] | 628 | else |
Manuel Pégourié-Gonnard | 5b2d776 | 2014-02-28 12:42:57 +0100 | [diff] [blame] | 629 | # don't request a client cert at all |
Simon Butcher | ac22d11 | 2016-09-04 22:31:09 +0100 | [diff] [blame] | 630 | M_SERVER_ARGS="$M_SERVER_ARGS ca_file=none auth_mode=none" |
Manuel Pégourié-Gonnard | 5b2d776 | 2014-02-28 12:42:57 +0100 | [diff] [blame] | 631 | G_SERVER_ARGS="$G_SERVER_ARGS --disable-client-cert" |
| 632 | |
Simon Butcher | ac22d11 | 2016-09-04 22:31:09 +0100 | [diff] [blame] | 633 | M_CLIENT_ARGS="$M_CLIENT_ARGS ca_file=none auth_mode=none" |
Manuel Pégourié-Gonnard | 5de31ec | 2014-03-19 17:34:52 +0100 | [diff] [blame] | 634 | O_CLIENT_ARGS="$O_CLIENT_ARGS" |
| 635 | G_CLIENT_ARGS="$G_CLIENT_ARGS --insecure" |
Manuel Pégourié-Gonnard | d941a79 | 2014-02-19 13:35:52 +0100 | [diff] [blame] | 636 | fi |
| 637 | |
| 638 | case $TYPE in |
| 639 | "ECDSA") |
Simon Butcher | ac22d11 | 2016-09-04 22:31:09 +0100 | [diff] [blame] | 640 | M_SERVER_ARGS="$M_SERVER_ARGS crt_file=data_files/server5.crt key_file=data_files/server5.key" |
Manuel Pégourié-Gonnard | 9ada01a | 2014-02-19 14:24:24 +0100 | [diff] [blame] | 641 | O_SERVER_ARGS="$O_SERVER_ARGS -cert data_files/server5.crt -key data_files/server5.key" |
Manuel Pégourié-Gonnard | 5b2d776 | 2014-02-28 12:42:57 +0100 | [diff] [blame] | 642 | G_SERVER_ARGS="$G_SERVER_ARGS --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key" |
| 643 | |
Manuel Pégourié-Gonnard | 1b149ef | 2014-02-27 14:38:29 +0100 | [diff] [blame] | 644 | if [ "X$VERIFY" = "XYES" ]; then |
Simon Butcher | ac22d11 | 2016-09-04 22:31:09 +0100 | [diff] [blame] | 645 | M_CLIENT_ARGS="$M_CLIENT_ARGS crt_file=data_files/server6.crt key_file=data_files/server6.key" |
Manuel Pégourié-Gonnard | 1b149ef | 2014-02-27 14:38:29 +0100 | [diff] [blame] | 646 | O_CLIENT_ARGS="$O_CLIENT_ARGS -cert data_files/server6.crt -key data_files/server6.key" |
Manuel Pégourié-Gonnard | a437144 | 2014-03-13 16:21:59 +0100 | [diff] [blame] | 647 | G_CLIENT_ARGS="$G_CLIENT_ARGS --x509certfile data_files/server6.crt --x509keyfile data_files/server6.key" |
Manuel Pégourié-Gonnard | 1b149ef | 2014-02-27 14:38:29 +0100 | [diff] [blame] | 648 | else |
Simon Butcher | ac22d11 | 2016-09-04 22:31:09 +0100 | [diff] [blame] | 649 | M_CLIENT_ARGS="$M_CLIENT_ARGS crt_file=none key_file=none" |
Manuel Pégourié-Gonnard | 1b149ef | 2014-02-27 14:38:29 +0100 | [diff] [blame] | 650 | fi |
Manuel Pégourié-Gonnard | d941a79 | 2014-02-19 13:35:52 +0100 | [diff] [blame] | 651 | ;; |
| 652 | |
| 653 | "RSA") |
Manuel Pégourié-Gonnard | 499bf4c | 2020-08-21 12:24:32 +0200 | [diff] [blame] | 654 | M_SERVER_ARGS="$M_SERVER_ARGS crt_file=data_files/server2-sha256.crt key_file=data_files/server2.key" |
| 655 | O_SERVER_ARGS="$O_SERVER_ARGS -cert data_files/server2-sha256.crt -key data_files/server2.key" |
| 656 | G_SERVER_ARGS="$G_SERVER_ARGS --x509certfile data_files/server2-sha256.crt --x509keyfile data_files/server2.key" |
Manuel Pégourié-Gonnard | 5b2d776 | 2014-02-28 12:42:57 +0100 | [diff] [blame] | 657 | |
Manuel Pégourié-Gonnard | 1b149ef | 2014-02-27 14:38:29 +0100 | [diff] [blame] | 658 | if [ "X$VERIFY" = "XYES" ]; then |
Manuel Pégourié-Gonnard | 499bf4c | 2020-08-21 12:24:32 +0200 | [diff] [blame] | 659 | M_CLIENT_ARGS="$M_CLIENT_ARGS crt_file=data_files/cert_sha256.crt key_file=data_files/server1.key" |
| 660 | O_CLIENT_ARGS="$O_CLIENT_ARGS -cert data_files/cert_sha256.crt -key data_files/server1.key" |
| 661 | G_CLIENT_ARGS="$G_CLIENT_ARGS --x509certfile data_files/cert_sha256.crt --x509keyfile data_files/server1.key" |
Manuel Pégourié-Gonnard | 1b149ef | 2014-02-27 14:38:29 +0100 | [diff] [blame] | 662 | else |
Simon Butcher | ac22d11 | 2016-09-04 22:31:09 +0100 | [diff] [blame] | 663 | M_CLIENT_ARGS="$M_CLIENT_ARGS crt_file=none key_file=none" |
Manuel Pégourié-Gonnard | 1b149ef | 2014-02-27 14:38:29 +0100 | [diff] [blame] | 664 | fi |
Manuel Pégourié-Gonnard | d941a79 | 2014-02-19 13:35:52 +0100 | [diff] [blame] | 665 | ;; |
| 666 | |
| 667 | "PSK") |
Manuel Pégourié-Gonnard | 5b2d776 | 2014-02-28 12:42:57 +0100 | [diff] [blame] | 668 | # give RSA-PSK-capable server a RSA cert |
Manuel Pégourié-Gonnard | 1b149ef | 2014-02-27 14:38:29 +0100 | [diff] [blame] | 669 | # (should be a separate type, but harder to close with openssl) |
Manuel Pégourié-Gonnard | 499bf4c | 2020-08-21 12:24:32 +0200 | [diff] [blame] | 670 | M_SERVER_ARGS="$M_SERVER_ARGS psk=6162636465666768696a6b6c6d6e6f70 ca_file=none crt_file=data_files/server2-sha256.crt key_file=data_files/server2.key" |
Manuel Pégourié-Gonnard | 1b149ef | 2014-02-27 14:38:29 +0100 | [diff] [blame] | 671 | O_SERVER_ARGS="$O_SERVER_ARGS -psk 6162636465666768696a6b6c6d6e6f70 -nocert" |
Manuel Pégourié-Gonnard | 499bf4c | 2020-08-21 12:24:32 +0200 | [diff] [blame] | 672 | G_SERVER_ARGS="$G_SERVER_ARGS --x509certfile data_files/server2-sha256.crt --x509keyfile data_files/server2.key --pskpasswd data_files/passwd.psk" |
Manuel Pégourié-Gonnard | 5b2d776 | 2014-02-28 12:42:57 +0100 | [diff] [blame] | 673 | |
Simon Butcher | ac22d11 | 2016-09-04 22:31:09 +0100 | [diff] [blame] | 674 | M_CLIENT_ARGS="$M_CLIENT_ARGS psk=6162636465666768696a6b6c6d6e6f70 crt_file=none key_file=none" |
Manuel Pégourié-Gonnard | 9ada01a | 2014-02-19 14:24:24 +0100 | [diff] [blame] | 675 | O_CLIENT_ARGS="$O_CLIENT_ARGS -psk 6162636465666768696a6b6c6d6e6f70" |
Manuel Pégourié-Gonnard | a437144 | 2014-03-13 16:21:59 +0100 | [diff] [blame] | 676 | G_CLIENT_ARGS="$G_CLIENT_ARGS --pskusername Client_identity --pskkey=6162636465666768696a6b6c6d6e6f70" |
Manuel Pégourié-Gonnard | d941a79 | 2014-02-19 13:35:52 +0100 | [diff] [blame] | 677 | ;; |
| 678 | esac |
| 679 | } |
| 680 | |
Simon Butcher | ac22d11 | 2016-09-04 22:31:09 +0100 | [diff] [blame] | 681 | # is_mbedtls <cmd_line> |
| 682 | is_mbedtls() { |
Manuel Pégourié-Gonnard | 3eec604 | 2014-02-27 15:37:24 +0100 | [diff] [blame] | 683 | echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null |
| 684 | } |
| 685 | |
| 686 | # has_mem_err <log_file_name> |
| 687 | has_mem_err() { |
| 688 | if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" && |
| 689 | grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null |
| 690 | then |
| 691 | return 1 # false: does not have errors |
| 692 | else |
| 693 | return 0 # true: has errors |
| 694 | fi |
| 695 | } |
| 696 | |
Gilles Peskine | 12c49c7 | 2017-12-14 19:02:00 +0100 | [diff] [blame] | 697 | # Wait for process $2 to be listening on port $1 |
| 698 | if type lsof >/dev/null 2>/dev/null; then |
| 699 | wait_server_start() { |
| 700 | START_TIME=$(date +%s) |
| 701 | if is_dtls "$MODE"; then |
| 702 | proto=UDP |
| 703 | else |
| 704 | proto=TCP |
| 705 | fi |
| 706 | while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do |
| 707 | if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then |
| 708 | echo "SERVERSTART TIMEOUT" |
| 709 | echo "SERVERSTART TIMEOUT" >> $SRV_OUT |
| 710 | break |
| 711 | fi |
| 712 | # Linux and *BSD support decimal arguments to sleep. On other |
| 713 | # OSes this may be a tight loop. |
| 714 | sleep 0.1 2>/dev/null || true |
| 715 | done |
| 716 | } |
| 717 | else |
Gilles Peskine | 3c9e2b5 | 2018-01-08 12:38:15 +0100 | [diff] [blame] | 718 | echo "Warning: lsof not available, wait_server_start = sleep" |
Gilles Peskine | 12c49c7 | 2017-12-14 19:02:00 +0100 | [diff] [blame] | 719 | wait_server_start() { |
Manuel Pégourié-Gonnard | 0d225da | 2018-01-22 10:22:09 +0100 | [diff] [blame] | 720 | sleep 2 |
Gilles Peskine | 12c49c7 | 2017-12-14 19:02:00 +0100 | [diff] [blame] | 721 | } |
| 722 | fi |
| 723 | |
| 724 | |
Manuel Pégourié-Gonnard | 304beef | 2014-02-19 14:45:00 +0100 | [diff] [blame] | 725 | # start_server <name> |
| 726 | # also saves name and command |
| 727 | start_server() { |
Manuel Pégourié-Gonnard | 304beef | 2014-02-19 14:45:00 +0100 | [diff] [blame] | 728 | case $1 in |
| 729 | [Oo]pen*) |
Manuel Pégourié-Gonnard | 74faf3c | 2014-03-13 18:47:44 +0100 | [diff] [blame] | 730 | SERVER_CMD="$OPENSSL_CMD s_server $O_SERVER_ARGS" |
Manuel Pégourié-Gonnard | 304beef | 2014-02-19 14:45:00 +0100 | [diff] [blame] | 731 | ;; |
Manuel Pégourié-Gonnard | 5b2d776 | 2014-02-28 12:42:57 +0100 | [diff] [blame] | 732 | [Gg]nu*) |
Manuel Pégourié-Gonnard | 74faf3c | 2014-03-13 18:47:44 +0100 | [diff] [blame] | 733 | SERVER_CMD="$GNUTLS_SERV $G_SERVER_ARGS --priority $G_SERVER_PRIO" |
Manuel Pégourié-Gonnard | 5b2d776 | 2014-02-28 12:42:57 +0100 | [diff] [blame] | 734 | ;; |
Manuel Pégourié-Gonnard | a8f3b75 | 2015-01-22 17:05:05 +0000 | [diff] [blame] | 735 | mbed*) |
Simon Butcher | ac22d11 | 2016-09-04 22:31:09 +0100 | [diff] [blame] | 736 | SERVER_CMD="$M_SRV $M_SERVER_ARGS" |
Manuel Pégourié-Gonnard | 3eec604 | 2014-02-27 15:37:24 +0100 | [diff] [blame] | 737 | if [ "$MEMCHECK" -gt 0 ]; then |
| 738 | SERVER_CMD="valgrind --leak-check=full $SERVER_CMD" |
| 739 | fi |
Manuel Pégourié-Gonnard | 304beef | 2014-02-19 14:45:00 +0100 | [diff] [blame] | 740 | ;; |
| 741 | *) |
| 742 | echo "error: invalid server name: $1" >&2 |
| 743 | exit 1 |
| 744 | ;; |
| 745 | esac |
| 746 | SERVER_NAME=$1 |
| 747 | |
| 748 | log "$SERVER_CMD" |
Manuel Pégourié-Gonnard | bc3b16c | 2014-05-28 23:06:50 +0200 | [diff] [blame] | 749 | echo "$SERVER_CMD" > $SRV_OUT |
Manuel Pégourié-Gonnard | d1af102 | 2014-07-11 17:01:06 +0200 | [diff] [blame] | 750 | # for servers without -www or equivalent |
Manuel Pégourié-Gonnard | 82cf0a1 | 2015-02-09 13:05:54 +0000 | [diff] [blame] | 751 | while :; do echo bla; sleep 1; done | $SERVER_CMD >> $SRV_OUT 2>&1 & |
Manuel Pégourié-Gonnard | 304beef | 2014-02-19 14:45:00 +0100 | [diff] [blame] | 752 | PROCESS_ID=$! |
| 753 | |
Gilles Peskine | 12c49c7 | 2017-12-14 19:02:00 +0100 | [diff] [blame] | 754 | wait_server_start "$PORT" "$PROCESS_ID" |
Manuel Pégourié-Gonnard | 304beef | 2014-02-19 14:45:00 +0100 | [diff] [blame] | 755 | } |
| 756 | |
Manuel Pégourié-Gonnard | 1649449 | 2014-08-31 10:37:14 +0200 | [diff] [blame] | 757 | # terminate the running server |
Manuel Pégourié-Gonnard | 9595771 | 2014-02-19 15:29:38 +0100 | [diff] [blame] | 758 | stop_server() { |
Manuel Pégourié-Gonnard | 74b1170 | 2014-08-14 15:47:33 +0200 | [diff] [blame] | 759 | kill $PROCESS_ID 2>/dev/null |
| 760 | wait $PROCESS_ID 2>/dev/null |
Manuel Pégourié-Gonnard | 3eec604 | 2014-02-27 15:37:24 +0100 | [diff] [blame] | 761 | |
| 762 | if [ "$MEMCHECK" -gt 0 ]; then |
Simon Butcher | ac22d11 | 2016-09-04 22:31:09 +0100 | [diff] [blame] | 763 | if is_mbedtls "$SERVER_CMD" && has_mem_err $SRV_OUT; then |
Manuel Pégourié-Gonnard | 3eec604 | 2014-02-27 15:37:24 +0100 | [diff] [blame] | 764 | echo " ! Server had memory errors" |
Manuel Pégourié-Gonnard | 72e51ee | 2014-08-31 10:22:11 +0200 | [diff] [blame] | 765 | SRVMEM=$(( $SRVMEM + 1 )) |
Manuel Pégourié-Gonnard | 3eec604 | 2014-02-27 15:37:24 +0100 | [diff] [blame] | 766 | return |
| 767 | fi |
| 768 | fi |
| 769 | |
Manuel Pégourié-Gonnard | bc3b16c | 2014-05-28 23:06:50 +0200 | [diff] [blame] | 770 | rm -f $SRV_OUT |
Manuel Pégourié-Gonnard | 9595771 | 2014-02-19 15:29:38 +0100 | [diff] [blame] | 771 | } |
| 772 | |
Manuel Pégourié-Gonnard | a9062e9 | 2014-02-25 16:21:22 +0100 | [diff] [blame] | 773 | # kill the running server (used when killed by signal) |
| 774 | cleanup() { |
Manuel Pégourié-Gonnard | bc3b16c | 2014-05-28 23:06:50 +0200 | [diff] [blame] | 775 | rm -f $SRV_OUT $CLI_OUT |
Manuel Pégourié-Gonnard | 1649449 | 2014-08-31 10:37:14 +0200 | [diff] [blame] | 776 | kill $PROCESS_ID >/dev/null 2>&1 |
| 777 | kill $WATCHDOG_PID >/dev/null 2>&1 |
Manuel Pégourié-Gonnard | a9062e9 | 2014-02-25 16:21:22 +0100 | [diff] [blame] | 778 | exit 1 |
| 779 | } |
| 780 | |
Manuel Pégourié-Gonnard | c0f6a69 | 2014-08-30 22:41:47 +0200 | [diff] [blame] | 781 | # wait for client to terminate and set EXIT |
| 782 | # must be called right after starting the client |
| 783 | wait_client_done() { |
| 784 | CLI_PID=$! |
| 785 | |
| 786 | ( sleep "$DOG_DELAY"; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) & |
| 787 | WATCHDOG_PID=$! |
| 788 | |
| 789 | wait $CLI_PID |
| 790 | EXIT=$? |
| 791 | |
| 792 | kill $WATCHDOG_PID |
| 793 | wait $WATCHDOG_PID |
| 794 | |
| 795 | echo "EXIT: $EXIT" >> $CLI_OUT |
| 796 | } |
| 797 | |
Manuel Pégourié-Gonnard | 330e411 | 2014-02-19 15:23:21 +0100 | [diff] [blame] | 798 | # run_client <name> <cipher> |
| 799 | run_client() { |
Manuel Pégourié-Gonnard | 87ae303 | 2014-02-27 11:12:30 +0100 | [diff] [blame] | 800 | # announce what we're going to do |
Manuel Pégourié-Gonnard | 72e51ee | 2014-08-31 10:22:11 +0200 | [diff] [blame] | 801 | TESTS=$(( $TESTS + 1 )) |
Manuel Pégourié-Gonnard | 87ae303 | 2014-02-27 11:12:30 +0100 | [diff] [blame] | 802 | VERIF=$(echo $VERIFY | tr '[:upper:]' '[:lower:]') |
Manuel Pégourié-Gonnard | 72e51ee | 2014-08-31 10:22:11 +0200 | [diff] [blame] | 803 | TITLE="`echo $1 | head -c1`->`echo $SERVER_NAME | head -c1`" |
| 804 | TITLE="$TITLE $MODE,$VERIF $2" |
Gilles Peskine | 231befa | 2020-08-26 20:05:11 +0200 | [diff] [blame] | 805 | printf "%s " "$TITLE" |
Manuel Pégourié-Gonnard | 72e51ee | 2014-08-31 10:22:11 +0200 | [diff] [blame] | 806 | LEN=$(( 72 - `echo "$TITLE" | wc -c` )) |
Manuel Pégourié-Gonnard | f46f128 | 2014-12-11 11:51:28 +0100 | [diff] [blame] | 807 | for i in `seq 1 $LEN`; do printf '.'; done; printf ' ' |
Manuel Pégourié-Gonnard | 87ae303 | 2014-02-27 11:12:30 +0100 | [diff] [blame] | 808 | |
Manuel Pégourié-Gonnard | 53aef81 | 2014-07-11 17:41:24 +0200 | [diff] [blame] | 809 | # should we skip? |
| 810 | if [ "X$SKIP_NEXT" = "XYES" ]; then |
| 811 | SKIP_NEXT="NO" |
| 812 | echo "SKIP" |
| 813 | SKIPPED=$(( $SKIPPED + 1 )) |
| 814 | return |
| 815 | fi |
| 816 | |
Manuel Pégourié-Gonnard | 330e411 | 2014-02-19 15:23:21 +0100 | [diff] [blame] | 817 | # run the command and interpret result |
| 818 | case $1 in |
| 819 | [Oo]pen*) |
Manuel Pégourié-Gonnard | 74faf3c | 2014-03-13 18:47:44 +0100 | [diff] [blame] | 820 | CLIENT_CMD="$OPENSSL_CMD s_client $O_CLIENT_ARGS -cipher $2" |
Manuel Pégourié-Gonnard | 330e411 | 2014-02-19 15:23:21 +0100 | [diff] [blame] | 821 | log "$CLIENT_CMD" |
Manuel Pégourié-Gonnard | bc3b16c | 2014-05-28 23:06:50 +0200 | [diff] [blame] | 822 | echo "$CLIENT_CMD" > $CLI_OUT |
Manuel Pégourié-Gonnard | 9afdc83 | 2015-08-04 17:15:13 +0200 | [diff] [blame] | 823 | printf 'GET HTTP/1.0\r\n\r\n' | $CLIENT_CMD >> $CLI_OUT 2>&1 & |
Manuel Pégourié-Gonnard | c0f6a69 | 2014-08-30 22:41:47 +0200 | [diff] [blame] | 824 | wait_client_done |
Manuel Pégourié-Gonnard | 330e411 | 2014-02-19 15:23:21 +0100 | [diff] [blame] | 825 | |
Manuel Pégourié-Gonnard | 72e51ee | 2014-08-31 10:22:11 +0200 | [diff] [blame] | 826 | if [ $EXIT -eq 0 ]; then |
Manuel Pégourié-Gonnard | 330e411 | 2014-02-19 15:23:21 +0100 | [diff] [blame] | 827 | RESULT=0 |
| 828 | else |
Darryl Green | 11999bb | 2018-03-13 15:22:58 +0000 | [diff] [blame] | 829 | # If the cipher isn't supported... |
Manuel Pégourié-Gonnard | bc3b16c | 2014-05-28 23:06:50 +0200 | [diff] [blame] | 830 | if grep 'Cipher is (NONE)' $CLI_OUT >/dev/null; then |
Manuel Pégourié-Gonnard | 330e411 | 2014-02-19 15:23:21 +0100 | [diff] [blame] | 831 | RESULT=1 |
| 832 | else |
| 833 | RESULT=2 |
| 834 | fi |
| 835 | fi |
| 836 | ;; |
| 837 | |
Manuel Pégourié-Gonnard | a437144 | 2014-03-13 16:21:59 +0100 | [diff] [blame] | 838 | [Gg]nu*) |
Manuel Pégourié-Gonnard | 29980b1 | 2014-07-10 20:12:56 +0200 | [diff] [blame] | 839 | # need to force IPv4 with UDP, but keep localhost for auth |
| 840 | if is_dtls "$MODE"; then |
| 841 | G_HOST="127.0.0.1" |
| 842 | else |
| 843 | G_HOST="localhost" |
| 844 | fi |
| 845 | CLIENT_CMD="$GNUTLS_CLI $G_CLIENT_ARGS --priority $G_PRIO_MODE:$2 $G_HOST" |
Manuel Pégourié-Gonnard | a437144 | 2014-03-13 16:21:59 +0100 | [diff] [blame] | 846 | log "$CLIENT_CMD" |
Manuel Pégourié-Gonnard | bc3b16c | 2014-05-28 23:06:50 +0200 | [diff] [blame] | 847 | echo "$CLIENT_CMD" > $CLI_OUT |
Manuel Pégourié-Gonnard | 9afdc83 | 2015-08-04 17:15:13 +0200 | [diff] [blame] | 848 | printf 'GET HTTP/1.0\r\n\r\n' | $CLIENT_CMD >> $CLI_OUT 2>&1 & |
Manuel Pégourié-Gonnard | c0f6a69 | 2014-08-30 22:41:47 +0200 | [diff] [blame] | 849 | wait_client_done |
Manuel Pégourié-Gonnard | a437144 | 2014-03-13 16:21:59 +0100 | [diff] [blame] | 850 | |
Manuel Pégourié-Gonnard | 72e51ee | 2014-08-31 10:22:11 +0200 | [diff] [blame] | 851 | if [ $EXIT -eq 0 ]; then |
Manuel Pégourié-Gonnard | a437144 | 2014-03-13 16:21:59 +0100 | [diff] [blame] | 852 | RESULT=0 |
| 853 | else |
Manuel Pégourié-Gonnard | 9edba77 | 2014-03-13 17:45:35 +0100 | [diff] [blame] | 854 | RESULT=2 |
| 855 | # interpret early failure, with a handshake_failure alert |
| 856 | # before the server hello, as "no ciphersuite in common" |
Manuel Pégourié-Gonnard | bc3b16c | 2014-05-28 23:06:50 +0200 | [diff] [blame] | 857 | if grep -F 'Received alert [40]: Handshake failed' $CLI_OUT; then |
| 858 | if grep -i 'SERVER HELLO .* was received' $CLI_OUT; then : |
Manuel Pégourié-Gonnard | 9edba77 | 2014-03-13 17:45:35 +0100 | [diff] [blame] | 859 | else |
| 860 | RESULT=1 |
| 861 | fi |
| 862 | fi >/dev/null |
Manuel Pégourié-Gonnard | a437144 | 2014-03-13 16:21:59 +0100 | [diff] [blame] | 863 | fi |
| 864 | ;; |
| 865 | |
Manuel Pégourié-Gonnard | a8f3b75 | 2015-01-22 17:05:05 +0000 | [diff] [blame] | 866 | mbed*) |
Simon Butcher | ac22d11 | 2016-09-04 22:31:09 +0100 | [diff] [blame] | 867 | CLIENT_CMD="$M_CLI $M_CLIENT_ARGS force_ciphersuite=$2" |
Manuel Pégourié-Gonnard | 3eec604 | 2014-02-27 15:37:24 +0100 | [diff] [blame] | 868 | if [ "$MEMCHECK" -gt 0 ]; then |
| 869 | CLIENT_CMD="valgrind --leak-check=full $CLIENT_CMD" |
| 870 | fi |
Manuel Pégourié-Gonnard | 330e411 | 2014-02-19 15:23:21 +0100 | [diff] [blame] | 871 | log "$CLIENT_CMD" |
Manuel Pégourié-Gonnard | bc3b16c | 2014-05-28 23:06:50 +0200 | [diff] [blame] | 872 | echo "$CLIENT_CMD" > $CLI_OUT |
Manuel Pégourié-Gonnard | c0f6a69 | 2014-08-30 22:41:47 +0200 | [diff] [blame] | 873 | $CLIENT_CMD >> $CLI_OUT 2>&1 & |
| 874 | wait_client_done |
Manuel Pégourié-Gonnard | 330e411 | 2014-02-19 15:23:21 +0100 | [diff] [blame] | 875 | |
| 876 | case $EXIT in |
Simon Butcher | ac22d11 | 2016-09-04 22:31:09 +0100 | [diff] [blame] | 877 | # Success |
Manuel Pégourié-Gonnard | 330e411 | 2014-02-19 15:23:21 +0100 | [diff] [blame] | 878 | "0") RESULT=0 ;; |
Simon Butcher | ac22d11 | 2016-09-04 22:31:09 +0100 | [diff] [blame] | 879 | |
| 880 | # Ciphersuite not supported |
Manuel Pégourié-Gonnard | 330e411 | 2014-02-19 15:23:21 +0100 | [diff] [blame] | 881 | "2") RESULT=1 ;; |
Simon Butcher | ac22d11 | 2016-09-04 22:31:09 +0100 | [diff] [blame] | 882 | |
| 883 | # Error |
Manuel Pégourié-Gonnard | 330e411 | 2014-02-19 15:23:21 +0100 | [diff] [blame] | 884 | *) RESULT=2 ;; |
| 885 | esac |
Manuel Pégourié-Gonnard | 3eec604 | 2014-02-27 15:37:24 +0100 | [diff] [blame] | 886 | |
| 887 | if [ "$MEMCHECK" -gt 0 ]; then |
Simon Butcher | ac22d11 | 2016-09-04 22:31:09 +0100 | [diff] [blame] | 888 | if is_mbedtls "$CLIENT_CMD" && has_mem_err $CLI_OUT; then |
Manuel Pégourié-Gonnard | 3eec604 | 2014-02-27 15:37:24 +0100 | [diff] [blame] | 889 | RESULT=2 |
| 890 | fi |
| 891 | fi |
| 892 | |
Manuel Pégourié-Gonnard | 330e411 | 2014-02-19 15:23:21 +0100 | [diff] [blame] | 893 | ;; |
| 894 | |
| 895 | *) |
| 896 | echo "error: invalid client name: $1" >&2 |
| 897 | exit 1 |
| 898 | ;; |
| 899 | esac |
| 900 | |
Manuel Pégourié-Gonnard | bc3b16c | 2014-05-28 23:06:50 +0200 | [diff] [blame] | 901 | echo "EXIT: $EXIT" >> $CLI_OUT |
Manuel Pégourié-Gonnard | e01af4c | 2014-03-25 14:16:44 +0100 | [diff] [blame] | 902 | |
Manuel Pégourié-Gonnard | 330e411 | 2014-02-19 15:23:21 +0100 | [diff] [blame] | 903 | # report and count result |
Manuel Pégourié-Gonnard | 330e411 | 2014-02-19 15:23:21 +0100 | [diff] [blame] | 904 | case $RESULT in |
| 905 | "0") |
Manuel Pégourié-Gonnard | 4145b89 | 2014-02-24 13:20:14 +0100 | [diff] [blame] | 906 | echo PASS |
Manuel Pégourié-Gonnard | 330e411 | 2014-02-19 15:23:21 +0100 | [diff] [blame] | 907 | ;; |
| 908 | "1") |
Manuel Pégourié-Gonnard | 4145b89 | 2014-02-24 13:20:14 +0100 | [diff] [blame] | 909 | echo SKIP |
Manuel Pégourié-Gonnard | 72e51ee | 2014-08-31 10:22:11 +0200 | [diff] [blame] | 910 | SKIPPED=$(( $SKIPPED + 1 )) |
Manuel Pégourié-Gonnard | 330e411 | 2014-02-19 15:23:21 +0100 | [diff] [blame] | 911 | ;; |
| 912 | "2") |
Manuel Pégourié-Gonnard | 4145b89 | 2014-02-24 13:20:14 +0100 | [diff] [blame] | 913 | echo FAIL |
Manuel Pégourié-Gonnard | 72e51ee | 2014-08-31 10:22:11 +0200 | [diff] [blame] | 914 | cp $SRV_OUT c-srv-${TESTS}.log |
| 915 | cp $CLI_OUT c-cli-${TESTS}.log |
| 916 | echo " ! outputs saved to c-srv-${TESTS}.log, c-cli-${TESTS}.log" |
Manuel Pégourié-Gonnard | 7fa6772 | 2014-08-31 17:42:53 +0200 | [diff] [blame] | 917 | |
Manuel Pégourié-Gonnard | 882148e | 2020-07-27 09:46:53 +0200 | [diff] [blame] | 918 | if [ "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then |
Manuel Pégourié-Gonnard | 7fa6772 | 2014-08-31 17:42:53 +0200 | [diff] [blame] | 919 | echo " ! server output:" |
| 920 | cat c-srv-${TESTS}.log |
| 921 | echo " ! ===================================================" |
| 922 | echo " ! client output:" |
| 923 | cat c-cli-${TESTS}.log |
| 924 | fi |
| 925 | |
Manuel Pégourié-Gonnard | 72e51ee | 2014-08-31 10:22:11 +0200 | [diff] [blame] | 926 | FAILED=$(( $FAILED + 1 )) |
Manuel Pégourié-Gonnard | 330e411 | 2014-02-19 15:23:21 +0100 | [diff] [blame] | 927 | ;; |
| 928 | esac |
Manuel Pégourié-Gonnard | 87ae303 | 2014-02-27 11:12:30 +0100 | [diff] [blame] | 929 | |
Manuel Pégourié-Gonnard | bc3b16c | 2014-05-28 23:06:50 +0200 | [diff] [blame] | 930 | rm -f $CLI_OUT |
Manuel Pégourié-Gonnard | 330e411 | 2014-02-19 15:23:21 +0100 | [diff] [blame] | 931 | } |
| 932 | |
Manuel Pégourié-Gonnard | 9dea8bd | 2014-02-26 18:21:02 +0100 | [diff] [blame] | 933 | # |
| 934 | # MAIN |
| 935 | # |
| 936 | |
Manuel Pégourié-Gonnard | 19db8ea | 2015-03-10 13:41:04 +0000 | [diff] [blame] | 937 | if cd $( dirname $0 ); then :; else |
| 938 | echo "cd $( dirname $0 ) failed" >&2 |
| 939 | exit 1 |
| 940 | fi |
| 941 | |
Manuel Pégourié-Gonnard | 3947d04 | 2014-03-14 18:13:53 +0100 | [diff] [blame] | 942 | get_options "$@" |
| 943 | |
Manuel Pégourié-Gonnard | f7a2690 | 2014-02-27 12:25:54 +0100 | [diff] [blame] | 944 | # sanity checks, avoid an avalanche of errors |
Simon Butcher | ac22d11 | 2016-09-04 22:31:09 +0100 | [diff] [blame] | 945 | if [ ! -x "$M_SRV" ]; then |
| 946 | echo "Command '$M_SRV' is not an executable file" >&2 |
Manuel Pégourié-Gonnard | f7a2690 | 2014-02-27 12:25:54 +0100 | [diff] [blame] | 947 | exit 1 |
| 948 | fi |
Simon Butcher | ac22d11 | 2016-09-04 22:31:09 +0100 | [diff] [blame] | 949 | if [ ! -x "$M_CLI" ]; then |
| 950 | echo "Command '$M_CLI' is not an executable file" >&2 |
Manuel Pégourié-Gonnard | f7a2690 | 2014-02-27 12:25:54 +0100 | [diff] [blame] | 951 | exit 1 |
| 952 | fi |
Manuel Pégourié-Gonnard | 3947d04 | 2014-03-14 18:13:53 +0100 | [diff] [blame] | 953 | |
| 954 | if echo "$PEERS" | grep -i openssl > /dev/null; then |
| 955 | if which "$OPENSSL_CMD" >/dev/null 2>&1; then :; else |
| 956 | echo "Command '$OPENSSL_CMD' not found" >&2 |
Manuel Pégourié-Gonnard | 74faf3c | 2014-03-13 18:47:44 +0100 | [diff] [blame] | 957 | exit 1 |
| 958 | fi |
Manuel Pégourié-Gonnard | 3947d04 | 2014-03-14 18:13:53 +0100 | [diff] [blame] | 959 | fi |
Manuel Pégourié-Gonnard | f7a2690 | 2014-02-27 12:25:54 +0100 | [diff] [blame] | 960 | |
Manuel Pégourié-Gonnard | 3947d04 | 2014-03-14 18:13:53 +0100 | [diff] [blame] | 961 | if echo "$PEERS" | grep -i gnutls > /dev/null; then |
| 962 | for CMD in "$GNUTLS_CLI" "$GNUTLS_SERV"; do |
| 963 | if which "$CMD" >/dev/null 2>&1; then :; else |
| 964 | echo "Command '$CMD' not found" >&2 |
| 965 | exit 1 |
| 966 | fi |
| 967 | done |
| 968 | fi |
| 969 | |
| 970 | for PEER in $PEERS; do |
| 971 | case "$PEER" in |
Manuel Pégourié-Gonnard | a8f3b75 | 2015-01-22 17:05:05 +0000 | [diff] [blame] | 972 | mbed*|[Oo]pen*|[Gg]nu*) |
Manuel Pégourié-Gonnard | 3947d04 | 2014-03-14 18:13:53 +0100 | [diff] [blame] | 973 | ;; |
| 974 | *) |
| 975 | echo "Unknown peers: $PEER" >&2 |
| 976 | exit 1 |
| 977 | esac |
| 978 | done |
Manuel Pégourié-Gonnard | 9dea8bd | 2014-02-26 18:21:02 +0100 | [diff] [blame] | 979 | |
Manuel Pégourié-Gonnard | 8066b81 | 2014-05-28 22:59:30 +0200 | [diff] [blame] | 980 | # Pick a "unique" port in the range 10000-19999. |
| 981 | PORT="0000$$" |
Manuel Pégourié-Gonnard | fab2a3c | 2014-06-16 16:54:36 +0200 | [diff] [blame] | 982 | PORT="1$(echo $PORT | tail -c 5)" |
Manuel Pégourié-Gonnard | 8066b81 | 2014-05-28 22:59:30 +0200 | [diff] [blame] | 983 | |
Manuel Pégourié-Gonnard | bc3b16c | 2014-05-28 23:06:50 +0200 | [diff] [blame] | 984 | # Also pick a unique name for intermediate files |
| 985 | SRV_OUT="srv_out.$$" |
| 986 | CLI_OUT="cli_out.$$" |
| 987 | |
Manuel Pégourié-Gonnard | c0f6a69 | 2014-08-30 22:41:47 +0200 | [diff] [blame] | 988 | # client timeout delay: be more patient with valgrind |
| 989 | if [ "$MEMCHECK" -gt 0 ]; then |
| 990 | DOG_DELAY=30 |
| 991 | else |
| 992 | DOG_DELAY=10 |
| 993 | fi |
| 994 | |
Manuel Pégourié-Gonnard | 53aef81 | 2014-07-11 17:41:24 +0200 | [diff] [blame] | 995 | SKIP_NEXT="NO" |
| 996 | |
Manuel Pégourié-Gonnard | a9062e9 | 2014-02-25 16:21:22 +0100 | [diff] [blame] | 997 | trap cleanup INT TERM HUP |
| 998 | |
Manuel Pégourié-Gonnard | 9595771 | 2014-02-19 15:29:38 +0100 | [diff] [blame] | 999 | for VERIFY in $VERIFIES; do |
| 1000 | for MODE in $MODES; do |
Manuel Pégourié-Gonnard | 9595771 | 2014-02-19 15:29:38 +0100 | [diff] [blame] | 1001 | for TYPE in $TYPES; do |
Manuel Pégourié-Gonnard | 9edba77 | 2014-03-13 17:45:35 +0100 | [diff] [blame] | 1002 | for PEER in $PEERS; do |
Paul Bakker | 7e5e7ca | 2013-04-17 19:27:58 +0200 | [diff] [blame] | 1003 | |
Manuel Pégourié-Gonnard | 9595771 | 2014-02-19 15:29:38 +0100 | [diff] [blame] | 1004 | setup_arguments |
Manuel Pégourié-Gonnard | 5b2d776 | 2014-02-28 12:42:57 +0100 | [diff] [blame] | 1005 | |
Manuel Pégourié-Gonnard | 9edba77 | 2014-03-13 17:45:35 +0100 | [diff] [blame] | 1006 | case "$PEER" in |
Manuel Pégourié-Gonnard | d331319 | 2013-09-13 19:20:37 +0200 | [diff] [blame] | 1007 | |
Manuel Pégourié-Gonnard | 9edba77 | 2014-03-13 17:45:35 +0100 | [diff] [blame] | 1008 | [Oo]pen*) |
Paul Bakker | 398cb51 | 2012-04-10 08:22:31 +0000 | [diff] [blame] | 1009 | |
Manuel Pégourié-Gonnard | 39e2ca9 | 2015-08-04 16:43:37 +0200 | [diff] [blame] | 1010 | if test "$OSSL_NO_DTLS" -gt 0 && is_dtls "$MODE"; then |
| 1011 | continue; |
| 1012 | fi |
| 1013 | |
Ronald Cron | 618955d | 2022-03-23 14:14:19 +0100 | [diff] [blame] | 1014 | # OpenSSL <1.0.2 doesn't support DTLS 1.2. Check if OpenSSL |
| 1015 | # supports $O_MODE from the s_server help. (The s_client |
| 1016 | # help isn't accurate as of 1.0.2g: it supports DTLS 1.2 |
| 1017 | # but doesn't list it. But the s_server help seems to be |
| 1018 | # accurate.) |
| 1019 | if ! $OPENSSL_CMD s_server -help 2>&1 | grep -q "^ *-$O_MODE "; then |
| 1020 | continue; |
| 1021 | fi |
| 1022 | |
Manuel Pégourié-Gonnard | 9edba77 | 2014-03-13 17:45:35 +0100 | [diff] [blame] | 1023 | reset_ciphersuites |
Manuel Pégourié-Gonnard | 12b8472 | 2014-03-25 19:07:28 +0100 | [diff] [blame] | 1024 | add_common_ciphersuites |
Manuel Pégourié-Gonnard | 9edba77 | 2014-03-13 17:45:35 +0100 | [diff] [blame] | 1025 | add_openssl_ciphersuites |
| 1026 | filter_ciphersuites |
Manuel Pégourié-Gonnard | 330e411 | 2014-02-19 15:23:21 +0100 | [diff] [blame] | 1027 | |
Simon Butcher | ac22d11 | 2016-09-04 22:31:09 +0100 | [diff] [blame] | 1028 | if [ "X" != "X$M_CIPHERS" ]; then |
Manuel Pégourié-Gonnard | 9edba77 | 2014-03-13 17:45:35 +0100 | [diff] [blame] | 1029 | start_server "OpenSSL" |
Simon Butcher | ac22d11 | 2016-09-04 22:31:09 +0100 | [diff] [blame] | 1030 | for i in $M_CIPHERS; do |
Manuel Pégourié-Gonnard | 53aef81 | 2014-07-11 17:41:24 +0200 | [diff] [blame] | 1031 | check_openssl_server_bug $i |
Manuel Pégourié-Gonnard | e4f6edc | 2015-01-22 16:43:54 +0000 | [diff] [blame] | 1032 | run_client mbedTLS $i |
Manuel Pégourié-Gonnard | 9edba77 | 2014-03-13 17:45:35 +0100 | [diff] [blame] | 1033 | done |
| 1034 | stop_server |
| 1035 | fi |
Manuel Pégourié-Gonnard | 5b2d776 | 2014-02-28 12:42:57 +0100 | [diff] [blame] | 1036 | |
Manuel Pégourié-Gonnard | 9edba77 | 2014-03-13 17:45:35 +0100 | [diff] [blame] | 1037 | if [ "X" != "X$O_CIPHERS" ]; then |
Manuel Pégourié-Gonnard | e4f6edc | 2015-01-22 16:43:54 +0000 | [diff] [blame] | 1038 | start_server "mbedTLS" |
Manuel Pégourié-Gonnard | 9edba77 | 2014-03-13 17:45:35 +0100 | [diff] [blame] | 1039 | for i in $O_CIPHERS; do |
| 1040 | run_client OpenSSL $i |
| 1041 | done |
| 1042 | stop_server |
| 1043 | fi |
Manuel Pégourié-Gonnard | 5b2d776 | 2014-02-28 12:42:57 +0100 | [diff] [blame] | 1044 | |
Manuel Pégourié-Gonnard | 9edba77 | 2014-03-13 17:45:35 +0100 | [diff] [blame] | 1045 | ;; |
Manuel Pégourié-Gonnard | 5b2d776 | 2014-02-28 12:42:57 +0100 | [diff] [blame] | 1046 | |
Manuel Pégourié-Gonnard | 9edba77 | 2014-03-13 17:45:35 +0100 | [diff] [blame] | 1047 | [Gg]nu*) |
Paul Bakker | fab5c82 | 2012-02-06 16:45:10 +0000 | [diff] [blame] | 1048 | |
Manuel Pégourié-Gonnard | 9edba77 | 2014-03-13 17:45:35 +0100 | [diff] [blame] | 1049 | reset_ciphersuites |
Manuel Pégourié-Gonnard | 12b8472 | 2014-03-25 19:07:28 +0100 | [diff] [blame] | 1050 | add_common_ciphersuites |
Manuel Pégourié-Gonnard | 9edba77 | 2014-03-13 17:45:35 +0100 | [diff] [blame] | 1051 | add_gnutls_ciphersuites |
| 1052 | filter_ciphersuites |
Paul Bakker | fab5c82 | 2012-02-06 16:45:10 +0000 | [diff] [blame] | 1053 | |
Simon Butcher | ac22d11 | 2016-09-04 22:31:09 +0100 | [diff] [blame] | 1054 | if [ "X" != "X$M_CIPHERS" ]; then |
Manuel Pégourié-Gonnard | 9edba77 | 2014-03-13 17:45:35 +0100 | [diff] [blame] | 1055 | start_server "GnuTLS" |
Simon Butcher | ac22d11 | 2016-09-04 22:31:09 +0100 | [diff] [blame] | 1056 | for i in $M_CIPHERS; do |
Manuel Pégourié-Gonnard | e4f6edc | 2015-01-22 16:43:54 +0000 | [diff] [blame] | 1057 | run_client mbedTLS $i |
Manuel Pégourié-Gonnard | 9edba77 | 2014-03-13 17:45:35 +0100 | [diff] [blame] | 1058 | done |
| 1059 | stop_server |
| 1060 | fi |
| 1061 | |
| 1062 | if [ "X" != "X$G_CIPHERS" ]; then |
Manuel Pégourié-Gonnard | e4f6edc | 2015-01-22 16:43:54 +0000 | [diff] [blame] | 1063 | start_server "mbedTLS" |
Manuel Pégourié-Gonnard | 9edba77 | 2014-03-13 17:45:35 +0100 | [diff] [blame] | 1064 | for i in $G_CIPHERS; do |
| 1065 | run_client GnuTLS $i |
| 1066 | done |
| 1067 | stop_server |
| 1068 | fi |
| 1069 | |
| 1070 | ;; |
| 1071 | |
Manuel Pégourié-Gonnard | a8f3b75 | 2015-01-22 17:05:05 +0000 | [diff] [blame] | 1072 | mbed*) |
Manuel Pégourié-Gonnard | 9edba77 | 2014-03-13 17:45:35 +0100 | [diff] [blame] | 1073 | |
| 1074 | reset_ciphersuites |
Manuel Pégourié-Gonnard | 12b8472 | 2014-03-25 19:07:28 +0100 | [diff] [blame] | 1075 | add_common_ciphersuites |
Manuel Pégourié-Gonnard | 9edba77 | 2014-03-13 17:45:35 +0100 | [diff] [blame] | 1076 | add_openssl_ciphersuites |
| 1077 | add_gnutls_ciphersuites |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 1078 | add_mbedtls_ciphersuites |
Manuel Pégourié-Gonnard | 9edba77 | 2014-03-13 17:45:35 +0100 | [diff] [blame] | 1079 | filter_ciphersuites |
| 1080 | |
Simon Butcher | ac22d11 | 2016-09-04 22:31:09 +0100 | [diff] [blame] | 1081 | if [ "X" != "X$M_CIPHERS" ]; then |
Manuel Pégourié-Gonnard | e4f6edc | 2015-01-22 16:43:54 +0000 | [diff] [blame] | 1082 | start_server "mbedTLS" |
Simon Butcher | ac22d11 | 2016-09-04 22:31:09 +0100 | [diff] [blame] | 1083 | for i in $M_CIPHERS; do |
Manuel Pégourié-Gonnard | e4f6edc | 2015-01-22 16:43:54 +0000 | [diff] [blame] | 1084 | run_client mbedTLS $i |
Manuel Pégourié-Gonnard | 9edba77 | 2014-03-13 17:45:35 +0100 | [diff] [blame] | 1085 | done |
| 1086 | stop_server |
| 1087 | fi |
| 1088 | |
| 1089 | ;; |
| 1090 | |
Manuel Pégourié-Gonnard | a1a9f9a | 2014-03-25 18:04:59 +0100 | [diff] [blame] | 1091 | *) |
Paul Bakker | 1ebc0c5 | 2014-05-22 15:47:58 +0200 | [diff] [blame] | 1092 | echo "Unknown peer: $PEER" >&2 |
Manuel Pégourié-Gonnard | a1a9f9a | 2014-03-25 18:04:59 +0100 | [diff] [blame] | 1093 | exit 1 |
| 1094 | ;; |
| 1095 | |
Manuel Pégourié-Gonnard | 9edba77 | 2014-03-13 17:45:35 +0100 | [diff] [blame] | 1096 | esac |
| 1097 | |
| 1098 | done |
Manuel Pégourié-Gonnard | 9595771 | 2014-02-19 15:29:38 +0100 | [diff] [blame] | 1099 | done |
| 1100 | done |
Manuel Pégourié-Gonnard | 9791a40 | 2013-08-27 19:57:15 +0200 | [diff] [blame] | 1101 | done |
Manuel Pégourié-Gonnard | 70064fd | 2013-08-27 22:00:47 +0200 | [diff] [blame] | 1102 | |
Manuel Pégourié-Gonnard | 4145b89 | 2014-02-24 13:20:14 +0100 | [diff] [blame] | 1103 | echo "------------------------------------------------------------------------" |
Manuel Pégourié-Gonnard | 70064fd | 2013-08-27 22:00:47 +0200 | [diff] [blame] | 1104 | |
Manuel Pégourié-Gonnard | 72e51ee | 2014-08-31 10:22:11 +0200 | [diff] [blame] | 1105 | if [ $FAILED -ne 0 -o $SRVMEM -ne 0 ]; |
Manuel Pégourié-Gonnard | 70064fd | 2013-08-27 22:00:47 +0200 | [diff] [blame] | 1106 | then |
Manuel Pégourié-Gonnard | f46f128 | 2014-12-11 11:51:28 +0100 | [diff] [blame] | 1107 | printf "FAILED" |
Manuel Pégourié-Gonnard | 70064fd | 2013-08-27 22:00:47 +0200 | [diff] [blame] | 1108 | else |
Manuel Pégourié-Gonnard | f46f128 | 2014-12-11 11:51:28 +0100 | [diff] [blame] | 1109 | printf "PASSED" |
Manuel Pégourié-Gonnard | 70064fd | 2013-08-27 22:00:47 +0200 | [diff] [blame] | 1110 | fi |
| 1111 | |
Manuel Pégourié-Gonnard | ba0b844 | 2014-03-13 17:57:45 +0100 | [diff] [blame] | 1112 | if [ "$MEMCHECK" -gt 0 ]; then |
Manuel Pégourié-Gonnard | 72e51ee | 2014-08-31 10:22:11 +0200 | [diff] [blame] | 1113 | MEMREPORT=", $SRVMEM server memory errors" |
Manuel Pégourié-Gonnard | ba0b844 | 2014-03-13 17:57:45 +0100 | [diff] [blame] | 1114 | else |
| 1115 | MEMREPORT="" |
| 1116 | fi |
| 1117 | |
Manuel Pégourié-Gonnard | 72e51ee | 2014-08-31 10:22:11 +0200 | [diff] [blame] | 1118 | PASSED=$(( $TESTS - $FAILED )) |
| 1119 | echo " ($PASSED / $TESTS tests ($SKIPPED skipped$MEMREPORT))" |
Manuel Pégourié-Gonnard | 70064fd | 2013-08-27 22:00:47 +0200 | [diff] [blame] | 1120 | |
Manuel Pégourié-Gonnard | 72e51ee | 2014-08-31 10:22:11 +0200 | [diff] [blame] | 1121 | FAILED=$(( $FAILED + $SRVMEM )) |
| 1122 | exit $FAILED |