diff options
author | tomsmeding <tom.smeding@gmail.com> | 2016-10-03 13:00:14 +0200 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2016-10-03 13:00:14 +0200 |
commit | 2bf5effe95641667a1ed51c04eff7760f6a42ef4 (patch) | |
tree | ee02ed7d87ebcfae07ac1e69017d6edced3ed386 /rsa.cpp |
Initial
Diffstat (limited to 'rsa.cpp')
-rw-r--r-- | rsa.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -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); +} |