1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 07:47:34 +00:00

LibCrypto: Add Poly1305

This commit is contained in:
stelar7 2022-04-07 00:16:32 +02:00 committed by Ali Mohammad Pur
parent e109b967a1
commit c237991222
5 changed files with 567 additions and 0 deletions

View 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;
};
}