* Add Crypt for 2.4.3

This commit is contained in:
shlainn 2011-09-25 22:55:26 +02:00
parent 22f11c1810
commit e2950efbe6
3 changed files with 37 additions and 4 deletions

View File

@ -84,7 +84,7 @@ void WorldSocket::OnRead()
break;
}
if(GetSession()->GetInstance()->GetConf()->client > CLIENT_CLASSIC_WOW)
if(GetSession()->GetInstance()->GetConf()->client > CLIENT_TBC)//Funny, old sources have this in TBC already...
{
// read first byte and check if size is 3 or 2 bytes
uint8 firstSizeByte;
@ -115,8 +115,8 @@ void WorldSocket::OnRead()
else
{
ServerPktHeader hdr;
ibuf.Read(((char*)&hdr), sizeof(ServerPktHeader)); // read header, except first byte
(_crypt.*pDecryptRecv)(((uint8*)&hdr), sizeof(ServerPktHeader)); // decrypt all except first
ibuf.Read(((char*)&hdr), sizeof(ServerPktHeader)); // read header
(_crypt.*pDecryptRecv)(((uint8*)&hdr), sizeof(ServerPktHeader)); // decrypt all
_remaining = ntohs(hdr.size) - 2;
_opcode = hdr.cmd;
@ -176,7 +176,15 @@ void WorldSocket::InitCrypt(BigNumber *k)
pEncryptSend = &AuthCrypt::EncryptSend_6005;
break;
}
default:
case CLIENT_TBC:
{
logdebug("Setting Crypt to Build 8606");
pInit = &AuthCrypt::Init_8606;
pDecryptRecv = &AuthCrypt::DecryptRecv_6005;
pEncryptSend = &AuthCrypt::EncryptSend_6005;
break;
}
case CLIENT_WOTLK:
{
logdebug("Setting Crypt to Build 12340");
pInit = &AuthCrypt::Init_12340;
@ -184,6 +192,9 @@ void WorldSocket::InitCrypt(BigNumber *k)
pEncryptSend = &AuthCrypt::EncryptSend_12340;
break;
}
default:
logerror("Error setting up Crypt - will crash now (check conf)");
break;
}
(_crypt.*pInit)(k);
const char *hexstr = k->AsHexStr();

View File

@ -78,6 +78,25 @@ void AuthCrypt::EncryptSend_12340(uint8 *data, size_t len)
}
void AuthCrypt::Init_8606(BigNumber *K)
{
uint8 *key = new uint8[SHA_DIGEST_LENGTH];
uint8 recvSeed[SEED_KEY_SIZE] = { 0x38, 0xA7, 0x83, 0x15, 0xF8, 0x92, 0x25, 0x30, 0x71, 0x98, 0x67, 0xB1, 0x8C, 0x4, 0xE2, 0xAA };
HmacHash recvHash(SEED_KEY_SIZE, (uint8*)recvSeed);
recvHash.UpdateBigNumber(K);
recvHash.Finalize();
memcpy(key, recvHash.GetDigest(), SHA_DIGEST_LENGTH);
_key.resize(SHA_DIGEST_LENGTH);
std::copy(key, key + SHA_DIGEST_LENGTH, _key.begin());
delete[] key;
_send_i = _send_j = _recv_i = _recv_j = 0;
_initialized = true;
}
//1.12.2
void AuthCrypt::Init_6005(BigNumber *K)
{

View File

@ -39,6 +39,9 @@ class AuthCrypt
void DecryptRecv_12340(uint8 *, size_t);
void EncryptSend_12340(uint8 *, size_t);
//2.4.3
void Init_8606(BigNumber *K);
//1.12.X
void Init_6005(BigNumber *K);
void SetKey_6005(uint8 *, size_t);