diff options
author | stelar7 <dudedbz@gmail.com> | 2022-04-07 00:16:32 +0200 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2022-04-08 14:02:02 +0430 |
commit | c2379912227bb6b64cf2ef2a252f87e452c9e8d4 (patch) | |
tree | a05d9099c6488dfc39d11a1a39c0e6e729f435da /Userland/Libraries/LibCrypto/Authentication/Poly1305.h | |
parent | e109b967a18711dbf884e6d380598225a3b5901b (diff) | |
download | serenity-c2379912227bb6b64cf2ef2a252f87e452c9e8d4.zip |
LibCrypto: Add Poly1305
Diffstat (limited to 'Userland/Libraries/LibCrypto/Authentication/Poly1305.h')
-rw-r--r-- | Userland/Libraries/LibCrypto/Authentication/Poly1305.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Userland/Libraries/LibCrypto/Authentication/Poly1305.h b/Userland/Libraries/LibCrypto/Authentication/Poly1305.h new file mode 100644 index 0000000000..b4c921dc18 --- /dev/null +++ b/Userland/Libraries/LibCrypto/Authentication/Poly1305.h @@ -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; +}; + +} |