Blame tests/gnutls-cli-debug.sh

Packit aea12f
#!/bin/sh
Packit aea12f
Packit aea12f
# Copyright (C) 2017-2018 Red Hat, Inc.
Packit aea12f
#
Packit aea12f
# Author: Nikos Mavrogiannopoulos
Packit aea12f
#
Packit aea12f
# This file is part of GnuTLS.
Packit aea12f
#
Packit aea12f
# GnuTLS is free software; you can redistribute it and/or modify it
Packit aea12f
# under the terms of the GNU General Public License as published by the
Packit aea12f
# Free Software Foundation; either version 3 of the License, or (at
Packit aea12f
# your option) any later version.
Packit aea12f
#
Packit aea12f
# GnuTLS is distributed in the hope that it will be useful, but
Packit aea12f
# WITHOUT ANY WARRANTY; without even the implied warranty of
Packit aea12f
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit aea12f
# General Public License for more details.
Packit aea12f
#
Packit aea12f
# You should have received a copy of the GNU Lesser General Public License
Packit aea12f
# along with this program.  If not, see <https://www.gnu.org/licenses/>
Packit aea12f
#
Packit aea12f
Packit aea12f
srcdir="${srcdir:-.}"
Packit aea12f
SERV="${SERV:-../src/gnutls-serv${EXEEXT}}"
Packit aea12f
DCLI="${DCLI:-../src/gnutls-cli-debug${EXEEXT}}"
Packit aea12f
OUTFILE=cli-debug.$$.tmp
Packit Service 991b93
TMPFILE=config.$$.tmp
Packit aea12f
unset RETCODE
Packit aea12f
Packit aea12f
if ! test -x "${SERV}"; then
Packit aea12f
	exit 77
Packit aea12f
fi
Packit aea12f
Packit aea12f
if ! test -x "${DCLI}"; then
Packit aea12f
	exit 77
Packit aea12f
fi
Packit aea12f
Packit aea12f
if test "${WINDIR}" != ""; then
Packit aea12f
	exit 77
Packit aea12f
fi 
Packit aea12f
Packit aea12f
if ! test -z "${VALGRIND}"; then
Packit aea12f
	VALGRIND="${LIBTOOL:-libtool} --mode=execute ${VALGRIND} --error-exitcode=15"
Packit aea12f
fi
Packit aea12f
Packit aea12f
Packit aea12f
SERV="${SERV} -q"
Packit aea12f
Packit aea12f
. "${srcdir}/scripts/common.sh"
Packit aea12f
Packit aea12f
check_for_datefudge
Packit aea12f
Packit aea12f
Packit aea12f
KEY1=${srcdir}/../doc/credentials/x509/key-rsa.pem
Packit aea12f
CERT1=${srcdir}/../doc/credentials/x509/cert-rsa.pem
Packit aea12f
KEY2=${srcdir}/../doc/credentials/x509/key-ecc.pem
Packit aea12f
CERT2=${srcdir}/../doc/credentials/x509/cert-ecc.pem
Packit aea12f
KEY3=${srcdir}/../doc/credentials/x509/key-rsa-pss.pem
Packit aea12f
CERT3=${srcdir}/../doc/credentials/x509/cert-rsa-pss.pem
Packit Service 991b93
KEY4=${srcdir}/../doc/credentials/x509/key-gost12.pem
Packit Service 991b93
CERT4=${srcdir}/../doc/credentials/x509/cert-gost12.pem
Packit aea12f
CAFILE=${srcdir}/../doc/credentials/x509/ca.pem
Packit aea12f
TMPFILE=outcert.$$.tmp
Packit aea12f
Packit aea12f
# TLS1.1 and TLS1.2 test
Packit aea12f
echo "Checking output of gnutls-cli-debug for TLS1.1 and TLS1.2 server"
Packit aea12f
Packit aea12f
eval "${GETPORT}"
Packit aea12f
launch_server $$ --echo --priority "NORMAL:-VERS-ALL:+VERS-TLS1.2:+VERS-TLS1.1" --x509keyfile ${KEY1} --x509certfile ${CERT1} \
Packit aea12f
	--x509keyfile ${KEY2} --x509certfile ${CERT2} --x509keyfile ${KEY3} --x509certfile ${CERT3} >/dev/null 2>&1
Packit aea12f
PID=$!
Packit aea12f
wait_server ${PID}
Packit aea12f
Packit aea12f
timeout 1800 datefudge "2017-08-9" \
Packit aea12f
"${DCLI}" -p "${PORT}" localhost >$OUTFILE 2>&1 || fail ${PID} "gnutls-cli-debug run should have succeeded!"
Packit aea12f
Packit aea12f
kill ${PID}
Packit aea12f
wait
Packit aea12f
Packit aea12f
check_text() {
Packit aea12f
	echo " - Checking ${OUTFILE} for \"$1\""
Packit aea12f
	grep "$1" $OUTFILE >/dev/null
Packit aea12f
	if test $? != 0; then
Packit aea12f
		echo "failed"
Packit aea12f
		exit 1
Packit aea12f
	fi
Packit aea12f
}
Packit aea12f
Packit aea12f
check_text "whether we need to disable TLS 1.2... no"
Packit aea12f
check_text "for TLS 1.0 (RFC2246) support... no"
Packit aea12f
check_text "for TLS 1.1 (RFC4346) support... yes"
Packit aea12f
check_text "for TLS 1.2 (RFC5246) support... yes"
Packit aea12f
check_text "TLS1.2 neg fallback from TLS 1.6 to... TLS1.2"
Packit aea12f
check_text "for safe renegotiation (RFC5746) support... yes"
Packit aea12f
check_text "for encrypt-then-MAC (RFC7366) support... yes"
Packit aea12f
check_text "for ext master secret (RFC7627) support... yes"
Packit aea12f
check_text "for RFC7919 Diffie-Hellman support... yes"
Packit Service 991b93
check_text "for RSA key exchange support... yes"
Packit aea12f
check_text "for curve SECP256r1 (RFC4492)... yes"
Packit aea12f
check_text "for AES-GCM cipher (RFC5288) support... yes"
Packit aea12f
check_text "for SHA1 MAC support... yes"
Packit aea12f
if test "${GNUTLS_FORCE_FIPS_MODE}" != 1; then
Packit aea12f
	#these tests are not run in FIPS mode
Packit aea12f
	check_text "for MD5 MAC support... no"
Packit aea12f
	check_text "for ARCFOUR 128 cipher (RFC2246) support... no"
Packit aea12f
	check_text "for CHACHA20-POLY1305 cipher (RFC7905) support... yes"
Packit aea12f
fi
Packit aea12f
Packit aea12f
rm -f ${OUTFILE}
Packit aea12f
Packit aea12f
# TLS1.3 and TLS1.2 test
Packit aea12f
echo ""
Packit aea12f
echo "Checking output of gnutls-cli-debug for TLS1.3 and TLS1.2 server"
Packit aea12f
Packit aea12f
eval "${GETPORT}"
Packit aea12f
launch_server $$ --echo --priority "NORMAL:-VERS-ALL:+VERS-TLS1.3:+VERS-TLS1.2" --x509keyfile ${KEY1} --x509certfile ${CERT1} \
Packit aea12f
	--x509keyfile ${KEY2} --x509certfile ${CERT2} --x509keyfile ${KEY3} --x509certfile ${CERT3} >/dev/null 2>&1
Packit aea12f
PID=$!
Packit aea12f
wait_server ${PID}
Packit aea12f
Packit aea12f
timeout 1800 datefudge "2017-08-9" \
Packit aea12f
"${DCLI}" -p "${PORT}" localhost >$OUTFILE 2>&1 || fail ${PID} "gnutls-cli-debug run should have succeeded!"
Packit aea12f
Packit aea12f
kill ${PID}
Packit aea12f
wait
Packit aea12f
Packit aea12f
check_text "whether we need to disable TLS 1.2... no"
Packit aea12f
check_text "for TLS 1.0 (RFC2246) support... no"
Packit aea12f
check_text "for TLS 1.1 (RFC4346) support... no"
Packit aea12f
check_text "for TLS 1.2 (RFC5246) support... yes"
Packit aea12f
check_text "for TLS 1.3 (RFC8446) support... yes"
Packit aea12f
check_text "TLS1.2 neg fallback from TLS 1.6 to... TLS1.2"
Packit aea12f
check_text "for safe renegotiation (RFC5746) support... yes"
Packit aea12f
check_text "for encrypt-then-MAC (RFC7366) support... yes"
Packit aea12f
check_text "for ext master secret (RFC7627) support... yes"
Packit aea12f
check_text "for RFC7919 Diffie-Hellman support... yes"
Packit aea12f
check_text "for curve SECP256r1 (RFC4492)... yes"
Packit aea12f
check_text "for AES-GCM cipher (RFC5288) support... yes"
Packit Service 991b93
check_text "for RSA key exchange support... yes"
Packit aea12f
check_text "for SHA1 MAC support... yes"
Packit Service 991b93
check_text "whether the server accepts default record size (512 bytes)... yes"
Packit Service 991b93
check_text "whether %ALLOW_SMALL_RECORDS is required... no"
Packit Service 991b93
Packit aea12f
if test "${GNUTLS_FORCE_FIPS_MODE}" != 1; then
Packit aea12f
	#these tests are not run in FIPS mode
Packit aea12f
	check_text "for MD5 MAC support... no"
Packit aea12f
	check_text "for ARCFOUR 128 cipher (RFC2246) support... no"
Packit aea12f
	check_text "for CHACHA20-POLY1305 cipher (RFC7905) support... yes"
Packit aea12f
fi
Packit aea12f
Packit aea12f
rm -f ${OUTFILE}
Packit aea12f
Packit Service 991b93
# Small records test
Packit Service 991b93
echo ""
Packit Service 991b93
echo "Checking output of gnutls-cli-debug for small records and no RSA"
Packit Service 991b93
Packit Service 991b93
eval "${GETPORT}"
Packit Service 991b93
launch_server $$ --echo --priority "NORMAL:-VERS-ALL:+VERS-TLS1.3:+VERS-TLS1.2:-RSA:%ALLOW_SMALL_RECORDS" --x509keyfile ${KEY1} --x509certfile ${CERT1} \
Packit Service 991b93
	--x509keyfile ${KEY2} --x509certfile ${CERT2} --x509keyfile ${KEY3} --x509certfile ${CERT3} --recordsize=64 >/dev/null 2>&1
