No empty .Rs/.Re
[netbsd-mini2440.git] / crypto / dist / heimdal / lib / hx509 / test_crypto.in
blob6ef6ac5bac20a44bd23c16c7df13956db771a0aa
1 #!/bin/sh
3 # Copyright (c) 2006 Kungliga Tekniska Högskolan
4 # (Royal Institute of Technology, Stockholm, Sweden).
5 # All rights reserved.
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
9 # are met:
11 # 1. Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
14 # 2. Redistributions in binary form must reproduce the above copyright
15 # notice, this list of conditions and the following disclaimer in the
16 # documentation and/or other materials provided with the distribution.
18 # 3. Neither the name of the Institute nor the names of its contributors
19 # may be used to endorse or promote products derived from this software
20 # without specific prior written permission.
22 # THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
23 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 # ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
26 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 # SUCH DAMAGE.
34 # $Heimdal: test_crypto.in 20898 2007-06-04 23:07:46Z lha $
35 # $NetBSD$
38 srcdir="@srcdir@"
39 objdir="@objdir@"
41 stat="--statistic-file=${objdir}/statfile"
43 hxtool="${TESTS_ENVIRONMENT} ./hxtool ${stat}"
45 if ${hxtool} info | grep 'rsa: hcrypto null RSA' > /dev/null ; then
46 exit 77
48 if ${hxtool} info | grep 'rand: not available' > /dev/null ; then
49 exit 77
53 echo "Bleichenbacher good cert (from eay)"
54 ${hxtool} verify --missing-revoke \
55 --time=2006-09-25 \
56 cert:FILE:$srcdir/data/bleichenbacher-good.pem \
57 anchor:FILE:$srcdir/data/bleichenbacher-good.pem > /dev/null || exit 1
59 echo "Bleichenbacher bad cert (from eay)"
60 ${hxtool} verify --missing-revoke \
61 --time=2006-09-25 \
62 cert:FILE:$srcdir/data/bleichenbacher-bad.pem \
63 anchor:FILE:$srcdir/data/bleichenbacher-bad.pem > /dev/null && exit 1
65 echo "Bleichenbacher good cert (from yutaka)"
66 ${hxtool} verify --missing-revoke \
67 --time=2006-09-25 \
68 cert:FILE:$srcdir/data/yutaka-pad-ok-cert.pem \
69 anchor:FILE:$srcdir/data/yutaka-pad-ok-ca.pem > /dev/null || exit 1
71 echo "Bleichenbacher bad cert (from yutaka)"
72 ${hxtool} verify --missing-revoke \
73 --time=2006-09-25 \
74 cert:FILE:$srcdir/data/yutaka-pad-broken-cert.pem \
75 anchor:FILE:$srcdir/data/yutaka-pad-broken-ca.pem > /dev/null && exit 1
77 # Ralf-Philipp Weinmann <weinmann@cdc.informatik.tu-darmstadt.de>
78 # Andrew Pyshkin <pychkine@cdc.informatik.tu-darmstadt.de>
79 echo "Bleichenbacher bad cert (sf pad correct)"
80 ${hxtool} verify --missing-revoke \
81 --time=2006-09-25 \
82 cert:FILE:$srcdir/data/bleichenbacher-sf-pad-correct.pem \
83 anchor:FILE:$srcdir/data/sf-class2-root.pem > /dev/null && exit 1
85 echo Read 50 kilobyte random data
86 ${hxtool} random-data 50kilobyte > random-data || exit 1
88 echo "crypto select1"
89 ${hxtool} crypto-select > test || { echo "select1"; exit 1; }
90 cmp test ${srcdir}/tst-crypto-select1 > /dev/null || \
91 { echo "select1 failure"; exit 1; }
93 echo "crypto select1"
94 ${hxtool} crypto-select --type=digest > test || { echo "select1"; exit 1; }
95 cmp test ${srcdir}/tst-crypto-select1 > /dev/null || \
96 { echo "select1 failure"; exit 1; }
98 echo "crypto select2"
99 ${hxtool} crypto-select --type=public-sig > test || { echo "select2"; exit 1; }
100 cmp test ${srcdir}/tst-crypto-select2 > /dev/null || \
101 { echo "select2 failure"; exit 1; }
103 echo "crypto select3"
104 ${hxtool} crypto-select \
105 --type=public-sig \
106 --peer-cmstype=1.2.840.113549.1.1.4 \
107 > test || { echo "select3"; exit 1; }
108 cmp test ${srcdir}/tst-crypto-select3 > /dev/null || \
109 { echo "select3 failure"; exit 1; }
111 echo "crypto select4"
112 ${hxtool} crypto-select \
113 --type=public-sig \
114 --peer-cmstype=1.2.840.113549.1.1.5 \
115 --peer-cmstype=1.2.840.113549.1.1.4 \
116 > test || { echo "select4"; exit 1; }
117 cmp test ${srcdir}/tst-crypto-select4 > /dev/null || \
118 { echo "select4 failure"; exit 1; }
120 echo "crypto select5"
121 ${hxtool} crypto-select \
122 --type=public-sig \
123 --peer-cmstype=1.2.840.113549.1.1.11 \
124 --peer-cmstype=1.2.840.113549.1.1.5 \
125 > test || { echo "select5"; exit 1; }
126 cmp test ${srcdir}/tst-crypto-select5 > /dev/null || \
127 { echo "select5 failure"; exit 1; }
129 echo "crypto select6"
130 ${hxtool} crypto-select \
131 --type=public-sig \
132 --peer-cmstype=1.2.840.113549.2.5 \
133 --peer-cmstype=1.2.840.113549.1.1.5 \
134 > test || { echo "select6"; exit 1; }
135 cmp test ${srcdir}/tst-crypto-select6 > /dev/null || \
136 { echo "select6 failure"; exit 1; }
138 echo "crypto select7"
139 ${hxtool} crypto-select \
140 --type=secret \
141 --peer-cmstype=2.16.840.1.101.3.4.1.42 \
142 --peer-cmstype=1.2.840.113549.3.7 \
143 --peer-cmstype=1.2.840.113549.1.1.5 \
144 > test || { echo "select7"; exit 1; }
145 cmp test ${srcdir}/tst-crypto-select7 > /dev/null || \
146 { echo "select7 failure"; exit 1; }
148 echo "crypto available1"
149 ${hxtool} crypto-available \
150 --type=all \
151 > test || { echo "available1"; exit 1; }
152 cmp test ${srcdir}/tst-crypto-available1 > /dev/null || \
153 { echo "available1 failure"; exit 1; }
155 echo "crypto available2"
156 ${hxtool} crypto-available \
157 --type=digest \
158 > test || { echo "available2"; exit 1; }
159 cmp test ${srcdir}/tst-crypto-available2 > /dev/null || \
160 { echo "available2 failure"; exit 1; }
162 echo "crypto available3"
163 ${hxtool} crypto-available \
164 --type=public-sig \
165 > test || { echo "available3"; exit 1; }
166 cmp test ${srcdir}/tst-crypto-available3 > /dev/null || \
167 { echo "available3 failure"; exit 1; }
169 echo "copy keystore FILE existing -> FILE"
170 ${hxtool} certificate-copy \
171 FILE:${srcdir}/data/test.crt,${srcdir}/data/test.key \
172 FILE:out.pem || exit 1
174 echo "copy keystore FILE -> FILE"
175 ${hxtool} certificate-copy \
176 FILE:out.pem \
177 FILE:out2.pem || exit 1
179 echo "copy keystore FILE -> PKCS12"
180 ${hxtool} certificate-copy \
181 FILE:out.pem \
182 PKCS12:out2.pem || exit 1
184 echo "print certificate with utf8"
185 ${hxtool} print \
186 FILE:$srcdir/data/j.pem >/dev/null 2>/dev/null || exit 1
188 exit 0