1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 11:28:11 +00:00

LibCrypto: Implement and test CTR decryption

This commit is contained in:
Ben Wiederhake 2020-07-26 05:40:07 +02:00 committed by Andreas Kling
parent a51cbc2978
commit a296020e03
2 changed files with 41 additions and 8 deletions

View file

@ -95,9 +95,12 @@ public:
virtual ~CTR() { }
// Must intercept `Intent`, because AES must always be set to
// Encryption, even when decrypting AES-CTR.
// TODO: How to deal with ciphers that take different arguments?
template<typename... Args>
explicit constexpr CTR<T>(Args... args)
: Mode<T>(args...)
explicit constexpr CTR<T>(const ByteBuffer& user_key, size_t key_bits, Intent = Intent::Encryption, Args... args)
: Mode<T>(user_key, key_bits, args...)
{
}
@ -125,10 +128,8 @@ public:
virtual void decrypt(const ByteBuffer& in, ByteBuffer& out, Optional<ByteBuffer> ivec = {}) override
{
(void)in;
(void)out;
(void)ivec;
// FIXME: Implement CTR decryption when it is needed.
// XOR (and thus CTR) is the most symmetric mode.
this->encrypt(in, out, ivec);
}
private: