digestpp 1.0
C++11 header-only message digest library
Loading...
Searching...
No Matches
skein_mixin.hpp
Go to the documentation of this file.
1/*
2This code is written by kerukuro and released into public domain.
3*/
4
5#ifndef DIGESTPP_MIXINS_SKEIN_HPP
6#define DIGESTPP_MIXINS_SKEIN_HPP
7
8namespace digestpp
9{
10
11namespace mixin
12{
13
18template<typename T>
20{
21public:
28 inline hasher<T, mixin::skein_mixin>& set_personalization(const std::string& personalization)
29 {
30 auto& skein = static_cast<hasher<T, mixin::skein_mixin>&>(*this);
31 skein.provider.set_personalization(personalization);
32 skein.provider.init();
33 return skein;
34 }
35
43 template<typename C, typename std::enable_if<detail::is_byte<C>::value>::type* = nullptr>
44 inline hasher<T, mixin::skein_mixin>& set_personalization(const C* personalization, size_t personalization_len)
45 {
46 return set_personalization(std::string(reinterpret_cast<const char*>(personalization), personalization_len));
47 }
48
55 inline hasher<T, mixin::skein_mixin>& set_key(const std::string& key)
56 {
57 auto& skein = static_cast<hasher<T, mixin::skein_mixin>&>(*this);
58 skein.provider.set_key(key);
59 skein.provider.init();
60 return skein;
61 }
62
70 template<typename C, typename std::enable_if<detail::is_byte<C>::value>::type* = nullptr>
71 inline hasher<T, mixin::skein_mixin>& set_key(const C* key, size_t key_len)
72 {
73 return set_key(std::string(reinterpret_cast<const char*>(key), key_len));
74 }
75
82 inline hasher<T, mixin::skein_mixin>& set_nonce(const std::string& nonce)
83 {
84 auto& skein = static_cast<hasher<T, mixin::skein_mixin>&>(*this);
85 skein.provider.set_nonce(nonce);
86 skein.provider.init();
87 return skein;
88 }
89
97 template<typename C, typename std::enable_if<detail::is_byte<C>::value>::type* = nullptr>
98 inline hasher<T, mixin::skein_mixin>& set_nonce(const C* nonce, size_t nonce_len)
99 {
100 return set_nonce(std::string(reinterpret_cast<const char*>(nonce), nonce_len));
101 }
102};
103
104} // namespace mixin
105
106} // namespace digestpp
107
108#endif
Main class template implementing the public API for hashing.
Definition hasher.hpp:38
Defines additional public functions for Skein family of algorithms.
Definition skein_mixin.hpp:20
hasher< T, mixin::skein_mixin > & set_key(const C *key, size_t key_len)
Set key from raw buffer.
Definition skein_mixin.hpp:71
hasher< T, mixin::skein_mixin > & set_nonce(const C *nonce, size_t nonce_len)
Set nonce from raw buffer.
Definition skein_mixin.hpp:98
hasher< T, mixin::skein_mixin > & set_key(const std::string &key)
Set key from std::string.
Definition skein_mixin.hpp:55
hasher< T, mixin::skein_mixin > & set_nonce(const std::string &nonce)
Set nonce from std::string.
Definition skein_mixin.hpp:82
hasher< T, mixin::skein_mixin > & set_personalization(const std::string &personalization)
Set personalization from std::string.
Definition skein_mixin.hpp:28
hasher< T, mixin::skein_mixin > & set_personalization(const C *personalization, size_t personalization_len)
Set personalization from raw buffer.
Definition skein_mixin.hpp:44
digestpp namespace
Definition ascon.hpp:14