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