tests.sh revision ba751492fcc4f161a18b983d4f018a1a52938cb9
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews#!/bin/sh
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews#
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews# Copyright (C) 2010, 2012 Internet Systems Consortium, Inc. ("ISC")
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews#
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# Permission to use, copy, modify, and/or distribute this software for any
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# purpose with or without fee is hereby granted, provided that the above
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews# copyright notice and this permission notice appear in all copies.
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews#
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews# PERFORMANCE OF THIS SOFTWARE.
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews# $Id: tests.sh,v 1.3 2010/06/08 23:50:24 tbox Exp $
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark AndrewsSYSTEMTESTTOP=..
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews. $SYSTEMTESTTOP/conf.sh
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark AndrewsRANDFILE=random.data
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark AndrewsDIGOPTS="+tcp +noadd +nosea +nostat +nocmd +dnssec -p 5300"
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrewsstatus=0
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrewsret=0
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrewssupported=`cat supported`
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrewscase $supported in
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews rsaonly) algs="rsa" ;;
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews ecconly) algs="ecc" ;;
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews both) algs="rsa ecc" ;;
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrewsesac
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrewsfor alg in $algs; do
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews zonefile=ns1/$alg.example.db
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews echo "I:testing PKCS#11 key generation ($alg)"
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews count=`$PK11LIST | grep robie-$alg-ksk | wc -l`
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews if [ $count != 2 ]; then echo "I:failed"; status=1; fi
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews echo "I:testing offline signing with PKCS#11 keys ($alg)"
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews count=`grep RRSIG $zonefile.signed | wc -l`
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews if [ $count != 12 ]; then echo "I:failed"; status=1; fi
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews echo "I:testing inline signing with PKCS#11 keys ($alg)"
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews $NSUPDATE > /dev/null <<END || status=1
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrewsserver 10.53.0.1 5300
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrewsttl 300
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrewszone $alg.example.
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrewsupdate add `grep -v ';' ns1/${alg}.key`
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrewssend
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark AndrewsEND
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews echo "I:waiting 20 seconds for key changes to take effect"
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews sleep 20
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews $DIG $DIGOPTS ns.$alg.example. @10.53.0.1 a > dig.out || ret=1
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews if [ $ret != 0 ]; then echo "I:failed"; fi
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews status=`expr $status + $ret`
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews count=`grep RRSIG dig.out | wc -l`
1c9f629c181dfd14bb429a6699d22c3c023aa218Mark Andrews if [ $count != 4 ]; then echo "I:failed"; status=1; fi
echo "I:testing PKCS#11 key destroy ($alg)"
ret=0
$PK11DEL -l robie-$alg-ksk -w0 > /dev/null 2>&1 || ret=1
$PK11DEL -l robie-$alg-zsk1 -w0 > /dev/null 2>&1 || ret=1
case $alg in
rsa) id=02 ;;
ecc) id=04 ;;
esac
$PK11DEL -i $id -w0 > /dev/null 2>&1 || ret=1
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`
count=`$PK11LIST | grep robie-$alg | wc -l`
if [ $count != 0 ]; then echo "I:failed"; fi
status=`expr $status + $count`
done
echo "I:exit status: $status"
exit $status