security/nss/tests/lowhash/lowhash.sh

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/nss/tests/lowhash/lowhash.sh	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,97 @@
     1.4 +#! /bin/bash  
     1.5 +#
     1.6 +# This Source Code Form is subject to the terms of the Mozilla Public
     1.7 +# License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.9 +
    1.10 +########################################################################
    1.11 +# mozilla/security/nss/tests/lowhash/lowhash.sh
    1.12 +#
    1.13 +# Script to test basic functionallity of the NSSLoHash API
    1.14 +#
    1.15 +# included from 
    1.16 +# --------------
    1.17 +#   all.sh
    1.18 +#
    1.19 +# needs to work on all Linux platforms
    1.20 +#
    1.21 +# tests implemented:
    1.22 +# lowash (verify encryption cert - bugzilla bug 119059)
    1.23 +#
    1.24 +# special strings
    1.25 +# ---------------
    1.26 +#
    1.27 +########################################################################
    1.28 +
    1.29 +errors=0
    1.30 +
    1.31 +############################## lowhash_init ##############################
    1.32 +# local shell function to initialize this script 
    1.33 +########################################################################
    1.34 +lowhash_init()
    1.35 +{
    1.36 +  SCRIPTNAME=lowhash.sh      # sourced - $0 would point to all.sh
    1.37 +
    1.38 +  if [ -z "${CLEANUP}" ] ; then     # if nobody else is responsible for
    1.39 +      CLEANUP="${SCRIPTNAME}"       # cleaning this script will do it
    1.40 +  fi
    1.41 +
    1.42 +  if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ]; then
    1.43 +      cd ../common
    1.44 +      . ./init.sh
    1.45 +  fi
    1.46 +  LOWHASHDIR=../lowhash
    1.47 +  mkdir -p ${LOWHASHDIR}
    1.48 +  if [ -f /proc/sys/crypto/fips_enabled ]; then
    1.49 +    FVAL=`cat /proc/sys/crypto/fips_enabled`
    1.50 +    html_head "Lowhash Tests - /proc/sys/crypto/fips_enabled is ${FVAL}"
    1.51 +  else
    1.52 +    html_head "Lowhash Tests"
    1.53 +  fi
    1.54 +  cd ${LOWHASHDIR}
    1.55 +}
    1.56 +
    1.57 +############################## lowhash_test ##############################
    1.58 +# local shell function to test basic the NSS Low Hash API both in
    1.59 +# FIPS 140 compliant mode and not
    1.60 +########################################################################
    1.61 +lowhash_test()
    1.62 +{
    1.63 +  if [ ! -f ${BINDIR}/lowhashtest -a  \
    1.64 +       ! -f ${BINDIR}/lowhashtest${PROG_SUFFIX} ]; then
    1.65 +    echo "freebl lowhash not supported in this plaform."
    1.66 +  else
    1.67 +    TESTS="MD5 SHA1 SHA224 SHA256 SHA384 SHA512"
    1.68 +    OLD_MODE=`echo ${NSS_FIPS}`
    1.69 +    for fips_mode in 0 1; do
    1.70 +      echo "lowhashtest with fips mode=${fips_mode}"
    1.71 +      export NSS_FIPS=${fips_mode}
    1.72 +      for TEST in ${TESTS}
    1.73 +      do
    1.74 +        echo "lowhashtest ${TEST}"
    1.75 +        ${BINDIR}/lowhashtest ${TEST} 2>&1
    1.76 +        RESULT=$?
    1.77 +        html_msg ${RESULT} 0 "lowhashtest with fips mode=${fips_mode} for ${TEST}"
    1.78 +      done
    1.79 +    done
    1.80 +    export NSS_FIPS=${OLD_MODE}
    1.81 +  fi
    1.82 +}
    1.83 +
    1.84 +############################## lowhash_cleanup ############################
    1.85 +# local shell function to finish this script (no exit since it might be 
    1.86 +# sourced)
    1.87 +########################################################################
    1.88 +lowhash_cleanup()
    1.89 +{
    1.90 +  html "</TABLE><BR>"
    1.91 +  cd ${QADIR}
    1.92 +  . common/cleanup.sh
    1.93 +}
    1.94 +
    1.95 +################## main #################################################
    1.96 +
    1.97 +lowhash_init
    1.98 +lowhash_test
    1.99 +lowhash_cleanup
   1.100 +echo "lowhash.sh done"

mercurial