test_nist_pkcs12.in revision 178825
1184902Srwatson#!/bin/sh
2184902Srwatson#
3187214Srwatson# Copyright (c) 2004 - 2005 Kungliga Tekniska H�gskolan
4187214Srwatson# (Royal Institute of Technology, Stockholm, Sweden). 
5187214Srwatson# All rights reserved. 
6187214Srwatson#
7187214Srwatson# Redistribution and use in source and binary forms, with or without 
8187214Srwatson# modification, are permitted provided that the following conditions 
9187214Srwatson# are met: 
10187214Srwatson#
11187214Srwatson# 1. Redistributions of source code must retain the above copyright 
12187214Srwatson#    notice, this list of conditions and the following disclaimer. 
13187214Srwatson#
14187214Srwatson# 2. Redistributions in binary form must reproduce the above copyright 
15187214Srwatson#    notice, this list of conditions and the following disclaimer in the 
16187214Srwatson#    documentation and/or other materials provided with the distribution. 
17187214Srwatson#
18187214Srwatson# 3. Neither the name of the Institute nor the names of its contributors 
19187214Srwatson#    may be used to endorse or promote products derived from this software 
20187214Srwatson#    without specific prior written permission. 
21187214Srwatson#
22186647Srwatson# THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
23186647Srwatson# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
24186647Srwatson# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
25186647Srwatson# ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
26186647Srwatson# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
27186647Srwatson# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
28186647Srwatson# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
29186647Srwatson# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
30186647Srwatson# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
31186647Srwatson# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
32186647Srwatson# SUCH DAMAGE. 
33186647Srwatson#
34186647Srwatson# $Id: test_nist_pkcs12.in 22256 2007-12-09 06:04:02Z lha $
35186647Srwatson#
36186647Srwatson
37186647Srwatsonsrcdir="@srcdir@"
38186647Srwatsonobjdir="@objdir@"
39186647Srwatsonpass="--pass=PASS:password"
40186647Srwatsonnistdir=${objdir}/PKITS_data
41186647Srwatsonnistzip=${srcdir}/data/PKITS_data.zip
42186647Srwatson
43186647Srwatson# nistzip is not distributed part of the distribution
44186647Srwatsontest -f "$nistzip" || exit 77
45186647Srwatson
46186647Srwatsonstat="--statistic-file=${objdir}/statfile"
47186647Srwatson
48186647Srwatsonhxtool="${TESTS_ENVIRONMENT} ./hxtool ${stat}"
49186647Srwatson
50186647Srwatsonif ${hxtool} info | grep 'rsa: hcrypto null RSA' > /dev/null ; then
51186647Srwatson    exit 77
52186647Srwatsonfi
53186647Srwatsonif ${hxtool} info | grep 'rand: not available' > /dev/null ; then
54186647Srwatson    exit 77
55186647Srwatsonfi
56186647Srwatson
57186647Srwatsonif [ ! -d "$nistdir" ] ; then
58186647Srwatson    ( mkdir "$nistdir" &&  cd "$nistdir" && unzip "$nistzip" ) >/dev/null || \
59186647Srwatson	{ rm -rf "$nistdir" ; exit 1; }
60186647Srwatsonfi
61186647Srwatson
62186647Srwatsonecho "nist pkcs12 tests"
63186647Srwatson
64186647Srwatsonfor a in $nistdir/pkcs12/*.p12 ; do
65186647Srwatson
66186647Srwatson    if ${hxtool} validate $pass PKCS12:$a > /dev/null; then
67184902Srwatson	:
68184902Srwatson    else
69184902Srwatson	echo "$a failed"
70184902Srwatson	exit 1
71184902Srwatson    fi
72184902Srwatson
73184902Srwatsondone
74184902Srwatson
75184902Srwatsonecho "done!"
76184902Srwatson
77184902Srwatsonexit 0