blob: 25ee707619775cfbeb40c4d1f32ffc617785e5f0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/*
* Poly1305
* (C) 2014 Jack Lloyd
*
* Botan is released under the Simplified BSD License (see license.txt)
*/
#ifndef BOTAN_MAC_POLY1305_H__
#define BOTAN_MAC_POLY1305_H__
#include <botan/mac.h>
#include <memory>
namespace Botan {
/**
* DJB's Poly1305
* Important note: each key can only be used once
*/
class BOTAN_DLL Poly1305 final : public MessageAuthenticationCode
{
public:
std::string name() const override { return "Poly1305"; }
MessageAuthenticationCode* clone() const override { return new Poly1305; }
void clear() override;
size_t output_length() const override { return 16; }
Key_Length_Specification key_spec() const override
{
return Key_Length_Specification(32);
}
private:
void add_data(const uint8_t[], size_t) override;
void final_result(uint8_t[]) override;
void key_schedule(const uint8_t[], size_t) override;
secure_vector<uint64_t> m_poly;
secure_vector<uint8_t> m_buf;
size_t m_buf_pos = 0;
};
}
#endif
|