summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2017-08-26 17:16:26 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2017-08-27 15:58:28 +0200
commit7345481ba5962d16bccfaacb3432e8328e2ff816 (patch)
tree9e639d90cf972f32d49f9d0f96ab3f0fd3ab2579
parent15df5bb9dd45ec263779ebf9306d276a55bfa57d (diff)
downloadgnutls-7345481ba5962d16bccfaacb3432e8328e2ff816.tar.gz
tests: added unit test of p11tool with --set-pin
Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
-rwxr-xr-xtests/suite/testpkcs11.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/suite/testpkcs11.sh b/tests/suite/testpkcs11.sh
index dcf932c7fc..199e2cb5c1 100755
--- a/tests/suite/testpkcs11.sh
+++ b/tests/suite/testpkcs11.sh
@@ -735,6 +735,24 @@ test_sign () {
echo ok
}
+# This tests the signing operation as well as the usage of --set-pin
+test_sign_set_pin () {
+ pin="$2"
+ token="$1"
+
+ unset GNUTLS_PIN
+
+ echo -n "* Testing signatures using the private key and --set-pin... "
+ ${P11TOOL} ${ADDITIONAL_PARAM} --login --set-pin ${pin} --test-sign "${token};object=serv-key" >>"${TMPFILE}" 2>&1
+ if test $? != 0; then
+ echo "failed. Cannot test signatures."
+ exit_error
+ fi
+ echo ok
+
+ export GNUTLS_PIN=${pin}
+}
+
# $1: token
# $2: PIN
# $3: certfile
@@ -857,6 +875,8 @@ write_certificate_id_test_rsa "${TOKEN}" "${GNUTLS_PIN}" "${srcdir}/pkcs11-certs
write_certificate_id_test_rsa2 "${TOKEN}" "${GNUTLS_PIN}" "${srcdir}/pkcs11-certs/ca.key" "${srcdir}/pkcs11-certs/ca.crt"
write_certificate_id_test_ecdsa "${TOKEN}" "${GNUTLS_PIN}" "${srcdir}/pkcs11-certs/ca.key" "${srcdir}/pkcs11-certs/ca.crt"
+test_sign_set_pin "${TOKEN}" "${GNUTLS_PIN}"
+
if test ${RETCODE} = 0; then
echo "* All smart cards tests succeeded"
fi