]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
tests: Added unit test on EdDSA key parsing
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Fri, 26 May 2017 15:26:34 +0000 (17:26 +0200)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Mon, 17 Jul 2017 15:08:01 +0000 (17:08 +0200)
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
tests/key-tests/Makefile.am
tests/key-tests/data/pkcs8-eddsa.pem [new file with mode: 0644]
tests/key-tests/data/pkcs8-eddsa.pem.txt [new file with mode: 0644]
tests/key-tests/pkcs8-eddsa [new file with mode: 0755]

index 1ff28b5863dc36d701b23a820d5cb466df861ea8..888b6131899d127bf38befb8226f6040a96f7d9b 100644 (file)
@@ -31,11 +31,12 @@ EXTRA_DIST = data/key-ca.pem data/key-user.pem \
        data/bad-key.pem data/p8key-illegal.pem data/key-illegal.pem data/pkcs8-pbes2-sha256.pem \
        data/pkcs8-pbes1-des-md5.pem data/pkcs8-invalid8.der data/key-invalid1.der \
        data data/pkcs8-invalid9.der data/key-invalid2.der data/pkcs8-invalid10.der \
-       data/key-invalid3.der
+       data/key-invalid3.der data/pkcs8-eddsa.pem data/pkcs8-eddsa.pem.txt
 
-dist_check_SCRIPTS = key-id pkcs8 pkcs8-decode dsa ecdsa illegal-rsa pkcs8-invalid key-invalid
+dist_check_SCRIPTS = key-id pkcs8 pkcs8-decode dsa ecdsa illegal-rsa pkcs8-invalid key-invalid \
+       pkcs8-eddsa
 
-TESTS = key-id ecdsa pkcs8-invalid key-invalid pkcs8-decode pkcs8
+TESTS = key-id ecdsa pkcs8-invalid key-invalid pkcs8-decode pkcs8 pkcs8-eddsa
 
 if !WITH_OLD_NETTLE
 TESTS += illegal-rsa
diff --git a/tests/key-tests/data/pkcs8-eddsa.pem b/tests/key-tests/data/pkcs8-eddsa.pem
new file mode 100644 (file)
index 0000000..e447080
--- /dev/null
@@ -0,0 +1,3 @@
+-----BEGIN PRIVATE KEY-----
+MC4CAQAwBQYDK2VwBCIEINTuctv5E1hK1bbY8fdp+K06/nwoy/HU++CXqI9EdVhC
+-----END PRIVATE KEY-----
diff --git a/tests/key-tests/data/pkcs8-eddsa.pem.txt b/tests/key-tests/data/pkcs8-eddsa.pem.txt
new file mode 100644 (file)
index 0000000..665124d
--- /dev/null
@@ -0,0 +1,25 @@
+Public Key Info:
+       Public Key Algorithm: EdDSA (Ed25519)
+       Key Security Level: High (256 bits)
+
+curve: Ed25519
+private key:
+       d4:ee:72:db:f9:13:58:4a:d5:b6:d8:f1:f7:69:f8:ad
+       3a:fe:7c:28:cb:f1:d4:fb:e0:97:a8:8f:44:75:58:42
+       
+
+x:
+       19:bf:44:09:69:84:cd:fe:85:41:ba:c1:67:dc:3b:96
+       c8:50:86:aa:30:b6:b6:cb:0c:5c:38:ad:70:31:66:e1
+       
+
+
+Public Key PIN:
+       pin-sha256:oekVYFTgT6yJmunydRMs3Ael28TqLCrTof/G4NJTaB8=
+Public Key ID:
+       sha256:a1e9156054e04fac899ae9f275132cdc07a5dbc4ea2c2ad3a1ffc6e0d253681f
+       sha1:3a04967761a552db7e9e18c6dba4bd4aae119908
+
+-----BEGIN PRIVATE KEY-----
+MC4CAQAwBQYDK2VwBCIEINTuctv5E1hK1bbY8fdp+K06/nwoy/HU++CXqI9EdVhC
+-----END PRIVATE KEY-----
diff --git a/tests/key-tests/pkcs8-eddsa b/tests/key-tests/pkcs8-eddsa
new file mode 100755 (executable)
index 0000000..7474078
--- /dev/null
@@ -0,0 +1,64 @@
+#!/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-eddsa.$$.tmp
+
+if ! test -x "${CERTTOOL}"; then
+       exit 77
+fi
+
+if test "${GNUTLS_FORCE_FIPS_MODE}" = 1;then
+       echo "Cannot run in FIPS140-2 mode"
+       exit 77
+fi
+
+if ! test -z "${VALGRIND}"; then
+       VALGRIND="${LIBTOOL:-libtool} --mode=execute ${VALGRIND}"
+fi
+
+for p8 in "pkcs8-eddsa.pem"; do
+       set -- ${p8}
+       file="$1"
+       ${VALGRIND} "${CERTTOOL}" --key-info --pkcs8 --password "" \
+               --infile "${srcdir}/data/${file}" --outfile $TMPFILE
+       rc=$?
+       if test ${rc} != 0; then
+               echo "PKCS8 FATAL ${p8}"
+               exit 1
+       fi
+
+       echo ""
+       ${DIFF} -u "${srcdir}/data/${p8}.txt" $TMPFILE
+       rc=$?
+       if test ${rc} != 0; then
+               cat $TMPFILE
+               echo "PKCS8 FATAL TXT ${p8}"
+               exit 1
+       fi
+done
+rm -f $TMPFILE
+
+echo "PKCS8 DONE"
+exit 0