dsa.sh (2997B)
1 #!/bin/sh 2 # 3 # This Source Code Form is subject to the terms of the Mozilla Public 4 # License, v. 2.0. If a copy of the MPL was not distributed with this 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 # 7 # A Bourne shell script for running the NIST DSA Validation System 8 # 9 # Before you run the script, set your PATH, LD_LIBRARY_PATH, ... environment 10 # variables appropriately so that the fipstest command and the NSPR and NSS 11 # shared libraries/DLLs are on the search path. Then run this script in the 12 # directory where the REQUEST (.req) files reside. The script generates the 13 # RESPONSE (.rsp) files in the same directory. 14 BASEDIR=${1-.} 15 TESTDIR=${BASEDIR}/DSA2 16 COMMAND=${2-run} 17 REQDIR=${TESTDIR}/req 18 RSPDIR=${TESTDIR}/resp 19 20 21 # 22 # several of the DSA tests do use known answer tests to verify the result. 23 # in those cases, feed generated tests back into the fipstest tool and 24 # see if we can verify those value. NOTE: th PQGVer and SigVer tests verify 25 # the dsa pqgver and dsa sigver functions, so we know they can detect errors 26 # in those PQGGen and SigGen. Only the KeyPair verify is potentially circular. 27 # 28 if [ ${COMMAND} = "verify" ]; then 29 result=0 30 # verify generated keys 31 name=KeyPair 32 echo ">>>>> $name" 33 fipstest dsa keyver ${RSPDIR}/$name.rsp | grep ^Result.=.F 34 test 1 = $? 35 last_result=$? 36 result=`expr $result + $last_result` 37 # verify generated pqg values 38 name=PQGGen 39 echo ">>>>> $name" 40 fipstest dsa pqgver ${RSPDIR}/$name.rsp | grep ^Result.=.F 41 test 1 = $? 42 last_result=$? 43 result=`expr $result + $last_result` 44 # verify PQGVer with known answer 45 sh ./validate1.sh ${TESTDIR} PQGVer1863.req ' ' '-e /^Result.=.F/s;.(.*);; -e /^Result.=.P/s;.(.*);;' 46 last_result=$? 47 result=`expr $result + $last_result` 48 # verify signatures 49 name=SigGen 50 echo ">>>>> $name" 51 fipstest dsa sigver ${RSPDIR}/$name.rsp | grep ^Result.=.F 52 test 1 = $? 53 last_result=$? 54 result=`expr $result + $last_result` 55 # verify SigVer with known answer 56 sh ./validate1.sh ${TESTDIR} SigVer.req ' ' '-e /^X.=/d -e /^Result.=.F/s;.(.*);;' 57 last_result=$? 58 result=`expr $result + $last_result` 59 exit $result 60 fi 61 62 test -d "${RSPDIR}" || mkdir "${RSPDIR}" 63 64 request=KeyPair.req 65 response=`echo $request | sed -e "s/req/rsp/"` 66 echo $request $response 67 fipstest dsa keypair ${REQDIR}/$request > ${RSPDIR}/$response 68 69 request=PQGGen.req 70 response=`echo $request | sed -e "s/req/rsp/"` 71 echo $request $response 72 fipstest dsa pqggen ${REQDIR}/$request > ${RSPDIR}/$response 73 74 request=PQGVer1863.req 75 response=`echo $request | sed -e "s/req/rsp/"` 76 echo $request $response 77 fipstest dsa pqgver ${REQDIR}/$request > ${RSPDIR}/$response 78 79 request=SigGen.req 80 response=`echo $request | sed -e "s/req/rsp/"` 81 echo $request $response 82 fipstest dsa siggen ${REQDIR}/$request > ${RSPDIR}/$response 83 84 request=SigVer.req 85 response=`echo $request | sed -e "s/req/rsp/"` 86 echo $request $response 87 fipstest dsa sigver ${REQDIR}/$request > ${RSPDIR}/$response 88 exit 0