Introduce concept Cipher.

This commit is contained in:
hashlag committed 2026-09-13 01:32:59 +03:00
1 parent c9e90e4d0d
commit cc7c8e1e55
2 files changed
+38

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
#ifndef CHAOS_CIPHER_BLOCK_CIPHER_HPP
#define CHAOS_CIPHER_BLOCK_CIPHER_HPP
#include <concepts>
#include <type_traits>
#include "Key.hpp"
#include "Encryptor.hpp"
#include "Decryptor.hpp"
namespace Chaos::Cipher::Block
{
template<typename T>
concept Cipher = requires
{
typename T::Block;
typename T::Key;
typename T::Encryptor;
typename T::Decryptor;
requires std::unsigned_integral<std::remove_cvref_t<decltype(T::BlockSize)>>;
typename std::integral_constant<decltype(T::BlockSize), T::BlockSize>;
requires std::unsigned_integral<std::remove_cvref_t<decltype(T::KeySize)>>;
typename std::integral_constant<decltype(T::KeySize), T::KeySize>;
requires Key<typename T::Key>;
requires Encryptor<typename T::Encryptor>;
requires Decryptor<typename T::Decryptor>;
};
} // namespace Chaos::Cipher::Block
#endif // CHAOS_CIPHER_BLOCK_CIPHER_HPP
+3
View File
@@ -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<DesCrypt>);
} // namespace Chaos::Cipher::Block::Des
#endif // CHAOS_CIPHER_BLOCK_DES_DESCRYPT_HPP