From: Kees Monshouwer Date: Wed, 11 Feb 2015 21:54:08 +0000 (+0100) Subject: evaluate KSK ZSK pairs per algorithm X-Git-Tag: dnsdist-1.0.0-alpha1~306^2~10^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7dc95f99c6aaafb9d1856a9ef85896022de04f93;p=pdns evaluate KSK ZSK pairs per algorithm --- diff --git a/pdns/dnssecsigner.cc b/pdns/dnssecsigner.cc index dcf0cc90c..c84073aab 100644 --- a/pdns/dnssecsigner.cc +++ b/pdns/dnssecsigner.cc @@ -51,34 +51,36 @@ int getRRSIGsForRRSET(DNSSECKeeper& dk, const std::string& signer, const std::st // we sign the RRSET in toSign + the rrc w/o hash DNSSECKeeper::keyset_t keys = dk.getKeys(signer); // we don't want the . for the root! - vector KSKs, ZSKs; - vector* signingKeys; - - // if ksk==1, only get KSKs - // if ksk==0, get ZSKs, unless there is no ZSK, then get KSK + set algoHasKSK, algoHasZSK; + vector signingKeys; + + BOOST_FOREACH(DNSSECKeeper::keyset_t::value_type& keymeta, keys) { + if(keymeta.second.active) { + if(keymeta.second.keyOrZone) + algoHasKSK.insert(keymeta.first.d_algorithm); + else + algoHasZSK.insert(keymeta.first.d_algorithm); + } + } + BOOST_FOREACH(DNSSECKeeper::keyset_t::value_type& keymeta, keys) { - rrc.d_algorithm = keymeta.first.d_algorithm; - if(!keymeta.second.active) + if(!keymeta.second.active) continue; - if(keymeta.second.keyOrZone) - KSKs.push_back(keymeta.first); - else - ZSKs.push_back(keymeta.first); - } - if(signQType == QType::DNSKEY) { - if(KSKs.empty()) - signingKeys = &ZSKs; - else - signingKeys = &KSKs; - } else { - if(ZSKs.empty()) - signingKeys = &KSKs; - else - signingKeys = &ZSKs; + if(signQType == QType::DNSKEY) { + // skip ZSK, if this algorithm has a KSK + if(!keymeta.second.keyOrZone && algoHasKSK.count(keymeta.first.d_algorithm)) + continue; + } else { + // skip KSK, if this algorithm has a ZSK + if(keymeta.second.keyOrZone && algoHasZSK.count(keymeta.first.d_algorithm)) + continue; + } + + signingKeys.push_back(keymeta.first); } - BOOST_FOREACH(DNSSECPrivateKey& dpk, *signingKeys) { + BOOST_FOREACH(DNSSECPrivateKey& dpk, signingKeys) { fillOutRRSIG(dpk, signQName, rrc, toSign); rrcs.push_back(rrc); }