Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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 | # |
michael@0 | 9 | # mozilla/security/nss/tests/cipher/cipher.sh |
michael@0 | 10 | # |
michael@0 | 11 | # Script to test NSS ciphers |
michael@0 | 12 | # |
michael@0 | 13 | # needs to work on all Unix and Windows platforms |
michael@0 | 14 | # |
michael@0 | 15 | # special strings |
michael@0 | 16 | # --------------- |
michael@0 | 17 | # FIXME ... known problems, search for this string |
michael@0 | 18 | # NOTE .... unexpected behavior |
michael@0 | 19 | # |
michael@0 | 20 | ######################################################################## |
michael@0 | 21 | |
michael@0 | 22 | ############################## cipher_init ############################# |
michael@0 | 23 | # local shell function to initialize this script |
michael@0 | 24 | ######################################################################## |
michael@0 | 25 | cipher_init() |
michael@0 | 26 | { |
michael@0 | 27 | SCRIPTNAME="cipher.sh" |
michael@0 | 28 | if [ -z "${CLEANUP}" ] ; then # if nobody else is responsible for |
michael@0 | 29 | CLEANUP="${SCRIPTNAME}" # cleaning this script will do it |
michael@0 | 30 | fi |
michael@0 | 31 | if [ -z "${INIT_SOURCED}" ] ; then |
michael@0 | 32 | cd ../common |
michael@0 | 33 | . ./init.sh |
michael@0 | 34 | fi |
michael@0 | 35 | SCRIPTNAME="cipher.sh" |
michael@0 | 36 | html_head "Cipher Tests" |
michael@0 | 37 | |
michael@0 | 38 | CIPHERDIR=${HOSTDIR}/cipher |
michael@0 | 39 | CIPHERTESTDIR=${QADIR}/../cmd/bltest |
michael@0 | 40 | GCMTESTDIR=${QADIR}/../cmd/pk11gcmtest |
michael@0 | 41 | D_CIPHER="Cipher.$version" |
michael@0 | 42 | |
michael@0 | 43 | CIPHER_TXT=${QADIR}/cipher/cipher.txt |
michael@0 | 44 | GCM_TXT=${QADIR}/cipher/gcm.txt |
michael@0 | 45 | |
michael@0 | 46 | mkdir -p ${CIPHERDIR} |
michael@0 | 47 | |
michael@0 | 48 | cd ${CIPHERDIR} |
michael@0 | 49 | P_CIPHER=. |
michael@0 | 50 | if [ -n "${MULTIACCESS_DBM}" ]; then |
michael@0 | 51 | P_CIPHER="multiaccess:${D_CIPHER}" |
michael@0 | 52 | fi |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | ############################## cipher_main ############################# |
michael@0 | 56 | # local shell function to test NSS ciphers |
michael@0 | 57 | ######################################################################## |
michael@0 | 58 | cipher_main() |
michael@0 | 59 | { |
michael@0 | 60 | while read EXP_RET PARAM TESTNAME |
michael@0 | 61 | do |
michael@0 | 62 | if [ -n "$EXP_RET" -a "$EXP_RET" != "#" ] ; then |
michael@0 | 63 | PARAM=`echo $PARAM | sed -e "s/_-/ -/g"` |
michael@0 | 64 | TESTNAME=`echo $TESTNAME | sed -e "s/_/ /g"` |
michael@0 | 65 | echo "$SCRIPTNAME: $TESTNAME --------------------------------" |
michael@0 | 66 | failedStr="" |
michael@0 | 67 | inOff=0 |
michael@0 | 68 | res=0 |
michael@0 | 69 | while [ $inOff -lt 8 ] |
michael@0 | 70 | do |
michael@0 | 71 | outOff=0 |
michael@0 | 72 | while [ $outOff -lt 8 ] |
michael@0 | 73 | do |
michael@0 | 74 | echo "bltest -T -m $PARAM -d $CIPHERTESTDIR -1 $inOff -2 $outOff" |
michael@0 | 75 | ${PROFTOOL} ${BINDIR}/bltest${PROG_SUFFIX} -T -m $PARAM -d $CIPHERTESTDIR -1 $inOff -2 $outOff |
michael@0 | 76 | if [ $? -ne 0 ]; then |
michael@0 | 77 | failedStr="$failedStr[$inOff:$outOff]" |
michael@0 | 78 | fi |
michael@0 | 79 | outOff=`expr $outOff + 1` |
michael@0 | 80 | done |
michael@0 | 81 | inOff=`expr $inOff + 1` |
michael@0 | 82 | done |
michael@0 | 83 | if [ -n "$failedStr" ]; then |
michael@0 | 84 | html_msg 1 $EXP_RET "$TESTNAME (Failed in/out offset pairs:" \ |
michael@0 | 85 | " $failedStr)" |
michael@0 | 86 | else |
michael@0 | 87 | html_msg $res $EXP_RET "$TESTNAME" |
michael@0 | 88 | fi |
michael@0 | 89 | fi |
michael@0 | 90 | done < ${CIPHER_TXT} |
michael@0 | 91 | } |
michael@0 | 92 | |
michael@0 | 93 | ############################## cipher_gcm ############################# |
michael@0 | 94 | # local shell function to test NSS AES GCM |
michael@0 | 95 | ######################################################################## |
michael@0 | 96 | cipher_gcm() |
michael@0 | 97 | { |
michael@0 | 98 | while read EXP_RET INPUT_FILE TESTNAME |
michael@0 | 99 | do |
michael@0 | 100 | if [ -n "$EXP_RET" -a "$EXP_RET" != "#" ] ; then |
michael@0 | 101 | TESTNAME=`echo $TESTNAME | sed -e "s/_/ /g"` |
michael@0 | 102 | echo "$SCRIPTNAME: $TESTNAME --------------------------------" |
michael@0 | 103 | echo "pk11gcmtest aes kat gcm $GCMTESTDIR/tests/$INPUT_FILE" |
michael@0 | 104 | ${PROFTOOL} ${BINDIR}/pk11gcmtest aes kat gcm $GCMTESTDIR/tests/$INPUT_FILE |
michael@0 | 105 | html_msg $? $EXP_RET "$TESTNAME" |
michael@0 | 106 | fi |
michael@0 | 107 | done < ${GCM_TXT} |
michael@0 | 108 | } |
michael@0 | 109 | |
michael@0 | 110 | ############################## cipher_cleanup ############################ |
michael@0 | 111 | # local shell function to finish this script (no exit since it might be |
michael@0 | 112 | # sourced) |
michael@0 | 113 | ######################################################################## |
michael@0 | 114 | cipher_cleanup() |
michael@0 | 115 | { |
michael@0 | 116 | html "</TABLE><BR>" |
michael@0 | 117 | cd ${QADIR} |
michael@0 | 118 | . common/cleanup.sh |
michael@0 | 119 | } |
michael@0 | 120 | |
michael@0 | 121 | ################## main ################################################# |
michael@0 | 122 | |
michael@0 | 123 | # When building without softoken, bltest isn't built. It was already |
michael@0 | 124 | # built and the cipher suite run as part of an nss-softoken build. |
michael@0 | 125 | if [ ! -x ${DIST}/${OBJDIR}/bin/bltest${PROG_SUFFIX} ]; then |
michael@0 | 126 | echo "bltest not built, skipping this test." >> ${LOGFILE} |
michael@0 | 127 | res = 0 |
michael@0 | 128 | html_msg $res $EXP_RET "$TESTNAME" |
michael@0 | 129 | return 0 |
michael@0 | 130 | fi |
michael@0 | 131 | cipher_init |
michael@0 | 132 | # Skip cipher_main if this an NSS without softoken build. |
michael@0 | 133 | if [ "${NSS_BUILD_WITHOUT_SOFTOKEN}" != "1" ]; then |
michael@0 | 134 | cipher_main |
michael@0 | 135 | fi |
michael@0 | 136 | # Skip cipher_gcm if this is a softoken only build. |
michael@0 | 137 | if [ "${NSS_BUILD_SOFTOKEN_ONLY}" != "1" ]; then |
michael@0 | 138 | cipher_gcm |
michael@0 | 139 | fi |
michael@0 | 140 | cipher_cleanup |