forked from csumathdyj/libdigest-hmac-sha256-cxx11
-
Notifications
You must be signed in to change notification settings - Fork 0
/
digest-poly1305.hpp
32 lines (28 loc) · 870 Bytes
/
digest-poly1305.hpp
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
#pragma once
#include <cstdint>
#include <array>
#include <string>
#include "digest.hpp"
namespace digest {
class POLY1305 : public base {
public:
explicit POLY1305 (void);
POLY1305& set_key256 (std::array<std::uint8_t,32> const& key);
POLY1305& set_authdata (std::string const& a);
POLY1305& set_aead_construction (bool const a);
std::size_t blocksize () const { return 16U; }
std::string digest ();
protected:
std::string authdata;
bool aead_construction;
std::array<std::uint64_t,5> poly;
std::array<std::uint32_t,5> sum;
std::array<std::uint32_t,5> scale;
std::array<std::uint32_t,5> scale5;
std::array<std::uint8_t,16> termination;
void init_sum ();
void update_sum_with_data (std::string const& data);
void update_sum (std::string::const_iterator s);
void last_sum ();
};
}//namespace digest