Blame tests/rsa-md5-collision/rsa-md5-collision.sh

Packit 549fdc
#!/bin/sh
Packit 549fdc
Packit 549fdc
# Copyright (C) 2006, 2008, 2010, 2012 Free Software Foundation, Inc.
Packit 549fdc
# Copyright (C) 2016, Red Hat, Inc.
Packit 549fdc
#
Packit 549fdc
# Author: Simon Josefsson, 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
CERTTOOL="${CERTTOOL:-../src/certtool${EXEEXT}}"
Packit 549fdc
TMPFILE1=rsa-md5.$$.tmp
Packit 549fdc
TMPFILE2=rsa-md5-2.$$.tmp
Packit 549fdc
Packit 549fdc
if ! test -x "${CERTTOOL}"; then
Packit 549fdc
	exit 77
Packit 549fdc
fi
Packit 549fdc
Packit 549fdc
. ${srcdir}/scripts/common.sh
Packit 549fdc
check_for_datefudge
Packit 549fdc
Packit 549fdc
# Disable leak detection
Packit 549fdc
ASAN_OPTIONS="detect_leaks=0"
Packit 549fdc
export ASAN_OPTIONS
Packit 549fdc
Packit 549fdc
datefudge -s "2006-10-1" \
Packit 549fdc
"${CERTTOOL}" --verify-chain --outfile "$TMPFILE1" --infile "${srcdir}/rsa-md5-collision/colliding-chain-md5-1.pem"
Packit 549fdc
if test $? = 0;then
Packit 549fdc
	echo "Verification on chain1 succeeded"
Packit 549fdc
	exit 1
Packit 549fdc
fi
Packit 549fdc
Packit 549fdc
grep 'Not verified.' $TMPFILE1| grep 'insecure algorithm'
Packit 549fdc
if test $? != 0;then
Packit 549fdc
	echo "Output on chain1 doesn't match the expected"
Packit 549fdc
	exit 1
Packit 549fdc
fi
Packit 549fdc
Packit 549fdc
Packit 549fdc
datefudge -s "2006-10-1" \
Packit 549fdc
"${CERTTOOL}" --verify-chain --outfile "$TMPFILE2" --infile "${srcdir}/rsa-md5-collision/colliding-chain-md5-2.pem"
Packit 549fdc
if test $? = 0;then
Packit 549fdc
	echo "Verification on chain2 succeeded"
Packit 549fdc
	exit 1
Packit 549fdc
fi
Packit 549fdc
Packit 549fdc
grep 'Not verified.' $TMPFILE2| grep 'insecure algorithm'
Packit 549fdc
if test $? != 0;then
Packit 549fdc
	echo "Output on chain2 doesn't match the expected"
Packit 549fdc
	exit 1
Packit 549fdc
fi
Packit 549fdc
Packit 549fdc
rm -f $TMPFILE1 $TMPFILE2
Packit 549fdc
Packit 549fdc
# We're done.
Packit 549fdc
exit 0