diff options
author | lloyd <[email protected]> | 2014-12-29 02:40:08 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2014-12-29 02:40:08 +0000 |
commit | dfc93a3c8992b067f66ca148ac91c24489f493fc (patch) | |
tree | d2af4bc335fc1ceebbaedc75dc7fa2d4f04ff2b4 /src/lib/mac/poly1305/poly1305.h | |
parent | 05b6811827fe7f4e107a9339142f6aec56f0f202 (diff) |
Add Poly1305, based on poly1305-donna by Andrew Moon.
Diffstat (limited to 'src/lib/mac/poly1305/poly1305.h')
-rw-r--r-- | src/lib/mac/poly1305/poly1305.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/lib/mac/poly1305/poly1305.h b/src/lib/mac/poly1305/poly1305.h new file mode 100644 index 000000000..8334edb03 --- /dev/null +++ b/src/lib/mac/poly1305/poly1305.h @@ -0,0 +1,48 @@ +/* +* Poly1305 +* (C) 2014 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#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 : public MessageAuthenticationCode + { + public: + std::string name() const override { return "Poly1305"; } + + MessageAuthenticationCode* clone() const { return new Poly1305; } + + void clear(); + + size_t output_length() const { return 16; } + + Key_Length_Specification key_spec() const + { + return Key_Length_Specification(32); + } + + private: + void add_data(const byte[], size_t); + void final_result(byte[]); + void key_schedule(const byte[], size_t); + + secure_vector<u64bit> m_poly; + secure_vector<byte> m_buf; + size_t m_buf_pos = 0; + }; + +} + +#endif |