diff options
Diffstat (limited to 'src/server/shared')
| -rw-r--r-- | src/server/shared/Packets/ByteBuffer.h | 13 | ||||
| -rw-r--r-- | src/server/shared/Realm/RealmList.cpp | 11 |
2 files changed, 18 insertions, 6 deletions
diff --git a/src/server/shared/Packets/ByteBuffer.h b/src/server/shared/Packets/ByteBuffer.h index 296da13dafe..13d77b41c14 100644 --- a/src/server/shared/Packets/ByteBuffer.h +++ b/src/server/shared/Packets/ByteBuffer.h @@ -20,6 +20,7 @@ #include "Define.h" #include "ByteConverter.h" +#include <array> #include <string> #include <vector> #include <cstring> @@ -472,6 +473,12 @@ class TC_SHARED_API ByteBuffer _rpos += len; } + template <size_t Size> + void read(std::array<uint8, Size>& arr) + { + read(arr.data(), Size); + } + void ReadPackedUInt64(uint64& guid) { guid = 0; @@ -564,6 +571,12 @@ class TC_SHARED_API ByteBuffer append(buffer.contents(), buffer.size()); } + template <size_t Size> + void append(std::array<uint8, Size> const& arr) + { + append(arr.data(), Size); + } + // can be used in SMSG_MONSTER_MOVE opcode void appendPackXYZ(float x, float y, float z) { diff --git a/src/server/shared/Realm/RealmList.cpp b/src/server/shared/Realm/RealmList.cpp index ca591e423f5..5673636eb28 100644 --- a/src/server/shared/Realm/RealmList.cpp +++ b/src/server/shared/Realm/RealmList.cpp @@ -17,7 +17,7 @@ #include "RealmList.h" #include "BattlenetRpcErrorCodes.h" -#include "BigNumber.h" +#include "CryptoRandom.h" #include "DatabaseEnv.h" #include "DeadlineTimer.h" #include "Errors.h" @@ -404,15 +404,14 @@ uint32 RealmList::JoinRealm(uint32 realmAddress, uint32 build, boost::asio::ip:: if (compress(compressed.data() + 4, &compressedLength, reinterpret_cast<uint8 const*>(json.c_str()), uLong(json.length() + 1)) != Z_OK) return ERROR_UTIL_SERVER_FAILED_TO_SERIALIZE_RESPONSE; - BigNumber serverSecret; - serverSecret.SetRand(8 * 32); + std::array<uint8, 32> serverSecret = Trinity::Crypto::GetRandomBytes<32>(); std::array<uint8, 64> keyData; memcpy(&keyData[0], clientSecret.data(), 32); - memcpy(&keyData[32], serverSecret.AsByteArray(32).get(), 32); + memcpy(&keyData[32], serverSecret.data(), 32); LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_BNET_GAME_ACCOUNT_LOGIN_INFO); - stmt->setString(0, ByteArrayToHexStr(keyData.data(), keyData.size())); + stmt->setString(0, ByteArrayToHexStr(keyData)); stmt->setString(1, clientAddress.to_string()); stmt->setUInt8(2, locale); stmt->setString(3, os); @@ -429,7 +428,7 @@ uint32 RealmList::JoinRealm(uint32 realmAddress, uint32 build, boost::asio::ip:: attribute = response->add_attribute(); attribute->set_name("Param_JoinSecret"); - attribute->mutable_value()->set_blob_value(serverSecret.AsByteArray(32).get(), 32); + attribute->mutable_value()->set_blob_value(serverSecret.data(), 32); return ERROR_OK; } |
