Changeset 1761
- Timestamp:
- 12/27/10 21:55:18 (2 years ago)
- Location:
- trunk/pdns/pdns
- Files:
-
- 5 modified
-
dnssecinfra.cc (modified) (2 diffs)
-
dnssecinfra.hh (modified) (1 diff)
-
dnsseckeeper.hh (modified) (2 diffs)
-
fsdnsseckeeper.cc (modified) (10 diffs)
-
tcpreceiver.cc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pdns/pdns/dnssecinfra.cc
r1757 r1761 150 150 } 151 151 152 DNSKEYRecordContent makeDNSKEYFromRSAKey( rsa_context* rc, uint8_t algorithm)152 DNSKEYRecordContent makeDNSKEYFromRSAKey(const rsa_context* rc, uint8_t algorithm, uint16_t flags) 153 153 { 154 154 DNSKEYRecordContent drc; … … 176 176 drc.d_algorithm = algorithm; 177 177 178 drc.d_flags= 256 + (modulus.length()>128); // oops, I just made this up..178 drc.d_flags=flags; 179 179 180 180 return drc; -
trunk/pdns/pdns/dnssecinfra.hh
r1616 r1761 29 29 bool sharedDNSSECCompare(const boost::shared_ptr<DNSRecordContent>& a, const shared_ptr<DNSRecordContent>& b); 30 30 string getSHA1HashForRRSET(const std::string& qname, const RRSIGRecordContent& rrc, std::vector<boost::shared_ptr<DNSRecordContent> >& signRecords); 31 DNSKEYRecordContent makeDNSKEYFromRSAKey( rsa_context* rc, uint8_t algorithm);31 DNSKEYRecordContent makeDNSKEYFromRSAKey(const rsa_context* rc, uint8_t algorithm, uint16_t flags); 32 32 DSRecordContent makeDSFromDNSKey(const std::string& qname, const DNSKEYRecordContent& drc, int digest=1); 33 33 -
trunk/pdns/pdns/dnsseckeeper.hh
r1757 r1761 56 56 } 57 57 58 rsa_context& getContext()58 const rsa_context& getConstContext() const 59 59 { 60 60 return d_context; 61 61 } 62 63 rsa_context& getContext() 64 { 65 return d_context; 66 } 67 62 68 63 69 void create(unsigned int bits); … … 78 84 79 85 RSAContext d_key; 80 DNSKEYRecordContent getDNSKEY() ;86 DNSKEYRecordContent getDNSKEY() const; 81 87 uint8_t d_algorithm; 88 uint16_t d_flags; 82 89 }; 83 90 -
trunk/pdns/pdns/fsdnsseckeeper.cc
r1760 r1761 69 69 } 70 70 return !keys.empty(); 71 72 #if 073 fs::path full_path = fs::system_complete( fs::path(d_dirname + "/" + zone + "/keys/" ) );74 75 if ( !fs::exists( full_path ) )76 return false;77 78 fs::directory_iterator end_iter;79 for ( fs::directory_iterator dir_itr( full_path );80 dir_itr != end_iter;81 ++dir_itr )82 {83 // cerr<<"Entry: '"<< dir_itr->leaf() <<"'"<<endl;84 if(ends_with(dir_itr->leaf(),".private")) {85 // cerr<<"Hit!"<<endl;86 87 if(dpk) {88 getRSAKeyFromISC(&dpk->d_key.getContext(), dir_itr->path().file_string().c_str());89 90 if(getNSEC3PARAM(zone)) {91 dpk->d_algorithm = 7;92 }93 else {94 dpk->d_algorithm = 5;95 }96 97 }98 return true;99 }100 }101 102 return false;103 #endif104 71 } 105 72 … … 129 96 130 97 if ( !fs::exists( full_path ) ) 131 unixDie("Unable to get f ree key id from '"+dirname+"'");98 unixDie("Unable to get filname key id from '"+dirname+"'"); 132 99 133 100 fs::directory_iterator end_iter; … … 137 104 ++dir_itr ) 138 105 { 106 if(!ends_with(dir_itr->leaf(), ".private")) 107 continue; 139 108 parts = splitField(dir_itr->leaf(), '-'); 140 109 if(atoi(parts.first.c_str()) == (signed int)id) … … 152 121 string isc = dpk.d_key.convertToISC(); 153 122 DNSKEYRecordContent drc = dpk.getDNSKEY(); 154 drc.d_flags = 256 ; // KSK123 drc.d_flags = 256 + keyOrZone; // KSK 155 124 drc.d_algorithm = algorithm; 156 125 string iscName=d_dirname+"/"+name+"/keys/"; … … 189 158 void DNSSECKeeper::removeKey(const std::string& zname, unsigned int id) 190 159 { 191 string fname = getKeyFilenameById(d_dirname+"/ keys/", id);160 string fname = getKeyFilenameById(d_dirname+"/"+zname+"/keys", id); 192 161 if(unlink(fname.c_str()) < 0) 193 162 unixDie("removing key file '"+fname+"'"); … … 196 165 void DNSSECKeeper::deactivateKey(const std::string& zname, unsigned int id) 197 166 { 198 string fname = getKeyFilenameById(d_dirname+"/ keys/", id);167 string fname = getKeyFilenameById(d_dirname+"/"+zname+"/keys/", id); 199 168 string newname = boost::replace_last_copy(fname, ".active", ".passive"); 200 169 if(rename(fname.c_str(), newname.c_str()) < 0) … … 204 173 void DNSSECKeeper::activateKey(const std::string& zname, unsigned int id) 205 174 { 206 string fname = getKeyFilenameById(d_dirname+"/ keys/", id);175 string fname = getKeyFilenameById(d_dirname+"/"+zname+"/keys/", id); 207 176 string newname = boost::replace_last_copy(fname, ".passive", ".active"); 208 177 if(rename(fname.c_str(), newname.c_str()) < 0) … … 275 244 dpk.d_algorithm = 5; 276 245 } 277 278 246 struct tm ts1, ts2; 279 247 … … 296 264 kmd.active = kmd.fname.find(".active") != string::npos; 297 265 kmd.keyOrZone = kmd.fname.find(".ksk") != string::npos; 266 267 dpk.d_flags = 256 + kmd.keyOrZone; // this is a clear sign we've got our abstractions wrong! FIXME XXX 268 298 269 if(boost::indeterminate(allOrKeyOrZone) || allOrKeyOrZone == kmd.keyOrZone) 299 270 keyset.push_back(make_pair(dpk, kmd)); … … 305 276 } 306 277 307 DNSKEYRecordContent DNSSECPrivateKey::getDNSKEY() 308 { 309 return makeDNSKEYFromRSAKey(&d_key.getCon text(), d_algorithm);278 DNSKEYRecordContent DNSSECPrivateKey::getDNSKEY() const 279 { 280 return makeDNSKEYFromRSAKey(&d_key.getConstContext(), d_algorithm, d_flags); 310 281 } 311 282 -
trunk/pdns/pdns/tcpreceiver.cc
r1563 r1761 19 19 #include "utility.hh" 20 20 #include "dnssecinfra.hh" 21 #include "dnsseckeeper.hh" 21 22 #include <cstdio> 22 23 #include <cstring> … … 457 458 outpacket->addRecord(soa); // AXFR format begins and ends with a SOA record, so we add one 458 459 // sendPacket(outpacket, outsock); 460 typedef map<string, set<uint16_t>, CanonicalCompare> nsecrepo_t; 461 nsecrepo_t nsecrepo; 462 // this is where the DNSKEYs go 463 464 DNSSECKeeper dk(::arg()["key-repository"]); 465 DNSSECKeeper::keyset_t keys = dk.getKeys(target); 466 BOOST_FOREACH(const DNSSECKeeper::keyset_t::value_type& value, keys) { 467 rr.qname = target; 468 rr.qtype = QType(QType::DNSKEY); 469 rr.ttl = 3600; 470 rr.content = value.first.getDNSKEY().getZoneRepresentation(); 471 nsecrepo[rr.qname].insert(rr.qtype.getCode()); 472 outpacket->addRecord(rr); 473 } 459 474 460 475 /* now write all other records */ … … 469 484 outpacket->d_dnssecOk=true; // WRONG 470 485 471 typedef map<string, set<uint16_t>, CanonicalCompare> nsecrepo_t; 472 nsecrepo_t nsecrepo; 486 473 487 474 488 while(B->get(rr)) {