aboutsummaryrefslogtreecommitdiff
path: root/rsa.cpp
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2016-10-03 13:00:14 +0200
committertomsmeding <tom.smeding@gmail.com>2016-10-03 13:00:14 +0200
commit2bf5effe95641667a1ed51c04eff7760f6a42ef4 (patch)
treeee02ed7d87ebcfae07ac1e69017d6edced3ed386 /rsa.cpp
Initial
Diffstat (limited to 'rsa.cpp')
-rw-r--r--rsa.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/rsa.cpp b/rsa.cpp
new file mode 100644
index 0000000..11bf0eb
--- /dev/null
+++ b/rsa.cpp
@@ -0,0 +1,12 @@
+#include <cassert>
+#include "numalgo.h"
+#include "rsa.h"
+
+Bigint encrypt(const PublicKey &pubkey,Bigint msg){
+ assert(msg>1&&msg<pubkey.mod);
+ return expmod(msg,pubkey.exp,pubkey.mod);
+}
+
+Bigint decrypt(const PrivateKey &privkey,Bigint encr){
+ return expmod(encr,privkey.pexp,privkey.pub.mod);
+}