Blame tests/cipher-listings.sh

Packit aea12f
#!/bin/sh
Packit aea12f
Packit aea12f
# Copyright (C) 2010-2016 Free Software Foundation, 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 General Public License
Packit aea12f
# along with GnuTLS; if not, write to the Free Software Foundation,
Packit aea12f
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Packit aea12f
Packit aea12f
srcdir="${srcdir:-.}"
Packit aea12f
CLI="${CLI:-../src/gnutls-cli${EXEEXT}}"
Packit aea12f
DIFF="${DIFF:-diff -b -B}"
Packit aea12f
SED="${SED:-sed}"
Packit aea12f
unset RETCODE
Packit aea12f
Packit aea12f
TMPFILE=cipher-listings.$$.tmp
Packit aea12f
TMPFILE2=cipher-listings2.$$.tmp
Packit aea12f
Packit aea12f
if ! test -x "${CLI}"; 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
. "${srcdir}/scripts/common.sh"
Packit aea12f
Packit aea12f
echo "Checking ciphersuite listings"
Packit aea12f
Packit aea12f
tab=$(printf '\t')
Packit aea12f
check()
Packit aea12f
{
Packit aea12f
	prio=$2
Packit aea12f
	name=$1
Packit aea12f
	echo checking $prio
Packit aea12f
	"${CLI}" --list --priority $prio|grep -v ^Certificate|grep -v ^Ciphers|grep -v ^MACs|grep -v ^Key|grep -v Compression|grep -v ^Groups|grep -v ^Elliptic|${SED} -e 's/'"${tab}"'SSL3.0$//g' -e 's/'"${tab}"'TLS1.0$//g'|grep -v ^PK>$TMPFILE
Packit aea12f
	cat ${srcdir}/data/listings-$name|${SED} 's/'"${tab}"'SSL3.0$//g' >$TMPFILE2
Packit aea12f
	${DIFF} ${TMPFILE} ${TMPFILE2}
Packit aea12f
	if test $? != 0;then
Packit aea12f
		echo Error checking $prio with $name
Packit aea12f
		echo output in ${TMPFILE}
Packit aea12f
		exit 1
Packit aea12f
	fi
Packit aea12f
}
Packit aea12f
Packit aea12f
${CLI} --fips140-mode
Packit aea12f
if test $? = 0;then
Packit aea12f
	echo "Cannot run this test in FIPS140-2 mode"
Packit aea12f
	exit 77
Packit aea12f
fi
Packit aea12f
Packit aea12f
# We check whether the ciphersuites listed by gnutls-cli
Packit aea12f
# for specific (legacy) protocols remain constant. We
Packit aea12f
# don't check newer protocols as these change more often.
Packit aea12f
Packit aea12f
# This is a unit test for gnutls_priority_get_cipher_suite_index
Packit aea12f
Packit aea12f
if test "${ENABLE_SSL3}" = "1";then
Packit Service 991b93
echo "Running with SSL3.0 enabled"
Packit aea12f
check SSL3.0 "NORMAL:-VERS-ALL:+VERS-SSL3.0:+ARCFOUR-128"
Packit Service 991b93
check old-SSL3.0-TLS1.1 "NORMAL:-VERS-ALL:+VERS-TLS1.0:+VERS-SSL3.0:+VERS-TLS1.1"
Packit Service 991b93
else
Packit Service 991b93
echo "Running without support for SSL3.0"
Packit Service 991b93
check SSL3.0-TLS1.1 "NORMAL:-VERS-ALL:+VERS-TLS1.0:+VERS-SSL3.0:+VERS-TLS1.1"
Packit aea12f
fi
Packit aea12f
check TLS1.0 "NORMAL:-VERS-ALL:+VERS-TLS1.0"
Packit aea12f
check TLS1.1 "NORMAL:-VERS-ALL:+VERS-TLS1.1"
Packit aea12f
check DTLS1.0 "NORMAL:-VERS-ALL:+VERS-DTLS1.0"
Packit aea12f
# Priority strings prior to 3.6.x did not require the +GROUP option; here we
Packit aea12f
# test whether these work as expected.
Packit aea12f
check legacy1 "NONE:+VERS-TLS-ALL:+MAC-ALL:+RSA:+AES-128-GCM:+SIGN-ALL:+COMP-NULL"
Packit aea12f
check legacy2 "NONE:+VERS-TLS-ALL:+MAC-ALL:+RSA:+CAMELLIA-256-GCM:+SIGN-ALL:+COMP-NULL"
Packit aea12f
check legacy3 "NONE:+VERS-TLS-ALL:+MAC-ALL:+RSA:+CAMELLIA-256-GCM:+SIGN-ALL:+COMP-NULL:+CTYPE-OPENPGP"
Packit aea12f
check legacy4 "NONE:+VERS-TLS-ALL:+MAC-ALL:+RSA:+CAMELLIA-256-GCM:+SIGN-ALL:+COMP-NULL:-CTYPE-OPENPGP"
Packit aea12f
Packit aea12f
Packit aea12f
rm -f ${TMPFILE}
Packit aea12f
rm -f ${TMPFILE2}
Packit aea12f
exit 0