security/nss/tests/cipher/cipher.sh

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/nss/tests/cipher/cipher.sh	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,140 @@
     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 +#
    1.12 +# mozilla/security/nss/tests/cipher/cipher.sh
    1.13 +#
    1.14 +# Script to test NSS ciphers
    1.15 +#
    1.16 +# needs to work on all Unix and Windows platforms
    1.17 +#
    1.18 +# special strings
    1.19 +# ---------------
    1.20 +#   FIXME ... known problems, search for this string
    1.21 +#   NOTE .... unexpected behavior
    1.22 +#
    1.23 +########################################################################
    1.24 +
    1.25 +############################## cipher_init #############################
    1.26 +# local shell function to initialize this script
    1.27 +########################################################################
    1.28 +cipher_init()
    1.29 +{
    1.30 +  SCRIPTNAME="cipher.sh"
    1.31 +  if [ -z "${CLEANUP}" ] ; then     # if nobody else is responsible for
    1.32 +      CLEANUP="${SCRIPTNAME}"       # cleaning this script will do it
    1.33 +  fi
    1.34 +  if [ -z "${INIT_SOURCED}" ] ; then
    1.35 +      cd ../common
    1.36 +      . ./init.sh
    1.37 +  fi
    1.38 +  SCRIPTNAME="cipher.sh"
    1.39 +  html_head "Cipher Tests"
    1.40 +
    1.41 +  CIPHERDIR=${HOSTDIR}/cipher
    1.42 +  CIPHERTESTDIR=${QADIR}/../cmd/bltest
    1.43 +  GCMTESTDIR=${QADIR}/../cmd/pk11gcmtest
    1.44 +  D_CIPHER="Cipher.$version"
    1.45 +
    1.46 +  CIPHER_TXT=${QADIR}/cipher/cipher.txt
    1.47 +  GCM_TXT=${QADIR}/cipher/gcm.txt
    1.48 +
    1.49 +  mkdir -p ${CIPHERDIR}
    1.50 +
    1.51 +  cd ${CIPHERDIR}
    1.52 +  P_CIPHER=.
    1.53 +  if [ -n "${MULTIACCESS_DBM}" ]; then
    1.54 +    P_CIPHER="multiaccess:${D_CIPHER}"
    1.55 +  fi
    1.56 +}
    1.57 +
    1.58 +############################## cipher_main #############################
    1.59 +# local shell function to test NSS ciphers
    1.60 +########################################################################
    1.61 +cipher_main()
    1.62 +{
    1.63 +  while read EXP_RET PARAM TESTNAME
    1.64 +  do
    1.65 +      if [ -n "$EXP_RET" -a "$EXP_RET" != "#" ] ; then
    1.66 +          PARAM=`echo $PARAM | sed -e "s/_-/ -/g"`
    1.67 +          TESTNAME=`echo $TESTNAME | sed -e "s/_/ /g"`
    1.68 +          echo "$SCRIPTNAME: $TESTNAME --------------------------------"
    1.69 +          failedStr=""
    1.70 +          inOff=0
    1.71 +          res=0
    1.72 +          while [ $inOff -lt 8 ]
    1.73 +          do
    1.74 +             outOff=0
    1.75 +             while [ $outOff -lt 8 ]
    1.76 +             do
    1.77 +                 echo "bltest -T -m $PARAM -d $CIPHERTESTDIR -1 $inOff -2 $outOff"
    1.78 +                 ${PROFTOOL} ${BINDIR}/bltest${PROG_SUFFIX} -T -m $PARAM -d $CIPHERTESTDIR -1 $inOff -2 $outOff
    1.79 +                 if [ $? -ne 0 ]; then
    1.80 +                     failedStr="$failedStr[$inOff:$outOff]"
    1.81 +                 fi
    1.82 +                 outOff=`expr $outOff + 1`
    1.83 +             done
    1.84 +             inOff=`expr $inOff + 1`
    1.85 +          done
    1.86 +          if [ -n "$failedStr" ]; then
    1.87 +              html_msg 1 $EXP_RET "$TESTNAME (Failed in/out offset pairs:" \
    1.88 +                        " $failedStr)"
    1.89 +          else
    1.90 +              html_msg $res $EXP_RET "$TESTNAME"
    1.91 +          fi
    1.92 +      fi
    1.93 +  done < ${CIPHER_TXT}
    1.94 +}
    1.95 +
    1.96 +############################## cipher_gcm #############################
    1.97 +# local shell function to test NSS AES GCM
    1.98 +########################################################################
    1.99 +cipher_gcm()
   1.100 +{
   1.101 +  while read EXP_RET INPUT_FILE TESTNAME
   1.102 +  do
   1.103 +      if [ -n "$EXP_RET" -a "$EXP_RET" != "#" ] ; then
   1.104 +          TESTNAME=`echo $TESTNAME | sed -e "s/_/ /g"`
   1.105 +          echo "$SCRIPTNAME: $TESTNAME --------------------------------"
   1.106 +          echo "pk11gcmtest aes kat gcm $GCMTESTDIR/tests/$INPUT_FILE"
   1.107 +          ${PROFTOOL} ${BINDIR}/pk11gcmtest aes kat gcm $GCMTESTDIR/tests/$INPUT_FILE
   1.108 +          html_msg $? $EXP_RET "$TESTNAME"
   1.109 +      fi
   1.110 +  done < ${GCM_TXT}
   1.111 +}
   1.112 +
   1.113 +############################## cipher_cleanup ############################
   1.114 +# local shell function to finish this script (no exit since it might be
   1.115 +# sourced)
   1.116 +########################################################################
   1.117 +cipher_cleanup()
   1.118 +{
   1.119 +  html "</TABLE><BR>"
   1.120 +  cd ${QADIR}
   1.121 +  . common/cleanup.sh
   1.122 +}
   1.123 +
   1.124 +################## main #################################################
   1.125 +
   1.126 +# When building without softoken, bltest isn't built. It was already
   1.127 +# built and the cipher suite run as part of an nss-softoken build. 
   1.128 +if [ ! -x ${DIST}/${OBJDIR}/bin/bltest${PROG_SUFFIX} ]; then
   1.129 +    echo "bltest not built, skipping this test." >> ${LOGFILE}
   1.130 +    res = 0
   1.131 +    html_msg $res $EXP_RET "$TESTNAME"
   1.132 +    return 0
   1.133 +fi
   1.134 +cipher_init
   1.135 +# Skip cipher_main if this an NSS without softoken build.
   1.136 +if [ "${NSS_BUILD_WITHOUT_SOFTOKEN}" != "1" ]; then
   1.137 +    cipher_main
   1.138 +fi
   1.139 +# Skip cipher_gcm if this is a softoken only build.
   1.140 +if [ "${NSS_BUILD_SOFTOKEN_ONLY}" != "1" ]; then
   1.141 +    cipher_gcm
   1.142 +fi
   1.143 +cipher_cleanup

mercurial