aboutsummaryrefslogtreecommitdiff
path: root/rsa.h
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2016-10-08 22:03:52 +0200
committertomsmeding <tom.smeding@gmail.com>2016-10-08 22:03:52 +0200
commitd6cc28665d2025afba1f3701a486927f0b3a51da (patch)
tree86e6723fda17b705bb2cc61abc7c1ffd43463706 /rsa.h
parent93b1a18fd61890eb4976a7f52d17e0990ccca661 (diff)
Lots of renaming (mainly {Public,Private}Key -> Key)
Diffstat (limited to 'rsa.h')
-rw-r--r--rsa.h19
1 files changed, 8 insertions, 11 deletions
diff --git a/rsa.h b/rsa.h
index f931ab3..bed8400 100644
--- a/rsa.h
+++ b/rsa.h
@@ -6,22 +6,19 @@
namespace RSA{
- struct PublicKey{
+ struct Key{
Bigint mod,exp;
};
- struct PrivateKey{
- PublicKey pub;
- Bigint pexp;
- };
+ Bigint encrypt(Bigint msg,const Key &key);
+ Bigint decrypt(Bigint msg,const Key &key);
- Bigint encrypt(Bigint msg,const PublicKey &key);
- Bigint decrypt(Bigint msg,const PrivateKey &key);
+ std::pair<Key,Key> genkeys(int nbits); //nbits is target number of bits of modulus
+ std::pair<Key,Key> genkeys(int nbits,const std::string &password); //generates keys seeded by password
- 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::string exportKey(const Key&);
- std::pair<std::string,std::string> exportkey(const PrivateKey&); //returns {pub,priv}
- PrivateKey importkey(const std::string &pub,const std::string &priv);
+ //throws invalid_argument if the imported key is of invalid format
+ Key importKey(const std::string &repr);
}