Expose block sizes of block ciphers.
All checks were successful
Chaos Ci / test-and-benchmark (push) Successful in 1m45s
All checks were successful
Chaos Ci / test-and-benchmark (push) Successful in 1m45s
Both via static data members and Encryptor/Decryptor interfaces. Crucial for safe memory allocation routine.
This commit is contained in:
@@ -20,6 +20,11 @@ public:
|
||||
return Impl().DecryptBlock(block);
|
||||
}
|
||||
|
||||
auto GetBlockSize()
|
||||
{
|
||||
return Impl().GetBlockSize();
|
||||
}
|
||||
|
||||
protected:
|
||||
Decryptor() = default;
|
||||
|
||||
|
||||
@@ -196,6 +196,9 @@ class DesCrypt
|
||||
{
|
||||
public:
|
||||
using Block = uint64_t;
|
||||
static constexpr size_t BlockSize = 8;
|
||||
|
||||
static_assert(BlockSize == sizeof(Block));
|
||||
|
||||
DesCrypt() = delete;
|
||||
|
||||
@@ -227,6 +230,8 @@ public:
|
||||
class DesEncryptor : public Encryptor<DesEncryptor>
|
||||
{
|
||||
public:
|
||||
static constexpr size_t BlockSize = DesCrypt::BlockSize;
|
||||
|
||||
DesEncryptor(const Key & key)
|
||||
: Schedule_(Inner_::KeySchedule::Direction::Encrypt, key.Key_)
|
||||
{ }
|
||||
@@ -255,6 +260,11 @@ public:
|
||||
return DesCrypt::ProcessBlock(block, Schedule_);
|
||||
}
|
||||
|
||||
constexpr size_t GetBlockSize()
|
||||
{
|
||||
return BlockSize;
|
||||
}
|
||||
|
||||
private:
|
||||
Inner_::KeySchedule Schedule_;
|
||||
};
|
||||
@@ -262,6 +272,8 @@ public:
|
||||
class DesDecryptor : public Decryptor<DesDecryptor>
|
||||
{
|
||||
public:
|
||||
static constexpr size_t BlockSize = DesCrypt::BlockSize;
|
||||
|
||||
DesDecryptor(const Key & key)
|
||||
: Schedule_(Inner_::KeySchedule::Direction::Decrypt, key.Key_)
|
||||
{ }
|
||||
@@ -290,6 +302,11 @@ public:
|
||||
return DesCrypt::ProcessBlock(block, Schedule_);
|
||||
}
|
||||
|
||||
constexpr size_t GetBlockSize()
|
||||
{
|
||||
return BlockSize;
|
||||
}
|
||||
|
||||
private:
|
||||
Inner_::KeySchedule Schedule_;
|
||||
};
|
||||
|
||||
@@ -20,6 +20,11 @@ public:
|
||||
return Impl().EncryptBlock(block);
|
||||
}
|
||||
|
||||
auto GetBlockSize()
|
||||
{
|
||||
return Impl().GetBlockSize();
|
||||
}
|
||||
|
||||
protected:
|
||||
Encryptor() = default;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user