diff options
author | Jack Lloyd <[email protected]> | 2016-11-06 12:42:43 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2016-11-06 12:42:43 -0500 |
commit | 7305a0f6775ac5d24c912d38c3ddd4b367a7dc7f (patch) | |
tree | 7f89ecae91021e7ca0b44a03875f2fad158e9bc9 | |
parent | f731fce948595fc82ab46298608f3d099644f992 (diff) |
Add ec_group_info cmdlet
-rw-r--r-- | src/cli/pubkey.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/cli/pubkey.cpp b/src/cli/pubkey.cpp index cb23ddb66..3a4ce7717 100644 --- a/src/cli/pubkey.cpp +++ b/src/cli/pubkey.cpp @@ -20,6 +20,10 @@ #include <botan/dl_group.h> #endif +#if defined(BOTAN_HAS_ECC_GROUP) + #include <botan/ec_group.h> +#endif + namespace Botan_CLI { class PK_Keygen final : public Command @@ -144,6 +148,37 @@ class PK_Verify final : public Command BOTAN_REGISTER_COMMAND("verify", PK_Verify); +#if defined(BOTAN_HAS_ECC_GROUP) + +class EC_Group_Info final : public Command + { + public: + EC_Group_Info() : Command("ec_group_info --pem name") {} + + void go() override + { + Botan::EC_Group group(get_arg("name")); + + if(flag_set("pem")) + { + output() << group.PEM_encode(); + } + else + { + output() << "P = " << std::hex << group.get_curve().get_p() << "\n" + << "A = " << std::hex << group.get_curve().get_a() << "\n" + << "B = " << std::hex << group.get_curve().get_b() << "\n" + << "G = " << group.get_base_point().get_affine_x() << "," + << group.get_base_point().get_affine_y() << "\n"; + } + + } + }; + +BOTAN_REGISTER_COMMAND("ec_group_info", EC_Group_Info); + +#endif + #if defined(BOTAN_HAS_DL_GROUP) class DL_Group_Info final : public Command |