summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Vcelak <jan.vcelak@nic.cz>2016-02-26 16:17:48 +0100
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2016-02-27 21:44:49 +0100
commit85196f9fc98dd1a1426da4d7fd84e9397df05bb4 (patch)
tree69d6c69832cb0cad614871232ec7052ada340d2c
parent1b573fc2d00f0884041e3a009539f7074d2adafa (diff)
downloadgnutls-85196f9fc98dd1a1426da4d7fd84e9397df05bb4.tar.gz
pkcs11: tests for RSA, ECC, DSA private key import
Signed-off-by: Jan Vcelak <jan.vcelak@nic.cz>
-rwxr-xr-xtests/suite/testpkcs11.sh54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/suite/testpkcs11.sh b/tests/suite/testpkcs11.sh
index 2c04dff48d..3b9c45085a 100755
--- a/tests/suite/testpkcs11.sh
+++ b/tests/suite/testpkcs11.sh
@@ -322,6 +322,53 @@ generate_temp_ecc_privkey () {
fi
}
+# $1: name
+# $2: label prefix
+# $3: generate option
+# $4: token
+# $5: PIN
+# $6: bits
+import_privkey () {
+ export GNUTLS_PIN="$5"
+ name="$1"
+ prefix="$2"
+ gen_option="$3"
+ token="$4"
+ bits="$6"
+
+ outfile="tmp-${prefix}-${bits}.pem"
+
+ echo -n "* Importing ${name} private key (${bits})... "
+
+ "${CERTTOOL}" ${CERTTOOL_PARAM} --generate-privkey "${gen_option}" --pkcs8 --password= --outfile "${outfile}" >>"${TMPFILE}" 2>&1
+ if test $? != 0; then
+ RETCODE=1
+ echo failed
+ return
+ fi
+
+ ${P11TOOL} ${ADDITIONAL_PARAM} --login --write --label "${prefix}-${bits}" --load-privkey "${outfile}" "${token}" >>"${TMPFILE}" 2>&1
+ if test $? = 0; then
+ RETCODE=0
+ echo ok
+ else
+ echo failed
+ RETCODE=1
+ fi
+}
+
+import_temp_rsa_privkey () {
+ import_privkey RSA temp-rsa --rsa $@
+}
+
+import_temp_ecc_privkey () {
+ import_privkey ECC temp-ecc --ecc $@
+}
+
+import_temp_dsa_privkey () {
+ import_privkey DSA temp-dsa --dsa $@
+}
+
# $1: token
# $2: PIN
# $3: cakey: ${srcdir}/pkcs11-certs/ca.key
@@ -556,6 +603,13 @@ delete_temp_privkey "${TOKEN}" "${GNUTLS_PIN}" rsa-2048
generate_temp_dsa_privkey "${TOKEN}" "${GNUTLS_PIN}" 3072
delete_temp_privkey "${TOKEN}" "${GNUTLS_PIN}" dsa-3072
+import_temp_rsa_privkey "${TOKEN}" "${GNUTLS_PIN}" 1024
+delete_temp_privkey "${TOKEN}" "${GNUTLS_PIN}" rsa-1024
+import_temp_ecc_privkey "${TOKEN}" "${GNUTLS_PIN}" 256
+delete_temp_privkey "${TOKEN}" "${GNUTLS_PIN}" ecc-256
+import_temp_dsa_privkey "${TOKEN}" "${GNUTLS_PIN}" 2048
+delete_temp_privkey "${TOKEN}" "${GNUTLS_PIN}" dsa-2048
+
generate_rsa_privkey "${TOKEN}" "${GNUTLS_PIN}" 1024
change_id_of_privkey "${TOKEN}" "${GNUTLS_PIN}"
export_pubkey_of_privkey "${TOKEN}" "${GNUTLS_PIN}"