Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 64 additions & 24 deletions .github/scripts/openssl-ech.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cleanup() {
trap cleanup EXIT

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

Expand All @@ -22,6 +22,7 @@ MODE=""
SUITE=""
PQC=""
FORCE_HRR=0
REJECT=0

WORKSPACE=${GITHUB_WORKSPACE:-"."}

Expand Down Expand Up @@ -51,6 +52,10 @@ while [ $# -gt 0 ]; do
FORCE_HRR=1
shift
;;
--reject)
REJECT=1
shift
;;
--workspace)
[ -z "$2" ] && { echo "ERROR: --workspace requires a value"; exit 1; }
WORKSPACE="$2"
Expand Down Expand Up @@ -84,9 +89,12 @@ WOLFSSL_CLIENT=${WOLFSSL_CLIENT:-"$WORKSPACE/examples/client/client"}
WOLFSSL_SERVER=${WOLFSSL_SERVER:-"$WORKSPACE/examples/server/server"}
CERT_DIR=${CERT_DIR:-"$WORKSPACE/certs"}

# correct ECH config, but it's old, ECH will be rejected
REJECT_ECH_CONFIG="AD7+DQA6rAAgACCATZdDlHed6GlDeiYsu3r7sdWUkLVHZuTa3lbOf+hIbAAEAAEAAQALZXhhbXBsZS5jb20AAA=="

TMP_LOG="$WORKSPACE/tmp_file.log"
PRIV_NAME="ech-private-name.com"
PUB_NAME="ech-public-name.com"
PUB_NAME="example.com"
MAX_WAIT=50

# --------------------------------------------------------------------------
Expand Down Expand Up @@ -128,6 +136,8 @@ openssl_server(){

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

# start OpenSSL ECH server with ephemeral port; line-buffer so the
Expand Down Expand Up @@ -158,17 +168,29 @@ openssl_server(){
done
echo "parsed port: $port" &>> "$TMP_LOG"

# test with wolfssl client
$WOLFSSL_CLIENT -v 4 \
-p "$port" \
-S "$PRIV_NAME" \
--ech "$ech_config" \
$wolfssl_extra \
&>> "$TMP_LOG"

rm -f "$ech_file"

grep -q "ech_success=1" "$TMP_LOG"
# test with wolfssl client
if [ "$REJECT" -ne 0 ]; then
$WOLFSSL_CLIENT -v 4 \
-p "$port" \
-S "$PRIV_NAME" \
--ech "$ech_config" \
$wolfssl_extra \
&>> "$TMP_LOG" || true

grep -q "ECH offered but rejected by server" "$TMP_LOG"
grep -q "ech_success=0" "$TMP_LOG"
else
$WOLFSSL_CLIENT -v 4 \
-p "$port" \
-S "$PRIV_NAME" \
--ech "$ech_config" \
$wolfssl_extra \
&>> "$TMP_LOG"

grep -q "ech_success=1" "$TMP_LOG"
fi
}

# --------------------------------------------------------------------------
Expand Down Expand Up @@ -246,21 +268,39 @@ openssl_client(){
exit 1
fi
done
# reject overrides the config the client connects with
[ "$REJECT" -ne 0 ] && ech_config="$REJECT_ECH_CONFIG"
echo "parsed ech config: $ech_config" &>> "$TMP_LOG"

# test with OpenSSL s_client using ECH
echo "wolfssl" | $OPENSSL s_client \
-tls1_3 \
-connect "localhost:$port" \
-cert "$CERT_DIR/client-cert.pem" \
-key "$CERT_DIR/client-key.pem" \
-CAfile "$CERT_DIR/ca-cert.pem" \
-servername "$PRIV_NAME" \
-ech_config_list "$ech_config" \
$openssl_groups \
&>> "$TMP_LOG"

grep -q "ECH: success: 1" "$TMP_LOG"
if [ "$REJECT" -ne 0 ]; then
# test with OpenSSL s_client using ECH
echo "wolfssl" | $OPENSSL s_client \
-tls1_3 \
-connect "localhost:$port" \
-cert "$CERT_DIR/client-cert.pem" \
-key "$CERT_DIR/client-key.pem" \
-CAfile "$CERT_DIR/ca-cert.pem" \
-servername "$PRIV_NAME" \
-ech_config_list "$ech_config" \
$openssl_groups \
&>> "$TMP_LOG" || true

grep -q "ECH: Got 1 retry-configs" "$TMP_LOG"
else
# test with OpenSSL s_client using ECH
echo "wolfssl" | $OPENSSL s_client \
-tls1_3 \
-connect "localhost:$port" \
-cert "$CERT_DIR/client-cert.pem" \
-key "$CERT_DIR/client-key.pem" \
-CAfile "$CERT_DIR/ca-cert.pem" \
-servername "$PRIV_NAME" \
-ech_config_list "$ech_config" \
$openssl_groups \
&>> "$TMP_LOG"

grep -q "ECH: success: 1" "$TMP_LOG"
fi
}

rm -f "$TMP_LOG"
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/openssl-ech.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ jobs:
echo -e "\nTesting weird suite with OpenSSL client and wolfSSL server\n" &>> "$LOG_FILE"
bash ./openssl-ech.sh client --suite "18,1,2" &>> "$LOG_FILE"

echo -e "\nTesting rejection with OpenSSL server and wolfSSL client\n" &>> "$LOG_FILE"
bash ./openssl-ech.sh server --reject &>> "$LOG_FILE"

echo -e "\nTesting rejection with OpenSSL client and wolfSSL server\n" &>> "$LOG_FILE"
bash ./openssl-ech.sh client --reject &>> "$LOG_FILE"

# cleanup
rm -f "$LOG_FILE"

Expand Down
Loading
Loading