From 3f820afa67c0702a893c4fefa6f21483e99db45c Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Sat, 26 Aug 2017 17:16:26 +0200 Subject: tests: added unit test of p11tool with --set-pin Signed-off-by: Nikos Mavrogiannopoulos --- tests/suite/testpkcs11.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/suite/testpkcs11.sh b/tests/suite/testpkcs11.sh index 8692756644..289564c44e 100755 --- a/tests/suite/testpkcs11.sh +++ b/tests/suite/testpkcs11.sh @@ -716,6 +716,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 @@ -838,6 +856,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 -- cgit v1.2.1