aboutsummaryrefslogtreecommitdiff
path: root/src/server/shared/Cryptography/Authentication
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/shared/Cryptography/Authentication')
-rw-r--r--src/server/shared/Cryptography/Authentication/PacketCrypt.cpp39
-rw-r--r--src/server/shared/Cryptography/Authentication/PacketCrypt.h (renamed from src/server/shared/Cryptography/Authentication/AuthCrypt.h)21
-rw-r--r--src/server/shared/Cryptography/Authentication/WorldPacketCrypt.cpp (renamed from src/server/shared/Cryptography/Authentication/AuthCrypt.cpp)38
-rw-r--r--src/server/shared/Cryptography/Authentication/WorldPacketCrypt.h34
4 files changed, 92 insertions, 40 deletions
diff --git a/src/server/shared/Cryptography/Authentication/PacketCrypt.cpp b/src/server/shared/Cryptography/Authentication/PacketCrypt.cpp
new file mode 100644
index 00000000000..7fac311b8a2
--- /dev/null
+++ b/src/server/shared/Cryptography/Authentication/PacketCrypt.cpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "PacketCrypt.h"
+
+PacketCrypt::PacketCrypt(uint32 rc4InitSize)
+ : _clientDecrypt(rc4InitSize), _serverEncrypt(rc4InitSize), _initialized(false)
+{
+}
+
+void PacketCrypt::DecryptRecv(uint8* data, size_t len)
+{
+ if (!_initialized)
+ return;
+
+ _clientDecrypt.UpdateData(len, data);
+}
+
+void PacketCrypt::EncryptSend(uint8* data, size_t len)
+{
+ if (!_initialized)
+ return;
+
+ _serverEncrypt.UpdateData(len, data);
+}
diff --git a/src/server/shared/Cryptography/Authentication/AuthCrypt.h b/src/server/shared/Cryptography/Authentication/PacketCrypt.h
index 8fa150068a2..36f3b81fb53 100644
--- a/src/server/shared/Cryptography/Authentication/AuthCrypt.h
+++ b/src/server/shared/Cryptography/Authentication/PacketCrypt.h
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
- * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -16,27 +15,29 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _AUTHCRYPT_H
-#define _AUTHCRYPT_H
+#ifndef _PACKETCRYPT_H
+#define _PACKETCRYPT_H
#include "Cryptography/ARC4.h"
class BigNumber;
-class AuthCrypt
+class PacketCrypt
{
public:
- AuthCrypt();
+ PacketCrypt(uint32 rc4InitSize);
+ virtual ~PacketCrypt() { }
- void Init(BigNumber* K);
- void DecryptRecv(uint8 *, size_t);
- void EncryptSend(uint8 *, size_t);
+ virtual void Init(BigNumber* K) = 0;
+ void DecryptRecv(uint8* data, size_t length);
+ void EncryptSend(uint8* data, size_t length);
bool IsInitialized() const { return _initialized; }
- private:
+ protected:
ARC4 _clientDecrypt;
ARC4 _serverEncrypt;
bool _initialized;
};
-#endif
+
+#endif // _PACKETCRYPT_H
diff --git a/src/server/shared/Cryptography/Authentication/AuthCrypt.cpp b/src/server/shared/Cryptography/Authentication/WorldPacketCrypt.cpp
index ff94f307254..10403b84a1f 100644
--- a/src/server/shared/Cryptography/Authentication/AuthCrypt.cpp
+++ b/src/server/shared/Cryptography/Authentication/WorldPacketCrypt.cpp
@@ -16,58 +16,36 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "AuthCrypt.h"
-#include "Cryptography/HMACSHA1.h"
+#include "WorldPacketCrypt.h"
+#include "Cryptography/HmacHash.h"
#include "Cryptography/BigNumber.h"
-AuthCrypt::AuthCrypt() :
- _clientDecrypt(SHA_DIGEST_LENGTH), _serverEncrypt(SHA_DIGEST_LENGTH),
- _initialized(false)
-{ }
+WorldPacketCrypt::WorldPacketCrypt() : PacketCrypt(SHA_DIGEST_LENGTH)
+{
+}
-void AuthCrypt::Init(BigNumber* K)
+void WorldPacketCrypt::Init(BigNumber* K)
{
uint8 ServerEncryptionKey[SEED_KEY_SIZE] = { 0xCC, 0x98, 0xAE, 0x04, 0xE8, 0x97, 0xEA, 0xCA, 0x12, 0xDD, 0xC0, 0x93, 0x42, 0x91, 0x53, 0x57 };
- HmacHash serverEncryptHmac(SEED_KEY_SIZE, (uint8*)ServerEncryptionKey);
+ HmacSha1 serverEncryptHmac(SEED_KEY_SIZE, (uint8*)ServerEncryptionKey);
uint8 *encryptHash = serverEncryptHmac.ComputeHash(K);
uint8 ServerDecryptionKey[SEED_KEY_SIZE] = { 0xC2, 0xB3, 0x72, 0x3C, 0xC6, 0xAE, 0xD9, 0xB5, 0x34, 0x3C, 0x53, 0xEE, 0x2F, 0x43, 0x67, 0xCE };
- HmacHash clientDecryptHmac(SEED_KEY_SIZE, (uint8*)ServerDecryptionKey);
+ HmacSha1 clientDecryptHmac(SEED_KEY_SIZE, (uint8*)ServerDecryptionKey);
uint8 *decryptHash = clientDecryptHmac.ComputeHash(K);
- //ARC4 _serverDecrypt(encryptHash);
_clientDecrypt.Init(decryptHash);
_serverEncrypt.Init(encryptHash);
- //ARC4 _clientEncrypt(decryptHash);
// Drop first 1024 bytes, as WoW uses ARC4-drop1024.
uint8 syncBuf[1024];
memset(syncBuf, 0, 1024);
_serverEncrypt.UpdateData(1024, syncBuf);
- //_clientEncrypt.UpdateData(1024, syncBuf);
memset(syncBuf, 0, 1024);
- //_serverDecrypt.UpdateData(1024, syncBuf);
_clientDecrypt.UpdateData(1024, syncBuf);
_initialized = true;
}
-
-void AuthCrypt::DecryptRecv(uint8 *data, size_t len)
-{
- if (!_initialized)
- return;
-
- _clientDecrypt.UpdateData(len, data);
-}
-
-void AuthCrypt::EncryptSend(uint8 *data, size_t len)
-{
- if (!_initialized)
- return;
-
- _serverEncrypt.UpdateData(len, data);
-}
-
diff --git a/src/server/shared/Cryptography/Authentication/WorldPacketCrypt.h b/src/server/shared/Cryptography/Authentication/WorldPacketCrypt.h
new file mode 100644
index 00000000000..7ccca11f09d
--- /dev/null
+++ b/src/server/shared/Cryptography/Authentication/WorldPacketCrypt.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _WORLDPACKETCRYPT_H
+#define _WORLDPACKETCRYPT_H
+
+#include "PacketCrypt.h"
+
+class BigNumber;
+
+class WorldPacketCrypt : public PacketCrypt
+{
+ public:
+ WorldPacketCrypt();
+
+ void Init(BigNumber* K) override;
+};
+
+#endif // _WORLDPACKETCRYPT_H