Don't read past the last list entry in _add_priority, doing so adds algorithms that...
[gnutls.git] / tests / pkcs1-padding / pkcs1-pad
blob3101c7e04976ea63d1e5277fb9a706a5585b7b26
1 #!/bin/sh
3 # Copyright (C) 2004-2006, 2008-2010, 2012 Free Software Foundation,
4 # Inc.
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.
24 set -e
26 srcdir=${srcdir:-.}
27 CERTTOOL=${CERTTOOL:-../../src/certtool$EXEEXT}
29 # Check for datefudge
30 TSTAMP=`datefudge "2006-09-23" date -u +%s || true`
31 if test "$TSTAMP" != "1158962400"; then
32 echo "You need datefudge to run this test"
33 exit 77
36 # Test 1, PKCS#1 pad digestAlgorithm.parameters
38 EXPECT1=2002
40 datefudge "2006-09-23" $CERTTOOL --verify-chain --infile $srcdir/pkcs1-pad-ok.pem | tee out1 >/dev/null 2>&1
41 datefudge "2006-09-23" $CERTTOOL --verify-chain --infile $srcdir/pkcs1-pad-broken.pem | tee out2 >/dev/null 2>&1
43 out1oks=`grep 'Verified.' out1 | wc -l | tr -d " "`
44 out2oks=`grep 'Verified.' out2 | wc -l | tr -d " "`
45 out1fails=`grep 'Not verified.' out1 | wc -l | tr -d " "`
46 out2fails=`grep 'Not verified.' out2 | wc -l | tr -d " "`
48 if test "$out1oks$out2oks$out1fails$out2fails" != "$EXPECT1"; then
49 echo out1 oks $out1oks fails $out1fails out2 oks $out2oks fails $out2fails
50 echo expected $EXPECT1
51 echo "PKCS1-PAD1 FAIL"
52 exit 1
55 rm -f out1 out2
57 echo "PKCS1-PAD1 OK"
59 # Test 2, Bleichenbacher's Crypto 06 rump session
61 EXPECT2=2002
63 datefudge "2006-09-23" $CERTTOOL --verify-chain --infile $srcdir/pkcs1-pad-ok2.pem | tee out1 >/dev/null 2>&1
64 datefudge "2006-09-23" $CERTTOOL --verify-chain --infile $srcdir/pkcs1-pad-broken2.pem | tee out2 >/dev/null 2>&1
66 out1oks=`grep 'Verified.' out1 | wc -l | tr -d " "`
67 out2oks=`grep 'Verified.' out2 | wc -l | tr -d " "`
68 out1fails=`grep 'Not verified.' out1 | wc -l | tr -d " "`
69 out2fails=`grep 'Not verified.' out2 | wc -l | tr -d " "`
71 if test "$out1oks$out2oks$out1fails$out2fails" != "$EXPECT2"; then
72 echo out1 oks $out1oks fails $out1fails out2 oks $out2oks fails $out2fails
73 echo expected $EXPECT2
74 echo "PKCS1-PAD2 FAIL"
75 exit 1
78 rm -f out1 out2
80 echo "PKCS1-PAD2 OK"
82 # Test 3, forged Starfield certificate,
83 # by Andrei Pyshkin, Erik Tews and Ralf-Philipp Weinmann.
86 EXPECT3=02
88 datefudge "2006-09-23" $CERTTOOL --verify-chain --infile $srcdir/pkcs1-pad-broken3.pem | tee out1 >/dev/null 2>&1
90 out1oks=`grep 'Verified.' out1 | wc -l | tr -d " "`
91 out1fails=`grep 'Not verified.' out1 | wc -l | tr -d " "`
93 if test "$out1oks$out1fails" != "$EXPECT3"; then
94 echo out1 oks $out1oks fails $out1fails
95 echo expected $EXPECT3
96 echo "PKCS1-PAD3 FAIL"
97 exit 1
100 rm -f out1
102 echo "PKCS1-PAD3 OK"
104 # We're done.
105 exit 0