mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 07:47:34 +00:00
LibCrypto: Add Poly1305
This commit is contained in:
parent
e109b967a1
commit
c237991222
5 changed files with 567 additions and 0 deletions
34
Userland/Libraries/LibCrypto/Authentication/Poly1305.h
Normal file
34
Userland/Libraries/LibCrypto/Authentication/Poly1305.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright (c) 2022, stelar7 <dudedbz@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/ByteBuffer.h>
|
||||
|
||||
namespace Crypto::Authentication {
|
||||
|
||||
struct State {
|
||||
u32 r[4] {};
|
||||
u32 s[4] {};
|
||||
u64 a[8] {};
|
||||
u8 blocks[17] {};
|
||||
u8 block_count {};
|
||||
};
|
||||
|
||||
class Poly1305 {
|
||||
|
||||
public:
|
||||
explicit Poly1305(ReadonlyBytes key);
|
||||
void update(ReadonlyBytes message);
|
||||
ErrorOr<ByteBuffer> digest();
|
||||
|
||||
private:
|
||||
void process_block();
|
||||
|
||||
State m_state;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue