Changeset 1726

Show
Ignore:
Timestamp:
10/09/10 15:50:18 (3 years ago)
Author:
ahu
Message:

make dnsseckeeper & pdnssec understand the new world of 'active' and 'passive' keys

Location:
trunk/pdns/pdns
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/pdns/pdns/dnsseckeeper.cc

    r1724 r1726  
    1313#include <boost/algorithm/string.hpp> 
    1414#include <boost/format.hpp> 
    15  
     15#include <boost/assign/std/vector.hpp> // for 'operator+=()' 
     16#include <boost/assign/list_inserter.hpp> 
     17using namespace boost::assign; 
    1618namespace fs = boost::filesystem; 
    1719 
     
    3537  typedef vector<pair<string, mpi*> > outputs_t; 
    3638  outputs_t outputs; 
    37  
    38   outputs.push_back(make_pair("Modulus", &d_context.N)); 
    39   outputs.push_back(make_pair("PublicExponent",&d_context.E)); 
    40   outputs.push_back(make_pair("PrivateExponent",&d_context.D)); 
    41   outputs.push_back(make_pair("Prime1",&d_context.P)); 
    42   outputs.push_back(make_pair("Prime2",&d_context.Q)); 
    43   outputs.push_back(make_pair("Exponent1",&d_context.DP)); 
    44   outputs.push_back(make_pair("Exponent2",&d_context.DQ)); 
    45   outputs.push_back(make_pair("Coefficient",&d_context.QP)); 
     39  push_back(outputs)("Modulus", &d_context.N)("PublicExponent",&d_context.E) 
     40    ("Modulus", &d_context.N) 
     41    ("PublicExponent",&d_context.E) 
     42    ("PrivateExponent",&d_context.D) 
     43    ("Prime1",&d_context.P) 
     44    ("Prime2",&d_context.Q) 
     45    ("Exponent1",&d_context.DP) 
     46    ("Exponent2",&d_context.DQ) 
     47    ("Coefficient",&d_context.QP); 
    4648 
    4749  ret = "Private-key-format: v1.2\nAlgorithm: 5 (RSASHA1)\n"; 
     
    9597} 
    9698 
    97 void DNSSECKeeper::addZSKFor(const std::string& name, int algorithm, bool next) 
     99void DNSSECKeeper::addZSKFor(const std::string& name, int algorithm, bool active) 
    98100{ 
    99101  DNSSECPrivateKey dpk; 
     
    105107  drc.d_algorithm = algorithm;  
    106108  string iscName=d_dirname+"/"+name+"/zsks/"; 
    107   time_t inception=getCurrentInception(); 
    108   time_t end=inception+14*86400; 
    109  
    110   if(next) { 
    111     inception += 14*86400; 
    112     end += 14*86400; 
    113   } 
     109  time_t inception=time(0); 
     110 
     111  
    114112 
    115113  struct tm ts; 
     
    120118              % ts.tm_mday % ts.tm_hour % ts.tm_min).str(); 
    121119 
    122   iscName += "-"; 
    123  
    124   gmtime_r(&end, &ts); 
    125   iscName += (boost::format("%04d%02d%02d%02d%02d.%u")  
    126               % (1900+ts.tm_year) % (ts.tm_mon + 1) 
    127               % ts.tm_mday % ts.tm_hour % ts.tm_min % drc.getTag()).str(); 
    128  
     120  iscName += active ? ".active" : ".passive"; 
     121   
    129122  {   
    130123    ofstream iscFile((iscName+".isc").c_str()); 
     
    224217      memset(&ts2, 0, sizeof(ts2)); 
    225218       
    226       sscanf(dir_itr->leaf().c_str(), "%04d%02d%02d%02d%02d-%04d%02d%02d%02d%02d", 
     219      sscanf(dir_itr->leaf().c_str(), "%04d%02d%02d%02d%02d", 
    227220             &ts1.tm_year,  
    228              &ts1.tm_mon, &ts1.tm_mday, &ts1.tm_hour, &ts1.tm_min, 
    229              &ts2.tm_year,  
    230              &ts2.tm_mon, &ts2.tm_mday, &ts2.tm_hour, &ts2.tm_min); 
     221             &ts1.tm_mon, &ts1.tm_mday, &ts1.tm_hour, &ts1.tm_min); 
     222              
    231223 
    232224      ts1.tm_year -= 1900; 
    233       ts2.tm_year -= 1900; 
    234  
     225       
    235226      ts1.tm_mon--; 
    236       ts2.tm_mon--; 
    237  
     227       
    238228      KeyMetaData kmd; 
    239       /* 
    240       kmd.beginValidity=timegm(&ts1); 
    241       kmd.endValidity=timegm(&ts2); 
    242       time_t now=time(0); 
    243       */ 
    244       kmd.active = 1; // XXX FIXME GOOD ONE! // now > kmd.beginValidity && now < kmd.endValidity; 
     229       
     230       
    245231      kmd.fname = dir_itr->leaf(); 
     232      kmd.active = kmd.fname.find(".active") != string::npos; 
    246233      zskset.push_back(make_pair(dpk, kmd)); 
    247234    } 
  • trunk/pdns/pdns/pdnssec.cc

    r1724 r1726  
    291291      cout << "ZSKs for zone '"<<zone<<"':"<<endl; 
    292292      BOOST_FOREACH(DNSSECKeeper::zskset_t::value_type value, zskset) { 
    293         cout<<"Tag = "<<value.first.getDNSKEY().getTag()<<"\tActive: "<<value.second.active<<", "<< endl; // humanTime(value.second.beginValidity)<<" - "<<humanTime(value.second.endValidity)<<endl; 
     293        cout<<"Tag = "<<value.first.getDNSKEY().getTag()<<"\tActive: "<<value.second.active<< endl; // humanTime(value.second.beginValidity)<<" - "<<humanTime(value.second.endValidity)<<endl; 
    294294      } 
    295295    }