mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:17:35 +00:00
LibCrypto: Implement HMAC
This commit is contained in:
parent
4f89a377a4
commit
f2cd004d11
8 changed files with 249 additions and 3 deletions
|
@ -120,6 +120,8 @@ namespace Cipher {
|
|||
virtual void encrypt_block(const BlockType& in, BlockType& out) override;
|
||||
virtual void decrypt_block(const BlockType& in, BlockType& out) override;
|
||||
|
||||
virtual String class_name() const override { return "AES"; }
|
||||
|
||||
protected:
|
||||
AESCipherKey m_key;
|
||||
};
|
||||
|
|
|
@ -129,6 +129,8 @@ namespace Cipher {
|
|||
virtual void encrypt_block(const BlockType& in, BlockType& out) = 0;
|
||||
virtual void decrypt_block(const BlockType& in, BlockType& out) = 0;
|
||||
|
||||
virtual String class_name() const = 0;
|
||||
|
||||
private:
|
||||
PaddingMode m_padding_mode;
|
||||
};
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibCrypto/Cipher/Mode/Mode.h>
|
||||
|
||||
namespace Crypto {
|
||||
|
@ -40,6 +42,14 @@ namespace Cipher {
|
|||
{
|
||||
}
|
||||
|
||||
virtual String class_name() const override
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append(this->cipher().class_name());
|
||||
builder.append("_CBC");
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
virtual Optional<ByteBuffer> encrypt(const ByteBuffer& in, ByteBuffer& out, Optional<ByteBuffer> ivec = {}) override
|
||||
{
|
||||
auto length = in.size();
|
||||
|
|
|
@ -50,6 +50,8 @@ namespace Cipher {
|
|||
return ByteBuffer::create_uninitialized(input_size + T::block_size() - remainder);
|
||||
}
|
||||
|
||||
virtual String class_name() const = 0;
|
||||
|
||||
protected:
|
||||
T& cipher() { return m_cipher; }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue