3 # Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010 Free Software
6 # Author: Simon Josefsson
8 # This file is part of GnuTLS.
10 # GnuTLS is free software; you can redistribute it and/or modify it
11 # under the terms of the GNU General Public License as published by the
12 # Free Software Foundation; either version 3 of the License, or (at
13 # your option) any later version.
15 # GnuTLS is distributed in the hope that it will be useful, but
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 # General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with GnuTLS; if not, write to the Free Software Foundation,
22 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 CERTTOOL=${CERTTOOL:-../../src/certtool$EXEEXT}
28 TSTAMP=`datefudge "2006-09-23" date -u +%s`
29 if test "$TSTAMP" != "1158962400"; then
30 echo "Cannot fake timestamps, please install datefudge..."
34 # Test 1, PKCS#1 pad digestAlgorithm.parameters
38 datefudge "2006-09-23" $CERTTOOL --verify-chain --infile $srcdir/pkcs1-pad-ok.pem | tee out1 >/dev/null 2>&1
39 datefudge "2006-09-23" $CERTTOOL --verify-chain --infile $srcdir/pkcs1-pad-broken.pem | tee out2 >/dev/null 2>&1
41 out1oks=`grep 'Verified.' out1 | wc -l | tr -d " "`
42 out2oks=`grep 'Verified.' out2 | wc -l | tr -d " "`
43 out1fails=`grep 'Not verified.' out1 | wc -l | tr -d " "`
44 out2fails=`grep 'Not verified.' out2 | wc -l | tr -d " "`
46 if test "$out1oks$out2oks$out1fails$out2fails" != "$EXPECT1"; then
47 echo out1 oks $out1oks fails $out1fails out2 oks $out2oks fails $out2fails
48 echo expected $EXPECT1
49 echo "PKCS1-PAD1 FAIL"
57 # Test 2, Bleichenbacher's Crypto 06 rump session
61 datefudge "2006-09-23" $CERTTOOL --verify-chain --infile $srcdir/pkcs1-pad-ok2.pem | tee out1 >/dev/null 2>&1
62 datefudge "2006-09-23" $CERTTOOL --verify-chain --infile $srcdir/pkcs1-pad-broken2.pem | tee out2 >/dev/null 2>&1
64 out1oks=`grep 'Verified.' out1 | wc -l | tr -d " "`
65 out2oks=`grep 'Verified.' out2 | wc -l | tr -d " "`
66 out1fails=`grep 'Not verified.' out1 | wc -l | tr -d " "`
67 out2fails=`grep 'Not verified.' out2 | wc -l | tr -d " "`
69 if test "$out1oks$out2oks$out1fails$out2fails" != "$EXPECT2"; then
70 echo out1 oks $out1oks fails $out1fails out2 oks $out2oks fails $out2fails
71 echo expected $EXPECT2
72 echo "PKCS1-PAD2 FAIL"
80 # Test 3, forged Starfield certificate,
81 # by Andrei Pyshkin, Erik Tews and Ralf-Philipp Weinmann.
86 datefudge "2006-09-23" $CERTTOOL --verify-chain --infile $srcdir/pkcs1-pad-broken3.pem | tee out1 >/dev/null 2>&1
88 out1oks=`grep 'Verified.' out1 | wc -l | tr -d " "`
89 out1fails=`grep 'Not verified.' out1 | wc -l | tr -d " "`
91 if test "$out1oks$out1fails" != "$EXPECT3"; then
92 echo out1 oks $out1oks fails $out1fails
93 echo expected $EXPECT3
94 echo "PKCS1-PAD3 FAIL"