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