Introduce Block::Decryptor<> CRTP base class.
All checks were successful
Chaos Ci / test-and-benchmark (push) Successful in 1m43s
All checks were successful
Chaos Ci / test-and-benchmark (push) Successful in 1m43s
Inherit DesDecryptor from it.
This commit is contained in:
40
Chaos/Cipher/Block/Decryptor.hpp
Normal file
40
Chaos/Cipher/Block/Decryptor.hpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifndef CHAOS_CIPHER_BLOCK_DECRYPTOR_HPP
|
||||
#define CHAOS_CIPHER_BLOCK_DECRYPTOR_HPP
|
||||
|
||||
namespace Chaos::Cipher::Block
|
||||
{
|
||||
|
||||
template<typename T>
|
||||
class Decryptor
|
||||
{
|
||||
public:
|
||||
template<typename OutputIt, typename InputIt>
|
||||
void DecryptBlock(OutputIt out, InputIt inBegin, InputIt inEnd)
|
||||
{
|
||||
Impl().DecryptBlock(out, inBegin, inEnd);
|
||||
}
|
||||
|
||||
template<typename Block>
|
||||
auto DecryptBlock(Block block)
|
||||
{
|
||||
return Impl().DecryptBlock(block);
|
||||
}
|
||||
|
||||
protected:
|
||||
Decryptor() = default;
|
||||
|
||||
private:
|
||||
const T & Impl() const
|
||||
{
|
||||
return static_cast<const T &>(*this);
|
||||
}
|
||||
|
||||
T & Impl()
|
||||
{
|
||||
return static_cast<T &>(*this);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace Chaos::Cipher::Block
|
||||
|
||||
#endif // CHAOS_CIPHER_BLOCK_DECRYPTOR_HPP
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "Service/SeArray.hpp"
|
||||
|
||||
#include "Cipher/Block/Encryptor.hpp"
|
||||
#include "Cipher/Block/Decryptor.hpp"
|
||||
|
||||
namespace Chaos::Cipher::Block::Des::Inner_
|
||||
{
|
||||
@@ -258,7 +259,7 @@ public:
|
||||
Inner_::KeySchedule Schedule_;
|
||||
};
|
||||
|
||||
class DesDecryptor
|
||||
class DesDecryptor : public Decryptor<DesDecryptor>
|
||||
{
|
||||
public:
|
||||
DesDecryptor(const Key & key)
|
||||
|
||||
Reference in New Issue
Block a user