From cdcab2f4f77e2474c4ffa826ae742382f9527963 Mon Sep 17 00:00:00 2001 From: hashlag Date: Sat, 31 Jan 2026 23:56:25 +0300 Subject: [PATCH] Mark all Block::Encryptor<> methods const. This allows for convenient usage of const Encryptor &. --- Chaos/Cipher/Block/Des/DesCrypt.hpp | 6 +++--- Chaos/Cipher/Block/Encryptor.hpp | 6 +++--- ChaosTests/Cipher/DesCryptTests.cpp | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Chaos/Cipher/Block/Des/DesCrypt.hpp b/Chaos/Cipher/Block/Des/DesCrypt.hpp index 1328573..68eba67 100644 --- a/Chaos/Cipher/Block/Des/DesCrypt.hpp +++ b/Chaos/Cipher/Block/Des/DesCrypt.hpp @@ -237,7 +237,7 @@ public: { } template - void EncryptBlock(OutputIt out, InputIt inBegin, InputIt inEnd) + void EncryptBlock(OutputIt out, InputIt inBegin, InputIt inEnd) const { RawBlockArray block; @@ -255,12 +255,12 @@ public: Inner_::Bitwise::CrunchUInt64(out, encrypted); } - Block EncryptBlock(Block block) + Block EncryptBlock(Block block) const { return DesCrypt::ProcessBlock(block, Schedule_); } - constexpr size_t GetBlockSize() + constexpr size_t GetBlockSize() const { return BlockSize; } diff --git a/Chaos/Cipher/Block/Encryptor.hpp b/Chaos/Cipher/Block/Encryptor.hpp index 41fc034..18f9872 100644 --- a/Chaos/Cipher/Block/Encryptor.hpp +++ b/Chaos/Cipher/Block/Encryptor.hpp @@ -9,18 +9,18 @@ class Encryptor { public: template - void EncryptBlock(OutputIt out, InputIt inBegin, InputIt inEnd) + void EncryptBlock(OutputIt out, InputIt inBegin, InputIt inEnd) const { Impl().EncryptBlock(out, inBegin, inEnd); } template - auto EncryptBlock(Block block) + auto EncryptBlock(Block block) const { return Impl().EncryptBlock(block); } - auto GetBlockSize() + auto GetBlockSize() const { return Impl().GetBlockSize(); } diff --git a/ChaosTests/Cipher/DesCryptTests.cpp b/ChaosTests/Cipher/DesCryptTests.cpp index cde9961..5c66e72 100644 --- a/ChaosTests/Cipher/DesCryptTests.cpp +++ b/ChaosTests/Cipher/DesCryptTests.cpp @@ -498,7 +498,7 @@ TEST(DesCryptTests, OutIteratorUsageDecryptTest) } template -static std::vector EncryptThroughBase(Encryptor & enc, +static std::vector EncryptThroughBase(const Encryptor & enc, InputIt begin, InputIt end) { std::vector result; @@ -522,7 +522,7 @@ TEST(DesCryptTests, EncryptThroughBaseTest) } template -static uint64_t EncryptUInt64BlockThroughBase(Encryptor & enc, uint64_t block) +static uint64_t EncryptUInt64BlockThroughBase(const Encryptor & enc, uint64_t block) { return enc.EncryptBlock(block); }