Core/PacketIO: Updated packet structures to 9.2.7

Port From (https://github.com/TrinityCore/TrinityCore/commit/20f38369f30309e2c0cd53eca9cfe9c49376ed8c)
This commit is contained in:
hondacrx
2022-08-17 14:37:34 -04:00
parent 6efbe4b00e
commit cacfc06088
66 changed files with 6038 additions and 23 deletions
@@ -17,13 +17,13 @@
using Framework.Constants;
using Framework.Cryptography;
using Framework.Dynamic;
using Framework.Cryptography.Ed25519;
using Framework.IO;
using Game.DataStorage;
using System;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Linq;
using System.Security.Cryptography;
namespace Game.Networking.Packets
{
@@ -365,8 +365,23 @@ namespace Game.Networking.Packets
{
byte[] EncryptionKey;
bool Enabled;
static byte[] expandedPrivateKey;
static byte[] EnableEncryptionSeed = { 0x90, 0x9C, 0xD0, 0x50, 0x5A, 0x2C, 0x14, 0xDD, 0x5C, 0x2C, 0xC0, 0x64, 0x14, 0xF3, 0xFE, 0xC9 };
static byte[] EnableEncryptionContext = { 0xA7, 0x1F, 0xB6, 0x9B, 0xC9, 0x7C, 0xDD, 0x96, 0xE9, 0xBB, 0xB8, 0x21, 0x39, 0x8D, 0x5A, 0xD4 };
static byte[] EnterEncryptedModePrivateKey =
{
0x08, 0xBD, 0xC7, 0xA3, 0xCC, 0xC3, 0x4F, 0x3F,
0x6A, 0x0B, 0xFF, 0xCF, 0x31, 0xC1, 0xB6, 0x97,
0x69, 0x1E, 0x72, 0x9A, 0x0A, 0xAB, 0x2C, 0x77,
0xC3, 0x6F, 0x8A, 0xE7, 0x5A, 0x9A, 0xA7, 0xC9
};
static EnterEncryptedMode()
{
expandedPrivateKey = Ed25519.ExpandedPrivateKeyFromSeed(EnterEncryptedModePrivateKey);
}
public EnterEncryptedMode(byte[] encryptionKey, bool enabled) : base(ServerOpcodes.EnterEncryptedMode)
{
@@ -376,11 +391,11 @@ namespace Game.Networking.Packets
public override void Write()
{
HmacSha256 hash = new(EncryptionKey);
hash.Process(BitConverter.GetBytes(Enabled), 1);
hash.Finish(EnableEncryptionSeed, 16);
HmacSha256 toSign = new(EncryptionKey);
toSign.Process(BitConverter.GetBytes(Enabled), 1);
toSign.Finish(EnableEncryptionSeed, 16);
_worldPacket.WriteBytes(RsaCrypt.RSA.SignHash(hash.Digest, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1).Reverse().ToArray());
_worldPacket.WriteBytes(Ed25519.Sign(toSign.Digest, expandedPrivateKey, 0, EnableEncryptionContext));
_worldPacket.WriteBit(Enabled);
_worldPacket.FlushBits();
}