@@ -56,15 +56,15 @@ void WardenMac::Init(WorldSession* pClient, SessionKey const& K)
5656 _inputCrypto.Init (_inputKey);
5757 _outputCrypto.Init (_outputKey);
5858 TC_LOG_DEBUG (" warden" , " Server side warden for client %u initializing..." , pClient->GetAccountId ());
59- TC_LOG_DEBUG (" warden" , " C->S Key: %s" , ByteArrayToHexStr (_inputKey, 16 ).c_str ());
60- TC_LOG_DEBUG (" warden" , " S->C Key: %s" , ByteArrayToHexStr (_outputKey, 16 ).c_str ());
61- TC_LOG_DEBUG (" warden" , " Seed: %s" , ByteArrayToHexStr (_seed, 16 ).c_str ());
59+ TC_LOG_DEBUG (" warden" , " C->S Key: %s" , ByteArrayToHexStr (_inputKey).c_str ());
60+ TC_LOG_DEBUG (" warden" , " S->C Key: %s" , ByteArrayToHexStr (_outputKey).c_str ());
61+ TC_LOG_DEBUG (" warden" , " Seed: %s" , ByteArrayToHexStr (_seed).c_str ());
6262 TC_LOG_DEBUG (" warden" , " Loading Module..." );
6363
6464 _module = GetModuleForClient ();
6565
66- TC_LOG_DEBUG (" warden" , " Module Key: %s" , ByteArrayToHexStr (_module->Key , 16 ).c_str ());
67- TC_LOG_DEBUG (" warden" , " Module ID: %s" , ByteArrayToHexStr (_module->Id , 16 ).c_str ());
66+ TC_LOG_DEBUG (" warden" , " Module Key: %s" , ByteArrayToHexStr (_module->Key ).c_str ());
67+ TC_LOG_DEBUG (" warden" , " Module ID: %s" , ByteArrayToHexStr (_module->Id ).c_str ());
6868 RequestModule ();
6969}
7070
@@ -236,30 +236,23 @@ void WardenMac::HandleData(ByteBuffer &buff)
236236 Trinity::Crypto::SHA1 sha1;
237237 sha1.UpdateData (str);
238238 uint32 magic = 0xFEEDFACE ; // unsure
239- sha1.UpdateData (reinterpret_cast < uint8*>(magic) , 4 );
239+ sha1.UpdateData (( uint8*)&magic , 4 );
240240 sha1.Finalize ();
241241
242- uint8 sha1Hash[ 20 ] ;
243- buff.read (sha1Hash, 20 );
242+ std::array< uint8, Trinity::Crypto::SHA1::DIGEST_LENGTH> sha1Hash;
243+ buff.read (sha1Hash. data (), sha1Hash. size () );
244244
245- if (memcmp ( sha1Hash, sha1.GetDigest (). data (), 20 ) != 0 )
245+ if (sha1Hash != sha1.GetDigest ())
246246 {
247247 TC_LOG_DEBUG (" warden" , " Handle data failed: SHA1 hash is wrong!" );
248248 // found = true;
249249 }
250250
251- EVP_MD_CTX* mdctx = EVP_MD_CTX_new ();
252- EVP_DigestInit_ex (mdctx, EVP_md5 (), nullptr );
253- EVP_DigestUpdate (mdctx, str.c_str (), str.size ());
254- uint8 ourMD5Hash[16 ];
255- uint32 mg5DigestLength = EVP_MD_size (EVP_md5 ());
256- EVP_DigestFinal_ex (mdctx, ourMD5Hash, &mg5DigestLength);
257- EVP_MD_CTX_free (mdctx);
251+ std::array<uint8, 16 > ourMD5Hash = Trinity::Crypto::MD5::GetDigestOf (str);
252+ std::array<uint8, 16 > theirsMD5Hash;
253+ buff.read (theirsMD5Hash);
258254
259- uint8 theirsMD5Hash[16 ];
260- buff.read (theirsMD5Hash, 16 );
261-
262- if (memcmp (ourMD5Hash, theirsMD5Hash, 16 ) != 0 )
255+ if (ourMD5Hash != theirsMD5Hash)
263256 {
264257 TC_LOG_DEBUG (" warden" , " Handle data failed: MD5 hash is wrong!" );
265258 // found = true;
0 commit comments