michael@0: #! /bin/bash michael@0: # michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: ######################################################################## michael@0: # mozilla/security/nss/tests/lowhash/lowhash.sh michael@0: # michael@0: # Script to test basic functionallity of the NSSLoHash API michael@0: # michael@0: # included from michael@0: # -------------- michael@0: # all.sh michael@0: # michael@0: # needs to work on all Linux platforms michael@0: # michael@0: # tests implemented: michael@0: # lowash (verify encryption cert - bugzilla bug 119059) michael@0: # michael@0: # special strings michael@0: # --------------- michael@0: # michael@0: ######################################################################## michael@0: michael@0: errors=0 michael@0: michael@0: ############################## lowhash_init ############################## michael@0: # local shell function to initialize this script michael@0: ######################################################################## michael@0: lowhash_init() michael@0: { michael@0: SCRIPTNAME=lowhash.sh # sourced - $0 would point to all.sh michael@0: michael@0: if [ -z "${CLEANUP}" ] ; then # if nobody else is responsible for michael@0: CLEANUP="${SCRIPTNAME}" # cleaning this script will do it michael@0: fi michael@0: michael@0: if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ]; then michael@0: cd ../common michael@0: . ./init.sh michael@0: fi michael@0: LOWHASHDIR=../lowhash michael@0: mkdir -p ${LOWHASHDIR} michael@0: if [ -f /proc/sys/crypto/fips_enabled ]; then michael@0: FVAL=`cat /proc/sys/crypto/fips_enabled` michael@0: html_head "Lowhash Tests - /proc/sys/crypto/fips_enabled is ${FVAL}" michael@0: else michael@0: html_head "Lowhash Tests" michael@0: fi michael@0: cd ${LOWHASHDIR} michael@0: } michael@0: michael@0: ############################## lowhash_test ############################## michael@0: # local shell function to test basic the NSS Low Hash API both in michael@0: # FIPS 140 compliant mode and not michael@0: ######################################################################## michael@0: lowhash_test() michael@0: { michael@0: if [ ! -f ${BINDIR}/lowhashtest -a \ michael@0: ! -f ${BINDIR}/lowhashtest${PROG_SUFFIX} ]; then michael@0: echo "freebl lowhash not supported in this plaform." michael@0: else michael@0: TESTS="MD5 SHA1 SHA224 SHA256 SHA384 SHA512" michael@0: OLD_MODE=`echo ${NSS_FIPS}` michael@0: for fips_mode in 0 1; do michael@0: echo "lowhashtest with fips mode=${fips_mode}" michael@0: export NSS_FIPS=${fips_mode} michael@0: for TEST in ${TESTS} michael@0: do michael@0: echo "lowhashtest ${TEST}" michael@0: ${BINDIR}/lowhashtest ${TEST} 2>&1 michael@0: RESULT=$? michael@0: html_msg ${RESULT} 0 "lowhashtest with fips mode=${fips_mode} for ${TEST}" michael@0: done michael@0: done michael@0: export NSS_FIPS=${OLD_MODE} michael@0: fi michael@0: } michael@0: michael@0: ############################## lowhash_cleanup ############################ michael@0: # local shell function to finish this script (no exit since it might be michael@0: # sourced) michael@0: ######################################################################## michael@0: lowhash_cleanup() michael@0: { michael@0: html "
" michael@0: cd ${QADIR} michael@0: . common/cleanup.sh michael@0: } michael@0: michael@0: ################## main ################################################# michael@0: michael@0: lowhash_init michael@0: lowhash_test michael@0: lowhash_cleanup michael@0: echo "lowhash.sh done"