aboutsummaryrefslogtreecommitdiff
path: root/src/common/Cryptography/Authentication
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/Cryptography/Authentication')
-rw-r--r--src/common/Cryptography/Authentication/WorldPacketCrypt.cpp12
-rw-r--r--src/common/Cryptography/Authentication/WorldPacketCrypt.h4
2 files changed, 10 insertions, 6 deletions
diff --git a/src/common/Cryptography/Authentication/WorldPacketCrypt.cpp b/src/common/Cryptography/Authentication/WorldPacketCrypt.cpp
index af1ac4cfdc6..e06c45417c2 100644
--- a/src/common/Cryptography/Authentication/WorldPacketCrypt.cpp
+++ b/src/common/Cryptography/Authentication/WorldPacketCrypt.cpp
@@ -42,27 +42,31 @@ struct WorldPacketCryptIV
std::array<uint8, 12> Value;
};
-bool WorldPacketCrypt::DecryptRecv(uint8* data, size_t len, uint8* tag)
+bool WorldPacketCrypt::DecryptRecv(uint8* data, size_t length, uint8 (&tag)[12])
{
if (_initialized)
{
WorldPacketCryptIV iv{ _clientCounter, 0x544E4C43 };
- if (!_clientDecrypt.Process(iv.Value.data(), data, len, tag))
+ if (!_clientDecrypt.Process(iv.Value.data(), data, length, tag))
return false;
}
+ else
+ memset(tag, 0, sizeof(tag));
++_clientCounter;
return true;
}
-bool WorldPacketCrypt::EncryptSend(uint8* data, size_t len, uint8* tag)
+bool WorldPacketCrypt::EncryptSend(uint8* data, size_t length, uint8 (&tag)[12])
{
if (_initialized)
{
WorldPacketCryptIV iv{ _serverCounter, 0x52565253 };
- if (!_serverEncrypt.Process(iv.Value.data(), data, len, tag))
+ if (!_serverEncrypt.Process(iv.Value.data(), data, length, tag))
return false;
}
+ else
+ memset(tag, 0, sizeof(tag));
++_serverCounter;
return true;
diff --git a/src/common/Cryptography/Authentication/WorldPacketCrypt.h b/src/common/Cryptography/Authentication/WorldPacketCrypt.h
index 155d741fdea..476f423308a 100644
--- a/src/common/Cryptography/Authentication/WorldPacketCrypt.h
+++ b/src/common/Cryptography/Authentication/WorldPacketCrypt.h
@@ -29,8 +29,8 @@ public:
WorldPacketCrypt();
void Init(uint8 const* key);
- bool DecryptRecv(uint8* data, size_t length, uint8* tag);
- bool EncryptSend(uint8* data, size_t length, uint8* tag);
+ bool DecryptRecv(uint8* data, size_t length, uint8 (&tag)[12]);
+ bool EncryptSend(uint8* data, size_t length, uint8 (&tag)[12]);
bool IsInitialized() const { return _initialized; }