Poly1305.h 500 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * Copyright (c) 2022, stelar7 <dudedbz@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/ByteBuffer.h>
  8. namespace Crypto::Authentication {
  9. struct State {
  10. u32 r[4] {};
  11. u32 s[4] {};
  12. u64 a[8] {};
  13. u8 blocks[17] {};
  14. u8 block_count {};
  15. };
  16. class Poly1305 {
  17. public:
  18. explicit Poly1305(ReadonlyBytes key);
  19. void update(ReadonlyBytes message);
  20. ErrorOr<ByteBuffer> digest();
  21. private:
  22. void process_block();
  23. State m_state;
  24. };
  25. }