From: Peter van Dijk Date: Mon, 18 Mar 2013 11:17:34 +0000 (+0000) Subject: add pdnssec generate-zone-key command, thanks Aki. Closes #711 X-Git-Tag: rec-3.5-rc3~11 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=950bdddf505a3c598867039f41e8bf50b445d0d6;p=thirdparty%2Fpdns.git add pdnssec generate-zone-key command, thanks Aki. Closes #711 git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@3124 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- diff --git a/pdns/pdnssec.cc b/pdns/pdnssec.cc index 95991b7fcb..2a4fc9b1ec 100644 --- a/pdns/pdnssec.cc +++ b/pdns/pdnssec.cc @@ -811,6 +811,8 @@ try cerr<<"add-zone-key ZONE zsk|ksk [bits]\n"; cerr<<" [rsasha1|rsasha256|rsasha512|gost|ecdsa256|ecdsa384]\n"; cerr<<" Add a ZSK or KSK to zone and specify algo&bits\n"; + cerr<<"generate-zone-key zsk|ksk [bits] [algorithm]\n"; + cerr<<" Generate a ZSK or KSK to stdout with specified algo&bits\n"; cerr<<"check-zone ZONE Check a zone for correctness\n"; cerr<<"check-all-zones Check all zones for correctness\n"; cerr<<"create-bind-db FNAME Create DNSSEC db for BIND backend (bind-dnssec-db)\n"; @@ -1223,6 +1225,58 @@ try cout << zone << " IN DS "<0) { + algorithm = tmp_algo; + } else if(atoi(cmds[n].c_str())) + bits = atoi(cmds[n].c_str()); + else { + cerr<<"Unknown algorithm, key flag or size '"< dpk(DNSCryptoKeyEngine::make(algorithm)); // defaults to RSA for now, could be smart w/algorithm! XXX FIXME + if(!bits) { + if(algorithm <= 10) + bits = keyOrZone ? 2048 : 1024; + else { + if(algorithm == 12 || algorithm == 13 || algorithm == 250) // ECDSA, GOST, ED25519 + bits = 256; + else if(algorithm == 14) + bits = 384; + else { + throw runtime_error("Can't guess key size for algoritm "+lexical_cast(algorithm)); + } + } + } + dpk->create(bits); + dspk.setKey(dpk); + dspk.d_algorithm = algorithm; + dspk.d_flags = keyOrZone ? 257 : 256; + + // print key to stdout + cout << "Flags: " << dspk.d_flags << endl << + dspk.getKey()->convertToISC() << endl; + } else { cerr<<"Unknown command '"<