mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 04:37:00 +00:00
Just a commit
This commit is contained in:
parent
8f9849969b
commit
2626d8c243
7 changed files with 77 additions and 53 deletions
|
|
@ -21,36 +21,32 @@
|
|||
|
||||
SARC4::SARC4()
|
||||
{
|
||||
EVP_CIPHER_CTX_init(&m_encryptctx);
|
||||
EVP_EncryptInit_ex(&m_encryptctx, EVP_rc4(), NULL, NULL, NULL);
|
||||
EVP_CIPHER_CTX_set_key_length(&m_encryptctx, SHA_DIGEST_LENGTH);
|
||||
EVP_CIPHER_CTX_init(&m_decryptctx);
|
||||
EVP_DecryptInit_ex(&m_decryptctx, EVP_rc4(), NULL, NULL, NULL);
|
||||
EVP_CIPHER_CTX_set_key_length(&m_decryptctx, SHA_DIGEST_LENGTH);
|
||||
EVP_CIPHER_CTX_init(&m_ctx);
|
||||
EVP_EncryptInit_ex(&m_ctx, EVP_rc4(), NULL, NULL, NULL);
|
||||
EVP_CIPHER_CTX_set_key_length(&m_ctx, SHA_DIGEST_LENGTH);
|
||||
}
|
||||
|
||||
SARC4::SARC4(uint8 *seed)
|
||||
{
|
||||
EVP_CIPHER_CTX_init(&m_ctx);
|
||||
EVP_EncryptInit_ex(&m_ctx, EVP_rc4(), NULL, NULL, NULL);
|
||||
EVP_CIPHER_CTX_set_key_length(&m_ctx, SHA_DIGEST_LENGTH);
|
||||
EVP_EncryptInit_ex(&m_ctx, NULL, NULL, seed, NULL);
|
||||
}
|
||||
|
||||
SARC4::~SARC4()
|
||||
{
|
||||
EVP_CIPHER_CTX_cleanup(&m_encryptctx);
|
||||
EVP_CIPHER_CTX_cleanup(&m_decryptctx);
|
||||
EVP_CIPHER_CTX_cleanup(&m_ctx);
|
||||
}
|
||||
|
||||
void SARC4::Init(uint8 *seed1, uint8 *seed2)
|
||||
void SARC4::Init(uint8 *seed)
|
||||
{
|
||||
EVP_EncryptInit_ex(&m_encryptctx, NULL, NULL, seed1, NULL);
|
||||
EVP_DecryptInit_ex(&m_decryptctx, NULL, NULL, seed2, NULL);
|
||||
EVP_EncryptInit_ex(&m_ctx, NULL, NULL, seed, NULL);
|
||||
}
|
||||
|
||||
void SARC4::Encrypt(uint32 len, uint8 *data)
|
||||
void SARC4::UpdateData(int len, uint8 *data)
|
||||
{
|
||||
int outlen = 0;
|
||||
EVP_EncryptUpdate(&m_encryptctx, data, &outlen, data, len);
|
||||
EVP_EncryptFinal_ex(&m_encryptctx, data, &outlen);
|
||||
}
|
||||
|
||||
void SARC4::Decrypt(uint32 len, uint8 *data)
|
||||
{
|
||||
int outlen = 0;
|
||||
EVP_DecryptUpdate(&m_decryptctx, data, &outlen, data, len);
|
||||
EVP_DecryptFinal_ex(&m_decryptctx, data, &outlen);
|
||||
EVP_EncryptUpdate(&m_ctx, data, &outlen, data, len);
|
||||
EVP_EncryptFinal_ex(&m_ctx, data, &outlen);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue