Removed GMP and added OpenSSL. Rsa class might be moved to Crypto later.

This commit is contained in:
Henrique Santiago
2012-08-03 13:01:45 -03:00
parent fa27210d7f
commit 4e0642c814
9 changed files with 125 additions and 100 deletions

View File

@@ -86,10 +86,13 @@ std::string InputMessage::getString()
return std::string(v, stringLength);
}
bool InputMessage::decryptRsa(int size, const std::string& p, const std::string& q, const std::string& d)
bool InputMessage::decryptRsa(int size, const std::string& key, const std::string& p, const std::string& q, const std::string& d)
{
checkRead(size);
RSA::decrypt((char*)m_buffer + m_readPos, size, p.c_str(), q.c_str(), d.c_str());
g_rsa.setPublic(key.c_str(), "65537");
g_rsa.setPrivate(p.c_str(), q.c_str(), d.c_str());
g_rsa.check();
g_rsa.decrypt((unsigned char*)m_buffer + m_readPos, size);
return (getU8() == 0x00);
}

View File

@@ -52,7 +52,7 @@ public:
uint32 peekU32() { uint32 v = getU32(); m_readPos-=4; return v; }
uint64 peekU64() { uint64 v = getU64(); m_readPos-=8; return v; }
bool decryptRsa(int size, const std::string& p, const std::string& q, const std::string& d);
bool decryptRsa(int size, const std::string& key, const std::string& p, const std::string& q, const std::string& d);
int getReadSize() { return m_readPos - m_headerPos; }
int getReadPos() { return m_readPos; }

View File

@@ -94,7 +94,8 @@ void OutputMessage::encryptRsa(int size, const std::string& key)
if(m_messageSize < size)
throw stdext::exception("insufficient bytes in buffer to encrypt");
RSA::encrypt((char*)m_buffer + m_writePos - size, size, key.c_str());
g_rsa.setPublic(key.c_str(), "65537");
g_rsa.encrypt((unsigned char*)m_buffer + m_writePos - size, size);
}
void OutputMessage::writeChecksum()