Add more EVP_MD symbols, don't depend on SHA1_Init/SHA256_Init
[heimdal.git] / lib / hx509 / test_crypto.in
blob9206031bef7d6b952ed283f10a6e0a5806b9ae31
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 # $Id$
37 srcdir="@srcdir@"
38 objdir="@objdir@"
40 stat="--statistic-file=${objdir}/statfile"
42 hxtool="${TESTS_ENVIRONMENT} ./hxtool ${stat}"
44 if ${hxtool} info | grep 'rsa: hcrypto null RSA' > /dev/null ; then
45 exit 77
47 if ${hxtool} info | grep 'rand: not available' > /dev/null ; then
48 exit 77
52 echo "Bleichenbacher good cert (from eay)"
53 ${hxtool} verify --missing-revoke \
54 --time=2006-09-25 \
55 cert:FILE:$srcdir/data/bleichenbacher-good.pem \
56 anchor:FILE:$srcdir/data/bleichenbacher-good.pem > /dev/null || exit 1
58 echo "Bleichenbacher bad cert (from eay)"
59 ${hxtool} verify --missing-revoke \
60 --time=2006-09-25 \
61 cert:FILE:$srcdir/data/bleichenbacher-bad.pem \
62 anchor:FILE:$srcdir/data/bleichenbacher-bad.pem > /dev/null && exit 1
64 echo "Bleichenbacher good cert (from yutaka)"
65 ${hxtool} verify --missing-revoke \
66 --time=2006-09-25 \
67 cert:FILE:$srcdir/data/yutaka-pad-ok-cert.pem \
68 anchor:FILE:$srcdir/data/yutaka-pad-ok-ca.pem > /dev/null || exit 1
70 echo "Bleichenbacher bad cert (from yutaka)"
71 ${hxtool} verify --missing-revoke \
72 --time=2006-09-25 \
73 cert:FILE:$srcdir/data/yutaka-pad-broken-cert.pem \
74 anchor:FILE:$srcdir/data/yutaka-pad-broken-ca.pem > /dev/null && exit 1
76 # Ralf-Philipp Weinmann <weinmann@cdc.informatik.tu-darmstadt.de>
77 # Andrew Pyshkin <pychkine@cdc.informatik.tu-darmstadt.de>
78 echo "Bleichenbacher bad cert (sf pad correct)"
79 ${hxtool} verify --missing-revoke \
80 --time=2006-09-25 \
81 cert:FILE:$srcdir/data/bleichenbacher-sf-pad-correct.pem \
82 anchor:FILE:$srcdir/data/sf-class2-root.pem > /dev/null && exit 1
84 echo Read 50 kilobyte random data
85 ${hxtool} random-data 50kilobyte > random-data || exit 1
87 echo "crypto select1"
88 ${hxtool} crypto-select > test || { echo "select1"; exit 1; }
89 cmp test ${srcdir}/tst-crypto-select1 > /dev/null || \
90 { echo "select1 failure"; exit 1; }
92 echo "crypto select1"
93 ${hxtool} crypto-select --type=digest > test || { echo "select1"; exit 1; }
94 cmp test ${srcdir}/tst-crypto-select1 > /dev/null || \
95 { echo "select1 failure"; exit 1; }
97 echo "crypto select2"
98 ${hxtool} crypto-select --type=public-sig > test || { echo "select2"; exit 1; }
99 cmp test ${srcdir}/tst-crypto-select2 > /dev/null || \
100 { echo "select2 failure"; exit 1; }
102 echo "crypto select3"
103 ${hxtool} crypto-select \
104 --type=public-sig \
105 --peer-cmstype=1.2.840.113549.1.1.4 \
106 > test || { echo "select3"; exit 1; }
107 cmp test ${srcdir}/tst-crypto-select3 > /dev/null || \
108 { echo "select3 failure"; exit 1; }
110 echo "crypto select4"
111 ${hxtool} crypto-select \
112 --type=public-sig \
113 --peer-cmstype=1.2.840.113549.1.1.5 \
114 --peer-cmstype=1.2.840.113549.1.1.4 \
115 > test || { echo "select4"; exit 1; }
116 cmp test ${srcdir}/tst-crypto-select4 > /dev/null || \
117 { echo "select4 failure"; exit 1; }
119 echo "crypto select5"
120 ${hxtool} crypto-select \
121 --type=public-sig \
122 --peer-cmstype=1.2.840.113549.1.1.11 \
123 --peer-cmstype=1.2.840.113549.1.1.5 \
124 > test || { echo "select5"; exit 1; }
125 cmp test ${srcdir}/tst-crypto-select5 > /dev/null || \
126 { echo "select5 failure"; exit 1; }
128 echo "crypto select6"
129 ${hxtool} crypto-select \
130 --type=public-sig \
131 --peer-cmstype=1.2.840.113549.2.5 \
132 --peer-cmstype=1.2.840.113549.1.1.5 \
133 > test || { echo "select6"; exit 1; }
134 cmp test ${srcdir}/tst-crypto-select6 > /dev/null || \
135 { echo "select6 failure"; exit 1; }
137 echo "crypto select7"
138 ${hxtool} crypto-select \
139 --type=secret \
140 --peer-cmstype=2.16.840.1.101.3.4.1.42 \
141 --peer-cmstype=1.2.840.113549.3.7 \
142 --peer-cmstype=1.2.840.113549.1.1.5 \
143 > test || { echo "select7"; exit 1; }
144 cmp test ${srcdir}/tst-crypto-select7 > /dev/null || \
145 { echo "select7 failure"; exit 1; }
147 #echo "crypto available1"
148 #${hxtool} crypto-available \
149 # --type=all \
150 # > test || { echo "available1"; exit 1; }
151 #cmp test ${srcdir}/tst-crypto-available1 > /dev/null || \
152 # { echo "available1 failure"; exit 1; }
154 echo "crypto available2"
155 ${hxtool} crypto-available \
156 --type=digest \
157 > test || { echo "available2"; exit 1; }
158 cmp test ${srcdir}/tst-crypto-available2 > /dev/null || \
159 { echo "available2 failure"; exit 1; }
161 #echo "crypto available3"
162 #${hxtool} crypto-available \
163 # --type=public-sig \
164 # > test || { echo "available3"; exit 1; }
165 #cmp test ${srcdir}/tst-crypto-available3 > /dev/null || \
166 # { echo "available3 failure"; exit 1; }
168 echo "copy keystore FILE existing -> FILE"
169 ${hxtool} certificate-copy \
170 FILE:${srcdir}/data/test.crt,${srcdir}/data/test.key \
171 FILE:out.pem || exit 1
173 echo "copy keystore FILE -> FILE"
174 ${hxtool} certificate-copy \
175 FILE:out.pem \
176 FILE:out2.pem || exit 1
178 echo "copy keystore FILE -> PKCS12"
179 ${hxtool} certificate-copy \
180 FILE:out.pem \
181 PKCS12:out2.pem || exit 1
183 echo "print certificate with utf8"
184 ${hxtool} print \
185 FILE:$srcdir/data/j.pem >/dev/null 2>/dev/null || exit 1
187 echo "Make sure that we can parse EC private keys"
188 ${hxtool} print --content \
189 FILE:$srcdir/data/pkinit-ec.crt,$srcdir/data/pkinit-ec.key \
190 > /dev/null || exit 1
192 exit 0