Merge branch 'master' of git://repo.or.cz/gnutls
[gnutls.git] / tests / pkcs1-padding / pkcs1-pad
blob6dbc13ad96a2f152142404328e191208433ba71a
1 #!/bin/sh
3 # Copyright (C) 2004, 2005, 2006 Free Software Foundation
5 # Author: Simon Josefsson
7 # This file is part of GNUTLS.
9 # GNUTLS is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by the
11 # Free Software Foundation; either version 2 of the License, or (at
12 # your option) any later version.
14 # GNUTLS is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with GNUTLS; if not, write to the Free Software Foundation,
21 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 srcdir=${srcdir:-.}
24 CERTTOOL=${CERTTOOL:-../../src/certtool}
26 # Test 1, PKCS#1 pad digestAlgorithm.parameters
28 EXPECT1=2101
30 $CERTTOOL --verify-chain --infile $srcdir/pkcs1-pad-ok.pem | tee out1
31 $CERTTOOL --verify-chain --infile $srcdir/pkcs1-pad-broken.pem | tee out2
33 out1oks=`grep 'Verified.' out1 | wc -l | tr -d " "`
34 out2oks=`grep 'Verified.' out2 | wc -l | tr -d " "`
35 out1fails=`grep 'Not verified.' out1 | wc -l | tr -d " "`
36 out2fails=`grep 'Not verified.' out2 | wc -l | tr -d " "`
38 rm -f out1 out2
40 echo out1 oks $out1oks fails $out1fails out2 oks $out2oks fails $out2fails
42 if test "$out1oks$out2oks$out1fails$out2fails" != "$EXPECT1"; then
43 echo expected $EXPECT1
44 echo "PKCS1-PAD1 FAIL"
45 exit 1
48 echo "PKCS1-PAD1 OK"
50 # Test 2, Bleichenbacher's Crypto 06 rump session
52 EXPECT2=1001
54 $CERTTOOL --verify-chain --infile $srcdir/pkcs1-pad-ok2.pem | tee out1
55 $CERTTOOL --verify-chain --infile $srcdir/pkcs1-pad-broken2.pem | tee out2
57 out1oks=`grep 'Verified.' out1 | wc -l | tr -d " "`
58 out2oks=`grep 'Verified.' out2 | wc -l | tr -d " "`
59 out1fails=`grep 'Not verified.' out1 | wc -l | tr -d " "`
60 out2fails=`grep 'Not verified.' out2 | wc -l | tr -d " "`
62 rm -f out1 out2
64 echo out1 oks $out1oks fails $out1fails out2 oks $out2oks fails $out2fails
66 if test "$out1oks$out2oks$out1fails$out2fails" != "$EXPECT2"; then
67 echo expected $EXPECT2
68 echo "PKCS1-PAD2 FAIL"
69 exit 1
72 echo "PKCS1-PAD2 OK"
74 # Test 3, forged Starfield certificate,
75 # by Andrei Pyshkin, Erik Tews and Ralf-Philipp Weinmann.
77 EXPECT3=11
79 $CERTTOOL --verify-chain --infile $srcdir/pkcs1-pad-broken3.pem | tee out1
81 out1oks=`grep 'Verified.' out1 | wc -l | tr -d " "`
82 out1fails=`grep 'Not verified.' out1 | wc -l | tr -d " "`
84 rm -f out1
86 echo out1 oks $out1oks fails $out1fails
88 if test "$out1oks$out1fails" != "$EXPECT3"; then
89 echo expected $EXPECT3
90 echo "PKCS1-PAD3 FAIL"
91 exit 1
94 echo "PKCS1-PAD3 OK"
96 # We're done.
97 exit 0