ecdsa.sh (2642B)
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 ECDSA 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}/ECDSA2 16 COMMAND=${2-run} 17 REQDIR=${TESTDIR}/req 18 RSPDIR=${TESTDIR}/resp 19 20 # 21 # several of the ECDSA tests do not use known answer tests to verify the result. 22 # In those cases, feed generated tests back into the fipstest tool and 23 # see if we can verify those value. NOTE: PQGVer and SigVer tests verify 24 # the dsa pqgver and dsa sigver functions, so we know they can detect errors 25 # in those PQGGen and SigGen. Only the KeyPair verify is potentially circular. 26 # 27 if [ ${COMMAND} = "verify" ]; then 28 result=0; 29 # verify generated keys 30 name=KeyPair 31 echo ">>>>> $name" 32 fipstest ecdsa keyver ${RSPDIR}/$name.rsp | grep ^Result.=.F 33 test 1 = $? 34 last_result=$? 35 result=`expr $result + $last_result` 36 sh ./validate1.sh ${TESTDIR} PKV.req ' ' '-e /^X.=/d -e /^Result.=.F/s;.(.*);; -e /^Result.=.P/s;.(.*);;' 37 last_result=$? 38 result=`expr $result + $last_result` 39 # verify signatures 40 name=SigGen 41 echo ">>>>> $name" 42 fipstest ecdsa sigver ${RSPDIR}/$name.rsp | grep ^Result.=.F 43 test 1 = $? 44 last_result=$? 45 result=`expr $result + $last_result` 46 # verify SigVer with known answer 47 sh ./validate1.sh ${TESTDIR} SigVer.req ' ' '-e /^X.=/d -e /^Result.=.F/s;.(.*);; -e /^Result.=.P/s;.(.*);;' 48 last_result=$? 49 result=`expr $result + $last_result` 50 exit $result 51 fi 52 53 test -d "${RSPDIR}" || mkdir "${RSPDIR}" 54 55 request=KeyPair.req 56 response=`echo $request | sed -e "s/req/rsp/"` 57 echo $request $response 58 fipstest ecdsa keypair ${REQDIR}/$request > ${RSPDIR}/$response 59 60 request=PKV.req 61 response=`echo $request | sed -e "s/req/rsp/"` 62 echo $request $response 63 fipstest ecdsa pkv ${REQDIR}/$request > ${RSPDIR}/$response 64 65 request=SigGen.req 66 response=`echo $request | sed -e "s/req/rsp/"` 67 echo $request $response 68 fipstest ecdsa siggen ${REQDIR}/$request > ${RSPDIR}/$response 69 70 request=SigVer.req 71 response=`echo $request | sed -e "s/req/rsp/"` 72 echo $request $response 73 fipstest ecdsa sigver ${REQDIR}/$request > ${RSPDIR}/$response 74 exit 0