Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Server/Crypto: Use cipher update and cipher final functions instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
AriDEV3 committed Dec 30, 2023
1 parent c95acc1 commit cb065ed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/server/shared/Cryptography/ARC4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

ARC4::ARC4() : m_ctx(EVP_CIPHER_CTX_new())
{
EVP_CIPHER_CTX_init(m_ctx);
EVP_CIPHER_CTX_reset(m_ctx);
EVP_EncryptInit_ex(m_ctx, EVP_rc4(), NULL, NULL, NULL);
}

ARC4::~ARC4()
{
EVP_CIPHER_CTX_cleanup(m_ctx);
EVP_CIPHER_CTX_reset(m_ctx);
}

void ARC4::Init(uint8* seed, uint32 len)
Expand All @@ -26,6 +26,11 @@ void ARC4::Init(uint8* seed, uint32 len)
void ARC4::UpdateData(int len, uint8 *data)
{
int outlen = 0;
EVP_EncryptUpdate(m_ctx, data, &outlen, data, len);
EVP_EncryptFinal_ex(m_ctx, data, &outlen);
EVP_CipherUpdate(m_ctx, data, &outlen, data, len);
Finalize(outlen, data);
}

void ARC4::Finalize(int outlen, uint8* data)
{
EVP_CipherFinal_ex(m_ctx, data, &outlen);
}
1 change: 1 addition & 0 deletions src/server/shared/Cryptography/ARC4.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class ARC4
~ARC4();
void Init(uint8 *seed, uint32 len);
void UpdateData(int len, uint8 *data);
void Finalize(int outlen, uint8* data);
private:
EVP_CIPHER_CTX *m_ctx;
};
Expand Down

0 comments on commit cb065ed

Please sign in to comment.