Packit Service 991b93
PID=$!
Packit Service 991b93
wait_server ${PID}
Packit Service 991b93
Packit Service 991b93
timeout 1800 datefudge "2017-08-9" \
Packit Service 991b93
"${DCLI}" -p "${PORT}" localhost >$OUTFILE 2>&1 || fail ${PID} "gnutls-cli-debug run should have succeeded!"
Packit Service 991b93
Packit Service 991b93
kill ${PID}
Packit Service 991b93
wait
Packit Service 991b93
Packit Service 991b93
check_text "whether the server accepts default record size (512 bytes)... no"
Packit Service 991b93
check_text "whether %ALLOW_SMALL_RECORDS is required... yes"
Packit Service 991b93
check_text "for RSA key exchange support... no"
Packit Service 991b93
Packit Service 991b93
echo ""
Packit Service 991b93
echo "Checking output of gnutls-cli-debug when algorithms are disabled"
Packit Service 991b93
eval "${GETPORT}"
Packit Service 991b93
launch_server $$ --echo --priority "NORMAL:-VERS-ALL:+VERS-TLS1.3:+VERS-TLS1.2" --x509keyfile ${KEY1} --x509certfile ${CERT1} \
Packit Service 991b93
	--x509keyfile ${KEY2} --x509certfile ${CERT2} --x509keyfile ${KEY3} --x509certfile ${CERT3} >/dev/null 2>&1
Packit Service 991b93
PID=$!
Packit Service 991b93
wait_server ${PID}
Packit Service 991b93
Packit Service 991b93
cat <<_EOF_ > ${TMPFILE}
Packit Service 991b93
[overrides]
Packit Service 991b93
Packit Service 991b93
tls-disabled-cipher = CAMELLIA-128-CBC
Packit Service 991b93
tls-disabled-cipher = CAMELLIA-256-CBC
Packit Service 991b93
_EOF_
Packit Service 991b93
export GNUTLS_SYSTEM_PRIORITY_FILE="${TMPFILE}"
Packit Service 991b93
Packit Service 991b93
timeout 1800 datefudge "2017-08-9" \
Packit Service 991b93
"${DCLI}" -p "${PORT}" localhost >$OUTFILE 2>&1 || fail ${PID} "gnutls-cli-debug run should have succeeded!"
Packit Service 991b93
Packit Service 991b93
unset GNUTLS_SYSTEM_PRIORITY_FILE
Packit Service 991b93
Packit Service 991b93
kill ${PID}
Packit Service 991b93
wait
Packit Service 991b93
Packit Service 991b93
check_text "for AES-GCM cipher (RFC5288) support... yes"
Packit Service 991b93
check_text "for RSA key exchange support... yes"
Packit Service 991b93
check_text "for SHA1 MAC support... yes"
Packit Service 991b93
Packit Service 991b93
rm -f ${OUTFILE}
Packit Service 991b93
rm -f ${TMPFILE}
Packit Service 991b93
Packit Service 991b93
if test "${ENABLE_GOST}" = "1" && test "${GNUTLS_FORCE_FIPS_MODE}" != 1 ; then
Packit Service 991b93
	# GOST_CNT test
Packit Service 991b93
	echo ""
Packit Service 991b93
	echo "Checking output of gnutls-cli-debug for GOST-enabled server"
Packit Service 991b93
Packit Service 991b93
	eval "${GETPORT}"
Packit Service 991b93
	launch_server $$ --echo --priority "NORMAL" --x509keyfile ${KEY4} --x509certfile ${CERT4} >/dev/null 2>&1
Packit Service 991b93
	PID=$!
Packit Service 991b93
	wait_server ${PID}
Packit Service 991b93
Packit Service 991b93
	timeout 1800 datefudge "2017-08-9" \
Packit Service 991b93
	"${DCLI}" -p "${PORT}" localhost >$OUTFILE 2>&1 || fail ${PID} "gnutls-cli-debug run should have succeeded!"
Packit Service 991b93
Packit Service 991b93
	kill ${PID}
Packit Service 991b93
	wait
Packit Service 991b93
Packit Service 991b93
	check_text "for VKO GOST-2012 (draft-smyshlyaev-tls12-gost-suites) support... yes"
Packit Service 991b93
	check_text "for GOST28147-CNT cipher (draft-smyshlyaev-tls12-gost-suites) support... yes"
Packit Service 991b93
	check_text "for GOST28147-IMIT MAC (draft-smyshlyaev-tls12-gost-suites) support... yes"
Packit Service 991b93
Packit Service 991b93
	rm -f ${OUTFILE}
Packit Service 991b93
Packit Service 991b93
fi
Packit Service 991b93
Packit aea12f
exit 0