From d194fef1afe9cd34baa124e21037ffcbdae92c01 Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 1 Feb 2026 00:24:50 +0300 Subject: [PATCH] Mark all Block::Decryptor<> methods const. This allows for convenient usage of const Decryptor &. --- Chaos/Cipher/Block/Decryptor.hpp | 6 +++--- Chaos/Cipher/Block/Des/DesCrypt.hpp | 6 +++--- ChaosTests/Cipher/DesCryptTests.cpp | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Chaos/Cipher/Block/Decryptor.hpp b/Chaos/Cipher/Block/Decryptor.hpp index cd21712..01ac308 100644 --- a/Chaos/Cipher/Block/Decryptor.hpp +++ b/Chaos/Cipher/Block/Decryptor.hpp @@ -9,18 +9,18 @@ class Decryptor { public: template - void DecryptBlock(OutputIt out, InputIt inBegin, InputIt inEnd) + void DecryptBlock(OutputIt out, InputIt inBegin, InputIt inEnd) const { Impl().DecryptBlock(out, inBegin, inEnd); } template - auto DecryptBlock(Block block) + auto DecryptBlock(Block block) const { return Impl().DecryptBlock(block); } - auto GetBlockSize() + auto GetBlockSize() const { return Impl().GetBlockSize(); } diff --git a/Chaos/Cipher/Block/Des/DesCrypt.hpp b/Chaos/Cipher/Block/Des/DesCrypt.hpp index 68eba67..d25fd81 100644 --- a/Chaos/Cipher/Block/Des/DesCrypt.hpp +++ b/Chaos/Cipher/Block/Des/DesCrypt.hpp @@ -279,7 +279,7 @@ public: { } template - void DecryptBlock(OutputIt out, InputIt inBegin, InputIt inEnd) + void DecryptBlock(OutputIt out, InputIt inBegin, InputIt inEnd) const { RawBlockArray block; @@ -297,12 +297,12 @@ public: Inner_::Bitwise::CrunchUInt64(out, decrypted); } - Block DecryptBlock(Block block) + Block DecryptBlock(Block block) const { return DesCrypt::ProcessBlock(block, Schedule_); } - constexpr size_t GetBlockSize() + constexpr size_t GetBlockSize() const { return BlockSize; } diff --git a/ChaosTests/Cipher/DesCryptTests.cpp b/ChaosTests/Cipher/DesCryptTests.cpp index 5c66e72..1df1028 100644 --- a/ChaosTests/Cipher/DesCryptTests.cpp +++ b/ChaosTests/Cipher/DesCryptTests.cpp @@ -541,7 +541,7 @@ TEST(DesCryptTests, EncryptUInt64BlockThroughBaseTest) } template -static std::vector DecryptThroughBase(Decryptor & dec, +static std::vector DecryptThroughBase(const Decryptor & dec, InputIt begin, InputIt end) { std::vector result; @@ -565,7 +565,7 @@ TEST(DesCryptTests, DecryptThroughBaseTest) } template -static uint64_t DecryptUInt64BlockThroughBase(Decryptor & dec, uint64_t block) +static uint64_t DecryptUInt64BlockThroughBase(const Decryptor & dec, uint64_t block) { return dec.DecryptBlock(block); }