@@ -11,7 +11,7 @@ cleanup() {
1111trap cleanup EXIT
1212
1313usage () {
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=""
2222SUITE=" "
2323PQC=" "
2424FORCE_HRR=0
25+ REJECT=0
2526
2627WORKSPACE=${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"}
8489WOLFSSL_SERVER=${WOLFSSL_SERVER:- " $WORKSPACE /examples/server/server" }
8590CERT_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+
8795TMP_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.
8898PRIV_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"
90102MAX_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
266295rm -f " $TMP_LOG "
0 commit comments