|
|
61e0f4 |
From 10ed7e56f159dba8980644494532898c9063438d Mon Sep 17 00:00:00 2001
|
|
|
61e0f4 |
From: =?UTF-8?q?Micha=C5=82=20Trojnara?= <Michal.Trojnara@stunnel.org>
|
|
|
61e0f4 |
Date: Thu, 23 Aug 2018 22:19:04 +0200
|
|
|
61e0f4 |
Subject: [PATCH 03/23] ec-evp-sign test
|
|
|
61e0f4 |
|
|
|
61e0f4 |
---
|
|
|
61e0f4 |
tests/Makefile.am | 1 +
|
|
|
61e0f4 |
tests/ec-common.sh | 18 +++++-----
|
|
|
61e0f4 |
tests/ec-evp-sign.softhsm | 71 +++++++++++++++++++++++++++++++++++++++
|
|
|
61e0f4 |
tests/ec-testfork.softhsm | 2 +-
|
|
|
61e0f4 |
4 files changed, 82 insertions(+), 10 deletions(-)
|
|
|
61e0f4 |
create mode 100755 tests/ec-evp-sign.softhsm
|
|
|
61e0f4 |
|
|
|
61e0f4 |
diff --git a/tests/Makefile.am b/tests/Makefile.am
|
|
|
61e0f4 |
index 8864709..cd17051 100644
|
|
|
61e0f4 |
--- a/tests/Makefile.am
|
|
|
61e0f4 |
+++ b/tests/Makefile.am
|
|
|
61e0f4 |
@@ -21,6 +21,7 @@ dist_check_SCRIPTS = \
|
|
|
61e0f4 |
rsa-testfork.softhsm \
|
|
|
61e0f4 |
rsa-testlistkeys.softhsm \
|
|
|
61e0f4 |
rsa-evp-sign.softhsm \
|
|
|
61e0f4 |
+ ec-evp-sign.softhsm \
|
|
|
61e0f4 |
ec-testfork.softhsm \
|
|
|
61e0f4 |
fork-change-slot.softhsm \
|
|
|
61e0f4 |
rsa-pss-sign.softhsm \
|
|
|
61e0f4 |
diff --git a/tests/ec-common.sh b/tests/ec-common.sh
|
|
|
61e0f4 |
index a709c0d..a53a4ee 100755
|
|
|
61e0f4 |
--- a/tests/ec-common.sh
|
|
|
61e0f4 |
+++ b/tests/ec-common.sh
|
|
|
61e0f4 |
@@ -35,11 +35,11 @@ mkdir -p $outdir
|
|
|
61e0f4 |
|
|
|
61e0f4 |
for i in /usr/lib64/pkcs11 /usr/lib64/softhsm /usr/lib/x86_64-linux-gnu/softhsm /usr/local/lib/softhsm /opt/local/lib/softhsm /usr/lib/softhsm /usr/lib ;do
|
|
|
61e0f4 |
if test -f "$i/libsofthsm2.so"; then
|
|
|
61e0f4 |
- ADDITIONAL_PARAM="$i/libsofthsm2.so"
|
|
|
61e0f4 |
+ MODULE="$i/libsofthsm2.so"
|
|
|
61e0f4 |
break
|
|
|
61e0f4 |
else
|
|
|
61e0f4 |
if test -f "$i/libsofthsm.so";then
|
|
|
61e0f4 |
- ADDITIONAL_PARAM="$i/libsofthsm.so"
|
|
|
61e0f4 |
+ MODULE="$i/libsofthsm.so"
|
|
|
61e0f4 |
break
|
|
|
61e0f4 |
fi
|
|
|
61e0f4 |
fi
|
|
|
61e0f4 |
@@ -104,18 +104,18 @@ PUK=1234
|
|
|
61e0f4 |
init_card $PIN $PUK
|
|
|
61e0f4 |
|
|
|
61e0f4 |
# generate key in token
|
|
|
61e0f4 |
-pkcs11-tool -p $PIN --module $ADDITIONAL_PARAM -d 01020304 -a server-key -l -w ${srcdir}/ec-prvkey.der -y privkey >/dev/null
|
|
|
61e0f4 |
+pkcs11-tool -p $PIN --module $MODULE -d 01020304 -a server-key -l -w ${srcdir}/ec-prvkey.der -y privkey >/dev/null
|
|
|
61e0f4 |
if test $? != 0;then
|
|
|
61e0f4 |
exit 1;
|
|
|
61e0f4 |
fi
|
|
|
61e0f4 |
|
|
|
61e0f4 |
# pkcs11-tool currently only supports RSA public keys
|
|
|
61e0f4 |
-#pkcs11-tool -p $PIN --module $ADDITIONAL_PARAM -d 01020304 -a server-key -l -w ${srcdir}/ec-pubkey.der -y pubkey >/dev/null
|
|
|
61e0f4 |
-#if test $? != 0;then
|
|
|
61e0f4 |
-# exit 1;
|
|
|
61e0f4 |
-#fi
|
|
|
61e0f4 |
+pkcs11-tool -p $PIN --module $MODULE -d 01020304 -a server-key -l -w ${srcdir}/ec-pubkey.der -y pubkey >/dev/null
|
|
|
61e0f4 |
+if test $? != 0;then
|
|
|
61e0f4 |
+ exit 1;
|
|
|
61e0f4 |
+fi
|
|
|
61e0f4 |
|
|
|
61e0f4 |
-pkcs11-tool -p $PIN --module $ADDITIONAL_PARAM -d 01020304 -a server-key -l -w ${srcdir}/ec-cert.der -y cert >/dev/null
|
|
|
61e0f4 |
+pkcs11-tool -p $PIN --module $MODULE -d 01020304 -a server-key -l -w ${srcdir}/ec-cert.der -y cert >/dev/null
|
|
|
61e0f4 |
if test $? != 0;then
|
|
|
61e0f4 |
exit 1;
|
|
|
61e0f4 |
fi
|
|
|
61e0f4 |
@@ -123,4 +123,4 @@ fi
|
|
|
61e0f4 |
echo "***************"
|
|
|
61e0f4 |
echo "Listing objects"
|
|
|
61e0f4 |
echo "***************"
|
|
|
61e0f4 |
-pkcs11-tool -p $PIN --module $ADDITIONAL_PARAM -l -O
|
|
|
61e0f4 |
+pkcs11-tool -p $PIN --module $MODULE -l -O
|
|
|
61e0f4 |
diff --git a/tests/ec-evp-sign.softhsm b/tests/ec-evp-sign.softhsm
|
|
|
61e0f4 |
new file mode 100755
|
|
|
61e0f4 |
index 0000000..edecd4a
|
|
|
61e0f4 |
--- /dev/null
|
|
|
61e0f4 |
+++ b/tests/ec-evp-sign.softhsm
|
|
|
61e0f4 |
@@ -0,0 +1,71 @@
|
|
|
61e0f4 |
+#!/bin/sh
|
|
|
61e0f4 |
+
|
|
|
61e0f4 |
+# Copyright (C) 2015 Nikos Mavrogiannopoulos
|
|
|
61e0f4 |
+#
|
|
|
61e0f4 |
+# GnuTLS is free software; you can redistribute it and/or modify it
|
|
|
61e0f4 |
+# under the terms of the GNU General Public License as published by the
|
|
|
61e0f4 |
+# Free Software Foundation; either version 3 of the License, or (at
|
|
|
61e0f4 |
+# your option) any later version.
|
|
|
61e0f4 |
+#
|
|
|
61e0f4 |
+# GnuTLS is distributed in the hope that it will be useful, but
|
|
|
61e0f4 |
+# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
61e0f4 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
61e0f4 |
+# General Public License for more details.
|
|
|
61e0f4 |
+#
|
|
|
61e0f4 |
+# You should have received a copy of the GNU General Public License
|
|
|
61e0f4 |
+# along with GnuTLS; if not, write to the Free Software Foundation,
|
|
|
61e0f4 |
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
61e0f4 |
+
|
|
|
61e0f4 |
+outdir="output.$$"
|
|
|
61e0f4 |
+
|
|
|
61e0f4 |
+# Load common test functions
|
|
|
61e0f4 |
+. ${srcdir}/ec-common.sh
|
|
|
61e0f4 |
+
|
|
|
61e0f4 |
+# Do the common test initialization
|
|
|
61e0f4 |
+# common_init
|
|
|
61e0f4 |
+
|
|
|
61e0f4 |
+sed -e "s|@MODULE_PATH@|${MODULE}|g" -e "s|@ENGINE_PATH@|../src/.libs/pkcs11.so|g" <"${srcdir}/engines.cnf.in" >"${outdir}/engines.cnf"
|
|
|
61e0f4 |
+
|
|
|
61e0f4 |
+export OPENSSL_ENGINES="../src/.libs/"
|
|
|
61e0f4 |
+PRIVATE_KEY="pkcs11:token=libp11-test;id=%01%02%03%04;object=server-key;type=private;pin-value=1234"
|
|
|
61e0f4 |
+PUBLIC_KEY="pkcs11:token=libp11-test;id=%01%02%03%04;object=server-key;type=public;pin-value=1234"
|
|
|
61e0f4 |
+
|
|
|
61e0f4 |
+./evp-sign ctrl false "${outdir}/engines.cnf" ${PRIVATE_KEY} ${PUBLIC_KEY} ${MODULE}
|
|
|
61e0f4 |
+if test $? != 0;then
|
|
|
61e0f4 |
+ echo "Basic PKCS #11 test, using ctrl failed"
|
|
|
61e0f4 |
+ exit 1;
|
|
|
61e0f4 |
+fi
|
|
|
61e0f4 |
+
|
|
|
61e0f4 |
+./evp-sign default false "${outdir}/engines.cnf" ${PRIVATE_KEY} ${PUBLIC_KEY} ${MODULE}
|
|
|
61e0f4 |
+if test $? != 0;then
|
|
|
61e0f4 |
+ echo "Basic PKCS #11 test, using default failed"
|
|
|
61e0f4 |
+ exit 1;
|
|
|
61e0f4 |
+fi
|
|
|
61e0f4 |
+
|
|
|
61e0f4 |
+./evp-sign ctrl 1234 "${outdir}/engines.cnf" ${PRIVATE_KEY} ${PUBLIC_KEY} ${MODULE}
|
|
|
61e0f4 |
+if test $? != 0;then
|
|
|
61e0f4 |
+ echo "Basic PKCS #11 test without pin-value, using ctrl failed"
|
|
|
61e0f4 |
+ exit 1;
|
|
|
61e0f4 |
+fi
|
|
|
61e0f4 |
+
|
|
|
61e0f4 |
+./evp-sign default 1234 "${outdir}/engines.cnf" ${PRIVATE_KEY} ${PUBLIC_KEY} ${MODULE}
|
|
|
61e0f4 |
+if test $? != 0;then
|
|
|
61e0f4 |
+ echo "Basic PKCS #11 test without pin-value, using default failed"
|
|
|
61e0f4 |
+ exit 1;
|
|
|
61e0f4 |
+fi
|
|
|
61e0f4 |
+
|
|
|
61e0f4 |
+./evp-sign ctrl 1234 "${outdir}/engines.cnf" "label_server-key" "label_server-key" ${MODULE}
|
|
|
61e0f4 |
+if test $? != 0;then
|
|
|
61e0f4 |
+ echo "Basic PKCS #11 test with legacy name #1 failed"
|
|
|
61e0f4 |
+ exit 1;
|
|
|
61e0f4 |
+fi
|
|
|
61e0f4 |
+
|
|
|
61e0f4 |
+./evp-sign default 1234 "${outdir}/engines.cnf" "id_01020304" "id_01020304" ${MODULE}
|
|
|
61e0f4 |
+if test $? != 0;then
|
|
|
61e0f4 |
+ echo "Basic PKCS #11 test with legacy name #2 failed"
|
|
|
61e0f4 |
+ exit 1;
|
|
|
61e0f4 |
+fi
|
|
|
61e0f4 |
+
|
|
|
61e0f4 |
+rm -rf "$outdir"
|
|
|
61e0f4 |
+
|
|
|
61e0f4 |
+exit 0
|
|
|
61e0f4 |
diff --git a/tests/ec-testfork.softhsm b/tests/ec-testfork.softhsm
|
|
|
61e0f4 |
index 961424a..55b6516 100755
|
|
|
61e0f4 |
--- a/tests/ec-testfork.softhsm
|
|
|
61e0f4 |
+++ b/tests/ec-testfork.softhsm
|
|
|
61e0f4 |
@@ -21,7 +21,7 @@ outdir="output.$$"
|
|
|
61e0f4 |
|
|
|
61e0f4 |
. ${srcdir}/ec-common.sh
|
|
|
61e0f4 |
|
|
|
61e0f4 |
-./fork-test $ADDITIONAL_PARAM $PIN
|
|
|
61e0f4 |
+./fork-test $MODULE $PIN
|
|
|
61e0f4 |
if test $? != 0;then
|
|
|
61e0f4 |
exit 1;
|
|
|
61e0f4 |
fi
|
|
|
61e0f4 |
--
|
|
|
61e0f4 |
2.17.1
|
|
|
61e0f4 |
|