TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
WorldPackets::Auth::ConnectTo Class Referencefinal

#include <AuthenticationPackets.h>

Classes

struct  ConnectPayload
 

Public Member Functions

 ConnectTo ()
 
WorldPacket constWrite () override
 
- Public Member Functions inherited from WorldPackets::ServerPacket
 ServerPacket (OpcodeServer opcode, size_t initialSize=200, ConnectionType connection=CONNECTION_TYPE_DEFAULT)
 
void Read () overridefinal
 
void Clear ()
 
WorldPacket && Move ()
 
OpcodeServer GetOpcode () const
 
- Public Member Functions inherited from WorldPackets::Packet
 Packet (WorldPacket &&worldPacket)
 
virtual ~Packet ()=default
 
 Packet (Packet const &right)=delete
 
Packetoperator= (Packet const &right)=delete
 
WorldPacket constGetRawPacket () const
 
size_t GetSize () const
 
ConnectionType GetConnection () const
 

Public Attributes

uint64 Key = 0
 
ConnectToSerial Serial = ConnectToSerial::None
 
ConnectPayload Payload
 
uint8 Con = 0
 

Private Attributes

BigNumber p
 
BigNumber q
 
BigNumber dmp1
 
BigNumber dmq1
 
BigNumber iqmp
 

Static Private Attributes

static std::string const Haiku
 
static uint8 const PiDigits [130]
 

Additional Inherited Members

- Protected Attributes inherited from WorldPackets::Packet
WorldPacket _worldPacket
 

Constructor & Destructor Documentation

WorldPackets::Auth::ConnectTo::ConnectTo ( )
293  : ServerPacket(SMSG_CONNECT_TO, 8 + 4 + 256 + 1)
294 {
295  HexStrToByteArray("F41DCB2D728CF3337A4FF338FA89DB01BBBE9C3B65E9DA96268687353E48B94C", Payload.PanamaKey);
296  Payload.Adler32 = 0xA0A66C10;
297 
298  p.SetBinary(P, 128);
299  q.SetBinary(Q, 128);
300  dmp1.SetBinary(DP, 128);
301  dmq1.SetBinary(DQ, 128);
302  iqmp.SetBinary(InverseQ, 128);
303 }
uint8 const InverseQ[]
Definition: AuthenticationPackets.cpp:273
ServerPacket(OpcodeServer opcode, size_t initialSize=200, ConnectionType connection=CONNECTION_TYPE_DEFAULT)
Definition: Packet.h:49
BigNumber dmp1
Definition: AuthenticationPackets.h:171
uint8 PanamaKey[32]
Definition: AuthenticationPackets.h:155
BigNumber dmq1
Definition: AuthenticationPackets.h:172
Definition: Opcodes.h:924
BigNumber iqmp
Definition: AuthenticationPackets.h:173
void SetBinary(uint8 const *bytes, int32 len)
Definition: BigNumber.cpp:57
BigNumber p
Definition: AuthenticationPackets.h:169
void HexStrToByteArray(std::string const &str, uint8 *out, bool reverse)
Definition: Util.cpp:533
BigNumber q
Definition: AuthenticationPackets.h:170
uint8 const DP[]
Definition: AuthenticationPackets.cpp:249
uint8 const DQ[]
Definition: AuthenticationPackets.cpp:261
ConnectPayload Payload
Definition: AuthenticationPackets.h:165
uint8 const P[]
Definition: AuthenticationPackets.cpp:225
uint32 Adler32
Definition: AuthenticationPackets.h:153
uint8 const Q[]
Definition: AuthenticationPackets.cpp:237

+ Here is the call graph for this function:

Member Function Documentation

WorldPacket const * WorldPackets::Auth::ConnectTo::Write ( )
overridevirtual

Implements WorldPackets::Packet.

306 {
307  ByteBuffer payload;
308  uint16 port = Payload.Where.port();
309  uint8 address[16] = { 0 };
310  uint8 addressType = 3;
311  if (Payload.Where.address().is_v4())
312  {
313  memcpy(address, Payload.Where.address().to_v4().to_bytes().data(), 4);
314  addressType = 1;
315  }
316  else
317  {
318  memcpy(address, Payload.Where.address().to_v6().to_bytes().data(), 16);
319  addressType = 2;
320  }
321 
322  HmacSha1 hmacHash(64, WherePacketHmac);
323  hmacHash.UpdateData(address, 16);
324  hmacHash.UpdateData(&addressType, 1);
325  hmacHash.UpdateData((uint8* const)&port, 2);
326  hmacHash.UpdateData((uint8* const)Haiku.c_str(), 71);
327  hmacHash.UpdateData(Payload.PanamaKey, 32);
328  hmacHash.UpdateData(PiDigits, 108);
329  hmacHash.UpdateData(&Payload.XorMagic, 1);
330  hmacHash.Finalize();
331 
332  payload << uint32(Payload.Adler32);
333  payload << uint8(addressType);
334  payload.append(address, 16);
335  payload << uint16(port);
336  payload.append(Haiku.data(), 71);
337  payload.append(Payload.PanamaKey, 32);
338  payload.append(PiDigits, 108);
339  payload << uint8(Payload.XorMagic);
340  payload.append(hmacHash.GetDigest(), hmacHash.GetLength());
341 
342  BigNumber bnData;
343  bnData.SetBinary(payload.contents(), payload.size());
344 
345  BigNumber m1 = (bnData % p).ModExp(dmp1, p);
346  BigNumber m2 = (bnData % q).ModExp(dmq1, q);
347  BigNumber h = (iqmp * (m1 - m2)) % p;
348  // Be sure to use the positive remainder
349  if (h.IsNegative())
350  h += p;
351 
352  BigNumber m = m2 + h * q;
353 
354  _worldPacket << uint64(Key);
356  _worldPacket.append(m.AsByteArray(256).get(), 256);
357  _worldPacket << uint8(Con);
358  return &_worldPacket;
359 }
Definition: BigNumber.h:28
uint8 * contents()
Definition: ByteBuffer.h:573
Definition: ByteBuffer.h:70
BigNumber dmp1
Definition: AuthenticationPackets.h:171
uint8 PanamaKey[32]
Definition: AuthenticationPackets.h:155
static std::string const Haiku
Definition: AuthenticationPackets.h:147
BigNumber dmq1
Definition: AuthenticationPackets.h:172
uint8 const WherePacketHmac[]
Definition: AuthenticationPackets.cpp:285
uint64_t uint64
Definition: g3dmath.h:170
BigNumber iqmp
Definition: AuthenticationPackets.h:173
void SetBinary(uint8 const *bytes, int32 len)
Definition: BigNumber.cpp:57
Definition: HmacHash.h:34
WorldPacket _worldPacket
Definition: Packet.h:43
uint16_t uint16
Definition: g3dmath.h:166
uint64 Key
Definition: AuthenticationPackets.h:163
BigNumber p
Definition: AuthenticationPackets.h:169
bool IsNegative() const
Definition: BigNumber.cpp:172
BigNumber q
Definition: AuthenticationPackets.h:170
size_t size() const
Definition: ByteBuffer.h:587
ConnectToSerial Serial
Definition: AuthenticationPackets.h:164
uint16_t uint16
Definition: Define.h:151
static uint8 const PiDigits[130]
Definition: AuthenticationPackets.h:148
uint8 Con
Definition: AuthenticationPackets.h:166
void append(T value)
Definition: ByteBuffer.h:143
uint8_t uint8
Definition: g3dmath.h:164
std::unique_ptr< uint8[]> AsByteArray(int32 minSize=0, bool littleEndian=true)
Definition: BigNumber.cpp:177
ConnectPayload Payload
Definition: AuthenticationPackets.h:165
uint8_t uint8
Definition: Define.h:152
uint32_t uint32
Definition: g3dmath.h:168
tcp::endpoint Where
Definition: AuthenticationPackets.h:152
uint32 Adler32
Definition: AuthenticationPackets.h:153
uint8 XorMagic
Definition: AuthenticationPackets.h:154

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

uint8 WorldPackets::Auth::ConnectTo::Con = 0
BigNumber WorldPackets::Auth::ConnectTo::dmp1
private
BigNumber WorldPackets::Auth::ConnectTo::dmq1
private
std::string const WorldPackets::Auth::ConnectTo::Haiku
staticprivate
BigNumber WorldPackets::Auth::ConnectTo::iqmp
private
uint64 WorldPackets::Auth::ConnectTo::Key = 0
BigNumber WorldPackets::Auth::ConnectTo::p
private
ConnectPayload WorldPackets::Auth::ConnectTo::Payload
uint8 const WorldPackets::Auth::ConnectTo::PiDigits
staticprivate
Initial value:
=
{
0x31, 0x41, 0x59, 0x26, 0x53, 0x58, 0x97, 0x93, 0x23, 0x84,
0x62, 0x64, 0x33, 0x83, 0x27, 0x95, 0x02, 0x88, 0x41, 0x97,
0x16, 0x93, 0x99, 0x37, 0x51, 0x05, 0x82, 0x09, 0x74, 0x94,
0x45, 0x92, 0x30, 0x78, 0x16, 0x40, 0x62, 0x86, 0x20, 0x89,
0x98, 0x62, 0x80, 0x34, 0x82, 0x53, 0x42, 0x11, 0x70, 0x67,
0x98, 0x21, 0x48, 0x08, 0x65, 0x13, 0x28, 0x23, 0x06, 0x64,
0x70, 0x93, 0x84, 0x46, 0x09, 0x55, 0x05, 0x82, 0x23, 0x17,
0x25, 0x35, 0x94, 0x08, 0x12, 0x84, 0x81, 0x11, 0x74, 0x50,
0x28, 0x41, 0x02, 0x70, 0x19, 0x38, 0x52, 0x11, 0x05, 0x55,
0x96, 0x44, 0x62, 0x29, 0x48, 0x95, 0x49, 0x30, 0x38, 0x19,
0x64, 0x42, 0x88, 0x10, 0x97, 0x56, 0x65, 0x93, 0x34, 0x46,
0x12, 0x84, 0x75, 0x64, 0x82, 0x33, 0x78, 0x67, 0x83, 0x16,
0x52, 0x71, 0x20, 0x19, 0x09, 0x14, 0x56, 0x48, 0x56, 0x69,
}
BigNumber WorldPackets::Auth::ConnectTo::q
private
ConnectToSerial WorldPackets::Auth::ConnectTo::Serial = ConnectToSerial::None

The documentation for this class was generated from the following files: