В SC2 было так, но скорее всего сиды уже сменили... Ну и sessionKey тут не вововский помоему, а батлнетовский (64 байта):
Код:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using WoWSniff.Cryptology;
namespace WoWSniff.BattleNet
{
public class BNetCrypt
{
private static readonly byte[] EncryptServerDataSeed =
{ 0x68, 0xE0, 0xC7, 0x2E, 0xDD, 0xD6, 0xD2, 0xF3,
0x1E, 0x5A, 0xB1, 0x55, 0xB1, 0x8B, 0x63, 0x1E };
private static readonly byte[] DecryptClientDataSeed =
{ 0xDE, 0xA9, 0x65, 0xAE, 0x54, 0x3A, 0x1E, 0x93,
0x9E, 0x69, 0x0C, 0xAA, 0x68, 0xDE, 0x78, 0x39 };
/// <summary>
/// Encrypts data sent to the client
/// </summary>
private readonly ARC4 _encryptServerData;
/// <summary>
/// Decrypts data sent from the client
/// </summary>
private readonly ARC4 _decryptClientData;
public bool EncryptionEnabled { get; set; }
public byte[] SessionKey { get; set; }
public BNetCrypt(byte[] sessionKey)
{
EncryptionEnabled = false;
SessionKey = sessionKey;
var sessionKeyHMAC = new HMACSHA256(sessionKey);
var encryptHash = sessionKeyHMAC.ComputeHash(EncryptServerDataSeed);
var decryptHash = sessionKeyHMAC.ComputeHash(DecryptClientDataSeed);
// Used by the client to decrypt packets sent by the server
//var decryptServerData = new ARC4(encryptHash); // CLIENT-SIDE
// Used by the server to decrypt packets sent by the client
_decryptClientData = new ARC4(decryptHash); // SERVER-SIDE
// Used by the server to encrypt packets sent to the client
_encryptServerData = new ARC4(encryptHash); // SERVER-SIDE
// Used by the client to encrypt packets sent to the server
//var encryptClientData = new ARC4(decryptHash); // CLIENT-SIDE
}
public void Decrypt(byte[] data, int start, int count)
{
_decryptClientData.Process(data, start, count);
}
public void Encrypt(byte[] data, int start, int count)
{
_encryptServerData.Process(data, start, count);
}
}
}