aesgcm.sh (2240B)
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 AES Algorithm Validation Suite 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 15 BASEDIR=${1-.} 16 TESTDIR=${BASEDIR}/AES_GCM 17 COMMAND=${2-run} 18 REQDIR=${TESTDIR}/req 19 RSPDIR=${TESTDIR}/resp 20 21 gcm_decrypt_requests=" 22 gcmDecrypt128.req 23 gcmDecrypt192.req 24 gcmDecrypt256.req 25 " 26 27 gcm_encrypt_extiv_requests=" 28 gcmEncryptExtIV128.req 29 gcmEncryptExtIV192.req 30 gcmEncryptExtIV256.req 31 " 32 gcm_encrypt_intiv_requests=" 33 " 34 35 #gcm_encrypt_intiv_requests=" 36 #gcmEncryptIntIV128.req 37 #gcmEncryptIntIV192.req 38 #gcmEncryptIntIV256.req 39 #" 40 41 if [ ${COMMAND} = "verify" ]; then 42 result=0 43 for request in $gcm_decrypt_requests $gcm_encrypt_extiv_requests; do 44 sh ./validate1.sh ${TESTDIR} $request ' ' '-e /Reason:/d' 45 last_result=$? 46 result=`expr $result + $last_result` 47 done 48 for request in $gcm_encrypt_intiv_requests; do 49 name=`basename $request .req` 50 echo ">>>>> $name" 51 fipstest aes gcm decrypt ${RSPDIR}/$name.rsp | grep FAIL 52 test 1 = $? 53 last_result=$? 54 result=`expr $result + $last_result` 55 done 56 exit $result 57 fi 58 59 test -d "${RSPDIR}" || mkdir "${RSPDIR}" 60 61 for request in $gcm_decrypt_requests; do 62 response=`echo $request | sed -e "s/req/rsp/"` 63 echo $request $response 64 fipstest aes gcm decrypt ${REQDIR}/$request > ${RSPDIR}/$response 65 done 66 for request in $gcm_encrypt_intiv_requests; do 67 response=`echo $request | sed -e "s/req/rsp/"` 68 echo $request $response 69 fipstest aes gcm encrypt_intiv ${REQDIR}/$request > ${RSPDIR}/$response 70 done 71 for request in $gcm_encrypt_extiv_requests; do 72 response=`echo $request | sed -e "s/req/rsp/"` 73 echo $request $response 74 fipstest aes gcm encrypt_extiv ${REQDIR}/$request > ${RSPDIR}/$response 75 done 76 exit 0