Botan 3.11.0
Crypto and TLS for C&
poly1305.h
Go to the documentation of this file.
1/*
2* Poly1305
3* (C) 2014 Jack Lloyd
4*
5* Botan is released under the Simplified BSD License (see license.txt)
6*/
7
8#ifndef BOTAN_MAC_POLY1305_H_
9#define BOTAN_MAC_POLY1305_H_
10
11#include <botan/mac.h>
12#include <botan/internal/alignment_buffer.h>
13#include <memory>
14
15namespace Botan {
16
17/**
18* DJB's Poly1305
19* Important note: each key can only be used once
20*/
22 public:
23 std::string name() const override { return "Poly1305"; }
24
25 std::string provider() const override;
26
27 std::unique_ptr<MessageAuthenticationCode> new_object() const override { return std::make_unique<Poly1305>(); }
28
29 void clear() override;
30
31 size_t output_length() const override { return 16; }
32
34
35 bool fresh_key_required_per_message() const override { return true; }
36
37 bool has_keying_material() const override;
38
39 private:
40 void add_data(std::span<const uint8_t> input) override;
41 void final_result(std::span<uint8_t> output) override;
42 void key_schedule(std::span<const uint8_t> key) override;
43
44#if defined(BOTAN_HAS_POLY1305_AVX2)
45 static size_t poly1305_avx2_blocks(secure_vector<uint64_t>& X, const uint8_t m[], size_t blocks);
46#endif
47
48#if defined(BOTAN_HAS_POLY1305_AVX512)
49 static size_t poly1305_avx512_blocks(secure_vector<uint64_t>& X, const uint8_t m[], size_t blocks);
50#endif
51
52 // State layout: pad [2] || accum [3] || r [3] || r^2 [3] || ... || r^n [3]
55};
56
57} // namespace Botan
58
59#endif
Alignment buffer helper.
void final(uint8_t out[])
Definition buf_comp.h:69
void clear() override
Definition poly1305.cpp:332
std::string name() const override
Definition poly1305.h:23
Key_Length_Specification key_spec() const override
Definition poly1305.h:33
std::string provider() const override
Definition poly1305.cpp:348
size_t output_length() const override
Definition poly1305.h:31
bool has_keying_material() const override
Definition poly1305.cpp:337
std::unique_ptr< MessageAuthenticationCode > new_object() const override
Definition poly1305.h:27
bool fresh_key_required_per_message() const override
Definition poly1305.h:35
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:68