From c006c358d86a21067c77efd69c821097c56d96e4 Mon Sep 17 00:00:00 2001 From: hashlag <90853356+hashlag@users.noreply.github.com> Date: Thu, 4 Sep 2025 22:27:11 +0300 Subject: [PATCH 1/3] Add Arc4Crypt class skeleton --- Chaos/Cipher/Arc4/Arc4Crypt.hpp | 63 +++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Chaos/Cipher/Arc4/Arc4Crypt.hpp diff --git a/Chaos/Cipher/Arc4/Arc4Crypt.hpp b/Chaos/Cipher/Arc4/Arc4Crypt.hpp new file mode 100644 index 0000000..3b30d2d --- /dev/null +++ b/Chaos/Cipher/Arc4/Arc4Crypt.hpp @@ -0,0 +1,63 @@ +#ifndef CHAOS_CIPHER_ARC4CRYPT_HPP +#define CHAOS_CIPHER_ARC4CRYPT_HPP + +#include "Arc4Gen.hpp" +#include "Service/ChaosException.hpp" + +namespace Chaos::Cipher::Arc4 +{ + +class Arc4Crypt +{ +public: + Arc4Crypt() + : IsInitialized_(false) + { } + + template + Arc4Crypt(InputIt keyBegin, InputIt keyEnd) + { + RekeyImpl(keyBegin, keyEnd); + } + + template + void Rekey(InputIt keyBegin, InputIt keyEnd) + { + RekeyImpl(keyBegin, keyEnd); + } + + template + void Encrypt(OutputIt out, InputIt in, uint64_t count) + { + // TODO: + } + + template + void Decrypt(OutputIt out, InputIt in, uint64_t count) + { + // TODO: + } + +private: + bool IsInitialized_; + Arc4Gen Gen_; + + void EnsureInitialized() const + { + if (!IsInitialized_) + { + throw Service::ChaosException("Arc4Crypt: not initialized"); + } + } + + template + void RekeyImpl(InputIt keyBegin, InputIt keyEnd) + { + Gen_.Rekey(keyBegin, keyEnd); + IsInitialized_ = true; + } +}; + +} // namespace Chaos::Cipher::Arc4 + +#endif From 1b6f950c5a795a647772db1c4f3b69ce16040ba2 Mon Sep 17 00:00:00 2001 From: hashlag <90853356+hashlag@users.noreply.github.com> Date: Thu, 4 Sep 2025 22:27:11 +0300 Subject: [PATCH 2/3] Add Arc4Crypt class skeleton --- Chaos/Cipher/Arc4/Arc4Crypt.hpp | 63 +++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Chaos/Cipher/Arc4/Arc4Crypt.hpp diff --git a/Chaos/Cipher/Arc4/Arc4Crypt.hpp b/Chaos/Cipher/Arc4/Arc4Crypt.hpp new file mode 100644 index 0000000..3b30d2d --- /dev/null +++ b/Chaos/Cipher/Arc4/Arc4Crypt.hpp @@ -0,0 +1,63 @@ +#ifndef CHAOS_CIPHER_ARC4CRYPT_HPP +#define CHAOS_CIPHER_ARC4CRYPT_HPP + +#include "Arc4Gen.hpp" +#include "Service/ChaosException.hpp" + +namespace Chaos::Cipher::Arc4 +{ + +class Arc4Crypt +{ +public: + Arc4Crypt() + : IsInitialized_(false) + { } + + template + Arc4Crypt(InputIt keyBegin, InputIt keyEnd) + { + RekeyImpl(keyBegin, keyEnd); + } + + template + void Rekey(InputIt keyBegin, InputIt keyEnd) + { + RekeyImpl(keyBegin, keyEnd); + } + + template + void Encrypt(OutputIt out, InputIt in, uint64_t count) + { + // TODO: + } + + template + void Decrypt(OutputIt out, InputIt in, uint64_t count) + { + // TODO: + } + +private: + bool IsInitialized_; + Arc4Gen Gen_; + + void EnsureInitialized() const + { + if (!IsInitialized_) + { + throw Service::ChaosException("Arc4Crypt: not initialized"); + } + } + + template + void RekeyImpl(InputIt keyBegin, InputIt keyEnd) + { + Gen_.Rekey(keyBegin, keyEnd); + IsInitialized_ = true; + } +}; + +} // namespace Chaos::Cipher::Arc4 + +#endif From bd621d9dcfe358b59504e6631862d3afb37946a8 Mon Sep 17 00:00:00 2001 From: hashlag <90853356+hashlag@users.noreply.github.com> Date: Thu, 4 Sep 2025 22:27:11 +0300 Subject: [PATCH 3/3] Add Arc4Crypt class skeleton --- Chaos/Cipher/Arc4/Arc4Crypt.hpp | 63 +++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Chaos/Cipher/Arc4/Arc4Crypt.hpp diff --git a/Chaos/Cipher/Arc4/Arc4Crypt.hpp b/Chaos/Cipher/Arc4/Arc4Crypt.hpp new file mode 100644 index 0000000..3b30d2d --- /dev/null +++ b/Chaos/Cipher/Arc4/Arc4Crypt.hpp @@ -0,0 +1,63 @@ +#ifndef CHAOS_CIPHER_ARC4CRYPT_HPP +#define CHAOS_CIPHER_ARC4CRYPT_HPP + +#include "Arc4Gen.hpp" +#include "Service/ChaosException.hpp" + +namespace Chaos::Cipher::Arc4 +{ + +class Arc4Crypt +{ +public: + Arc4Crypt() + : IsInitialized_(false) + { } + + template + Arc4Crypt(InputIt keyBegin, InputIt keyEnd) + { + RekeyImpl(keyBegin, keyEnd); + } + + template + void Rekey(InputIt keyBegin, InputIt keyEnd) + { + RekeyImpl(keyBegin, keyEnd); + } + + template + void Encrypt(OutputIt out, InputIt in, uint64_t count) + { + // TODO: + } + + template + void Decrypt(OutputIt out, InputIt in, uint64_t count) + { + // TODO: + } + +private: + bool IsInitialized_; + Arc4Gen Gen_; + + void EnsureInitialized() const + { + if (!IsInitialized_) + { + throw Service::ChaosException("Arc4Crypt: not initialized"); + } + } + + template + void RekeyImpl(InputIt keyBegin, InputIt keyEnd) + { + Gen_.Rekey(keyBegin, keyEnd); + IsInitialized_ = true; + } +}; + +} // namespace Chaos::Cipher::Arc4 + +#endif