diff options
author | Treeston <treeston.mmoc@gmail.com> | 2020-07-26 01:53:34 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2020-08-03 19:39:00 +0200 |
commit | e9392ad28767626e519c463e2110184d71ba8426 (patch) | |
tree | da391d7daf1ede4ef73883b5053520e160dc4ec4 /src/common/Cryptography/Authentication | |
parent | caa1e1171a1ea4e2db754cfb52b3be795385d544 (diff) |
Core/Authserver: Authserver cleanup (PR#25093)
- Fix a handful of 1/256 bugs with most significant byte zero in BigNumber
- Get rid of (most of) the C-style arrays in authserver
- CryptoRandom as a unified source for cryptographic randomness
- Bring our other crypto APIs into 2020
- BigNumber usability improvements
- Authserver is now actually readable as a result of all of the above
(cherry picked from commit 210176fd915cf4ba16f428d3c1a249a71f4aa7a7)
Diffstat (limited to 'src/common/Cryptography/Authentication')
-rw-r--r-- | src/common/Cryptography/Authentication/WorldPacketCrypt.cpp | 10 | ||||
-rw-r--r-- | src/common/Cryptography/Authentication/WorldPacketCrypt.h | 11 |
2 files changed, 10 insertions, 11 deletions
diff --git a/src/common/Cryptography/Authentication/WorldPacketCrypt.cpp b/src/common/Cryptography/Authentication/WorldPacketCrypt.cpp index 6385c5cfd83..723657048d5 100644 --- a/src/common/Cryptography/Authentication/WorldPacketCrypt.cpp +++ b/src/common/Cryptography/Authentication/WorldPacketCrypt.cpp @@ -23,7 +23,7 @@ WorldPacketCrypt::WorldPacketCrypt() : _clientDecrypt(false), _serverEncrypt(tru { } -void WorldPacketCrypt::Init(uint8 const* key) +void WorldPacketCrypt::Init(Trinity::Crypto::AES::Key const& key) { _clientDecrypt.Init(key); _serverEncrypt.Init(key); @@ -41,12 +41,12 @@ struct WorldPacketCryptIV std::array<uint8, 12> Value; }; -bool WorldPacketCrypt::DecryptRecv(uint8* data, size_t length, uint8 (&tag)[12]) +bool WorldPacketCrypt::DecryptRecv(uint8* data, size_t length, Trinity::Crypto::AES::Tag& tag) { if (_initialized) { WorldPacketCryptIV iv{ _clientCounter, 0x544E4C43 }; - if (!_clientDecrypt.Process(iv.Value.data(), data, length, tag)) + if (!_clientDecrypt.Process(iv.Value, data, length, tag)) return false; } else @@ -56,12 +56,12 @@ bool WorldPacketCrypt::DecryptRecv(uint8* data, size_t length, uint8 (&tag)[12]) return true; } -bool WorldPacketCrypt::EncryptSend(uint8* data, size_t length, uint8 (&tag)[12]) +bool WorldPacketCrypt::EncryptSend(uint8* data, size_t length, Trinity::Crypto::AES::Tag& tag) { if (_initialized) { WorldPacketCryptIV iv{ _serverCounter, 0x52565253 }; - if (!_serverEncrypt.Process(iv.Value.data(), data, length, tag)) + if (!_serverEncrypt.Process(iv.Value, data, length, tag)) return false; } else diff --git a/src/common/Cryptography/Authentication/WorldPacketCrypt.h b/src/common/Cryptography/Authentication/WorldPacketCrypt.h index e2f061183f3..5cd6e1282b8 100644 --- a/src/common/Cryptography/Authentication/WorldPacketCrypt.h +++ b/src/common/Cryptography/Authentication/WorldPacketCrypt.h @@ -18,18 +18,17 @@ #ifndef _WORLDPACKETCRYPT_H #define _WORLDPACKETCRYPT_H -#include "Cryptography/AES.h" - -class BigNumber; +#include "AES.h" +#include <array> class TC_COMMON_API WorldPacketCrypt { public: WorldPacketCrypt(); - void Init(uint8 const* key); - bool DecryptRecv(uint8* data, size_t length, uint8 (&tag)[12]); - bool EncryptSend(uint8* data, size_t length, uint8 (&tag)[12]); + void Init(Trinity::Crypto::AES::Key const& key); + bool DecryptRecv(uint8* data, size_t length, Trinity::Crypto::AES::Tag& tag); + bool EncryptSend(uint8* data, size_t length, Trinity::Crypto::AES::Tag& tag); bool IsInitialized() const { return _initialized; } |