security/nss/tests/lowhash/lowhash.sh

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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/.
     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 ########################################################################
    26 errors=0
    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
    35   if [ -z "${CLEANUP}" ] ; then     # if nobody else is responsible for
    36       CLEANUP="${SCRIPTNAME}"       # cleaning this script will do it
    37   fi
    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 }
    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 }
    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 }
    92 ################## main #################################################
    94 lowhash_init
    95 lowhash_test
    96 lowhash_cleanup
    97 echo "lowhash.sh done"

mercurial