aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-10-06 20:58:03 -0400
committerJack Lloyd <[email protected]>2017-10-06 20:58:03 -0400
commit1c539719f170df9c8acc6977da3c331c7e78cbf2 (patch)
tree8563dd0de4563bb467fb6a70b73338f894016800 /src
parent1b09b194fa94522be56c6f8cce69b6fb166c842c (diff)
Add mod_inverse cmdlet
I needed it ;)
Diffstat (limited to 'src')
-rw-r--r--src/cli/math.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/cli/math.cpp b/src/cli/math.cpp
index ee1c2b1a9..f01d9a1bd 100644
--- a/src/cli/math.cpp
+++ b/src/cli/math.cpp
@@ -14,6 +14,22 @@
namespace Botan_CLI {
+class Modular_Inverse final : public Command
+ {
+ public:
+ Modular_Inverse() : Command("mod_inverse n mod") {}
+
+ void go() override
+ {
+ const Botan::BigInt n(get_arg("n"));
+ const Botan::BigInt mod(get_arg("mod"));
+
+ output() << Botan::inverse_mod(n, mod) << "\n";
+ }
+ };
+
+BOTAN_REGISTER_COMMAND("mod_inverse", Modular_Inverse);
+
class Gen_Prime final : public Command
{
public: