security/nss/tests/cipher/cipher.sh

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

mercurial