mirror of
https://github.com/mangosfour/server.git
synced 2025-12-22 04:37:01 +00:00
Updated to 9658 client build, SMSG_ADDON_INFO temporary disabled
This commit is contained in:
parent
6aadc16d7d
commit
8f9849969b
19 changed files with 110 additions and 70 deletions
|
|
@ -35,19 +35,26 @@ void AuthCrypt::Init(BigNumber *K)
|
|||
HmacHash recvHash(SEED_KEY_SIZE, (uint8*)recvSeed);
|
||||
recvHash.UpdateBigNumber(K);
|
||||
recvHash.Finalize();
|
||||
_recvCrypt.Init(SHA_DIGEST_LENGTH, recvHash.GetDigest());
|
||||
|
||||
uint8 sendSeed[SEED_KEY_SIZE] = { 0xF4, 0x66, 0x31, 0x59, 0xFC, 0x83, 0x6E, 0x31, 0x31, 0x02, 0x51, 0xD5, 0x44, 0x31, 0x67, 0x98 };
|
||||
HmacHash sendHash(SEED_KEY_SIZE, (uint8*)sendSeed);
|
||||
sendHash.UpdateBigNumber(K);
|
||||
sendHash.Finalize();
|
||||
_sendCrypt.Init(SHA_DIGEST_LENGTH, sendHash.GetDigest());
|
||||
|
||||
uint8 emptyBuf[1000];
|
||||
memset(emptyBuf, 0, 1000);
|
||||
_recvCrypt.Init(recvHash.GetDigest(), sendHash.GetDigest());
|
||||
_sendCrypt.Init(recvHash.GetDigest(), sendHash.GetDigest());
|
||||
|
||||
_sendCrypt.Process(1000, (uint8*)emptyBuf, (uint8*)emptyBuf);
|
||||
_recvCrypt.Process(1000, (uint8*)emptyBuf, (uint8*)emptyBuf);
|
||||
uint8 emptyBuf1[1024];
|
||||
memset(emptyBuf1, 0, 1024);
|
||||
|
||||
_sendCrypt.Encrypt(1024, (uint8*)emptyBuf1);
|
||||
_sendCrypt.Decrypt(1024, (uint8*)emptyBuf1);
|
||||
|
||||
uint8 emptyBuf2[1024];
|
||||
memset(emptyBuf2, 0, 1024);
|
||||
|
||||
_recvCrypt.Encrypt(1024, (uint8*)emptyBuf2);
|
||||
_recvCrypt.Decrypt(1024, (uint8*)emptyBuf2);
|
||||
|
||||
_initialized = true;
|
||||
}
|
||||
|
|
@ -57,7 +64,7 @@ void AuthCrypt::DecryptRecv(uint8 *data, size_t len)
|
|||
if (!_initialized)
|
||||
return;
|
||||
|
||||
_recvCrypt.Process(len, data, data);
|
||||
_recvCrypt.Decrypt(len, data);
|
||||
}
|
||||
|
||||
void AuthCrypt::EncryptSend(uint8 *data, size_t len)
|
||||
|
|
@ -65,5 +72,5 @@ void AuthCrypt::EncryptSend(uint8 *data, size_t len)
|
|||
if (!_initialized)
|
||||
return;
|
||||
|
||||
_sendCrypt.Process(len, data, data);
|
||||
_sendCrypt.Encrypt(len, data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
#define _AUTHCRYPT_H
|
||||
|
||||
#include <Common.h>
|
||||
#include <vector>
|
||||
#include "SARC4.h"
|
||||
|
||||
class BigNumber;
|
||||
|
|
@ -38,8 +37,8 @@ class AuthCrypt
|
|||
bool IsInitialized() { return _initialized; }
|
||||
|
||||
private:
|
||||
SARC4 _sendCrypt;
|
||||
SARC4 _recvCrypt;
|
||||
SARC4 _sendCrypt;
|
||||
bool _initialized;
|
||||
};
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -23,14 +23,12 @@ HmacHash::HmacHash(uint32 len, uint8 *seed)
|
|||
{
|
||||
ASSERT(len == SEED_KEY_SIZE);
|
||||
|
||||
memcpy(&m_key, seed, len);
|
||||
HMAC_CTX_init(&m_ctx);
|
||||
HMAC_Init_ex(&m_ctx, &m_key, SEED_KEY_SIZE, EVP_sha1(), NULL);
|
||||
HMAC_Init_ex(&m_ctx, seed, SEED_KEY_SIZE, EVP_sha1(), NULL);
|
||||
}
|
||||
|
||||
HmacHash::~HmacHash()
|
||||
{
|
||||
memset(&m_key, 0x00, SEED_KEY_SIZE);
|
||||
HMAC_CTX_cleanup(&m_ctx);
|
||||
}
|
||||
|
||||
|
|
@ -44,11 +42,6 @@ void HmacHash::UpdateData(const uint8 *data, int length)
|
|||
HMAC_Update(&m_ctx, data, length);
|
||||
}
|
||||
|
||||
void HmacHash::Initialize()
|
||||
{
|
||||
HMAC_Init_ex(&m_ctx, &m_key, SEED_KEY_SIZE, EVP_sha1(), NULL);
|
||||
}
|
||||
|
||||
void HmacHash::Finalize()
|
||||
{
|
||||
uint32 length = 0;
|
||||
|
|
|
|||
|
|
@ -34,13 +34,11 @@ class HmacHash
|
|||
~HmacHash();
|
||||
void UpdateBigNumber(BigNumber *bn);
|
||||
void UpdateData(const uint8 *data, int length);
|
||||
void Initialize();
|
||||
void Finalize();
|
||||
uint8 *GetDigest() { return m_digest; };
|
||||
int GetLength() { return SHA_DIGEST_LENGTH; };
|
||||
private:
|
||||
HMAC_CTX m_ctx;
|
||||
uint8 m_key[SEED_KEY_SIZE];
|
||||
uint8 m_digest[SHA_DIGEST_LENGTH];
|
||||
};
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -17,14 +17,40 @@
|
|||
*/
|
||||
|
||||
#include "Auth/SARC4.h"
|
||||
#include "BigNumber.h"
|
||||
#include <openssl/sha.h>
|
||||
|
||||
void SARC4::Init(uint32 len, uint8 *seed)
|
||||
SARC4::SARC4()
|
||||
{
|
||||
RC4_set_key(&m_rc4_key, len, seed);
|
||||
EVP_CIPHER_CTX_init(&m_encryptctx);
|
||||
EVP_EncryptInit_ex(&m_encryptctx, EVP_rc4(), NULL, NULL, NULL);
|
||||
EVP_CIPHER_CTX_set_key_length(&m_encryptctx, SHA_DIGEST_LENGTH);
|
||||
EVP_CIPHER_CTX_init(&m_decryptctx);
|
||||
EVP_DecryptInit_ex(&m_decryptctx, EVP_rc4(), NULL, NULL, NULL);
|
||||
EVP_CIPHER_CTX_set_key_length(&m_decryptctx, SHA_DIGEST_LENGTH);
|
||||
}
|
||||
|
||||
void SARC4::Process(uint32 len, uint8 *indata, uint8 *outdata)
|
||||
SARC4::~SARC4()
|
||||
{
|
||||
RC4(&m_rc4_key, len, indata, outdata);
|
||||
EVP_CIPHER_CTX_cleanup(&m_encryptctx);
|
||||
EVP_CIPHER_CTX_cleanup(&m_decryptctx);
|
||||
}
|
||||
|
||||
void SARC4::Init(uint8 *seed1, uint8 *seed2)
|
||||
{
|
||||
EVP_EncryptInit_ex(&m_encryptctx, NULL, NULL, seed1, NULL);
|
||||
EVP_DecryptInit_ex(&m_decryptctx, NULL, NULL, seed2, NULL);
|
||||
}
|
||||
|
||||
void SARC4::Encrypt(uint32 len, uint8 *data)
|
||||
{
|
||||
int outlen = 0;
|
||||
EVP_EncryptUpdate(&m_encryptctx, data, &outlen, data, len);
|
||||
EVP_EncryptFinal_ex(&m_encryptctx, data, &outlen);
|
||||
}
|
||||
|
||||
void SARC4::Decrypt(uint32 len, uint8 *data)
|
||||
{
|
||||
int outlen = 0;
|
||||
EVP_DecryptUpdate(&m_decryptctx, data, &outlen, data, len);
|
||||
EVP_DecryptFinal_ex(&m_decryptctx, data, &outlen);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,19 +20,18 @@
|
|||
#define _AUTH_SARC4_H
|
||||
|
||||
#include "Common.h"
|
||||
#include <openssl/rc4.h>
|
||||
#include <openssl/sha.h>
|
||||
|
||||
class BigNumber;
|
||||
|
||||
#define SEED_KEY_SIZE 16
|
||||
#include <openssl/evp.h>
|
||||
|
||||
class SARC4
|
||||
{
|
||||
public:
|
||||
void Init(uint32 len, uint8 *seed);
|
||||
void Process(uint32 len, uint8 *indata, uint8 *outdata);
|
||||
SARC4();
|
||||
~SARC4();
|
||||
void Init(uint8 *seed1, uint8 *seed2);
|
||||
void Encrypt(uint32 len, uint8 *data);
|
||||
void Decrypt(uint32 len, uint8 *data);
|
||||
private:
|
||||
RC4_KEY m_rc4_key;
|
||||
EVP_CIPHER_CTX m_encryptctx;
|
||||
EVP_CIPHER_CTX m_decryptctx;
|
||||
};
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue