From 6cad16991e84c396de8a8692112959e53e697546 Mon Sep 17 00:00:00 2001 From: hashlag Date: Mon, 12 Oct 2026 02:39:27 +0300 Subject: [PATCH 01/34] CI: introduce static-analysis job. --- .gitea/workflows/ChaosCi.yaml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.gitea/workflows/ChaosCi.yaml b/.gitea/workflows/ChaosCi.yaml index ab45374..da1e6ab 100644 --- a/.gitea/workflows/ChaosCi.yaml +++ b/.gitea/workflows/ChaosCi.yaml @@ -58,6 +58,38 @@ jobs: include-hidden-files: true retention-days: 10 + static-analysis: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: true + + - name: Install + run: | + sudo apt-get update + sudo apt-get install -y build-essential cmake cppcheck + + - name: Generate compile commands + run: | + mkdir build-debug + cmake -S . -B build-debug/ -D CMAKE_BUILD_TYPE=Debug -D CMAKE_EXPORT_COMPILE_COMMANDS=ON + + - name: Run cppcheck + run: | + cppcheck --version + cppcheck --project=build-debug/compile_commands.json \ + --file-filter="$PWD/Chaos/*" \ + --file-filter="$PWD/ChaosTests/*" \ + --file-filter="$PWD/ChaosBenches/*" \ + --enable=warning,performance,portability \ + --suppress='*:*/_deps/*' \ + --suppress=missingIncludeSystem \ + --inline-suppr \ + --error-exitcode=1 + benchmark: runs-on: ubuntu-latest From baaa98de03849020af623bb068e9034baecaed40 Mon Sep 17 00:00:00 2001 From: hashlag Date: Mon, 12 Oct 2026 02:56:30 +0300 Subject: [PATCH 02/34] CI: fix cppcheck's file-filter globs. --- .gitea/workflows/ChaosCi.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/ChaosCi.yaml b/.gitea/workflows/ChaosCi.yaml index da1e6ab..4a1377c 100644 --- a/.gitea/workflows/ChaosCi.yaml +++ b/.gitea/workflows/ChaosCi.yaml @@ -81,9 +81,8 @@ jobs: run: | cppcheck --version cppcheck --project=build-debug/compile_commands.json \ - --file-filter="$PWD/Chaos/*" \ - --file-filter="$PWD/ChaosTests/*" \ - --file-filter="$PWD/ChaosBenches/*" \ + --file-filter='*/ChaosTests/*' \ + --file-filter='*/ChaosBenches/*' \ --enable=warning,performance,portability \ --suppress='*:*/_deps/*' \ --suppress=missingIncludeSystem \ From 8d0780e016e37a6ddcbd9083fc2cda421337e1b8 Mon Sep 17 00:00:00 2001 From: hashlag Date: Mon, 12 Oct 2026 03:16:54 +0300 Subject: [PATCH 03/34] =?UTF-8?q?CI:=20fix=20cppcheck=E2=80=99s=20file-fil?= =?UTF-8?q?ter=20globs.=20Once=20again.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/ChaosCi.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/ChaosCi.yaml b/.gitea/workflows/ChaosCi.yaml index 4a1377c..e6613e0 100644 --- a/.gitea/workflows/ChaosCi.yaml +++ b/.gitea/workflows/ChaosCi.yaml @@ -81,8 +81,8 @@ jobs: run: | cppcheck --version cppcheck --project=build-debug/compile_commands.json \ - --file-filter='*/ChaosTests/*' \ - --file-filter='*/ChaosBenches/*' \ + --file-filter='*ChaosTests/*' \ + --file-filter='*ChaosBenches/*' \ --enable=warning,performance,portability \ --suppress='*:*/_deps/*' \ --suppress=missingIncludeSystem \ From d892b83e0a2e63b375e7d50b0e3e5fb7d9769082 Mon Sep 17 00:00:00 2001 From: hashlag Date: Tue, 13 Oct 2026 01:17:28 +0300 Subject: [PATCH 04/34] Configure cppcheck's suppressions list. --- .cppcheck | 3 +++ .gitea/workflows/ChaosCi.yaml | 1 + 2 files changed, 4 insertions(+) create mode 100644 .cppcheck diff --git a/.cppcheck b/.cppcheck new file mode 100644 index 0000000..6ed4955 --- /dev/null +++ b/.cppcheck @@ -0,0 +1,3 @@ +returnByReference:Chaos/Hash/Md4.hpp:141 +returnByReference:Chaos/Hash/Md5.hpp:165 +returnByReference:Chaos/Hash/Sha1.hpp:134 diff --git a/.gitea/workflows/ChaosCi.yaml b/.gitea/workflows/ChaosCi.yaml index e6613e0..cf115f1 100644 --- a/.gitea/workflows/ChaosCi.yaml +++ b/.gitea/workflows/ChaosCi.yaml @@ -86,6 +86,7 @@ jobs: --enable=warning,performance,portability \ --suppress='*:*/_deps/*' \ --suppress=missingIncludeSystem \ + --suppressions-list=.cppcheck \ --inline-suppr \ --error-exitcode=1 From f8a110964b39e1f03dab7f49f0dfbd4a6ead7a2d Mon Sep 17 00:00:00 2001 From: hashlag Date: Sat, 17 Oct 2026 21:47:25 +0300 Subject: [PATCH 05/34] Add move assignment operator for SeArray. --- Chaos/Service/SeArray.hpp | 2 +- ChaosTests/Service/SeArrayTests.cpp | 36 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/Chaos/Service/SeArray.hpp b/Chaos/Service/SeArray.hpp index 604cc01..9001451 100644 --- a/Chaos/Service/SeArray.hpp +++ b/Chaos/Service/SeArray.hpp @@ -21,7 +21,7 @@ public: SeArray(SeArray && other) = delete; SeArray & operator=(const SeArray & other) = default; - SeArray & operator=(SeArray && other) = delete; + SeArray & operator=(SeArray && other) = default; ~SeArray() { diff --git a/ChaosTests/Service/SeArrayTests.cpp b/ChaosTests/Service/SeArrayTests.cpp index 816a87e..cf00e92 100644 --- a/ChaosTests/Service/SeArrayTests.cpp +++ b/ChaosTests/Service/SeArrayTests.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "Service/SeArray.hpp" @@ -290,3 +291,38 @@ TEST(SeArrayTests, CopyAssignTest) ASSERT_EQ(0, arr1[4]); } } + +TEST(SeArrayTests, MoveAssignTest) +{ + { + SeArray arr1; + + SeArray arr2; + arr2[0] = 0xaa; + arr2[1] = 0xbb; + + arr1 = std::move(arr2); + + ASSERT_EQ(0xaa, arr1[0]); + ASSERT_EQ(0xbb, arr1[1]); + } + + { + SeArray arr1; + arr1[0] = 0x33; + arr1[1] = 0x44; + arr1[2] = 0x55; + arr1[3] = 0x66; + arr1[4] = 0x77; + + SeArray arr2; + + arr1 = std::move(arr2); + + ASSERT_EQ(0, arr1[0]); + ASSERT_EQ(0, arr1[1]); + ASSERT_EQ(0, arr1[2]); + ASSERT_EQ(0, arr1[3]); + ASSERT_EQ(0, arr1[4]); + } +} From ceccd04b35a35bfce9efb1e22f126d9ebdc0d318 Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 18 Oct 2026 00:35:41 +0300 Subject: [PATCH 06/34] Add move ctor for SeArray. --- Chaos/Service/SeArray.hpp | 2 +- ChaosTests/Service/SeArrayTests.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Chaos/Service/SeArray.hpp b/Chaos/Service/SeArray.hpp index 9001451..427dcf7 100644 --- a/Chaos/Service/SeArray.hpp +++ b/Chaos/Service/SeArray.hpp @@ -18,7 +18,7 @@ public: } SeArray(const SeArray & other) = delete; - SeArray(SeArray && other) = delete; + SeArray(SeArray && other) = default; SeArray & operator=(const SeArray & other) = default; SeArray & operator=(SeArray && other) = default; diff --git a/ChaosTests/Service/SeArrayTests.cpp b/ChaosTests/Service/SeArrayTests.cpp index cf00e92..4a09120 100644 --- a/ChaosTests/Service/SeArrayTests.cpp +++ b/ChaosTests/Service/SeArrayTests.cpp @@ -326,3 +326,16 @@ TEST(SeArrayTests, MoveAssignTest) ASSERT_EQ(0, arr1[4]); } } + +TEST(SeArrayTests, MoveConstructTest) +{ + { + SeArray arr1; + arr1[0] = 0x11; + arr1[1] = 0x22; + + SeArray arr2(std::move(arr1)); + ASSERT_EQ(0x11, arr2[0]); + ASSERT_EQ(0x22, arr2[1]); + } +} From 89bf5914d5c2895c504112eaa8583104c0caa623 Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 18 Oct 2026 00:39:40 +0300 Subject: [PATCH 07/34] Use SeArray as Hmac::KeyType. --- Chaos/Mac/Hmac.hpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Chaos/Mac/Hmac.hpp b/Chaos/Mac/Hmac.hpp index 9818852..07735b1 100644 --- a/Chaos/Mac/Hmac.hpp +++ b/Chaos/Mac/Hmac.hpp @@ -1,10 +1,10 @@ #ifndef CHAOS_MAC_HMAC_HPP #define CHAOS_MAC_HMAC_HPP -#include #include #include "Hash/Hasher.hpp" +#include "Service/SeArray.hpp" #include "Service/ChaosException.hpp" namespace Chaos::Mac::Hmac @@ -46,14 +46,14 @@ public: Hasher_.Reset(); KeyType opaddedKey = PadKey(Key_); - Hasher_.Update(opaddedKey.begin(), opaddedKey.end()); + Hasher_.Update(opaddedKey.Begin(), opaddedKey.End()); Hasher_.Update(innerDigest.begin(), innerDigest.end()); return Hasher_.Finish(); } private: - using KeyType = std::array; + using KeyType = Service::SeArray; static constexpr uint8_t OPAD_BYTE = 0x5c; static constexpr uint8_t IPAD_BYTE = 0x36; @@ -75,12 +75,12 @@ private: static KeyType GenerateKey(InputIt keyBegin, InputIt keyEnd) { KeyType key; - key.fill(0); + key.Fill(0); InputIt keyIt = keyBegin; uint64_t idx = 0; - for (; keyIt != keyEnd && idx < key.size(); + for (; keyIt != keyEnd && idx < key.Size(); ++keyIt, ++idx) { key[idx] = *keyIt; @@ -90,17 +90,17 @@ private: { HasherImpl keyHasher; - keyHasher.Update(key.begin(), key.end()); + keyHasher.Update(key.Begin(), key.End()); keyHasher.Update(keyIt, keyEnd); auto digest = keyHasher.Finish().GetRawDigest(); static_assert(digest.size() <= HasherImpl::BlockSize); - key.fill(0); + key.Fill(0); idx = 0; for (auto it = digest.begin(); - it != digest.end() && idx < key.size(); + it != digest.end() && idx < key.Size(); ++it, ++idx) { key[idx] = *it; @@ -118,8 +118,8 @@ private: KeyType paddedKey; uint64_t idx = 0; - for (auto it = key.cbegin(); - it != key.cend() && idx < paddedKey.size(); + for (auto it = key.Begin(); + it != key.End() && idx < paddedKey.Size(); ++it, ++idx) { paddedKey[idx] = (*it) ^ PAD_BYTE; @@ -135,7 +135,7 @@ private: Hasher_.Reset(); KeyType ipaddedKey = PadKey(Key_); - Hasher_.Update(ipaddedKey.begin(), ipaddedKey.end()); + Hasher_.Update(ipaddedKey.Begin(), ipaddedKey.End()); IsInitialized_ = true; } From fc67ba6b46dc6c20db81e65690a846faddaed893 Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 18 Oct 2026 00:59:18 +0300 Subject: [PATCH 08/34] Erase the source SeArray immediately in move ctor. --- Chaos/Service/SeArray.hpp | 8 +++++++- ChaosTests/Service/SeArrayTests.cpp | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Chaos/Service/SeArray.hpp b/Chaos/Service/SeArray.hpp index 427dcf7..c8bf88e 100644 --- a/Chaos/Service/SeArray.hpp +++ b/Chaos/Service/SeArray.hpp @@ -4,6 +4,7 @@ #include #include #include +#include namespace Chaos::Service { @@ -18,7 +19,12 @@ public: } SeArray(const SeArray & other) = delete; - SeArray(SeArray && other) = default; + + SeArray(SeArray && other) + { + Storage_ = std::move(other.Storage_); + other.EraseImpl(); + } SeArray & operator=(const SeArray & other) = default; SeArray & operator=(SeArray && other) = default; diff --git a/ChaosTests/Service/SeArrayTests.cpp b/ChaosTests/Service/SeArrayTests.cpp index 4a09120..3d6e33f 100644 --- a/ChaosTests/Service/SeArrayTests.cpp +++ b/ChaosTests/Service/SeArrayTests.cpp @@ -337,5 +337,8 @@ TEST(SeArrayTests, MoveConstructTest) SeArray arr2(std::move(arr1)); ASSERT_EQ(0x11, arr2[0]); ASSERT_EQ(0x22, arr2[1]); + + ASSERT_EQ(0, arr1[0]); + ASSERT_EQ(0, arr1[1]); } } From 0be43c9cf67aed003006f9c008f079f689436485 Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 18 Oct 2026 01:10:34 +0300 Subject: [PATCH 09/34] Erase the source SeArray immediately in move assignment operator. --- Chaos/Service/SeArray.hpp | 15 ++++++++++++++- ChaosTests/Service/SeArrayTests.cpp | 9 +++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Chaos/Service/SeArray.hpp b/Chaos/Service/SeArray.hpp index c8bf88e..0119942 100644 --- a/Chaos/Service/SeArray.hpp +++ b/Chaos/Service/SeArray.hpp @@ -27,7 +27,20 @@ public: } SeArray & operator=(const SeArray & other) = default; - SeArray & operator=(SeArray && other) = default; + + SeArray & operator=(SeArray && other) + { + if (this == &other) + { + return *this; + } + + EraseImpl(); + Storage_ = std::move(other.Storage_); + other.EraseImpl(); + + return *this; + } ~SeArray() { diff --git a/ChaosTests/Service/SeArrayTests.cpp b/ChaosTests/Service/SeArrayTests.cpp index 3d6e33f..199ad64 100644 --- a/ChaosTests/Service/SeArrayTests.cpp +++ b/ChaosTests/Service/SeArrayTests.cpp @@ -305,6 +305,9 @@ TEST(SeArrayTests, MoveAssignTest) ASSERT_EQ(0xaa, arr1[0]); ASSERT_EQ(0xbb, arr1[1]); + + ASSERT_EQ(0, arr2[0]); + ASSERT_EQ(0, arr2[1]); } { @@ -324,6 +327,12 @@ TEST(SeArrayTests, MoveAssignTest) ASSERT_EQ(0, arr1[2]); ASSERT_EQ(0, arr1[3]); ASSERT_EQ(0, arr1[4]); + + ASSERT_EQ(0, arr2[0]); + ASSERT_EQ(0, arr2[1]); + ASSERT_EQ(0, arr2[2]); + ASSERT_EQ(0, arr2[3]); + ASSERT_EQ(0, arr2[4]); } } From da47dfa954188400eb8440da4c580ead9e8aa05c Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 18 Oct 2026 01:25:57 +0300 Subject: [PATCH 10/34] DesCrypt KeySchedule: delete move,copy * constructor,operator. --- Chaos/Cipher/Block/Des/DesCrypt.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Chaos/Cipher/Block/Des/DesCrypt.hpp b/Chaos/Cipher/Block/Des/DesCrypt.hpp index addbff8..924e38c 100644 --- a/Chaos/Cipher/Block/Des/DesCrypt.hpp +++ b/Chaos/Cipher/Block/Des/DesCrypt.hpp @@ -114,6 +114,12 @@ public: Decrypt }; + KeySchedule(const KeySchedule & other) = delete; + KeySchedule(KeySchedule && other) = delete; + + KeySchedule & operator=(const KeySchedule & other) = delete; + KeySchedule & operator=(KeySchedule && other) = delete; + KeySchedule(Direction direction, const RawKey & rawKey) { Key56 key56 = Pc1(Bitwise::PackUInt64(rawKey.Begin(), rawKey.End())); From 90dafee249203bfdb82d2dfd18b1246d57a5bcac Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 18 Oct 2026 01:27:51 +0300 Subject: [PATCH 11/34] DesCrypt: delete move,copy * constructor,operator. --- Chaos/Cipher/Block/Des/DesCrypt.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Chaos/Cipher/Block/Des/DesCrypt.hpp b/Chaos/Cipher/Block/Des/DesCrypt.hpp index 924e38c..cf5bd97 100644 --- a/Chaos/Cipher/Block/Des/DesCrypt.hpp +++ b/Chaos/Cipher/Block/Des/DesCrypt.hpp @@ -216,6 +216,12 @@ public: DesCrypt() = delete; + DesCrypt(const DesCrypt & other) = delete; + DesCrypt(DesCrypt && other) = delete; + + DesCrypt & operator=(const DesCrypt & other) = delete; + DesCrypt & operator=(DesCrypt && other) = delete; + class Key { friend class DesCrypt; From e9c7b16d347e7ad18b162a42acfe7c77a0c738d9 Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 18 Oct 2026 01:30:43 +0300 Subject: [PATCH 12/34] DesCrypt::Encryptor: delete move,copy * constructor,operator. --- Chaos/Cipher/Block/Des/DesCrypt.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Chaos/Cipher/Block/Des/DesCrypt.hpp b/Chaos/Cipher/Block/Des/DesCrypt.hpp index cf5bd97..6c16e04 100644 --- a/Chaos/Cipher/Block/Des/DesCrypt.hpp +++ b/Chaos/Cipher/Block/Des/DesCrypt.hpp @@ -257,6 +257,12 @@ public: static constexpr size_t BlockSize = DesCrypt::BlockSize; static constexpr size_t KeySize = DesCrypt::KeySize; + Encryptor(const Encryptor & other) = delete; + Encryptor(Encryptor && other) = delete; + + Encryptor & operator=(const Encryptor & other) = delete; + Encryptor & operator=(Encryptor && other) = delete; + Encryptor(const Key & key) : Schedule_(Inner_::KeySchedule::Direction::Encrypt, key.Key_) { } From 9ec4e6f7e607b5ead9077fd8de412a1a0a7162df Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 18 Oct 2026 01:31:49 +0300 Subject: [PATCH 13/34] DesCrypt::Decryptor: delete move,copy * constructor,operator. --- Chaos/Cipher/Block/Des/DesCrypt.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Chaos/Cipher/Block/Des/DesCrypt.hpp b/Chaos/Cipher/Block/Des/DesCrypt.hpp index 6c16e04..6d6c7cf 100644 --- a/Chaos/Cipher/Block/Des/DesCrypt.hpp +++ b/Chaos/Cipher/Block/Des/DesCrypt.hpp @@ -311,6 +311,12 @@ public: static constexpr size_t BlockSize = DesCrypt::BlockSize; static constexpr size_t KeySize = DesCrypt::KeySize; + Decryptor(const Decryptor & other) = delete; + Decryptor(Decryptor && other) = delete; + + Decryptor & operator=(const Decryptor & other) = delete; + Decryptor & operator=(Decryptor && other) = delete; + Decryptor(const Key & key) : Schedule_(Inner_::KeySchedule::Direction::Decrypt, key.Key_) { } From 56d6aa3601dfb9eea3a918ed9f3dcc5a6b8e6bc4 Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 18 Oct 2026 01:33:08 +0300 Subject: [PATCH 14/34] EcbMode: delete default ctor. --- Chaos/Cipher/Block/Mode/Ecb.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Chaos/Cipher/Block/Mode/Ecb.hpp b/Chaos/Cipher/Block/Mode/Ecb.hpp index 794bd7b..cfc9337 100644 --- a/Chaos/Cipher/Block/Mode/Ecb.hpp +++ b/Chaos/Cipher/Block/Mode/Ecb.hpp @@ -19,6 +19,8 @@ public: using Cipher = CipherT; using Padder = PadderT; + EcbMode() = delete; + class Encryptor { public: From 62903ff9be3a7a2393dbff1bd2a6b56e3d17ccd2 Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 18 Oct 2026 01:34:44 +0300 Subject: [PATCH 15/34] EcbMode: delete move,copy * constructor,operator. --- Chaos/Cipher/Block/Mode/Ecb.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Chaos/Cipher/Block/Mode/Ecb.hpp b/Chaos/Cipher/Block/Mode/Ecb.hpp index cfc9337..95d004e 100644 --- a/Chaos/Cipher/Block/Mode/Ecb.hpp +++ b/Chaos/Cipher/Block/Mode/Ecb.hpp @@ -21,6 +21,12 @@ public: EcbMode() = delete; + EcbMode(const EcbMode & other) = delete; + EcbMode(EcbMode && other) = delete; + + EcbMode & operator=(const EcbMode & other) = delete; + EcbMode & operator=(EcbMode && other) = delete; + class Encryptor { public: From 643c1364c7c2ba34aeccc85c36c58097c14234c9 Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 18 Oct 2026 01:36:02 +0300 Subject: [PATCH 16/34] EcbMode:Encryptor: delete move,copy * constructor,operator. --- Chaos/Cipher/Block/Mode/Ecb.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Chaos/Cipher/Block/Mode/Ecb.hpp b/Chaos/Cipher/Block/Mode/Ecb.hpp index 95d004e..07e19c4 100644 --- a/Chaos/Cipher/Block/Mode/Ecb.hpp +++ b/Chaos/Cipher/Block/Mode/Ecb.hpp @@ -30,6 +30,12 @@ public: class Encryptor { public: + Encryptor(const Encryptor & other) = delete; + Encryptor(Encryptor && other) = delete; + + Encryptor & operator=(const Encryptor & other) = delete; + Encryptor & operator=(Encryptor && other) = delete; + Encryptor(const typename CipherT::Key & key) : Encryptor_(key) , BlockBytesPacked_(0) From 22ad1fbb2be91b0a7bfc5ffdad52ff6c93c685ac Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 18 Oct 2026 01:37:03 +0300 Subject: [PATCH 17/34] EcbMode:Decryptor: delete move,copy * constructor,operator. --- Chaos/Cipher/Block/Mode/Ecb.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Chaos/Cipher/Block/Mode/Ecb.hpp b/Chaos/Cipher/Block/Mode/Ecb.hpp index 07e19c4..770ea6b 100644 --- a/Chaos/Cipher/Block/Mode/Ecb.hpp +++ b/Chaos/Cipher/Block/Mode/Ecb.hpp @@ -129,6 +129,12 @@ public: class Decryptor { public: + Decryptor(const Decryptor & other) = delete; + Decryptor(Decryptor && other) = delete; + + Decryptor & operator=(const Decryptor & other) = delete; + Decryptor & operator=(Decryptor && other) = delete; + Decryptor(const typename CipherT::Key & key) : Decryptor_(key) , BlockBytesPacked_(0) From f636a60dab4fccc3eab9c980ba2808a6e8f81ee6 Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 18 Oct 2026 01:39:56 +0300 Subject: [PATCH 18/34] Arc4Crypt: delete move,copy * constructor,operator. --- Chaos/Cipher/Stream/Arc4/Arc4Crypt.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Chaos/Cipher/Stream/Arc4/Arc4Crypt.hpp b/Chaos/Cipher/Stream/Arc4/Arc4Crypt.hpp index 2194ede..3cc682b 100644 --- a/Chaos/Cipher/Stream/Arc4/Arc4Crypt.hpp +++ b/Chaos/Cipher/Stream/Arc4/Arc4Crypt.hpp @@ -17,6 +17,12 @@ public: Arc4Crypt() { } + Arc4Crypt(const Arc4Crypt & other) = delete; + Arc4Crypt(Arc4Crypt && other) = delete; + + Arc4Crypt & operator=(const Arc4Crypt & other) = delete; + Arc4Crypt & operator=(Arc4Crypt && other) = delete; + template Arc4Crypt(InputIt keyBegin, InputIt keyEnd) { From 8dcdaa6b852aa21edcfe1eae344f9b7337c19145 Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 18 Oct 2026 01:41:54 +0300 Subject: [PATCH 19/34] Arc4Gen: delete move,copy * constructor,operator. --- Chaos/Cipher/Stream/Arc4/Arc4Gen.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Chaos/Cipher/Stream/Arc4/Arc4Gen.hpp b/Chaos/Cipher/Stream/Arc4/Arc4Gen.hpp index b2c6173..a89ebf7 100644 --- a/Chaos/Cipher/Stream/Arc4/Arc4Gen.hpp +++ b/Chaos/Cipher/Stream/Arc4/Arc4Gen.hpp @@ -18,6 +18,12 @@ public: : IsInitialized_(false) { } + Arc4Gen(const Arc4Gen & other) = delete; + Arc4Gen(Arc4Gen && other) = delete; + + Arc4Gen & operator=(const Arc4Gen & other) = delete; + Arc4Gen & operator=(Arc4Gen && other) = delete; + template Arc4Gen(InputIt keyBegin, InputIt keyEnd) { From f776caa5285f7d0fb8eb5f39b064f504e03ad8d6 Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 18 Oct 2026 01:44:20 +0300 Subject: [PATCH 20/34] Md4: delete move,copy * constructor,operator. --- Chaos/Hash/Md4.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Chaos/Hash/Md4.hpp b/Chaos/Hash/Md4.hpp index 4ef3c4b..de84d8a 100644 --- a/Chaos/Hash/Md4.hpp +++ b/Chaos/Hash/Md4.hpp @@ -175,6 +175,12 @@ public: ResetImpl(); } + Md4Hasher(const Md4Hasher & other) = delete; + Md4Hasher(Md4Hasher && other) = delete; + + Md4Hasher & operator=(const Md4Hasher & other) = delete; + Md4Hasher & operator=(Md4Hasher && other) = delete; + void Reset() { ResetImpl(); From ac89f55feb1366edf64fbda850e0fd4db5b221fd Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 18 Oct 2026 01:45:16 +0300 Subject: [PATCH 21/34] Md5: delete move,copy * constructor,operator. --- Chaos/Hash/Md5.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Chaos/Hash/Md5.hpp b/Chaos/Hash/Md5.hpp index 08b8ce6..f7b93c3 100644 --- a/Chaos/Hash/Md5.hpp +++ b/Chaos/Hash/Md5.hpp @@ -199,6 +199,12 @@ public: ResetImpl(); } + Md5Hasher(const Md5Hasher & other) = delete; + Md5Hasher(Md5Hasher && other) = delete; + + Md5Hasher & operator=(const Md5Hasher & other) = delete; + Md5Hasher & operator=(Md5Hasher && other) = delete; + void Reset() { ResetImpl(); From 6638e46dd91d35ab7440e6a0d68b9c4558fc43b7 Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 18 Oct 2026 01:46:16 +0300 Subject: [PATCH 22/34] Sha1: delete move,copy * constructor,operator. --- Chaos/Hash/Sha1.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Chaos/Hash/Sha1.hpp b/Chaos/Hash/Sha1.hpp index a85c360..98eb9fa 100644 --- a/Chaos/Hash/Sha1.hpp +++ b/Chaos/Hash/Sha1.hpp @@ -169,6 +169,12 @@ public: ResetImpl(); } + Sha1Hasher(const Sha1Hasher & other) = delete; + Sha1Hasher(Sha1Hasher && other) = delete; + + Sha1Hasher & operator=(const Sha1Hasher & other) = delete; + Sha1Hasher & operator=(Sha1Hasher && other) = delete; + void Reset() { ResetImpl(); From a720c7b812d1a98c1262784a0fcc5a0a5fab9012 Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 18 Oct 2026 01:47:11 +0300 Subject: [PATCH 23/34] Hmac: delete move,copy * constructor,operator. --- Chaos/Mac/Hmac.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Chaos/Mac/Hmac.hpp b/Chaos/Mac/Hmac.hpp index 07735b1..03bdfc1 100644 --- a/Chaos/Mac/Hmac.hpp +++ b/Chaos/Mac/Hmac.hpp @@ -18,6 +18,12 @@ public: : IsInitialized_(false) { } + Hmac(const Hmac & other) = delete; + Hmac(Hmac && other) = delete; + + Hmac & operator=(const Hmac & other) = delete; + Hmac & operator=(Hmac && other) = delete; + template Hmac(InputIt keyBegin, InputIt keyEnd) { From 0c041a5e9a65d1a4e249bf4b569f0dbc63010af8 Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 18 Oct 2026 01:48:01 +0300 Subject: [PATCH 24/34] PadderIso7816: delete default ctor. --- Chaos/Padding/PadderIso7816.hpp | 2 ++ ChaosTests/Padding/PadderIso7816Tests.cpp | 14 ++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Chaos/Padding/PadderIso7816.hpp b/Chaos/Padding/PadderIso7816.hpp index ee21f27..91da45f 100644 --- a/Chaos/Padding/PadderIso7816.hpp +++ b/Chaos/Padding/PadderIso7816.hpp @@ -15,6 +15,8 @@ namespace Chaos::Padding class PadderIso7816 { public: + PadderIso7816() = delete; + template static void Pad(OutputIt begin, OutputIt end) { diff --git a/ChaosTests/Padding/PadderIso7816Tests.cpp b/ChaosTests/Padding/PadderIso7816Tests.cpp index e917063..8d8c470 100644 --- a/ChaosTests/Padding/PadderIso7816Tests.cpp +++ b/ChaosTests/Padding/PadderIso7816Tests.cpp @@ -110,9 +110,9 @@ TEST(PadIso7816Tests, PadOutIteratorUsageTest) } template -void PadGeneric(const PadderImpl & padder, OutputIt begin, OutputIt end) +void PadGeneric(OutputIt begin, OutputIt end) { - padder.Pad(begin, end); + PadderImpl::Pad(begin, end); } TEST(PadIso7816Tests, PadThroughBaseTest) @@ -126,8 +126,7 @@ TEST(PadIso7816Tests, PadThroughBaseTest) 0x80, 0x00, 0x00, 0x00, 0x00 }; - const PadderIso7816 padder; - PadGeneric(padder, fact.begin(), fact.end()); + PadGeneric(fact.begin(), fact.end()); ASSERT_EQ(expected, fact); } @@ -325,9 +324,9 @@ TEST(PadIso7816Tests, UnpadErrorTest) } template -auto ComputeUnpadGeneric(const PadderImpl & padder, OutputIt begin, OutputIt end) +auto ComputeUnpadGeneric(OutputIt begin, OutputIt end) { - return padder.ComputeUnpad(begin, end); + return PadderImpl::ComputeUnpad(begin, end); } TEST(PadIso7816Tests, ComputeUnpadThroughBaseTest) @@ -335,8 +334,7 @@ TEST(PadIso7816Tests, ComputeUnpadThroughBaseTest) { std::array data = { 0x80, 0x00, 0x00, 0x00, 0x00 }; - const PadderIso7816 padder; - auto result = ComputeUnpadGeneric(padder, data.begin(), data.end()); + auto result = ComputeUnpadGeneric(data.begin(), data.end()); ASSERT_TRUE(result.IsOkay_); ASSERT_EQ(5, result.PadSize_); From e7f346cda28f1bd55380dfd0dcab3b524ee30f4a Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 18 Oct 2026 01:48:35 +0300 Subject: [PATCH 25/34] PadderIso7816: delete move,copy * constructor,operator. --- Chaos/Padding/PadderIso7816.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Chaos/Padding/PadderIso7816.hpp b/Chaos/Padding/PadderIso7816.hpp index 91da45f..97db3e6 100644 --- a/Chaos/Padding/PadderIso7816.hpp +++ b/Chaos/Padding/PadderIso7816.hpp @@ -17,6 +17,12 @@ class PadderIso7816 public: PadderIso7816() = delete; + PadderIso7816(const PadderIso7816 & other) = delete; + PadderIso7816(PadderIso7816 && other) = delete; + + PadderIso7816 & operator=(const PadderIso7816 & other) = delete; + PadderIso7816 & operator=(PadderIso7816 && other) = delete; + template static void Pad(OutputIt begin, OutputIt end) { From 706e20821a61d02d156f8e509297175c989f8763 Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 18 Oct 2026 01:49:14 +0300 Subject: [PATCH 26/34] PadderPkcs7: delete default ctor. --- Chaos/Padding/PadderPkcs7.hpp | 2 ++ ChaosTests/Padding/PadderPkcs7Tests.cpp | 14 ++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Chaos/Padding/PadderPkcs7.hpp b/Chaos/Padding/PadderPkcs7.hpp index 61c4a60..b5141dc 100644 --- a/Chaos/Padding/PadderPkcs7.hpp +++ b/Chaos/Padding/PadderPkcs7.hpp @@ -16,6 +16,8 @@ namespace Chaos::Padding class PadderPkcs7 { public: + PadderPkcs7() = delete; + template static void Pad(OutputIt begin, OutputIt end) { diff --git a/ChaosTests/Padding/PadderPkcs7Tests.cpp b/ChaosTests/Padding/PadderPkcs7Tests.cpp index 57240ac..57e288a 100644 --- a/ChaosTests/Padding/PadderPkcs7Tests.cpp +++ b/ChaosTests/Padding/PadderPkcs7Tests.cpp @@ -138,9 +138,9 @@ TEST(PadPkcs7Tests, PadOutIteratorUsageTest) } template -void PadGeneric(const PadderImpl & padder, OutputIt begin, OutputIt end) +void PadGeneric(OutputIt begin, OutputIt end) { - padder.Pad(begin, end); + PadderImpl::Pad(begin, end); } TEST(PadPkcs7Tests, PadThroughBaseTest) @@ -152,8 +152,7 @@ TEST(PadPkcs7Tests, PadThroughBaseTest) 0x05, 0x05, 0x05, 0x05, 0x05 }; - const PadderPkcs7 padder; - PadGeneric(padder, fact.begin(), fact.end()); + PadGeneric(fact.begin(), fact.end()); ASSERT_EQ(expected, fact); } @@ -348,9 +347,9 @@ TEST(PadPkcs7Tests, UnpadErrorTest) } template -auto ComputeUnpadGeneric(const PadderImpl & padder, OutputIt begin, OutputIt end) +auto ComputeUnpadGeneric(OutputIt begin, OutputIt end) { - return padder.ComputeUnpad(begin, end); + return PadderImpl::ComputeUnpad(begin, end); } TEST(PadPkcs7Tests, ComputeUnpadThroughBaseTest) @@ -358,8 +357,7 @@ TEST(PadPkcs7Tests, ComputeUnpadThroughBaseTest) { std::array data = { 0x05, 0x05, 0x05, 0x05, 0x05 }; - const PadderPkcs7 padder; - auto result = ComputeUnpadGeneric(padder, data.begin(), data.end()); + auto result = ComputeUnpadGeneric(data.begin(), data.end()); ASSERT_TRUE(result.IsOkay_); ASSERT_EQ(5, result.PadSize_); From 3582890bb1e5749d70fdd38d41f20ae4764f3602 Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 18 Oct 2026 01:49:49 +0300 Subject: [PATCH 27/34] PadderPkcs7: delete move,copy * constructor,operator. --- Chaos/Padding/PadderPkcs7.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Chaos/Padding/PadderPkcs7.hpp b/Chaos/Padding/PadderPkcs7.hpp index b5141dc..8a8b54c 100644 --- a/Chaos/Padding/PadderPkcs7.hpp +++ b/Chaos/Padding/PadderPkcs7.hpp @@ -18,6 +18,12 @@ class PadderPkcs7 public: PadderPkcs7() = delete; + PadderPkcs7(const PadderPkcs7 & other) = delete; + PadderPkcs7(PadderPkcs7 && other) = delete; + + PadderPkcs7 & operator=(const PadderPkcs7 & other) = delete; + PadderPkcs7 & operator=(PadderPkcs7 && other) = delete; + template static void Pad(OutputIt begin, OutputIt end) { From b129507559e4b7e12e432a1b388af05eeb9dc1a5 Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 18 Oct 2026 02:09:45 +0300 Subject: [PATCH 28/34] DesCrypt::Key: delete move,copy * constructor,operator. --- Chaos/Cipher/Block/Des/DesCrypt.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Chaos/Cipher/Block/Des/DesCrypt.hpp b/Chaos/Cipher/Block/Des/DesCrypt.hpp index 6d6c7cf..203af24 100644 --- a/Chaos/Cipher/Block/Des/DesCrypt.hpp +++ b/Chaos/Cipher/Block/Des/DesCrypt.hpp @@ -226,6 +226,12 @@ public: { friend class DesCrypt; public: + Key(const Key & other) = delete; + Key(Key && other) = delete; + + Key & operator=(const Key & other) = delete; + Key & operator=(Key && other) = delete; + template Key(InputIt keyBegin, InputIt keyEnd) { From 6b632b8be18d1ebb5e9698a2cbf26a72426a33b0 Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 18 Oct 2026 02:12:31 +0300 Subject: [PATCH 29/34] SeArray: make move ctor noexcept. --- Chaos/Service/SeArray.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Chaos/Service/SeArray.hpp b/Chaos/Service/SeArray.hpp index 0119942..6faed01 100644 --- a/Chaos/Service/SeArray.hpp +++ b/Chaos/Service/SeArray.hpp @@ -20,7 +20,7 @@ public: SeArray(const SeArray & other) = delete; - SeArray(SeArray && other) + SeArray(SeArray && other) noexcept { Storage_ = std::move(other.Storage_); other.EraseImpl(); From 0ee4962f70e2ebdaaa0e5e24da51dc29f8af99bf Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 18 Oct 2026 02:13:11 +0300 Subject: [PATCH 30/34] SeArray: make move assignment operator noexcept. --- Chaos/Service/SeArray.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Chaos/Service/SeArray.hpp b/Chaos/Service/SeArray.hpp index 6faed01..7b01256 100644 --- a/Chaos/Service/SeArray.hpp +++ b/Chaos/Service/SeArray.hpp @@ -28,7 +28,7 @@ public: SeArray & operator=(const SeArray & other) = default; - SeArray & operator=(SeArray && other) + SeArray & operator=(SeArray && other) noexcept { if (this == &other) { From 7d312f9ba5fd7878523f3f67a787e0a5af7e03d0 Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 18 Oct 2026 02:18:11 +0300 Subject: [PATCH 31/34] SeArrayTests: add move self-assignment testcase. --- ChaosTests/Service/SeArrayTests.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ChaosTests/Service/SeArrayTests.cpp b/ChaosTests/Service/SeArrayTests.cpp index 199ad64..c51c4f6 100644 --- a/ChaosTests/Service/SeArrayTests.cpp +++ b/ChaosTests/Service/SeArrayTests.cpp @@ -334,6 +334,23 @@ TEST(SeArrayTests, MoveAssignTest) ASSERT_EQ(0, arr2[3]); ASSERT_EQ(0, arr2[4]); } + + { + SeArray arr1; + arr1[0] = 0x33; + arr1[1] = 0x44; + arr1[2] = 0x55; + arr1[3] = 0x66; + arr1[4] = 0x77; + + arr1 = std::move(arr1); + + ASSERT_EQ(0x33, arr1[0]); + ASSERT_EQ(0x44, arr1[1]); + ASSERT_EQ(0x55, arr1[2]); + ASSERT_EQ(0x66, arr1[3]); + ASSERT_EQ(0x77, arr1[4]); + } } TEST(SeArrayTests, MoveConstructTest) From 0b12c1303f86b5460162ff94ff25fd533870b4d6 Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 18 Oct 2026 02:39:05 +0300 Subject: [PATCH 32/34] Arc4Gen: init I_, J_ in ctor. No functional changes. Tidiness. --- Chaos/Cipher/Stream/Arc4/Arc4Gen.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Chaos/Cipher/Stream/Arc4/Arc4Gen.hpp b/Chaos/Cipher/Stream/Arc4/Arc4Gen.hpp index a89ebf7..fb7f7c8 100644 --- a/Chaos/Cipher/Stream/Arc4/Arc4Gen.hpp +++ b/Chaos/Cipher/Stream/Arc4/Arc4Gen.hpp @@ -16,6 +16,8 @@ class Arc4Gen public: Arc4Gen() : IsInitialized_(false) + , I_(0) + , J_(0) { } Arc4Gen(const Arc4Gen & other) = delete; From c4311991a97a1387dd11bc16d7e28bb0b6438b22 Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 18 Oct 2026 02:26:10 +0300 Subject: [PATCH 33/34] CI: update cppcheck's ignore rules for SeArrayTests. --- .cppcheck | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.cppcheck b/.cppcheck index 6ed4955..ac41dd3 100644 --- a/.cppcheck +++ b/.cppcheck @@ -1,3 +1,6 @@ returnByReference:Chaos/Hash/Md4.hpp:141 returnByReference:Chaos/Hash/Md5.hpp:165 returnByReference:Chaos/Hash/Sha1.hpp:134 +accessMoved:ChaosTests/Service/SeArrayTests.cpp:309 +accessMoved:ChaosTests/Service/SeArrayTests.cpp:331 +accessMoved:ChaosTests/Service/SeArrayTests.cpp:367 From a360e1b95ae1f94fc5f68b33e37b9078eb552bca Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 18 Oct 2026 02:34:31 +0300 Subject: [PATCH 34/34] CI: update cppcheck's ignore rules for SeArray. --- .cppcheck | 1 + 1 file changed, 1 insertion(+) diff --git a/.cppcheck b/.cppcheck index ac41dd3..4094858 100644 --- a/.cppcheck +++ b/.cppcheck @@ -1,6 +1,7 @@ returnByReference:Chaos/Hash/Md4.hpp:141 returnByReference:Chaos/Hash/Md5.hpp:165 returnByReference:Chaos/Hash/Sha1.hpp:134 +useInitializationList:Chaos/Service/SeArray.hpp:25 accessMoved:ChaosTests/Service/SeArrayTests.cpp:309 accessMoved:ChaosTests/Service/SeArrayTests.cpp:331 accessMoved:ChaosTests/Service/SeArrayTests.cpp:367