Add flexibility in login packets

* It's now possible to add custom data in the login packet
* Add utility funciton to generate RSA keys
* Make the protocol able to use RSA keys with 2048 bits or more
This commit is contained in:
Eduardo Bart
2013-01-28 20:52:03 -02:00
parent 6c7a163197
commit b7eef97239
17 changed files with 84 additions and 103 deletions

View File

@@ -89,12 +89,14 @@ void OutputMessage::addPaddingBytes(int bytes, uint8 byte)
m_messageSize += bytes;
}
void OutputMessage::encryptRsa(int size)
void OutputMessage::encryptRsa()
{
int size = g_crypt.rsaGetSize();
if(m_messageSize < size)
throw stdext::exception("insufficient bytes in buffer to encrypt");
g_crypt.rsaEncrypt((unsigned char*)m_buffer + m_writePos - size, size);
if(!g_crypt.rsaEncrypt((unsigned char*)m_buffer + m_writePos - size, size))
throw stdext::exception("rsa encryption failed");
}
void OutputMessage::writeChecksum()

View File

@@ -49,7 +49,7 @@ public:
void addString(const std::string& buffer);
void addPaddingBytes(int bytes, uint8 byte = 0);
void encryptRsa(int size);
void encryptRsa();
uint16 getWritePos() { return m_writePos; }
uint16 getMessageSize() { return m_messageSize; }