summaryrefslogtreecommitdiff
path: root/csgo-loader/csgo-server/Security/Encryption.cpp
diff options
context:
space:
mode:
authorboris <wzn@moneybot.cc>2018-12-30 15:00:51 +1300
committerboris <wzn@moneybot.cc>2018-12-30 15:00:51 +1300
commitd786e65a9a262638e74f6ebcf1b296917897ae49 (patch)
tree17199ab95db8a59abf4d3bf40543296d76e8659e /csgo-loader/csgo-server/Security/Encryption.cpp
parent0340821cc614fda2a94a96c255d16105dd2f6f9a (diff)
unban marcus or suffer my wrath
grr
Diffstat (limited to 'csgo-loader/csgo-server/Security/Encryption.cpp')
-rw-r--r--csgo-loader/csgo-server/Security/Encryption.cpp40
1 files changed, 21 insertions, 19 deletions
diff --git a/csgo-loader/csgo-server/Security/Encryption.cpp b/csgo-loader/csgo-server/Security/Encryption.cpp
index b79a1c3..f4681b8 100644
--- a/csgo-loader/csgo-server/Security/Encryption.cpp
+++ b/csgo-loader/csgo-server/Security/Encryption.cpp
@@ -259,7 +259,7 @@ namespace Wrapper
ByteArray::size_type Aes256::decrypt_start(const ByteArray::size_type encrypted_length)
{
- register unsigned char j;
+ unsigned char j;
m_remainingLength = encrypted_length;
@@ -308,7 +308,7 @@ namespace Wrapper
{
if(!m_decryptInitialized && m_buffer_pos == m_salt.size() + 1)
{
- register unsigned char j;
+ unsigned char j;
ByteArray::size_type padding;
// Get salt
@@ -370,7 +370,7 @@ namespace Wrapper
void Aes256::expand_enc_key(unsigned char* rc)
{
- register unsigned char i;
+ unsigned char i;
m_rkey[0] = m_rkey[0] ^ sbox[m_rkey[29]] ^ (*rc);
m_rkey[1] = m_rkey[1] ^ sbox[m_rkey[30]];
@@ -433,7 +433,7 @@ namespace Wrapper
void Aes256::sub_bytes(unsigned char* buffer)
{
- register unsigned char i = KEY_SIZE / 2;
+ unsigned char i = KEY_SIZE / 2;
while(i--)
buffer[i] = sbox[buffer[i]];
@@ -441,7 +441,7 @@ namespace Wrapper
void Aes256::sub_bytes_inv(unsigned char* buffer)
{
- register unsigned char i = KEY_SIZE / 2;
+ unsigned char i = KEY_SIZE / 2;
while(i--)
buffer[i] = sboxinv[buffer[i]];
@@ -459,7 +459,7 @@ namespace Wrapper
void Aes256::add_round_key(unsigned char* buffer, const unsigned char round)
{
- register unsigned char i = KEY_SIZE / 2;
+ unsigned char i = KEY_SIZE / 2;
while(i--)
buffer[i] ^= m_rkey[(round & 1) ? i + 16 : i];
@@ -467,7 +467,7 @@ namespace Wrapper
void Aes256::shift_rows(unsigned char* buffer)
{
- register unsigned char i, j, k, l; /* to make it potentially parallelable :) */
+ unsigned char i, j, k, l; /* to make it potentially parallelable :) */
i = buffer[1];
buffer[1] = buffer[5];
@@ -492,7 +492,7 @@ namespace Wrapper
void Aes256::shift_rows_inv(unsigned char* buffer)
{
- register unsigned char i, j, k, l; /* same as above :) */
+ unsigned char i, j, k, l; /* same as above :) */
i = buffer[1];
buffer[1] = buffer[13];
@@ -517,7 +517,7 @@ namespace Wrapper
void Aes256::mix_columns(unsigned char* buffer)
{
- register unsigned char i, a, b, c, d, e;
+ unsigned char i, a, b, c, d, e;
for(i = 0; i < 16; i += 4)
{
@@ -537,7 +537,7 @@ namespace Wrapper
void Aes256::mix_columns_inv(unsigned char* buffer)
{
- register unsigned char i, a, b, c, d, e, x, y, z;
+ unsigned char i, a, b, c, d, e, x, y, z;
for(i = 0; i < 16; i += 4)
{
@@ -581,7 +581,6 @@ namespace Wrapper
// Generate random bytes to use as encryption key.
if(CryptGenRandom(m_CryptProvider, RandomBytesCount, RandomBytes))
{
- m_EncryptionKey.reserve(RandomBytesCount);
m_EncryptionKey.insert(
m_EncryptionKey.begin(),
RandomBytes,
@@ -598,15 +597,10 @@ namespace Wrapper
{
// If an encryption key is provided, initialise the wrapper with
// the passed parameter.
- if(!EncryptionKey.empty())
- {
- m_EncryptionKey.reserve(EncryptionKey.size());
- std::copy(EncryptionKey.begin(), EncryptionKey.end(), m_EncryptionKey.begin());
- }
- else
- {
+ std::copy(EncryptionKey.begin(), EncryptionKey.end(), m_EncryptionKey.begin());
+
+ if(EncryptionKey.empty())
Start();
- }
}
ByteArray Encryption::Encrypt(ByteArray &Data)
@@ -614,7 +608,11 @@ namespace Wrapper
// Encrypt outgoing data.
ByteArray Encrypted;
+ #ifdef DEBUG
+ Encrypted = Data;
+ #else
Aes256::encrypt(m_EncryptionKey, Data, Encrypted);
+ #endif
return Encrypted;
}
@@ -624,7 +622,11 @@ namespace Wrapper
// Decrypt incoming data.
ByteArray Decrypted;
+ #ifdef DEBUG
+ Decrypted = Data;
+ #else
Aes256::decrypt(m_EncryptionKey, Data, Decrypted);
+ #endif
return Decrypted;
}