lowhash.sh (2860B)
1 #! /bin/bash 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 ######################################################################## 8 # mozilla/security/nss/tests/lowhash/lowhash.sh 9 # 10 # Script to test basic functionallity of the NSSLoHash API 11 # 12 # included from 13 # -------------- 14 # all.sh 15 # 16 # needs to work on all Linux platforms 17 # 18 # tests implemented: 19 # lowash (verify encryption cert - bugzilla bug 119059) 20 # 21 # special strings 22 # --------------- 23 # 24 ######################################################################## 25 26 errors=0 27 28 ############################## lowhash_init ############################## 29 # local shell function to initialize this script 30 ######################################################################## 31 lowhash_init() 32 { 33 SCRIPTNAME=lowhash.sh # sourced - $0 would point to all.sh 34 35 if [ -z "${CLEANUP}" ] ; then # if nobody else is responsible for 36 CLEANUP="${SCRIPTNAME}" # cleaning this script will do it 37 fi 38 39 if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ]; then 40 cd ../common 41 . ./init.sh 42 fi 43 LOWHASHDIR=../lowhash 44 mkdir -p ${LOWHASHDIR} 45 if [ -f /proc/sys/crypto/fips_enabled ]; then 46 FVAL=`cat /proc/sys/crypto/fips_enabled` 47 html_head "Lowhash Tests - /proc/sys/crypto/fips_enabled is ${FVAL}" 48 else 49 html_head "Lowhash Tests" 50 fi 51 cd ${LOWHASHDIR} 52 } 53 54 ############################## lowhash_test ############################## 55 # local shell function to test basic the NSS Low Hash API both in 56 # FIPS 140 compliant mode and not 57 ######################################################################## 58 lowhash_test() 59 { 60 if [ ! -f ${BINDIR}/lowhashtest -a \ 61 ! -f ${BINDIR}/lowhashtest${PROG_SUFFIX} ]; then 62 echo "freebl lowhash not supported in this plaform." 63 else 64 TESTS="MD5 SHA1 SHA224 SHA256 SHA384 SHA512" 65 OLD_MODE=`echo ${NSS_FIPS}` 66 for fips_mode in 0 1; do 67 echo "lowhashtest with fips mode=${fips_mode}" 68 export NSS_FIPS=${fips_mode} 69 for TEST in ${TESTS} 70 do 71 echo "lowhashtest ${TEST}" 72 ${BINDIR}/lowhashtest ${TEST} 2>&1 73 RESULT=$? 74 html_msg ${RESULT} 0 "lowhashtest with fips mode=${fips_mode} for ${TEST}" 75 done 76 done 77 export NSS_FIPS=${OLD_MODE} 78 fi 79 } 80 81 ############################## lowhash_cleanup ############################ 82 # local shell function to finish this script (no exit since it might be 83 # sourced) 84 ######################################################################## 85 lowhash_cleanup() 86 { 87 html "</TABLE><BR>" 88 cd ${QADIR} 89 . common/cleanup.sh 90 } 91 92 ################## main ################################################# 93 94 lowhash_init 95 lowhash_test 96 lowhash_cleanup 97 echo "lowhash.sh done"