diff options
author | Jan Vcelak <jan.vcelak@nic.cz> | 2016-02-26 16:17:48 +0100 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2016-02-27 21:48:00 +0100 |
commit | a52f4eb7fca9b70926e58727f3d9d6683cdcb686 (patch) | |
tree | 8a649b00ae3937b1132c8d07b88b721b1c8d5405 | |
parent | e12e681b4e3e7597a0956927d677ce1458fc1dcb (diff) | |
download | gnutls-a52f4eb7fca9b70926e58727f3d9d6683cdcb686.tar.gz |
pkcs11: tests for RSA, ECC, DSA private key import
Signed-off-by: Jan Vcelak <jan.vcelak@nic.cz>
-rwxr-xr-x | tests/suite/testpkcs11.sh | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/suite/testpkcs11.sh b/tests/suite/testpkcs11.sh index 8f862eda2e..f58248e9af 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}" |