summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorWan-Teh Chang <wtc@google.com>2013-04-02 14:49:51 -0700
committerWan-Teh Chang <wtc@google.com>2013-04-02 14:49:51 -0700
commitab36d6229ffdee734c8e7190aea04444f6d64f3f (patch)
tree274055ce615fb8b93bf4d6b29a50cae90c95ac9f /tests
parentc27d424f0bd6370998e9432ad91d68acdbd654da (diff)
downloadnss-hg-ab36d6229ffdee734c8e7190aea04444f6d64f3f.tar.gz
Bug 854063: Add an AES GCM test program (pk11gcmtest) that calls
PK11_Decrypt and PK11_Encrypt. Add AES GCM test vectors downloaded from NIST, and test them in tests/cipher/cipher.sh. r=sleevi.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/cipher/cipher.sh20
-rw-r--r--tests/cipher/gcm.txt16
2 files changed, 36 insertions, 0 deletions
diff --git a/tests/cipher/cipher.sh b/tests/cipher/cipher.sh
index 4cd33c856..1eb4a3f0a 100755
--- a/tests/cipher/cipher.sh
+++ b/tests/cipher/cipher.sh
@@ -37,9 +37,11 @@ cipher_init()
CIPHERDIR=${HOSTDIR}/cipher
CIPHERTESTDIR=${QADIR}/../cmd/bltest
+ GCMTESTDIR=${QADIR}/../cmd/pk11gcmtest
D_CIPHER="Cipher.$version"
CIPHER_TXT=${QADIR}/cipher/cipher.txt
+ GCM_TXT=${QADIR}/cipher/gcm.txt
mkdir -p ${CIPHERDIR}
@@ -88,6 +90,23 @@ cipher_main()
done < ${CIPHER_TXT}
}
+############################## cipher_gcm #############################
+# local shell function to test NSS AES GCM
+########################################################################
+cipher_gcm()
+{
+ while read EXP_RET INPUT_FILE TESTNAME
+ do
+ if [ -n "$EXP_RET" -a "$EXP_RET" != "#" ] ; then
+ TESTNAME=`echo $TESTNAME | sed -e "s/_/ /g"`
+ echo "$SCRIPTNAME: $TESTNAME --------------------------------"
+ echo "pk11gcmtest aes kat gcm $GCMTESTDIR/tests/$INPUT_FILE"
+ ${PROFTOOL} ${BINDIR}/pk11gcmtest aes kat gcm $GCMTESTDIR/tests/$INPUT_FILE
+ html_msg $? $EXP_RET "$TESTNAME"
+ fi
+ done < ${GCM_TXT}
+}
+
############################## cipher_cleanup ############################
# local shell function to finish this script (no exit since it might be
# sourced)
@@ -103,4 +122,5 @@ cipher_cleanup()
cipher_init
cipher_main
+cipher_gcm
cipher_cleanup
diff --git a/tests/cipher/gcm.txt b/tests/cipher/gcm.txt
new file mode 100644
index 000000000..4550faf49
--- /dev/null
+++ b/tests/cipher/gcm.txt
@@ -0,0 +1,16 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This file defines the AES GCM tests
+#
+# expected
+# return pk11gcmtest Test Case name
+# value input file
+# ------- ---------------------- -----------------------
+ 0 gcmDecrypt128.rsp NIST_AES128_GCM_Decrypt
+ 0 gcmDecrypt192.rsp NIST_AES192_GCM_Decrypt
+ 0 gcmDecrypt256.rsp NIST_AES256_GCM_Decrypt
+ 0 gcmEncryptExtIV128.rsp NIST_AES128_GCM_Encrypt
+ 0 gcmEncryptExtIV192.rsp NIST_AES192_GCM_Encrypt
+ 0 gcmEncryptExtIV256.rsp NIST_AES256_GCM_Encrypt