From: Bert Hubert Date: Sat, 1 Jan 2011 21:23:18 +0000 (+0000) Subject: move some more stuff to the 'infra' and away from the 'keeper' X-Git-Tag: auth-3.0~462 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f0397b959ea8e76ed92cd4742185afd16b28e218;p=pdns move some more stuff to the 'infra' and away from the 'keeper' git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1785 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- diff --git a/pdns/dnssecinfra.cc b/pdns/dnssecinfra.cc index 4987851af..fcb6a5a32 100644 --- a/pdns/dnssecinfra.cc +++ b/pdns/dnssecinfra.cc @@ -132,6 +132,70 @@ DNSKEYRecordContent getRSAKeyFromISC(rsa_context* rsa, const char* fname) return drc; } +DNSKEYRecordContent getRSAKeyFromISCString(rsa_context* rsa, const std::string& content) +{ + string sline; + string key,value; + map places; + + + rsa_init(rsa, RSA_PKCS_V15, 0, NULL, NULL ); + + places["Modulus"]=&rsa->N; + places["PublicExponent"]=&rsa->E; + places["PrivateExponent"]=&rsa->D; + places["Prime1"]=&rsa->P; + places["Prime2"]=&rsa->Q; + places["Exponent1"]=&rsa->DP; + places["Exponent2"]=&rsa->DQ; + places["Coefficient"]=&rsa->QP; + + DNSKEYRecordContent drc; + string modulus, exponent; + istringstream str(content); + unsigned char decoded[1024]; + while(getline(str, sline)) { + tie(key,value)=splitField(sline, ':'); + trim(value); + + if(places.count(key)) { + if(places[key]) { + int len=sizeof(decoded); + if(base64_decode(decoded, &len, (unsigned char*)value.c_str(), value.length()) < 0) { + cerr<<"Error base64 decoding '"<len = ( mpi_msb( &rsa->N ) + 7 ) >> 3; // no clue what this does + + if(exponent.length() < 255) + drc.d_key.assign(1, (char) (unsigned int) exponent.length()); + else { + drc.d_key.assign(1, 0); + uint16_t len=htons(exponent.length()); + drc.d_key.append((char*)&len, 2); + } + drc.d_key.append(exponent); + drc.d_key.append(modulus); + drc.d_protocol=3; + drc.d_algorithm = 0; // should not be filled out here.. + return drc; +} + + void makeRSAPublicKeyFromDNS(rsa_context* rc, const DNSKEYRecordContent& dkrc) { diff --git a/pdns/dnssecinfra.hh b/pdns/dnssecinfra.hh index 400c94e6d..e835fca94 100644 --- a/pdns/dnssecinfra.hh +++ b/pdns/dnssecinfra.hh @@ -24,7 +24,7 @@ struct CanonicalCompare: public binary_function DNSKEYRecordContent getRSAKeyFromISC(rsa_context* rsa, const char* fname); - +DNSKEYRecordContent getRSAKeyFromISCString(rsa_context* rsa, const std::string& content); void makeRSAPublicKeyFromDNS(rsa_context* rc, const DNSKEYRecordContent& dkrc); bool sharedDNSSECCompare(const boost::shared_ptr& a, const shared_ptr& b); string getSHA1HashForRRSET(const std::string& qname, const RRSIGRecordContent& rrc, std::vector >& signRecords); diff --git a/pdns/dnsseckeeper.hh b/pdns/dnsseckeeper.hh index 5fe0675f9..5c491feb0 100644 --- a/pdns/dnsseckeeper.hh +++ b/pdns/dnsseckeeper.hh @@ -117,8 +117,7 @@ public: bool getNSEC3PARAM(const std::string& zname, NSEC3PARAMRecordContent* n3p=0); void setNSEC3PARAM(const std::string& zname, const NSEC3PARAMRecordContent& n3p); void unsetNSEC3PARAM(const std::string& zname); - static unsigned int getNextKeyIDFromDir(const std::string& dirname); - std::string getKeyFilenameById(const std::string& dirname, unsigned int id); + private: std::string d_dirname; };