diff options
author | lloyd <[email protected]> | 2015-01-11 04:15:03 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2015-01-11 04:15:03 +0000 |
commit | b07e980986bd62ecaa951140dbe2c472bbd60d3b (patch) | |
tree | bb39a25c5e79448ac1886407561e8c31980501c2 /src/lib/mac/siphash/siphash.h | |
parent | 582e1cea2cb13c5d9d40610ff4566921f934ba27 (diff) |
Add SipHash
Diffstat (limited to 'src/lib/mac/siphash/siphash.h')
-rw-r--r-- | src/lib/mac/siphash/siphash.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/lib/mac/siphash/siphash.h b/src/lib/mac/siphash/siphash.h new file mode 100644 index 000000000..ec57864eb --- /dev/null +++ b/src/lib/mac/siphash/siphash.h @@ -0,0 +1,45 @@ +/* +* SipHash +* (C) 2014,2015 Jack Lloyd +* +* Botan is released under the Simplified BSD License (see license.txt) +*/ + +#ifndef BOTAN_SIPHASH_H__ +#define BOTAN_SIPHASH_H__ + +#include <botan/mac.h> + +namespace Botan { + +class BOTAN_DLL SipHash : public MessageAuthenticationCode + { + public: + SipHash(size_t c = 2, size_t d = 4) : m_C(c), m_D(d) {} + + void clear(); + std::string name() const; + + MessageAuthenticationCode* clone() const; + + size_t output_length() const { return 8; } + + Key_Length_Specification key_spec() const + { + return Key_Length_Specification(16); + } + private: + void add_data(const byte[], size_t); + void final_result(byte[]); + void key_schedule(const byte[], size_t); + + const size_t m_C, m_D; + secure_vector<u64bit> m_V; + u64bit m_mbuf = 0; + size_t m_mbuf_pos = 0; + byte m_words = 0; + }; + +} + +#endif |