1178825Sdfr#!/bin/sh 2178825Sdfr# 3233294Sstas# Copyright (c) 2004 - 2008 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.in 21787 2007-08-02 08:50:24Z lha $ 35178825Sdfr# 36178825Sdfr 37178825Sdfrsrcdir="@srcdir@" 38178825Sdfrobjdir="@objdir@" 39178825Sdfrnistdir=${objdir}/PKITS_data 40178825Sdfrnistzip=${srcdir}/data/PKITS_data.zip 41233294Sstasegrep="@egrep@" 42178825Sdfr 43178825Sdfrlimit="${1:-nolimit}" 44178825Sdfr 45178825Sdfrstat="--statistic-file=${objdir}/statfile" 46178825Sdfr 47178825Sdfrhxtool="${TESTS_ENVIRONMENT} ./hxtool ${stat}" 48178825Sdfr 49178825Sdfr# nistzip is not distributed part of the distribution 50178825Sdfrtest -f "$nistzip" || exit 77 51178825Sdfr 52178825Sdfrif ${hxtool} info | grep 'rsa: hcrypto null RSA' > /dev/null ; then 53178825Sdfr exit 77 54178825Sdfrfi 55178825Sdfrif ${hxtool} info | grep 'rand: not available' > /dev/null ; then 56178825Sdfr exit 77 57178825Sdfrfi 58178825Sdfr 59233294Sstas#--------- Try to find unzip 60233294Sstas 61233294Sstasoldifs=$IFS 62233294SstasIFS=: 63233294Sstasset -- $PATH 64233294SstasIFS=$oldifs 65233294Sstasfound= 66233294Sstas 67233294Sstasfor p in "$@" ; do 68233294Sstas test -x "$p/unzip" && { found=1 ; break; } 69233294Sstasdone 70233294Sstastest "X$found" = "X" && exit 77 71233294Sstas 72233294Sstas#--------- 73233294Sstas 74233294Sstas 75178825Sdfrecho "nist tests, version 2" 76178825Sdfr 77178825Sdfrif [ ! -d "$nistdir" ] ; then 78178825Sdfr ( mkdir "$nistdir" && unzip -d "${nistdir}" "${nistzip}" ) >/dev/null || \ 79178825Sdfr { rm -rf "$nistdir" ; exit 1; } 80178825Sdfrfi 81178825Sdfr 82178825Sdfrec= 83178825Sdfrname= 84178825Sdfrdescription= 85178825Sdfrwhile read result cert other ; do 86178825Sdfr if expr "$result" : "#" > /dev/null; then 87178825Sdfr name=${cert} 88178825Sdfr description="${other}" 89178825Sdfr continue 90178825Sdfr fi 91178825Sdfr 92178825Sdfr test nolimit != "${limit}" && ! expr "$name" : "$limit" > /dev/null && continue 93178825Sdfr 94178825Sdfr test "$result" = "end" && break 95178825Sdfr 96178825Sdfr args= 97178825Sdfr args="$args cert:FILE:$nistdir/certs/$cert" 98178825Sdfr args="$args chain:DIR:$nistdir/certs" 99178825Sdfr args="$args anchor:FILE:$nistdir/certs/TrustAnchorRootCertificate.crt" 100178825Sdfr 101178825Sdfr for a in $nistdir/crls/*.crl; do 102178825Sdfr args="$args crl:FILE:$a" 103178825Sdfr done 104178825Sdfr 105233294Sstas cmd="${hxtool} verify --time=2008-05-20 $args" 106178825Sdfr eval ${cmd} > /dev/null 107178825Sdfr res=$? 108178825Sdfr 109178825Sdfr case "${result},${res}" in 110178825Sdfr 0,0) r="PASSs";; 111178825Sdfr 0,*) r="FAILs";; 112178825Sdfr [123],0) r="FAILf";; 113178825Sdfr [123],*) r="PASSf";; 114178825Sdfr *) echo="unknown result ${result},${res}" ; exit 1 ;; 115178825Sdfr esac 116233294Sstas if ${egrep} "^${name} FAIL" $srcdir/data/nist-result2 > /dev/null; then 117178825Sdfr if expr "$r" : "PASS" >/dev/null; then 118178825Sdfr echo "${name} passed when expected not to" 119178825Sdfr echo "# ${description}" > nist2-passed-${name}.tmp 120178825Sdfr ec=1 121178825Sdfr fi 122233294Sstas elif ${egrep} "^${name} EITHER" $srcdir/data/nist-result2 > /dev/null; then 123233294Sstas : 124178825Sdfr elif expr "$r" : "FAIL.*" >/dev/null ; then 125178825Sdfr echo "$r ${name} ${description}" 126178825Sdfr echo "# ${description}" > nist2-failed-${name}.tmp 127178825Sdfr echo "$cmd" >> nist2-failed-${name}.tmp 128178825Sdfr ec=1 129178825Sdfr fi 130178825Sdfr 131178825Sdfrdone < $srcdir/data/nist-data2 132178825Sdfr 133178825Sdfr 134178825Sdfrecho "done!" 135178825Sdfr 136178825Sdfrexit $ec 137