1178825Sdfr#!/bin/sh
2178825Sdfr#
3178825Sdfr# Copyright (c) 2004 - 2005 Kungliga Tekniska H�gskolan
4178825Sdfr# (Royal Institute of Technology, Stockholm, Sweden). 
5178825Sdfr# All rights reserved. 
6178825Sdfr#
7178825Sdfr# Redistribution and use in source and binary forms, with or without 
8178825Sdfr# modification, are permitted provided that the following conditions 
9178825Sdfr# are met: 
10178825Sdfr#
11178825Sdfr# 1. Redistributions of source code must retain the above copyright 
12178825Sdfr#    notice, this list of conditions and the following disclaimer. 
13178825Sdfr#
14178825Sdfr# 2. Redistributions in binary form must reproduce the above copyright 
15178825Sdfr#    notice, this list of conditions and the following disclaimer in the 
16178825Sdfr#    documentation and/or other materials provided with the distribution. 
17178825Sdfr#
18178825Sdfr# 3. Neither the name of the Institute nor the names of its contributors 
19178825Sdfr#    may be used to endorse or promote products derived from this software 
20178825Sdfr#    without specific prior written permission. 
21178825Sdfr#
22178825Sdfr# THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
23178825Sdfr# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
24178825Sdfr# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
25178825Sdfr# ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
26178825Sdfr# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
27178825Sdfr# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
28178825Sdfr# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
29178825Sdfr# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
30178825Sdfr# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
31178825Sdfr# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
32178825Sdfr# SUCH DAMAGE. 
33178825Sdfr#
34178825Sdfr# $Id: test_nist_pkcs12.in 22256 2007-12-09 06:04:02Z lha $
35178825Sdfr#
36178825Sdfr
37178825Sdfrsrcdir="@srcdir@"
38178825Sdfrobjdir="@objdir@"
39178825Sdfrpass="--pass=PASS:password"
40178825Sdfrnistdir=${objdir}/PKITS_data
41178825Sdfrnistzip=${srcdir}/data/PKITS_data.zip
42178825Sdfr
43178825Sdfr# nistzip is not distributed part of the distribution
44178825Sdfrtest -f "$nistzip" || exit 77
45178825Sdfr
46178825Sdfrstat="--statistic-file=${objdir}/statfile"
47178825Sdfr
48178825Sdfrhxtool="${TESTS_ENVIRONMENT} ./hxtool ${stat}"
49178825Sdfr
50178825Sdfrif ${hxtool} info | grep 'rsa: hcrypto null RSA' > /dev/null ; then
51178825Sdfr    exit 77
52178825Sdfrfi
53178825Sdfrif ${hxtool} info | grep 'rand: not available' > /dev/null ; then
54178825Sdfr    exit 77
55178825Sdfrfi
56178825Sdfr
57178825Sdfrif [ ! -d "$nistdir" ] ; then
58178825Sdfr    ( mkdir "$nistdir" &&  cd "$nistdir" && unzip "$nistzip" ) >/dev/null || \
59178825Sdfr	{ rm -rf "$nistdir" ; exit 1; }
60178825Sdfrfi
61178825Sdfr
62178825Sdfrecho "nist pkcs12 tests"
63178825Sdfr
64178825Sdfrfor a in $nistdir/pkcs12/*.p12 ; do
65178825Sdfr
66178825Sdfr    if ${hxtool} validate $pass PKCS12:$a > /dev/null; then
67178825Sdfr	:
68178825Sdfr    else
69178825Sdfr	echo "$a failed"
70178825Sdfr	exit 1
71178825Sdfr    fi
72178825Sdfr
73178825Sdfrdone
74178825Sdfr
75178825Sdfrecho "done!"
76178825Sdfr
77178825Sdfrexit 0