mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-16 16:56:07 +00:00
refactor(src/common): remove unused imports (#19506)
* refactor(src/common): remove unused imports * fix: build * chore: fix build * chore: size_t -> std::size_t * chore: fix fuckup from previous commit * chore: fix build * chore: fix build * chore: fix build * chore: fix build with std::size_t * chore: fix build * chore: fix build * chore: fix build * chore: fix build * chore: fix build * chore: fix build * chore: fix build * chore: fix build * chore: fix build * chore: fix build * chore: fix build * chore: fix build
This commit is contained in:
@@ -37,7 +37,7 @@ void Acore::Crypto::AES::Init(Key const& key)
|
||||
ASSERT(status);
|
||||
}
|
||||
|
||||
bool Acore::Crypto::AES::Process(IV const& iv, uint8* data, size_t length, Tag& tag)
|
||||
bool Acore::Crypto::AES::Process(IV const& iv, uint8* data, std::size_t length, Tag& tag)
|
||||
{
|
||||
ASSERT(length <= static_cast<size_t>(std::numeric_limits<int>::max()));
|
||||
int len = static_cast<int>(length);
|
||||
|
||||
@@ -27,9 +27,9 @@ namespace Acore::Crypto
|
||||
class AC_COMMON_API AES
|
||||
{
|
||||
public:
|
||||
static constexpr size_t IV_SIZE_BYTES = 12;
|
||||
static constexpr size_t KEY_SIZE_BYTES = 16;
|
||||
static constexpr size_t TAG_SIZE_BYTES = 12;
|
||||
static constexpr std::size_t IV_SIZE_BYTES = 12;
|
||||
static constexpr std::size_t KEY_SIZE_BYTES = 16;
|
||||
static constexpr std::size_t TAG_SIZE_BYTES = 12;
|
||||
|
||||
using IV = std::array<uint8, IV_SIZE_BYTES>;
|
||||
using Key = std::array<uint8, KEY_SIZE_BYTES>;
|
||||
@@ -40,7 +40,7 @@ namespace Acore::Crypto
|
||||
|
||||
void Init(Key const& key);
|
||||
|
||||
bool Process(IV const& iv, uint8* data, size_t length, Tag& tag);
|
||||
bool Process(IV const& iv, uint8* data, std::size_t length, Tag& tag);
|
||||
|
||||
private:
|
||||
EVP_CIPHER_CTX* _ctx;
|
||||
|
||||
@@ -40,7 +40,7 @@ Acore::Crypto::ARC4::~ARC4()
|
||||
#endif
|
||||
}
|
||||
|
||||
void Acore::Crypto::ARC4::Init(uint8 const* seed, size_t len)
|
||||
void Acore::Crypto::ARC4::Init(uint8 const* seed, std::size_t len)
|
||||
{
|
||||
int result1 = EVP_CIPHER_CTX_set_key_length(_ctx, len);
|
||||
ASSERT(result1 == 1);
|
||||
@@ -48,7 +48,7 @@ void Acore::Crypto::ARC4::Init(uint8 const* seed, size_t len)
|
||||
ASSERT(result2 == 1);
|
||||
}
|
||||
|
||||
void Acore::Crypto::ARC4::UpdateData(uint8* data, size_t len)
|
||||
void Acore::Crypto::ARC4::UpdateData(uint8* data, std::size_t len)
|
||||
{
|
||||
int outlen = 0;
|
||||
int result1 = EVP_EncryptUpdate(_ctx, data, &outlen, data, len);
|
||||
|
||||
@@ -30,12 +30,12 @@ namespace Acore::Crypto
|
||||
ARC4();
|
||||
~ARC4();
|
||||
|
||||
void Init(uint8 const* seed, size_t len);
|
||||
void Init(uint8 const* seed, std::size_t len);
|
||||
|
||||
template <typename Container>
|
||||
void Init(Container const& c) { Init(std::data(c), std::size(c)); }
|
||||
|
||||
void UpdateData(uint8* data, size_t len);
|
||||
void UpdateData(uint8* data, std::size_t len);
|
||||
|
||||
template <typename Container>
|
||||
void UpdateData(Container& c) { UpdateData(std::data(c), std::size(c)); }
|
||||
|
||||
@@ -35,13 +35,13 @@ void AuthCrypt::Init(SessionKey const& K)
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
void AuthCrypt::DecryptRecv(uint8* data, size_t len)
|
||||
void AuthCrypt::DecryptRecv(uint8* data, std::size_t len)
|
||||
{
|
||||
ASSERT(_initialized);
|
||||
_clientDecrypt.UpdateData(data, len);
|
||||
}
|
||||
|
||||
void AuthCrypt::EncryptSend(uint8* data, size_t len)
|
||||
void AuthCrypt::EncryptSend(uint8* data, std::size_t len)
|
||||
{
|
||||
ASSERT(_initialized);
|
||||
_serverEncrypt.UpdateData(data, len);
|
||||
|
||||
@@ -27,8 +27,8 @@ public:
|
||||
AuthCrypt() = default;
|
||||
|
||||
void Init(SessionKey const& K);
|
||||
void DecryptRecv(uint8* data, size_t len);
|
||||
void EncryptSend(uint8* data, size_t len);
|
||||
void DecryptRecv(uint8* data, std::size_t len);
|
||||
void EncryptSend(uint8* data, std::size_t len);
|
||||
|
||||
bool IsInitialized() const { return _initialized; }
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "Define.h"
|
||||
#include <array>
|
||||
|
||||
constexpr size_t SESSION_KEY_LENGTH = 40;
|
||||
constexpr std::size_t SESSION_KEY_LENGTH = 40;
|
||||
using SessionKey = std::array<uint8, SESSION_KEY_LENGTH>;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -51,14 +51,14 @@ using SRP6 = Acore::Crypto::SRP6;
|
||||
{
|
||||
// split S into two buffers
|
||||
std::array<uint8, EPHEMERAL_KEY_LENGTH / 2> buf0{}, buf1{};
|
||||
for (size_t i = 0; i < EPHEMERAL_KEY_LENGTH / 2; ++i)
|
||||
for (std::size_t i = 0; i < EPHEMERAL_KEY_LENGTH / 2; ++i)
|
||||
{
|
||||
buf0[i] = S[2 * i + 0];
|
||||
buf1[i] = S[2 * i + 1];
|
||||
}
|
||||
|
||||
// find position of first nonzero byte
|
||||
size_t p = 0;
|
||||
std::size_t p = 0;
|
||||
while (p < EPHEMERAL_KEY_LENGTH && !S[p])
|
||||
++p;
|
||||
|
||||
@@ -73,7 +73,7 @@ using SRP6 = Acore::Crypto::SRP6;
|
||||
|
||||
// stick the two hashes back together
|
||||
SessionKey K;
|
||||
for (size_t i = 0; i < SHA1::DIGEST_LENGTH; ++i)
|
||||
for (std::size_t i = 0; i < SHA1::DIGEST_LENGTH; ++i)
|
||||
{
|
||||
K[2 * i + 0] = hash0[i];
|
||||
K[2 * i + 1] = hash1[i];
|
||||
|
||||
@@ -28,13 +28,13 @@ namespace Acore::Crypto
|
||||
class AC_COMMON_API SRP6
|
||||
{
|
||||
public:
|
||||
static constexpr size_t SALT_LENGTH = 32;
|
||||
static constexpr std::size_t SALT_LENGTH = 32;
|
||||
using Salt = std::array<uint8, SALT_LENGTH>;
|
||||
|
||||
static constexpr size_t VERIFIER_LENGTH = 32;
|
||||
static constexpr std::size_t VERIFIER_LENGTH = 32;
|
||||
using Verifier = std::array<uint8, VERIFIER_LENGTH>;
|
||||
|
||||
static constexpr size_t EPHEMERAL_KEY_LENGTH = 32;
|
||||
static constexpr std::size_t EPHEMERAL_KEY_LENGTH = 32;
|
||||
using EphemeralKey = std::array<uint8, EPHEMERAL_KEY_LENGTH>;
|
||||
|
||||
static std::array<uint8, 1> const g;
|
||||
|
||||
@@ -195,7 +195,7 @@ bool BigNumber::IsNegative() const
|
||||
return BN_is_negative(_bn);
|
||||
}
|
||||
|
||||
void BigNumber::GetBytes(uint8* buf, size_t bufsize, bool littleEndian) const
|
||||
void BigNumber::GetBytes(uint8* buf, std::size_t bufsize, bool littleEndian) const
|
||||
{
|
||||
#if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
int nBytes = GetNumBytes();
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
BigNumber(int32 v) : BigNumber() { SetDword(v); }
|
||||
BigNumber(std::string const& v) : BigNumber() { SetHexStr(v); }
|
||||
|
||||
template <size_t Size>
|
||||
template <std::size_t Size>
|
||||
BigNumber(std::array<uint8, Size> const& v, bool littleEndian = true) : BigNumber() { SetBinary(v.data(), Size, littleEndian); }
|
||||
|
||||
~BigNumber();
|
||||
@@ -116,7 +116,7 @@ public:
|
||||
|
||||
[[nodiscard]] uint32 AsDword() const;
|
||||
|
||||
void GetBytes(uint8* buf, size_t bufsize, bool littleEndian = true) const;
|
||||
void GetBytes(uint8* buf, std::size_t bufsize, bool littleEndian = true) const;
|
||||
[[nodiscard]] std::vector<uint8> ToByteVector(int32 minSize = 0, bool littleEndian = true) const;
|
||||
|
||||
template <std::size_t Size>
|
||||
|
||||
@@ -18,15 +18,13 @@
|
||||
#ifndef AZEROTHCORE_CRYPTO_CONSTANTS_H
|
||||
#define AZEROTHCORE_CRYPTO_CONSTANTS_H
|
||||
|
||||
#include "Define.h"
|
||||
|
||||
namespace Acore::Crypto
|
||||
{
|
||||
struct Constants
|
||||
{
|
||||
static constexpr size_t MD5_DIGEST_LENGTH_BYTES = 16;
|
||||
static constexpr size_t SHA1_DIGEST_LENGTH_BYTES = 20;
|
||||
static constexpr size_t SHA256_DIGEST_LENGTH_BYTES = 32;
|
||||
static constexpr std::size_t MD5_DIGEST_LENGTH_BYTES = 16;
|
||||
static constexpr std::size_t SHA1_DIGEST_LENGTH_BYTES = 20;
|
||||
static constexpr std::size_t SHA256_DIGEST_LENGTH_BYTES = 32;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Acore::Impl
|
||||
static void SplitFromBack(std::vector<uint8>& data, Container& tail)
|
||||
{
|
||||
ASSERT(data.size() >= std::size(tail));
|
||||
for (size_t i = 1, N = std::size(tail); i <= N; ++i)
|
||||
for (std::size_t i = 1, N = std::size(tail); i <= N; ++i)
|
||||
{
|
||||
tail[N - i] = data.back();
|
||||
data.pop_back();
|
||||
|
||||
@@ -43,14 +43,14 @@ namespace Acore::Impl
|
||||
#endif
|
||||
};
|
||||
|
||||
template <GenericHashImpl::HashCreator HashCreator, size_t DigestLength>
|
||||
template <GenericHashImpl::HashCreator HashCreator, std::size_t DigestLength>
|
||||
class GenericHash
|
||||
{
|
||||
public:
|
||||
static constexpr size_t DIGEST_LENGTH = DigestLength;
|
||||
static constexpr std::size_t DIGEST_LENGTH = DigestLength;
|
||||
using Digest = std::array<uint8, DIGEST_LENGTH>;
|
||||
|
||||
static Digest GetDigestOf(uint8 const* data, size_t len)
|
||||
static Digest GetDigestOf(uint8 const* data, std::size_t len)
|
||||
{
|
||||
GenericHash hash;
|
||||
hash.UpdateData(data, len);
|
||||
@@ -112,7 +112,7 @@ namespace Acore::Impl
|
||||
return *this;
|
||||
}
|
||||
|
||||
void UpdateData(uint8 const* data, size_t len)
|
||||
void UpdateData(uint8 const* data, std::size_t len)
|
||||
{
|
||||
int result = EVP_DigestUpdate(_ctx, data, len);
|
||||
ASSERT(result == 1);
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "Errors.h"
|
||||
#include <openssl/rand.h>
|
||||
|
||||
void Acore::Crypto::GetRandomBytes(uint8* buf, size_t len)
|
||||
void Acore::Crypto::GetRandomBytes(uint8* buf, std::size_t len)
|
||||
{
|
||||
int result = RAND_bytes(buf, len);
|
||||
ASSERT(result == 1, "Not enough randomness in OpenSSL's entropy pool. What in the world are you running on?");
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
namespace Acore::Crypto
|
||||
{
|
||||
AC_COMMON_API void GetRandomBytes(uint8* buf, size_t len);
|
||||
AC_COMMON_API void GetRandomBytes(uint8* buf, std::size_t len);
|
||||
|
||||
template <typename Container>
|
||||
void GetRandomBytes(Container& c)
|
||||
@@ -31,7 +31,7 @@ namespace Acore::Crypto
|
||||
GetRandomBytes(std::data(c), std::size(c));
|
||||
}
|
||||
|
||||
template <size_t S>
|
||||
template <std::size_t S>
|
||||
std::array<uint8, S> GetRandomBytes()
|
||||
{
|
||||
std::array<uint8, S> arr;
|
||||
|
||||
@@ -29,15 +29,15 @@ class BigNumber;
|
||||
|
||||
namespace Acore::Impl
|
||||
{
|
||||
template <GenericHashImpl::HashCreator HashCreator, size_t DigestLength>
|
||||
template <GenericHashImpl::HashCreator HashCreator, std::size_t DigestLength>
|
||||
class GenericHMAC
|
||||
{
|
||||
public:
|
||||
static constexpr size_t DIGEST_LENGTH = DigestLength;
|
||||
static constexpr std::size_t DIGEST_LENGTH = DigestLength;
|
||||
using Digest = std::array<uint8, DIGEST_LENGTH>;
|
||||
|
||||
template <typename Container>
|
||||
static Digest GetDigestOf(Container const& seed, uint8 const* data, size_t len)
|
||||
static Digest GetDigestOf(Container const& seed, uint8 const* data, std::size_t len)
|
||||
{
|
||||
GenericHMAC hash(seed);
|
||||
hash.UpdateData(data, len);
|
||||
@@ -54,7 +54,7 @@ namespace Acore::Impl
|
||||
return hash.GetDigest();
|
||||
}
|
||||
|
||||
GenericHMAC(uint8 const* seed, size_t len) : _ctx(GenericHashImpl::MakeCTX()), _key(EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, nullptr, seed, len))
|
||||
GenericHMAC(uint8 const* seed, std::size_t len) : _ctx(GenericHashImpl::MakeCTX()), _key(EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, nullptr, seed, len))
|
||||
{
|
||||
int result = EVP_DigestSignInit(_ctx, nullptr, HashCreator(), nullptr, _key);
|
||||
ASSERT(result == 1);
|
||||
@@ -105,7 +105,7 @@ namespace Acore::Impl
|
||||
return *this;
|
||||
}
|
||||
|
||||
void UpdateData(uint8 const* data, size_t len)
|
||||
void UpdateData(uint8 const* data, std::size_t len)
|
||||
{
|
||||
int result = EVP_DigestSignUpdate(_ctx, data, len);
|
||||
ASSERT(result == 1);
|
||||
@@ -120,7 +120,7 @@ namespace Acore::Impl
|
||||
|
||||
void Finalize()
|
||||
{
|
||||
size_t length = DIGEST_LENGTH;
|
||||
std::size_t length = DIGEST_LENGTH;
|
||||
int result = EVP_DigestSignFinal(_ctx, _digest.data(), &length);
|
||||
ASSERT(result == 1);
|
||||
ASSERT(length == DIGEST_LENGTH);
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
|
||||
#include "OpenSSLCrypto.h"
|
||||
#include "Errors.h"
|
||||
#include <openssl/crypto.h> // NOTE: this import is NEEDED (even though some IDEs report it as unused)
|
||||
|
||||
#if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER < 0x1010000fL
|
||||
|
||||
@@ -18,9 +18,6 @@
|
||||
#ifndef AZEROTHCORE_SESSIONKEYGENERATOR_HPP
|
||||
#define AZEROTHCORE_SESSIONKEYGENERATOR_HPP
|
||||
|
||||
#include "CryptoHash.h"
|
||||
#include <cstring>
|
||||
|
||||
template <typename Hash>
|
||||
class SessionKeyGenerator
|
||||
{
|
||||
@@ -30,8 +27,8 @@ public:
|
||||
o0it(o0.begin())
|
||||
{
|
||||
uint8 const* data = std::data(buf);
|
||||
size_t const len = std::size(buf);
|
||||
size_t const halflen = (len / 2);
|
||||
std::size_t const len = std::size(buf);
|
||||
std::size_t const halflen = (len / 2);
|
||||
|
||||
o1 = Hash::GetDigestOf(data, halflen);
|
||||
o2 = Hash::GetDigestOf(data + halflen, len - halflen);
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Acore::Crypto
|
||||
{
|
||||
struct AC_COMMON_API TOTP
|
||||
{
|
||||
static constexpr size_t RECOMMENDED_SECRET_LENGTH = 20;
|
||||
static constexpr std::size_t RECOMMENDED_SECRET_LENGTH = 20;
|
||||
using Secret = std::vector<uint8>;
|
||||
|
||||
static uint32 GenerateToken(Secret const& key, time_t timestamp);
|
||||
|
||||
Reference in New Issue
Block a user