From e7785d07443a85ed85347c5413acd5194e026c9e Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Mon, 14 Nov 2016 17:12:02 +0100 Subject: tests: added test suite with PKCS#8 files that have invalid encryption --- tests/key-tests/Makefile.am | 2 +- tests/key-tests/data/pkcs8-invalid1.der | Bin 0 -> 735 bytes tests/key-tests/data/pkcs8-invalid2.der | Bin 0 -> 674 bytes tests/key-tests/data/pkcs8-invalid3.der | Bin 0 -> 674 bytes tests/key-tests/data/pkcs8-invalid4.der | Bin 0 -> 735 bytes tests/key-tests/data/pkcs8-invalid5.der | Bin 0 -> 674 bytes tests/key-tests/data/pkcs8-invalid6.der | Bin 0 -> 674 bytes tests/key-tests/data/pkcs8-invalid7.der | Bin 0 -> 735 bytes tests/key-tests/pkcs8-invalid | 52 ++++++++++++++++++++++++++++++++ 9 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 tests/key-tests/data/pkcs8-invalid1.der create mode 100644 tests/key-tests/data/pkcs8-invalid2.der create mode 100644 tests/key-tests/data/pkcs8-invalid3.der create mode 100644 tests/key-tests/data/pkcs8-invalid4.der create mode 100644 tests/key-tests/data/pkcs8-invalid5.der create mode 100644 tests/key-tests/data/pkcs8-invalid6.der create mode 100644 tests/key-tests/data/pkcs8-invalid7.der create mode 100755 tests/key-tests/pkcs8-invalid (limited to 'tests') diff --git a/tests/key-tests/Makefile.am b/tests/key-tests/Makefile.am index acd44d6be6..7f66e1832f 100644 --- a/tests/key-tests/Makefile.am +++ b/tests/key-tests/Makefile.am @@ -33,7 +33,7 @@ EXTRA_DIST = data/key-ca.pem data/key-user.pem \ dist_check_SCRIPTS = key-id pkcs8 pkcs8-decode dsa ecdsa illegal-rsa -TESTS = key-id pkcs8 pkcs8-decode ecdsa +TESTS = key-id pkcs8 pkcs8-decode ecdsa pkcs8-invalid if !WITH_OLD_NETTLE TESTS += illegal-rsa 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 Binary files /dev/null and b/tests/key-tests/data/pkcs8-invalid1.der 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 Binary files /dev/null and b/tests/key-tests/data/pkcs8-invalid2.der 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 Binary files /dev/null and b/tests/key-tests/data/pkcs8-invalid3.der 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 Binary files /dev/null and b/tests/key-tests/data/pkcs8-invalid4.der 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 Binary files /dev/null and b/tests/key-tests/data/pkcs8-invalid5.der 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 Binary files /dev/null and b/tests/key-tests/data/pkcs8-invalid6.der 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 Binary files /dev/null and b/tests/key-tests/data/pkcs8-invalid7.der 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 -- cgit v1.2.1