~ubuntu-branches/ubuntu/intrepid/gnutls26/intrepid-security

« back to all changes in this revision

Viewing changes to tests/sha2/sha2

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Metzler
  • Date: 2008-05-01 13:09:49 UTC
  • Revision ID: james.westby@ubuntu.com-20080501130949-qsbsi06stso6a0ij
Tags: upstream-2.2.3~rc
ImportĀ upstreamĀ versionĀ 2.2.3~rc

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
# Copyright (C) 2006, 2007 Free Software Foundation
 
4
#
 
5
# Author: Simon Josefsson
 
6
#
 
7
# This file is part of GNUTLS.
 
8
#
 
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 3 of the License, or (at
 
12
# your option) any later version.
 
13
#
 
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.
 
18
#
 
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.
 
22
 
 
23
set -e
 
24
 
 
25
srcdir=${srcdir:-.}
 
26
CERTTOOL=${CERTTOOL:-../../src/certtool}
 
27
 
 
28
echo ca > template
 
29
echo cn = "SHA 512 CA" >> template
 
30
 
 
31
$CERTTOOL --generate-self-signed --template template \
 
32
    --load-privkey $srcdir/key-ca.pem \
 
33
    --outfile new-ca.pem \
 
34
    --hash sha512
 
35
 
 
36
echo ca > template
 
37
echo cn = "SHA 384 sub-CA" >> template
 
38
 
 
39
$CERTTOOL --generate-certificate --template template \
 
40
    --load-ca-privkey $srcdir/key-ca.pem \
 
41
    --load-ca-certificate new-ca.pem \
 
42
    --load-privkey $srcdir/key-subca.pem \
 
43
    --outfile new-subca.pem \
 
44
    --hash sha384
 
45
 
 
46
echo ca > template
 
47
echo cn = "SHA 256 sub-sub-CA" >> template
 
48
 
 
49
$CERTTOOL --generate-certificate --template template \
 
50
    --load-ca-privkey $srcdir/key-subca.pem \
 
51
    --load-ca-certificate new-subca.pem \
 
52
    --load-privkey $srcdir/key-subsubca.pem \
 
53
    --outfile new-subsubca.pem \
 
54
    --hash sha256
 
55
 
 
56
echo ca > template
 
57
echo cn = "End-user" >> template
 
58
 
 
59
$CERTTOOL --generate-certificate --template template \
 
60
    --load-ca-privkey $srcdir/key-subsubca.pem \
 
61
    --load-ca-certificate new-subsubca.pem \
 
62
    --load-privkey $srcdir/key-user.pem \
 
63
    --outfile new-user.pem
 
64
 
 
65
 
 
66
num=`cat new-user.pem new-subsubca.pem new-subca.pem new-ca.pem | $CERTTOOL --verify-chain | tee verify | grep -c Verified`
 
67
cat verify
 
68
 
 
69
if test "$num" != "4"; then
 
70
    echo Verification failure
 
71
    exit 1
 
72
else
 
73
    echo Test OK
 
74
fi
 
75
 
 
76
rm -f verify new-user.pem new-subsubca.pem new-subca.pem new-ca.pem template
 
77
 
 
78
exit 0