rework on dat and spr loader

This commit is contained in:
Eduardo Bart
2011-08-15 16:15:49 -03:00
parent b21ccd16f9
commit 2e1a96c2df
43 changed files with 191 additions and 581 deletions

View File

@@ -23,25 +23,6 @@ Rsa::~Rsa()
mpz_clear(m_mod);
}
bool Rsa::setKey(const std::string& file)
{
//loads p,q and d from a file
FILE* f = fopen(file.c_str(), "r");
if(!f){
return false;
}
char p[512];
char q[512];
char d[512];
delete fgets(p, 512, f);
delete fgets(q, 512, f);
delete fgets(d, 512, f);
setKey(p, q, d);
return true;
}
void Rsa::setKey(const char* p, const char* q, const char* d)
{
mpz_set_str(m_p, p, 10);

View File

@@ -9,8 +9,8 @@ class Rsa
public:
Rsa();
~Rsa();
void setKey(const char* p, const char* q, const char* d);
bool setKey(const std::string& file);
bool decrypt(char* msg, int32_t size);
static bool encrypt(char* msg, int32_t size, const char* key);
@@ -20,6 +20,4 @@ protected:
mpz_t m_p, m_q, m_u, m_d, m_dp, m_dq, m_mod;
};
typedef std::shared_ptr<Rsa> RsaPtr;
#endif //RSA_H
#endif