36 lines
805 B
C++
36 lines
805 B
C++
// Copyright (C) 2007-2025 EQ2EMulator
|
|
// Licensed under GPL v3
|
|
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
#include <mutex>
|
|
#include <array>
|
|
|
|
#include "rc4.h"
|
|
#include "../types.h"
|
|
|
|
class Crypto
|
|
{
|
|
public:
|
|
Crypto() noexcept = default;
|
|
~Crypto() = default;
|
|
|
|
static int64 RSADecrypt(uchar* text, int16 size) noexcept;
|
|
void RC4Encrypt(uchar* text, int32 size) noexcept;
|
|
void RC4Decrypt(uchar* text, int32 size) noexcept;
|
|
|
|
[[nodiscard]] int64 getRC4Key() const noexcept { return rc4_key; }
|
|
void setRC4Key(int64 key) noexcept;
|
|
|
|
[[nodiscard]] bool isEncrypted() const noexcept { return encrypted; }
|
|
void setEncrypted(bool in_val) noexcept { encrypted = in_val; }
|
|
|
|
private:
|
|
std::unique_ptr<RC4> server{};
|
|
std::unique_ptr<RC4> client{};
|
|
bool encrypted{false};
|
|
int64 rc4_key{0};
|
|
std::mutex m_crypto_mutex{};
|
|
};
|