]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
tests: added unit test of p11tool with --set-pin
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 26 Aug 2017 15:16:26 +0000 (17:16 +0200)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Sun, 27 Aug 2017 13:58:28 +0000 (15:58 +0200)
Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
tests/suite/testpkcs11.sh

index dcf932c7fc9a459c891df5c7875a1d3ff835be3b..199e2cb5c15aa71e9bdbd84f99d8573b82971828 100755 (executable)
@@ -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