From cc7c8e1e557fb1b8cd0708cc236eb33bf4c1f97e Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 13 Sep 2026 01:32:59 +0300 Subject: [PATCH] Introduce concept Cipher. --- Chaos/Cipher/Block/Cipher.hpp | 35 +++++++++++++++++++++++++++++ Chaos/Cipher/Block/Des/DesCrypt.hpp | 3 +++ 2 files changed, 38 insertions(+) create mode 100644 Chaos/Cipher/Block/Cipher.hpp diff --git a/Chaos/Cipher/Block/Cipher.hpp b/Chaos/Cipher/Block/Cipher.hpp new file mode 100644 index 0000000..ec32927 --- /dev/null +++ b/Chaos/Cipher/Block/Cipher.hpp @@ -0,0 +1,35 @@ +#ifndef CHAOS_CIPHER_BLOCK_CIPHER_HPP +#define CHAOS_CIPHER_BLOCK_CIPHER_HPP + +#include +#include + +#include "Key.hpp" +#include "Encryptor.hpp" +#include "Decryptor.hpp" + +namespace Chaos::Cipher::Block +{ + +template +concept Cipher = requires +{ + typename T::Block; + typename T::Key; + typename T::Encryptor; + typename T::Decryptor; + + requires std::unsigned_integral>; + typename std::integral_constant; + + requires std::unsigned_integral>; + typename std::integral_constant; + + requires Key; + requires Encryptor; + requires Decryptor; +}; + +} // namespace Chaos::Cipher::Block + +#endif // CHAOS_CIPHER_BLOCK_CIPHER_HPP diff --git a/Chaos/Cipher/Block/Des/DesCrypt.hpp b/Chaos/Cipher/Block/Des/DesCrypt.hpp index 1e50e76..3e46d6c 100644 --- a/Chaos/Cipher/Block/Des/DesCrypt.hpp +++ b/Chaos/Cipher/Block/Des/DesCrypt.hpp @@ -13,6 +13,7 @@ #include "Cipher/Block/Key.hpp" #include "Cipher/Block/Encryptor.hpp" #include "Cipher/Block/Decryptor.hpp" +#include "Cipher/Block/Cipher.hpp" namespace Chaos::Cipher::Block::Des::Inner_ { @@ -524,6 +525,8 @@ private: } }; +static_assert(Cipher::Block::Cipher); + } // namespace Chaos::Cipher::Block::Des #endif // CHAOS_CIPHER_BLOCK_DES_DESCRYPT_HPP