Skip to content

Commit b996def

Browse files
testing improvements (from #10542):
- *_wire_sni test is now more efficient - openssl-ech workflow now does interop with ECH rejection extra improvements: - tested TLSX_EchSwapExtensions - added ctx level SNI to padding calculation - Improvement of SNI handling for ECH - Changed EchSwapExtensions to append instead of prepend
1 parent 8681807 commit b996def

6 files changed

Lines changed: 736 additions & 317 deletions

File tree

.github/scripts/openssl-ech.sh

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ cleanup() {
1111
trap cleanup EXIT
1212

1313
usage() {
14-
echo "Usage: $0 <client|server> [--suite <KEM,KDF,AEAD>] [--pqc <group>] [--hrr] [--workspace <path>]"
14+
echo "Usage: $0 <client|server> [--suite <KEM,KDF,AEAD>] [--pqc <group>] [--hrr] [--reject] [--workspace <path>]"
1515
exit 1
1616
}
1717

@@ -22,6 +22,7 @@ MODE=""
2222
SUITE=""
2323
PQC=""
2424
FORCE_HRR=0
25+
REJECT=0
2526

2627
WORKSPACE=${GITHUB_WORKSPACE:-"."}
2728

@@ -51,6 +52,10 @@ while [ $# -gt 0 ]; do
5152
FORCE_HRR=1
5253
shift
5354
;;
55+
--reject)
56+
REJECT=1
57+
shift
58+
;;
5459
--workspace)
5560
[ -z "$2" ] && { echo "ERROR: --workspace requires a value"; exit 1; }
5661
WORKSPACE="$2"
@@ -84,9 +89,16 @@ WOLFSSL_CLIENT=${WOLFSSL_CLIENT:-"$WORKSPACE/examples/client/client"}
8489
WOLFSSL_SERVER=${WOLFSSL_SERVER:-"$WORKSPACE/examples/server/server"}
8590
CERT_DIR=${CERT_DIR:-"$WORKSPACE/certs"}
8691

92+
# correct ECH config, but it's old, ECH will be rejected
93+
REJECT_ECH_CONFIG="AD7+DQA6rAAgACCATZdDlHed6GlDeiYsu3r7sdWUkLVHZuTa3lbOf+hIbAAEAAEAAQALZXhhbXBsZS5jb20AAA=="
94+
8795
TMP_LOG="$WORKSPACE/tmp_file.log"
96+
# Will need to look into validating the name against the cert for the OSSL cli.
97+
# This is fine, but should be upgraded to use a second cert in the future.
8898
PRIV_NAME="ech-private-name.com"
89-
PUB_NAME="ech-public-name.com"
99+
# example.com is taken from the server certificate,
100+
# echConfigs needs to authenticate against the cert with this name to succeed
101+
PUB_NAME="example.com"
90102
MAX_WAIT=50
91103

92104
# --------------------------------------------------------------------------
@@ -128,6 +140,8 @@ openssl_server(){
128140

129141
# parse ECH config from file
130142
ech_config=$(sed -n '/BEGIN ECHCONFIG/,/END ECHCONFIG/{/BEGIN ECHCONFIG\|END ECHCONFIG/d;p}' "$ech_file" | tr -d '\n')
143+
# reject overrides the config the client connects with
144+
[ "$REJECT" -ne 0 ] && ech_config="$REJECT_ECH_CONFIG"
131145
echo "parsed ech config: $ech_config" &>> "$TMP_LOG"
132146

133147
# start OpenSSL ECH server with ephemeral port; line-buffer so the
@@ -158,17 +172,24 @@ openssl_server(){
158172
done
159173
echo "parsed port: $port" &>> "$TMP_LOG"
160174

175+
rm -f "$ech_file"
176+
161177
# test with wolfssl client
178+
# in reject mode the client is expected to error out, so tolerate a
179+
# nonzero exit
162180
$WOLFSSL_CLIENT -v 4 \
163181
-p "$port" \
164182
-S "$PRIV_NAME" \
165183
--ech "$ech_config" \
166184
$wolfssl_extra \
167-
&>> "$TMP_LOG"
185+
&>> "$TMP_LOG" || [ "$REJECT" -ne 0 ]
168186

169-
rm -f "$ech_file"
170-
171-
grep -q "ech_success=1" "$TMP_LOG"
187+
if [ "$REJECT" -ne 0 ]; then
188+
grep -q "ECH offered but rejected by server" "$TMP_LOG"
189+
grep -q "ech_success=0" "$TMP_LOG"
190+
else
191+
grep -q "ech_success=1" "$TMP_LOG"
192+
fi
172193
}
173194

174195
# --------------------------------------------------------------------------
@@ -246,9 +267,13 @@ openssl_client(){
246267
exit 1
247268
fi
248269
done
270+
# reject overrides the config the client connects with
271+
[ "$REJECT" -ne 0 ] && ech_config="$REJECT_ECH_CONFIG"
249272
echo "parsed ech config: $ech_config" &>> "$TMP_LOG"
250273

251274
# test with OpenSSL s_client using ECH
275+
# in reject mode the s_client is expected to error out, so tolerate a
276+
# nonzero exit
252277
echo "wolfssl" | $OPENSSL s_client \
253278
-tls1_3 \
254279
-connect "localhost:$port" \
@@ -258,9 +283,13 @@ openssl_client(){
258283
-servername "$PRIV_NAME" \
259284
-ech_config_list "$ech_config" \
260285
$openssl_groups \
261-
&>> "$TMP_LOG"
286+
&>> "$TMP_LOG" || [ "$REJECT" -ne 0 ]
262287

263-
grep -q "ECH: success: 1" "$TMP_LOG"
288+
if [ "$REJECT" -ne 0 ]; then
289+
grep -q "ECH: Got 1 retry-configs" "$TMP_LOG"
290+
else
291+
grep -q "ECH: success: 1" "$TMP_LOG"
292+
fi
264293
}
265294

266295
rm -f "$TMP_LOG"

.github/workflows/openssl-ech.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ jobs:
167167
echo -e "\nTesting weird suite with OpenSSL client and wolfSSL server\n" &>> "$LOG_FILE"
168168
bash ./openssl-ech.sh client --suite "18,1,2" &>> "$LOG_FILE"
169169
170+
echo -e "\nTesting rejection with OpenSSL server and wolfSSL client\n" &>> "$LOG_FILE"
171+
bash ./openssl-ech.sh server --reject &>> "$LOG_FILE"
172+
173+
echo -e "\nTesting rejection with OpenSSL client and wolfSSL server\n" &>> "$LOG_FILE"
174+
bash ./openssl-ech.sh client --reject &>> "$LOG_FILE"
175+
170176
# cleanup
171177
rm -f "$LOG_FILE"
172178

0 commit comments

Comments
 (0)