summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2016-11-14 17:12:02 +0100
committerNikos Mavrogiannopoulos <nmav@redhat.com>2016-12-14 11:15:14 +0100
commit72b37d6abfe496212cc7ec30ccf33e185889758c (patch)
tree16cd88318711b47897bcbd0834ba01430283c877 /tests
parent7bc0dc16851fa46753ffc63b065e4abaaca6cb39 (diff)
downloadgnutls-72b37d6abfe496212cc7ec30ccf33e185889758c.tar.gz
tests: added test suite with PKCS#8 files that have invalid encryption
Diffstat (limited to 'tests')
-rw-r--r--tests/key-tests/Makefile.am2
-rw-r--r--tests/key-tests/data/pkcs8-invalid1.derbin0 -> 735 bytes
-rw-r--r--tests/key-tests/data/pkcs8-invalid2.derbin0 -> 674 bytes
-rw-r--r--tests/key-tests/data/pkcs8-invalid3.derbin0 -> 674 bytes
-rw-r--r--tests/key-tests/data/pkcs8-invalid4.derbin0 -> 735 bytes
-rw-r--r--tests/key-tests/data/pkcs8-invalid5.derbin0 -> 674 bytes
-rw-r--r--tests/key-tests/data/pkcs8-invalid6.derbin0 -> 674 bytes
-rw-r--r--tests/key-tests/data/pkcs8-invalid7.derbin0 -> 735 bytes
-rwxr-xr-xtests/key-tests/pkcs8-invalid52
9 files changed, 53 insertions, 1 deletions
diff --git a/tests/key-tests/Makefile.am b/tests/key-tests/Makefile.am
index e388d3c7c4..df0214ad5b 100644
--- a/tests/key-tests/Makefile.am
+++ b/tests/key-tests/Makefile.am
@@ -26,7 +26,7 @@ EXTRA_DIST = README key-ca.pem key-user.pem \
dist_check_SCRIPTS = key-id pkcs8
-TESTS = key-id pkcs8
+TESTS = key-id pkcs8 pkcs8-invalid
TESTS_ENVIRONMENT = EXEEXT=$(EXEEXT) \
LC_ALL="C" \
diff --git a/tests/key-tests/data/pkcs8-invalid1.der b/tests/key-tests/data/pkcs8-invalid1.der
new file mode 100644
index 0000000000..8d05984ddf
--- /dev/null
+++ b/tests/key-tests/data/pkcs8-invalid1.der
Binary files differ
diff --git a/tests/key-tests/data/pkcs8-invalid2.der b/tests/key-tests/data/pkcs8-invalid2.der
new file mode 100644
index 0000000000..086a6613cb
--- /dev/null
+++ b/tests/key-tests/data/pkcs8-invalid2.der
Binary files differ
diff --git a/tests/key-tests/data/pkcs8-invalid3.der b/tests/key-tests/data/pkcs8-invalid3.der
new file mode 100644
index 0000000000..39b821fe04
--- /dev/null
+++ b/tests/key-tests/data/pkcs8-invalid3.der
Binary files differ
diff --git a/tests/key-tests/data/pkcs8-invalid4.der b/tests/key-tests/data/pkcs8-invalid4.der
new file mode 100644
index 0000000000..c8591a0b7c
--- /dev/null
+++ b/tests/key-tests/data/pkcs8-invalid4.der
Binary files differ
diff --git a/tests/key-tests/data/pkcs8-invalid5.der b/tests/key-tests/data/pkcs8-invalid5.der
new file mode 100644
index 0000000000..3f234599f2
--- /dev/null
+++ b/tests/key-tests/data/pkcs8-invalid5.der
Binary files differ
diff --git a/tests/key-tests/data/pkcs8-invalid6.der b/tests/key-tests/data/pkcs8-invalid6.der
new file mode 100644
index 0000000000..f1519feb84
--- /dev/null
+++ b/tests/key-tests/data/pkcs8-invalid6.der
Binary files differ
diff --git a/tests/key-tests/data/pkcs8-invalid7.der b/tests/key-tests/data/pkcs8-invalid7.der
new file mode 100644
index 0000000000..85e1357962
--- /dev/null
+++ b/tests/key-tests/data/pkcs8-invalid7.der
Binary files differ
diff --git a/tests/key-tests/pkcs8-invalid b/tests/key-tests/pkcs8-invalid
new file mode 100755
index 0000000000..bf2cb96a20
--- /dev/null
+++ b/tests/key-tests/pkcs8-invalid
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+# Copyright (C) 2004-2006, 2010, 2012 Free Software Foundation, Inc.
+#
+# Author: Simon Josefsson
+#
+# This file is part of GnuTLS.
+#
+# GnuTLS is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 3 of the License, or (at
+# your option) any later version.
+#
+# GnuTLS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GnuTLS; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+srcdir="${srcdir:-.}"
+CERTTOOL="${CERTTOOL:-../../src/certtool${EXEEXT}}"
+DIFF="${DIFF:-diff -b -B}"
+TMPFILE=pkcs8-invalid.$$.tmp
+
+if ! test -z "${VALGRIND}"; then
+ VALGRIND="${LIBTOOL:-libtool} --mode=execute ${VALGRIND}"
+fi
+
+ret=0
+for p8 in "pkcs8-invalid1.der 1234" "pkcs8-invalid2.der 1234" "pkcs8-invalid3.der 1234" "pkcs8-invalid4.der 1234" \
+ "pkcs8-invalid5.der 1234" "pkcs8-invalid6.der 1234" "pkcs8-invalid7.der 1234";do
+ set -- ${p8}
+ file="$1"
+ passwd="$2"
+ ${VALGRIND} "${CERTTOOL}" --inder --key-info --pkcs8 --password "${passwd}" \
+ --infile "${srcdir}/data/${file}"
+ rc=$?
+ if test ${rc} != 1; then
+ echo "PKCS8 FATAL ${p8} - errno ${rc}"
+ ret=1
+ else
+ echo "PKCS8 OK ${p8} - errno ${rc}"
+ fi
+done
+
+rm -f $TMPFILE
+
+echo "PKCS8 DONE (rc $ret)"
+exit $ret