aboutsummaryrefslogtreecommitdiff
path: root/rsa.h
diff options
context:
space:
mode:
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);
}