[gnutls-devel] [PATCH 2/2] pkcs11: tests for RSA, ECC, DSA private key import
Jan Vcelak
jan.vcelak at nic.cz
Fri Feb 26 16:17:48 CET 2016
Signed-off-by: Jan Vcelak <jan.vcelak at nic.cz>
---
tests/suite/testpkcs11.sh | 54 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/tests/suite/testpkcs11.sh b/tests/suite/testpkcs11.sh
index 2c04dff..3b9c450 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}"
--
2.5.0
More information about the Gnutls-devel
mailing list