From: Peter van Dijk Date: Fri, 5 Jun 2020 23:05:22 +0000 (+0200) Subject: auth pkcs11: add ECDSA support, use softhsm2-util, other fixes X-Git-Tag: dnsdist-1.5.0-rc3~5^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7e520f030d95a3f8ca0d37575901833da3d5efed;p=thirdparty%2Fpdns.git auth pkcs11: add ECDSA support, use softhsm2-util, other fixes --- diff --git a/pdns/pdnsutil.cc b/pdns/pdnsutil.cc index fd5bcccfe9..04fa2378ed 100644 --- a/pdns/pdnsutil.cc +++ b/pdns/pdnsutil.cc @@ -1682,7 +1682,7 @@ static bool showZone(DNSSECKeeper& dk, const DNSName& zone, bool exportDS = fals cout<<"ID = "<getBits() < 1) { - cerr<<" " <" <getBits() << " created" << std::endl; return 0; } #else diff --git a/pdns/pkcs11signers.cc b/pdns/pkcs11signers.cc index ddb1506492..a7c1886344 100644 --- a/pdns/pkcs11signers.cc +++ b/pdns/pkcs11signers.cc @@ -63,6 +63,14 @@ static std::map dnssec2hmech = boost::assign::ma (13, CKM_SHA256) (14, CKM_SHA384); +static std::map dnssec2cmech = boost::assign::map_list_of +(5, CKM_RSA_PKCS_KEY_PAIR_GEN) +(7, CKM_RSA_PKCS_KEY_PAIR_GEN) +(8, CKM_RSA_PKCS_KEY_PAIR_GEN) +(10, CKM_RSA_PKCS_KEY_PAIR_GEN) +(13, CKM_ECDSA_KEY_PAIR_GEN) +(14, CKM_ECDSA_KEY_PAIR_GEN); + typedef enum { Attribute_Byte, Attribute_Long, Attribute_String } CkaValueType; // Attribute handling @@ -212,7 +220,7 @@ class Pkcs11Slot { void logError(const std::string& operation) const { if (d_err) { - std::string msg = boost::str( boost::format("PKCS#11 operation %s failed: %s (0x%X)") % operation % p11_kit_strerror(d_err) % d_err ); + std::string msg = boost::str( boost::format("PKCS#11 operation %s failed: %s (0x%X) (%s)") % operation % p11_kit_strerror(d_err) % d_err % p11_kit_message() ); g_log<GenerateKeyPair(&mech, pubAttr, privAttr, &pubKey, &privKey)) { throw PDNSException("Keypair generation failed"); } diff --git a/regression-tests/start-test-stop b/regression-tests/start-test-stop index 96044e25f0..48e513e16c 100755 --- a/regression-tests/start-test-stop +++ b/regression-tests/start-test-stop @@ -129,22 +129,23 @@ securezone () else # check if PKCS#11 should be used if [ "$pkcs11" -eq 1 ]; then - if [ "$slot" == "" ]; then - slot=0 - else - slot=$((slot+1)) - fi - sudo softhsm --init-token --slot $slot --label label$slot --pin 123$slot --so-pin 123$slot - kid=`$PDNSUTIL --config-dir=. $configname hsm assign $zone ecdsa256 zsk softhsm label$slot 123$slot label$slot 2>&1 | grep softhsm | awk '{ print $NF }'` - kid=`$PDNSUTIL --config-dir=. $configname show-zone $zone | grep 'ID =.*ZSK' | awk '{ print $3 }'` - $PDNSUTIL --config-dir=. $configname hsm create-key $zone $kid - else - $PDNSUTIL --config-dir=. $configname secure-zone $zone 2>&1 - if [ "${zone: 0:20}" = "cdnskey-cds-test.com" ]; then - $PDNSUTIL --config-dir=. $configname set-publish-cds $zone 2>&1 - $PDNSUTIL --config-dir=. $configname set-publish-cdnskey $zone 2>&1 - fi - fi + if [ "$slot" == "" ]; then + slot=0 + else + slot=$((slot+1)) + fi + label=pdnstest-${EPOCHSECONDS}-${slot} + softhsm2-util --delete-token --label $label 2> /dev/null || true + softhsm2-util --init-token --label $label --free --pin 1234 --so-pin 1234 + kid=`$PDNSUTIL --config-dir=. $configname hsm assign $zone ecdsa256 ksk softhsm $label 1234 $label 2>&1 | grep softhsm | awk '{ print $NF }'` + $PDNSUTIL --config-dir=. $configname hsm create-key $zone $kid + else + $PDNSUTIL --config-dir=. $configname secure-zone $zone 2>&1 + fi + if [ "${zone: 0:20}" = "cdnskey-cds-test.com" ]; then + $PDNSUTIL --config-dir=. $configname set-publish-cds $zone 2>&1 + $PDNSUTIL --config-dir=. $configname set-publish-cdnskey $zone 2>&1 + fi fi }