Files
hashlag 2c6a24197a
Chaos Ci / test (push) Successful in 5m6s
Chaos Ci / benchmark (push) Successful in 1m29s
Replace Encryptor CRTP base with a concept.
2026-09-06 02:27:35 +03:00

30 lines
975 B
C++

#ifndef CHAOS_CIPHER_BLOCK_ENCRYPTOR_HPP
#define CHAOS_CIPHER_BLOCK_ENCRYPTOR_HPP
#include <concepts>
#include <cstdint>
#include <type_traits>
namespace Chaos::Cipher::Block
{
template<typename T>
concept Encryptor = requires(T encryptor,
typename T::Block block,
uint8_t * outBegin, uint8_t * outEnd,
uint8_t * inBegin, uint8_t * inEnd)
{
typename T::Block;
typename T::Key;
requires std::constructible_from<T, typename T::Key>;
requires std::unsigned_integral<std::remove_cvref_t<decltype(T::BlockSize)>>;
requires std::unsigned_integral<std::remove_cvref_t<decltype(T::KeySize)>>;
encryptor.EncryptBlock(outBegin, outEnd, inBegin, inEnd);
{ encryptor.EncryptBlock(block) } -> std::same_as<typename T::Block>;
{ encryptor.GetBlockSize() } -> std::unsigned_integral;
};
} // namespace Chaos::Cipher::Block
#endif // CHAOS_CIPHER_BLOCK_ENCRYPTOR_HPP