aboutsummaryrefslogtreecommitdiff
path: root/rsa.h
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2016-10-06 20:21:16 +0200
committertomsmeding <tom.smeding@gmail.com>2016-10-06 20:21:16 +0200
commitaa5365666bb17299035a3d857bcce962004bda1e (patch)
tree5381d1aa601812662eed0611c223785945502542 /rsa.h
parent053d2e76ad5848c8d95d7d56bfe7f8a6a324c229 (diff)
Base64 and import/export keys
Diffstat (limited to 'rsa.h')
-rw-r--r--rsa.h30
1 files changed, 21 insertions, 9 deletions
diff --git a/rsa.h b/rsa.h
index ec3c349..abedf84 100644
--- a/rsa.h
+++ b/rsa.h
@@ -1,15 +1,27 @@
#pragma once
+#include <string>
+#include <utility>
#include "bigint.h"
-struct PublicKey{
- Bigint mod,exp;
-};
+namespace RSA{
-struct PrivateKey{
- PublicKey pub;
- Bigint pexp;
-};
+ struct PublicKey{
+ Bigint mod,exp;
+ };
-Bigint encrypt(const PublicKey&,Bigint);
-Bigint decrypt(const PrivateKey&,Bigint);
+ struct PrivateKey{
+ PublicKey pub;
+ Bigint pexp;
+ };
+
+ Bigint encrypt(const PublicKey &key,Bigint msg);
+ Bigint decrypt(const PrivateKey &key,Bigint msg);
+
+ PrivateKey genkey(int nbits); //nbits is target number of bits of modulus
+ PrivateKey genkey(int nbits,const std::string &password); //generates key seeded by password
+
+ std::pair<std::string,std::string> exportkey(const PrivateKey&); //returns {pub,priv}
+ PrivateKey importkey(const std::string &pub,const std::string &priv);
+
+}