No empty .Rs/.Re
[netbsd-mini2440.git] / crypto / dist / heimdal / lib / hx509 / test_cms.in
blobaf7fb3d7fe6af51cf9a8f3c95b49e0cb7a3f2aa8
1 #!/bin/sh
3 # Copyright (c) 2005 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_cms.in 21311 2007-06-25 18:26:37Z 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
52 echo "create signed data"
53 ${hxtool} cms-create-sd \
54 --certificate=FILE:$srcdir/data/test.crt,$srcdir/data/test.key \
55 "$srcdir/test_chain.in" \
56 sd.data > /dev/null || exit 1
58 echo "verify signed data"
59 ${hxtool} cms-verify-sd \
60 --missing-revoke \
61 --anchors=FILE:$srcdir/data/ca.crt \
62 sd.data sd.data.out > /dev/null || exit 1
63 cmp "$srcdir/test_chain.in" sd.data.out || exit 1
65 echo "create signed data (id-by-name)"
66 ${hxtool} cms-create-sd \
67 --certificate=FILE:$srcdir/data/test.crt,$srcdir/data/test.key \
68 --id-by-name \
69 "$srcdir/test_chain.in" \
70 sd.data > /dev/null || exit 1
72 echo "verify signed data"
73 ${hxtool} cms-verify-sd \
74 --missing-revoke \
75 --anchors=FILE:$srcdir/data/ca.crt \
76 sd.data sd.data.out > /dev/null || exit 1
77 cmp "$srcdir/test_chain.in" sd.data.out || exit 1
79 echo "verify signed data (EE cert as anchor)"
80 ${hxtool} cms-verify-sd \
81 --missing-revoke \
82 --anchors=FILE:$srcdir/data/test.crt \
83 sd.data sd.data.out > /dev/null || exit 1
84 cmp "$srcdir/test_chain.in" sd.data.out || exit 1
86 echo "create signed data (password)"
87 ${hxtool} cms-create-sd \
88 --pass=PASS:foobar \
89 --certificate=FILE:$srcdir/data/test.crt,$srcdir/data/test-pw.key \
90 "$srcdir/test_chain.in" \
91 sd.data > /dev/null || exit 1
93 echo "verify signed data"
94 ${hxtool} cms-verify-sd \
95 --missing-revoke \
96 --anchors=FILE:$srcdir/data/ca.crt \
97 sd.data sd.data.out > /dev/null || exit 1
98 cmp "$srcdir/test_chain.in" sd.data.out || exit 1
100 echo "create signed data (combined)"
101 ${hxtool} cms-create-sd \
102 --certificate=FILE:$srcdir/data/test.combined.crt \
103 "$srcdir/test_chain.in" \
104 sd.data > /dev/null || exit 1
106 echo "verify signed data"
107 ${hxtool} cms-verify-sd \
108 --missing-revoke \
109 --anchors=FILE:$srcdir/data/ca.crt \
110 sd.data sd.data.out > /dev/null || exit 1
111 cmp "$srcdir/test_chain.in" sd.data.out || exit 1
113 echo "create signed data (content info)"
114 ${hxtool} cms-create-sd \
115 --certificate=FILE:$srcdir/data/test.crt,$srcdir/data/test.key \
116 --content-info \
117 "$srcdir/test_chain.in" \
118 sd.data > /dev/null || exit 1
120 echo "verify signed data (content info)"
121 ${hxtool} cms-verify-sd \
122 --missing-revoke \
123 --anchors=FILE:$srcdir/data/ca.crt \
124 --content-info \
125 sd.data sd.data.out > /dev/null || exit 1
126 cmp "$srcdir/test_chain.in" sd.data.out || exit 1
128 echo "create signed data (content type)"
129 ${hxtool} cms-create-sd \
130 --certificate=FILE:$srcdir/data/test.crt,$srcdir/data/test.key \
131 --content-type=1.1.1.1 \
132 "$srcdir/test_chain.in" \
133 sd.data > /dev/null || exit 1
135 echo "verify signed data (content type)"
136 ${hxtool} cms-verify-sd \
137 --missing-revoke \
138 --anchors=FILE:$srcdir/data/ca.crt \
139 sd.data sd.data.out > /dev/null || exit 1
140 cmp "$srcdir/test_chain.in" sd.data.out || exit 1
142 echo "create signed data (pem)"
143 ${hxtool} cms-create-sd \
144 --certificate=FILE:$srcdir/data/test.crt,$srcdir/data/test.key \
145 --pem \
146 "$srcdir/test_chain.in" \
147 sd.data > /dev/null || exit 1
149 echo "create signed data (pem, detached)"
150 ${hxtool} cms-create-sd \
151 --certificate=FILE:$srcdir/data/test.crt,$srcdir/data/test.key \
152 --detached-signature \
153 --pem \
154 "$srcdir/test_chain.in" \
155 sd.data > /dev/null || exit 1
157 echo "create signed data (p12)"
158 ${hxtool} cms-create-sd \
159 --pass=PASS:foobar \
160 --certificate=PKCS12:$srcdir/data/test.p12 \
161 --signer=friendlyname-test \
162 "$srcdir/test_chain.in" \
163 sd.data > /dev/null || exit 1
165 echo "verify signed data"
166 ${hxtool} cms-verify-sd \
167 --missing-revoke \
168 --anchors=FILE:$srcdir/data/ca.crt \
169 --content-info \
170 "$srcdir/data/test-signed-data" sd.data.out > /dev/null || exit 1
171 cmp "$srcdir/data/static-file" sd.data.out || exit 1
173 echo "verify signed data (no attr)"
174 ${hxtool} cms-verify-sd \
175 --missing-revoke \
176 --anchors=FILE:$srcdir/data/ca.crt \
177 --content-info \
178 "$srcdir/data/test-signed-data-noattr" sd.data.out > /dev/null || exit 1
179 cmp "$srcdir/data/static-file" sd.data.out || exit 1
181 echo "verify failure signed data (no attr, no certs)"
182 ${hxtool} cms-verify-sd \
183 --missing-revoke \
184 --anchors=FILE:$srcdir/data/ca.crt \
185 --content-info \
186 "$srcdir/data/test-signed-data-noattr-nocerts" \
187 sd.data.out > /dev/null 2>/dev/null && exit 1
189 echo "verify signed data (no attr, no certs)"
190 ${hxtool} cms-verify-sd \
191 --missing-revoke \
192 --anchors=FILE:$srcdir/data/ca.crt \
193 --certificate=FILE:$srcdir/data/test.crt \
194 --content-info \
195 "$srcdir/data/test-signed-data-noattr-nocerts" \
196 sd.data.out > /dev/null || exit 1
197 cmp "$srcdir/data/static-file" sd.data.out || exit 1
199 echo "create signed data (subcert, no certs)"
200 ${hxtool} cms-create-sd \
201 --certificate=FILE:$srcdir/data/sub-cert.crt,$srcdir/data/sub-cert.key \
202 "$srcdir/test_chain.in" \
203 sd.data > /dev/null || exit 1
205 echo "verify failure signed data"
206 ${hxtool} cms-verify-sd \
207 --missing-revoke \
208 --anchors=FILE:$srcdir/data/ca.crt \
209 sd.data sd.data.out > /dev/null 2> /dev/null && exit 1
211 echo "verify success signed data"
212 ${hxtool} cms-verify-sd \
213 --missing-revoke \
214 --certificate=FILE:$srcdir/data/sub-ca.crt \
215 --anchors=FILE:$srcdir/data/ca.crt \
216 sd.data sd.data.out > /dev/null || exit 1
217 cmp "$srcdir/test_chain.in" sd.data.out || exit 1
219 echo "create signed data (subcert, certs)"
220 ${hxtool} cms-create-sd \
221 --certificate=FILE:$srcdir/data/sub-cert.crt,$srcdir/data/sub-cert.key \
222 --pool=FILE:$srcdir/data/sub-ca.crt \
223 --anchors=FILE:$srcdir/data/ca.crt \
224 "$srcdir/test_chain.in" \
225 sd.data > /dev/null || exit 1
227 echo "verify success signed data"
228 ${hxtool} cms-verify-sd \
229 --missing-revoke \
230 --anchors=FILE:$srcdir/data/ca.crt \
231 sd.data sd.data.out > /dev/null || exit 1
232 cmp "$srcdir/test_chain.in" sd.data.out || exit 1
234 echo "create signed data (subcert, certs, no-root)"
235 ${hxtool} cms-create-sd \
236 --certificate=FILE:$srcdir/data/sub-cert.crt,$srcdir/data/sub-cert.key \
237 --pool=FILE:$srcdir/data/sub-ca.crt \
238 "$srcdir/test_chain.in" \
239 sd.data > /dev/null || exit 1
241 echo "verify success signed data"
242 ${hxtool} cms-verify-sd \
243 --missing-revoke \
244 --anchors=FILE:$srcdir/data/ca.crt \
245 sd.data sd.data.out > /dev/null || exit 1
246 cmp "$srcdir/test_chain.in" sd.data.out || exit 1
248 echo "create signed data (subcert, no-subca, no-root)"
249 ${hxtool} cms-create-sd \
250 --certificate=FILE:$srcdir/data/sub-cert.crt,$srcdir/data/sub-cert.key \
251 "$srcdir/test_chain.in" \
252 sd.data > /dev/null || exit 1
254 echo "verify failure signed data"
255 ${hxtool} cms-verify-sd \
256 --missing-revoke \
257 --anchors=FILE:$srcdir/data/ca.crt \
258 sd.data sd.data.out > /dev/null 2>/dev/null && exit 1
260 echo "create signed data (sd cert)"
261 ${hxtool} cms-create-sd \
262 --certificate=FILE:$srcdir/data/test-ds-only.crt,$srcdir/data/test-ds-only.key \
263 "$srcdir/test_chain.in" \
264 sd.data > /dev/null || exit 1
266 echo "create signed data (ke cert)"
267 ${hxtool} cms-create-sd \
268 --certificate=FILE:$srcdir/data/test-ke-only.crt,$srcdir/data/test-ke-only.key \
269 "$srcdir/test_chain.in" \
270 sd.data > /dev/null 2>/dev/null && exit 1
272 echo "create signed data (sd + ke certs)"
273 ${hxtool} cms-create-sd \
274 --certificate=FILE:$srcdir/data/test-ke-only.crt,$srcdir/data/test-ke-only.key \
275 --certificate=FILE:$srcdir/data/test-ds-only.crt,$srcdir/data/test-ds-only.key \
276 "$srcdir/test_chain.in" \
277 sd.data > /dev/null || exit 1
279 echo "create signed data (ke + sd certs)"
280 ${hxtool} cms-create-sd \
281 --certificate=FILE:$srcdir/data/test-ds-only.crt,$srcdir/data/test-ds-only.key \
282 --certificate=FILE:$srcdir/data/test-ke-only.crt,$srcdir/data/test-ke-only.key \
283 "$srcdir/test_chain.in" \
284 sd.data > /dev/null || exit 1
286 echo "create signed data (detached)"
287 ${hxtool} cms-create-sd \
288 --certificate=FILE:$srcdir/data/test.crt,$srcdir/data/test.key \
289 --detached-signature \
290 "$srcdir/test_chain.in" \
291 sd.data > /dev/null || exit 1
293 echo "verify signed data (detached)"
294 ${hxtool} cms-verify-sd \
295 --missing-revoke \
296 --signed-content="$srcdir/test_chain.in" \
297 --anchors=FILE:$srcdir/data/ca.crt \
298 sd.data sd.data.out > /dev/null || exit 1
299 cmp "$srcdir/test_chain.in" sd.data.out || exit 1
301 echo "verify failure signed data (detached)"
302 ${hxtool} cms-verify-sd \
303 --missing-revoke \
304 --anchors=FILE:$srcdir/data/ca.crt \
305 sd.data sd.data.out > /dev/null 2>/dev/null && exit 1
307 echo "create signed data (rsa)"
308 ${hxtool} cms-create-sd \
309 --peer-alg=1.2.840.113549.1.1.1 \
310 --certificate=FILE:$srcdir/data/test.crt,$srcdir/data/test.key \
311 "$srcdir/test_chain.in" \
312 sd.data > /dev/null || exit 1
314 echo "verify signed data (rsa)"
315 ${hxtool} cms-verify-sd \
316 --missing-revoke \
317 --anchors=FILE:$srcdir/data/ca.crt \
318 sd.data sd.data.out > /dev/null 2>/dev/null || exit 1
319 cmp "$srcdir/test_chain.in" sd.data.out || exit 1
321 echo "envelope data (content-type)"
322 ${hxtool} cms-envelope \
323 --certificate=FILE:$srcdir/data/test.crt \
324 --content-type=1.1.1.1 \
325 "$srcdir/data/static-file" \
326 ev.data > /dev/null || exit 1
328 echo "unenvelope data (content-type)"
329 ${hxtool} cms-unenvelope \
330 --certificate=FILE:$srcdir/data/test.crt,$srcdir/data/test.key \
331 ev.data ev.data.out \
332 FILE:$srcdir/data/test.crt,$srcdir/data/test.key > /dev/null || exit 1
333 cmp "$srcdir/data/static-file" ev.data.out || exit 1
335 echo "envelope data (content-info)"
336 ${hxtool} cms-envelope \
337 --certificate=FILE:$srcdir/data/test.crt \
338 --content-info \
339 "$srcdir/data/static-file" \
340 ev.data > /dev/null || exit 1
342 echo "unenvelope data (content-info)"
343 ${hxtool} cms-unenvelope \
344 --certificate=FILE:$srcdir/data/test.crt,$srcdir/data/test.key \
345 --content-info \
346 ev.data ev.data.out \
347 FILE:$srcdir/data/test.crt,$srcdir/data/test.key > /dev/null || exit 1
348 cmp "$srcdir/data/static-file" ev.data.out || exit 1
350 for a in des-ede3 aes-128 aes-256; do
352 rm -f ev.data ev.data.out
353 echo "envelope data ($a)"
354 ${hxtool} cms-envelope \
355 --encryption-type="$a-cbc" \
356 --certificate=FILE:$srcdir/data/test.crt \
357 "$srcdir/data/static-file" \
358 ev.data || exit 1
360 echo "unenvelope data ($a)"
361 ${hxtool} cms-unenvelope \
362 --certificate=FILE:$srcdir/data/test.crt,$srcdir/data/test.key \
363 ev.data ev.data.out > /dev/null || exit 1
364 cmp "$srcdir/data/static-file" ev.data.out || exit 1
365 done
367 for a in rc2-40 rc2-64 rc2-128 des-ede3 aes-128 aes-256; do
368 echo "static unenvelope data ($a)"
370 rm -f ev.data.out
371 ${hxtool} cms-unenvelope \
372 --certificate=FILE:$srcdir/data/test.crt,$srcdir/data/test.key \
373 --content-info \
374 "$srcdir/data/test-enveloped-$a" ev.data.out > /dev/null || exit 1
375 cmp "$srcdir/data/static-file" ev.data.out || exit 1
376 done
378 exit 0