Blame tests/server-multi-keys.sh

Packit 549fdc
#!/bin/sh
Packit 549fdc
Packit 549fdc
# Copyright (C) 2017 Nikos Mavrogiannopoulos
Packit 549fdc
#
Packit 549fdc
# Author: Nikos Mavrogiannopoulos
Packit 549fdc
#
Packit 549fdc
# This file is part of GnuTLS.
Packit 549fdc
#
Packit 549fdc
# GnuTLS is free software; you can redistribute it and/or modify it
Packit 549fdc
# under the terms of the GNU General Public License as published by the
Packit 549fdc
# Free Software Foundation; either version 3 of the License, or (at
Packit 549fdc
# your option) any later version.
Packit 549fdc
#
Packit 549fdc
# GnuTLS is distributed in the hope that it will be useful, but
Packit 549fdc
# WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 549fdc
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 549fdc
# General Public License for more details.
Packit 549fdc
#
Packit 549fdc
# You should have received a copy of the GNU General Public License
Packit 549fdc
# along with GnuTLS; if not, write to the Free Software Foundation,
Packit 549fdc
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Packit 549fdc
Packit 549fdc
srcdir="${srcdir:-.}"
Packit 549fdc
SERV="${SERV:-../src/gnutls-serv${EXEEXT}}"
Packit 549fdc
CLI="${CLI:-../src/gnutls-cli${EXEEXT}}"
Packit 549fdc
unset RETCODE
Packit 549fdc
Packit 549fdc
if ! test -x "${SERV}"; then
Packit 549fdc
	exit 77
Packit 549fdc
fi
Packit 549fdc
Packit 549fdc
if ! test -x "${CLI}"; then
Packit 549fdc
	exit 77
Packit 549fdc
fi
Packit 549fdc
Packit 549fdc
if test "${WINDIR}" != ""; then
Packit 549fdc
	exit 77
Packit 549fdc
fi 
Packit 549fdc
Packit 549fdc
if ! test -z "${VALGRIND}"; then
Packit 549fdc
	VALGRIND="${LIBTOOL:-libtool} --mode=execute ${VALGRIND} --error-exitcode=15"
Packit 549fdc
fi
Packit 549fdc
Packit 549fdc
Packit 549fdc
SERV="${SERV} -q"
Packit 549fdc
Packit 549fdc
. "${srcdir}/scripts/common.sh"
Packit 549fdc
Packit 549fdc
check_for_datefudge
Packit 549fdc
Packit 549fdc
echo "Checking whether server can utilize multiple keys"
Packit 549fdc
Packit 549fdc
KEY1=${srcdir}/../doc/credentials/x509/key-rsa.pem
Packit 549fdc
CERT1=${srcdir}/../doc/credentials/x509/cert-rsa.pem
Packit 549fdc
KEY2=${srcdir}/../doc/credentials/x509/key-ecc.pem
Packit 549fdc
CERT2=${srcdir}/../doc/credentials/x509/cert-ecc.pem
Packit 549fdc
KEY3=${srcdir}/../doc/credentials/x509/key-rsa-pss.pem
Packit 549fdc
CERT3=${srcdir}/../doc/credentials/x509/cert-rsa-pss.pem
Packit 549fdc
CAFILE=${srcdir}/../doc/credentials/x509/ca.pem
Packit 549fdc
TMPFILE=outcert.$$.tmp
Packit 549fdc
Packit 549fdc
PRIO_ADD=":+SIGN-RSA-PSS-SHA256:+SIGN-RSA-PSS-SHA384:+SIGN-RSA-PSS-SHA512"
Packit 549fdc
Packit 549fdc
eval "${GETPORT}"
Packit 549fdc
launch_server $$ --echo --priority "NORMAL:+ECDHE-RSA:+ECDHE-ECDSA${PRIO_ADD}" --x509keyfile ${KEY1} --x509certfile ${CERT1} \
Packit 549fdc
	--x509keyfile ${KEY2} --x509certfile ${CERT2} --x509keyfile ${KEY3} --x509certfile ${CERT3}
Packit 549fdc
PID=$!
Packit 549fdc
wait_server ${PID}
Packit 549fdc
Packit 549fdc
timeout 1800 datefudge "2017-08-9" \
Packit 549fdc
"${CLI}" -p "${PORT}" localhost --x509cafile ${CAFILE} --priority "NORMAL:-KX-ALL:+ECDHE-RSA${PRIO_ADD}" 
Packit 549fdc
	fail ${PID} "1. handshake with RSA should have succeeded!"
Packit 549fdc
Packit 549fdc
timeout 1800 datefudge "2017-08-9" \
Packit 549fdc
"${CLI}" -p "${PORT}" localhost --x509cafile ${CAFILE} --priority "NORMAL:-KX-ALL:+ECDHE-ECDSA${PRIO_ADD}" 
Packit 549fdc
	fail ${PID} "2. handshake with ECC should have succeeded!"
Packit 549fdc
Packit 549fdc
timeout 1800 datefudge "2017-08-9" \
Packit 549fdc
"${CLI}" -p "${PORT}" localhost --x509cafile ${CAFILE} --priority "NORMAL:-KX-ALL:+ECDHE-RSA:-SIGN-ALL:+SIGN-RSA-SHA256" --save-cert ${TMPFILE} 
Packit 549fdc
	fail ${PID} "3. handshake with RSA should have succeeded!"
Packit 549fdc
Packit 549fdc
cmp ${TMPFILE} ${CERT1}
Packit 549fdc
if test $? != 0;then
Packit 549fdc
	fail ${PID} "3. the certificate used by server was not the expected"
Packit 549fdc
fi
Packit 549fdc
Packit 549fdc
Packit 549fdc
# check whether the server used the RSA-PSS certificate when we asked for RSA-PSS signature
Packit 549fdc
timeout 1800 datefudge "2017-08-9" \
Packit 549fdc
"${CLI}" -p "${PORT}" localhost --x509cafile ${CAFILE} --priority "NORMAL:-KX-ALL:+ECDHE-RSA:-SIGN-ALL:+SIGN-RSA-PSS-SHA256" --save-cert ${TMPFILE} 
Packit 549fdc
	fail ${PID} "4. handshake with RSA-PSS and SHA256 should have succeeded!"
Packit 549fdc
Packit 549fdc
cmp ${TMPFILE} ${CERT3}
Packit 549fdc
if test $? != 0;then
Packit 549fdc
	fail ${PID} "4. the certificate used by server was not the expected"
Packit 549fdc
fi
Packit 549fdc
Packit 549fdc
kill ${PID}
Packit 549fdc
wait
Packit 549fdc
Packit 549fdc
exit 0