123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543 |
- #!/bin/sh
- # tls13.test
- # copyright wolfSSL 2016
- # getting unique port is modeled after resume.test script
- # need a unique port since may run the same time as testsuite
- # use server port zero hack to get one
- port=0
- no_pid=-1
- server_pid=$no_pid
- counter=0
- # let's use absolute path to a local dir (make distcheck may be in sub dir)
- # also let's add some randomness by adding pid in case multiple 'make check's
- # per source tree
- ready_file=`pwd`/wolfssl_tls13_ready$$
- echo "ready file $ready_file"
- create_port() {
- while [ ! -s $ready_file ]; do
- if [ -a "$counter" -gt 50 ]; then
- break
- fi
- echo -e "waiting for ready file..."
- sleep 0.1
- counter=$((counter+ 1))
- done
- if [ -e $ready_file ]; then
- echo -e "found ready file, starting client..."
- # get created port 0 ephemeral port
- port=`cat $ready_file`
- else
- echo -e "NO ready file ending test..."
- do_cleanup
- fi
- }
- remove_ready_file() {
- if [ -e $ready_file ]; then
- echo -e "removing existing ready file"
- rm $ready_file
- fi
- }
- do_cleanup() {
- echo "in cleanup"
- if [ $server_pid != $no_pid ]
- then
- echo "killing server"
- kill -9 $server_pid
- fi
- remove_ready_file
- }
- do_trap() {
- echo "got trap"
- do_cleanup
- exit -1
- }
- trap do_trap INT TERM
- [ ! -x ./examples/client/client ] && echo -e "\n\nClient doesn't exist" && exit 1
- # Usual TLS v1.3 server / TLS v1.3 client.
- echo -e "\n\nTLS v1.3 server with TLS v1.3 client"
- port=0
- ./examples/server/server -v 4 -R $ready_file -p $port &
- server_pid=$!
- create_port
- ./examples/client/client -v 4 -p $port
- RESULT=$?
- remove_ready_file
- if [ $RESULT -ne 0 ]; then
- echo -e "\n\nTLS v1.3 not enabled"
- do_cleanup
- exit 1
- fi
- echo ""
- # Usual TLS v1.3 server / TLS v1.3 client - fragment.
- echo -e "\n\nTLS v1.3 server with TLS v1.3 client - fragment"
- port=0
- ./examples/server/server -v 4 -R $ready_file -p $port &
- server_pid=$!
- create_port
- ./examples/client/client -v 4 -F 1 -p $port
- RESULT=$?
- remove_ready_file
- if [ $RESULT -ne 0 ]; then
- echo -e "\n\nTLS v1.3 and fragments not working"
- do_cleanup
- exit 1
- fi
- echo ""
- # Use HelloRetryRequest with TLS v1.3 server / TLS v1.3 client.
- echo -e "\n\nTLS v1.3 HelloRetryRequest"
- port=0
- ./examples/server/server -v 4 -R $ready_file -p $port &
- server_pid=$!
- create_port
- ./examples/client/client -v 4 -J -p $port
- RESULT=$?
- remove_ready_file
- if [ $RESULT -ne 0 ]; then
- echo -e "\n\nTLS v1.3 HelloRetryRequest not working"
- do_cleanup
- exit 1
- fi
- echo ""
- # Use HelloRetryRequest with TLS v1.3 server / TLS v1.3 client using cookie
- echo -e "\n\nTLS v1.3 HelloRetryRequest with cookie"
- port=0
- ./examples/server/server -v 4 -J -R $ready_file -p $port &
- server_pid=$!
- create_port
- ./examples/client/client -v 4 -J -p $port
- RESULT=$?
- remove_ready_file
- if [ $RESULT -ne 0 ]; then
- echo -e "\n\nTLS v1.3 HelloRetryRequest with cookie not working"
- do_cleanup
- exit 1
- fi
- echo ""
- # Use HelloRetryRequest with TLS v1.3 server / TLS v1.3 client - SHA384.
- echo -e "\n\nTLS v1.3 HelloRetryRequest - SHA384"
- port=0
- ./examples/server/server -v 4 -l TLS13-AES256-GCM-SHA384 -R $ready_file -p $port &
- server_pid=$!
- create_port
- ./examples/client/client -v 4 -J -p $port
- RESULT=$?
- remove_ready_file
- if [ $RESULT -ne 0 ]; then
- echo -e "\n\nTLS v1.3 HelloRetryRequest with SHA384 not working"
- do_cleanup
- exit 1
- fi
- echo ""
- # Resumption TLS v1.3 server / TLS v1.3 client.
- echo -e "\n\nTLS v1.3 resumption"
- port=0
- ./examples/server/server -v 4 -r -R $ready_file -p $port &
- server_pid=$!
- create_port
- ./examples/client/client -v 4 -r -p $port
- RESULT=$?
- remove_ready_file
- if [ $RESULT -ne 0 ]; then
- echo -e "\n\nTLS v1.3 resumption not working"
- do_cleanup
- exit 1
- fi
- echo ""
- # Resumption TLS v1.3 server / TLS v1.3 client - SHA384
- echo -e "\n\nTLS v1.3 resumption - SHA384"
- port=0
- ./examples/server/server -v 4 -l TLS13-AES256-GCM-SHA384 -r -R $ready_file -p $port &
- server_pid=$!
- create_port
- ./examples/client/client -v 4 -l TLS13-AES256-GCM-SHA384 -r -p $port
- RESULT=$?
- remove_ready_file
- if [ $RESULT -ne 0 ]; then
- echo -e "\n\nTLS v1.3 resumption with SHA384 not working"
- do_cleanup
- exit 1
- fi
- echo ""
- ./examples/client/client -v 4 -e 2>&1 | grep -- '-ECC'
- if [ $? -eq 0 ]; then
- # Usual TLS v1.3 server / TLS v1.3 client and ECC certificates.
- echo -e "\n\nTLS v1.3 server with TLS v1.3 client - ECC certificates"
- port=0
- ./examples/server/server -v 4 -A certs/client-ecc-cert.pem -c certs/server-ecc.pem -k certs/ecc-key.pem -R $ready_file -p $port &
- server_pid=$!
- create_port
- ./examples/client/client -v 4 -A certs/ca-ecc-cert.pem -c certs/client-ecc-cert.pem -k certs/ecc-client-key.pem -p $port
- RESULT=$?
- remove_ready_file
- if [ $RESULT -ne 0 ]; then
- echo -e "\n\nTLS v1.3 ECC certificates not working"
- do_cleanup
- exit 1
- fi
- echo ""
- fi
- # Usual TLS v1.3 server / TLS v1.3 client and no client certificate.
- echo -e "\n\nTLS v1.3 server with TLS v1.3 client - no client cretificate"
- port=0
- ./examples/server/server -v 4 -R $ready_file -p $port &
- server_pid=$!
- create_port
- ./examples/client/client -v 4 -x -p $port
- RESULT=$?
- remove_ready_file
- if [ $RESULT -ne 0 ]; then
- echo -e "\n\nTLS v1.3 and no client certificate not working"
- do_cleanup
- exit 1
- fi
- echo ""
- # Usual TLS v1.3 server / TLS v1.3 client and DH Key.
- echo -e "\n\nTLS v1.3 server with TLS v1.3 client - DH Key Exchange"
- port=0
- ./examples/server/server -v 4 -R $ready_file -p $port &
- server_pid=$!
- create_port
- ./examples/client/client -v 4 -y -p $port
- RESULT=$?
- remove_ready_file
- if [ $RESULT -ne 0 ]; then
- echo -e "\n\nTLS v1.3 DH Key Exchange not working"
- do_cleanup
- exit 1
- fi
- echo ""
- # Usual TLS v1.3 server / TLS v1.3 client and ECC Key.
- echo -e "\n\nTLS v1.3 server with TLS v1.3 client - ECC Key Exchange"
- port=0
- ./examples/server/server -v 4 -R $ready_file -p $port &
- server_pid=$!
- create_port
- ./examples/client/client -v 4 -Y -p $port
- RESULT=$?
- remove_ready_file
- if [ $RESULT -ne 0 ]; then
- echo -e "\n\nTLS v1.3 ECDH Key Exchange not working"
- do_cleanup
- exit 1
- fi
- echo ""
- # TLS 1.3 cipher suites server / client.
- echo -e "\n\nOnly TLS v1.3 cipher suites"
- port=0
- ./examples/server/server -v 4 -R $ready_file -p $port -l TLS13-AES128-GCM-SHA256:TLS13-AES256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES128-CCM-SHA256:TLS13-AES128-CCM-8-SHA256 &
- server_pid=$!
- create_port
- ./examples/client/client -v 4 -p $port
- RESULT=$?
- remove_ready_file
- if [ $RESULT -ne 0 ]; then
- echo -e "\n\nIssue with TLS v1.3 cipher suites - only TLS v1.3"
- do_cleanup
- exit 1
- fi
- echo ""
- # TLS 1.3 cipher suites server / client.
- echo -e "\n\nOnly TLS v1.3 cipher suite - AES128-GCM SHA-256"
- port=0
- ./examples/server/server -v 4 -R $ready_file -p $port -l TLS13-AES128-GCM-SHA256 &
- server_pid=$!
- create_port
- ./examples/client/client -v 4 -p $port
- RESULT=$?
- remove_ready_file
- if [ $RESULT -ne 0 ]; then
- echo -e "\n\nIssue with TLS v1.3 cipher suites - AES128-GCM SHA-256"
- do_cleanup
- exit 1
- fi
- echo ""
- # TLS 1.3 cipher suites server / client.
- echo -e "\n\nOnly TLS v1.3 cipher suite - AES256-GCM SHA-384"
- port=0
- ./examples/server/server -v 4 -R $ready_file -p $port -l TLS13-AES256-GCM-SHA384 &
- server_pid=$!
- create_port
- ./examples/client/client -v 4 -p $port
- RESULT=$?
- remove_ready_file
- if [ $RESULT -ne 0 ]; then
- echo -e "\n\nIssue with TLS v1.3 cipher suites - AES256-GCM SHA-384"
- do_cleanup
- exit 1
- fi
- echo ""
- # TLS 1.3 cipher suites server / client.
- echo -e "\n\nOnly TLS v1.3 cipher suite - CHACHA20-POLY1305 SHA-256"
- port=0
- ./examples/server/server -v 4 -R $ready_file -p $port -l TLS13-CHACHA20-POLY1305-SHA256 &
- server_pid=$!
- create_port
- ./examples/client/client -v 4 -p $port
- RESULT=$?
- remove_ready_file
- if [ $RESULT -ne 0 ]; then
- echo -e "\n\nIssue with TLS v1.3 cipher suites - CHACHA20-POLY1305 SHA-256"
- do_cleanup
- exit 1
- fi
- echo ""
- ./examples/client/client -v 4 -e 2>&1 | grep -- '-CCM'
- if [ $? -eq 0 ]; then
- # TLS 1.3 cipher suites server / client.
- echo -e "\n\nOnly TLS v1.3 cipher suite - AES128-CCM SHA-256"
- port=0
- ./examples/server/server -v 4 -R $ready_file -p $port -l TLS13-AES128-CCM-SHA256 &
- server_pid=$!
- create_port
- ./examples/client/client -v 4 -p $port
- RESULT=$?
- remove_ready_file
- if [ $RESULT -ne 0 ]; then
- echo -e "\n\nIssue with TLS v1.3 cipher suites - AES128-CCM SHA-256"
- do_cleanup
- exit 1
- fi
- echo ""
- # TLS 1.3 cipher suites server / client.
- echo -e "\n\nOnly TLS v1.3 cipher suite - AES128-CCM-8 SHA-256"
- port=0
- ./examples/server/server -v 4 -R $ready_file -p $port -l TLS13-AES128-CCM-8-SHA256 &
- server_pid=$!
- create_port
- ./examples/client/client -v 4 -p $port
- RESULT=$?
- remove_ready_file
- if [ $RESULT -ne 0 ]; then
- echo -e "\n\nIssue with TLS v1.3 cipher suites - AES128-CCM-8 SHA-256"
- do_cleanup
- exit 1
- fi
- echo ""
- fi
- # TLS 1.3 cipher suites server / client.
- echo -e "\n\nTLS v1.3 cipher suite mismatch"
- port=0
- ./examples/server/server -v 4 -R $ready_file -p $port -l TLS13-CHACHA20-POLY1305-SHA256 &
- server_pid=$!
- create_port
- ./examples/client/client -v 4 -p $port -l TLS13-AES256-GCM-SHA384
- RESULT=$?
- remove_ready_file
- if [ $RESULT -ne 1 ]; then
- echo -e "\n\nIssue with mismatched TLS v1.3 cipher suites"
- do_cleanup
- exit 1
- fi
- echo ""
- # TLS 1.3 server / TLS 1.2 client.
- echo -e "\n\nTLS v1.3 server downgrading to TLS v1.2"
- port=0
- ./examples/server/server -v 4 -R $ready_file -p $port &
- server_pid=$!
- create_port
- ./examples/client/client -v 3 -p $port
- RESULT=$?
- remove_ready_file
- if [ $RESULT -eq 0 ]; then
- echo -e "\n\nIssue with TLS v1.3 server downgrading to TLS v1.2"
- do_cleanup
- exit 1
- fi
- echo ""
- # TLS Downgrade server / TLS 1.2 client.
- echo -e "\n\nTLS server downgrading to TLS v1.2"
- port=0
- ./examples/server/server -v d -R $ready_file -p $port &
- server_pid=$!
- create_port
- ./examples/client/client -v 3 -p $port
- RESULT=$?
- remove_ready_file
- if [ $RESULT -ne 0 ]; then
- echo -e "\n\nIssue with TLS server downgrading to TLS v1.2"
- do_cleanup
- exit 1
- fi
- echo ""
- # TLS 1.2 server / TLS 1.3 client.
- echo -e "\n\nTLS v1.3 client upgrading server to TLS v1.3"
- port=0
- ./examples/server/server -v 3 -R $ready_file -p $port &
- server_pid=$!
- create_port
- ./examples/client/client -v 4 -p $port
- RESULT=$?
- remove_ready_file
- if [ $RESULT -eq 0 ]; then
- echo -e "\n\nIssue with TLS v1.3 client upgrading server to TLS v1.3"
- do_cleanup
- exit 1
- fi
- echo ""
- # TLS 1.2 server / TLS downgrade client.
- echo -e "\n\nTLS client downgrading to TLS v1.2"
- port=0
- ./examples/server/server -v 3 -R $ready_file -p $port &
- server_pid=$!
- create_port
- ./examples/client/client -v d -p $port
- RESULT=$?
- remove_ready_file
- if [ $RESULT -ne 0 ]; then
- echo -e "\n\nIssue with TLS client downgrading to TLS v1.2"
- do_cleanup
- exit 1
- fi
- echo ""
- # TLS Downgrade server / TLS Downgrade client.
- echo -e "\n\nTLS server and client able to downgrade but don't"
- port=0
- ./examples/server/server -v d -R $ready_file -p $port &
- server_pid=$!
- create_port
- ./examples/client/client -v d -p $port
- RESULT=$?
- remove_ready_file
- if [ $RESULT -ne 0 ]; then
- echo -e "\n\nIssue with TLS not downgrading"
- do_cleanup
- exit 1
- fi
- echo ""
- # TLS Downgrade server / TLS Downgrade client resumption.
- echo -e "\n\nTLS server and client able to downgrade but don't and resume"
- port=0
- ./examples/server/server -v d -r -R $ready_file -p $port &
- server_pid=$!
- create_port
- ./examples/client/client -v d -r -p $port
- RESULT=$?
- remove_ready_file
- if [ $RESULT -ne 0 ]; then
- echo -e "\n\nIssue with TLS not downgrading and resumption"
- do_cleanup
- exit 1
- fi
- echo ""
- # TLS Downgrade server / TLS 1.2 client and resume.
- echo -e "\n\nTLS server downgrade and resume"
- port=0
- ./examples/server/server -v d -r -R $ready_file -p $port &
- server_pid=$!
- create_port
- ./examples/client/client -v 3 -r -p $port
- RESULT=$?
- remove_ready_file
- if [ $RESULT -ne 0 ]; then
- echo -e "\n\nIssue with TLS server downgrading and resumption"
- do_cleanup
- exit 1
- fi
- echo ""
- # TLS 1.2 server / TLS downgrade client and resume.
- echo -e "\n\nTLS client downgrade and resume"
- port=0
- ./examples/server/server -v 3 -r -R $ready_file -p $port &
- server_pid=$!
- create_port
- ./examples/client/client -v d -r -p $port
- RESULT=$?
- remove_ready_file
- if [ $RESULT -ne 0 ]; then
- echo -e "\n\nIssue with TLS client downgrading and resumption"
- do_cleanup
- exit 1
- fi
- echo ""
- # TLS Downgrade server / TLS Downgrade client.
- # TLS 1.3 server / TLS 1.3 client send KeyUpdate before sending app data.
- echo -e "\n\nTLS v1.3 KeyUpdate"
- port=0
- ./examples/server/server -v 4 -U -R $ready_file -p $port &
- server_pid=$!
- create_port
- ./examples/client/client -v 4 -I -p $port
- RESULT=$?
- remove_ready_file
- if [ $RESULT -ne 0 ]; then
- echo -e "\n\nIssue with TLS v1.3 KeyUpdate"
- do_cleanup
- exit 1
- fi
- echo ""
- # TLS 1.3 server / TLS 1.3 client - don't use (EC)DHE with PSK.
- echo -e "\n\nTLS v1.3 PSK without (EC)DHE"
- port=0
- ./examples/server/server -v 4 -r -R $ready_file -p $port &
- server_pid=$!
- create_port
- ./examples/client/client -v 4 -r -K -p $port
- RESULT=$?
- remove_ready_file
- if [ $RESULT -ne 0 ]; then
- echo -e "\n\nIssue with TLS v1.3 PSK without (EC)DHE"
- do_cleanup
- exit 1
- fi
- echo ""
- # TLS 1.3 server / TLS 1.3 client and Post-Handshake Authentication.
- echo -e "\n\nTLS v1.3 Post-Handshake Authentication"
- port=0
- ./examples/server/server -v 4 -Q -R $ready_file -p $port &
- server_pid=$!
- create_port
- ./examples/client/client -v 4 -Q -p $port
- RESULT=$?
- remove_ready_file
- if [ $RESULT -ne 0 ]; then
- echo -e "\n\nIssue with TLS v1.3 Post-Handshake Auth"
- do_cleanup
- exit 1
- fi
- echo ""
- echo -e "\nALL Tests Passed"
- exit 0
|