diff options
author | Jack Lloyd <[email protected]> | 2018-05-21 17:50:27 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-05-21 17:50:27 -0400 |
commit | d08ce3d912343a9571d81b605ca04763560f8a00 (patch) | |
tree | eae1aec06d735fb3f38631610a2331b151bda401 /src | |
parent | 6e3cef104ac3c1108779d7fb494cba672e44da35 (diff) |
In gen_dl_group cmdlet let --seed be optional for DSA params
Diffstat (limited to 'src')
-rw-r--r-- | src/cli/pubkey.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/cli/pubkey.cpp b/src/cli/pubkey.cpp index a72ff68e6..339a0fa6e 100644 --- a/src/cli/pubkey.cpp +++ b/src/cli/pubkey.cpp @@ -450,27 +450,24 @@ class Gen_DL_Group final : public Command const size_t qbits = get_arg_sz("qbits"); const std::string type = get_arg("type"); + const std::string seed_str = get_arg("seed"); if(type == "strong") { + if(seed_str.size() > 0) + throw CLI_Usage_Error("Seed only supported for DSA param gen"); Botan::DL_Group grp(rng(), Botan::DL_Group::Strong, pbits); output() << grp.PEM_encode(Botan::DL_Group::ANSI_X9_42); } else if(type == "subgroup") { + if(seed_str.size() > 0) + throw CLI_Usage_Error("Seed only supported for DSA param gen"); Botan::DL_Group grp(rng(), Botan::DL_Group::Prime_Subgroup, pbits, qbits); output() << grp.PEM_encode(Botan::DL_Group::ANSI_X9_42); } else if(type == "dsa") { - const std::string seed_str = get_arg("seed"); - const std::vector<uint8_t> seed = Botan::hex_decode(seed_str); - - if(seed.empty()) - { - throw CLI_Usage_Error("Generating DSA parameter set requires providing seed"); - } - size_t dsa_qbits = qbits; if(dsa_qbits == 0) { @@ -482,8 +479,18 @@ class Gen_DL_Group final : public Command throw CLI_Usage_Error("Invalid DSA p/q sizes"); } - Botan::DL_Group grp(rng(), seed, pbits, dsa_qbits); - output() << grp.PEM_encode(Botan::DL_Group::ANSI_X9_42); + if(seed_str.empty()) + { + Botan::DL_Group grp(rng(), Botan::DL_Group::DSA_Kosherizer, pbits, dsa_qbits); + output() << grp.PEM_encode(Botan::DL_Group::ANSI_X9_42); + } + else + { + const std::vector<uint8_t> seed = Botan::hex_decode(seed_str); + Botan::DL_Group grp(rng(), seed, pbits, dsa_qbits); + output() << grp.PEM_encode(Botan::DL_Group::ANSI_X9_42); + } + } else { |