]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
tests: test whether PKCS#11 generation works without login
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 21 Oct 2017 13:17:22 +0000 (15:17 +0200)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 21 Oct 2017 13:17:27 +0000 (15:17 +0200)
Resolves #147

Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
tests/suite/testpkcs11.sh

index b5306cd9735848f824d5336563997b2aef829422..d1158e857ad06555f4f5ebcf148a353154c6cc97 100755 (executable)
@@ -370,6 +370,26 @@ generate_temp_ecc_privkey () {
        fi
 }
 
+# $1: token
+# $2: PIN
+# $3: bits
+# The same as generate_temp_ecc_privkey but no explicit login is performed.
+# p11tool should detect that login is required for the operation.
+generate_temp_ecc_privkey_no_login () {
+       export GNUTLS_PIN="$2"
+       token="$1"
+       bits="$3"
+
+       echo -n "* Generating ECC private key without --login (${bits})... "
+       ${P11TOOL} ${ADDITIONAL_PARAM} --label "temp-ecc-no-${bits}" --generate-ecc --bits "${bits}" "${token}" --outfile tmp-client.pub >>"${TMPFILE}" 2>&1
+       if test $? = 0; then
+               echo ok
+       else
+               echo failed
+               exit 1
+       fi
+}
+
 # $1: name
 # $2: label prefix
 # $3: generate option
@@ -847,6 +867,9 @@ write_privkey "${TOKEN}" "${GNUTLS_PIN}" "${srcdir}/pkcs11-certs/client.key"
 generate_temp_ecc_privkey "${TOKEN}" "${GNUTLS_PIN}" 256
 delete_temp_privkey "${TOKEN}" "${GNUTLS_PIN}" ecc-256
 
+generate_temp_ecc_privkey_no_login "${TOKEN}" "${GNUTLS_PIN}" 256
+delete_temp_privkey "${TOKEN}" "${GNUTLS_PIN}" ecc-no-256
+
 generate_temp_ecc_privkey "${TOKEN}" "${GNUTLS_PIN}" 384
 delete_temp_privkey "${TOKEN}" "${GNUTLS_PIN}" ecc-384