security/nss/tests/lowhash/lowhash.sh

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial