1 /*
2 This code is written by kerukuro and released into public domain.
3 */
4 
5 #ifndef DIGESTPP_ALGORITHM_SKEIN_HPP
6 #define DIGESTPP_ALGORITHM_SKEIN_HPP
7 
8 #include "../hasher.hpp"
9 #include "detail/skein_provider.hpp"
10 #include "mixin/skein_mixin.hpp"
11 
12 namespace digestpp
13 {
14 
15 /**
16  * @brief Skein1024 hash function
17  *
18  * Use this variant when the required hash size is known in advance. Otherwise, use \ref skein1024_xof
19  *
20  * @hash
21  *
22  * @outputsize arbitrary
23  *
24  * @defaultsize 1024 bits
25  *
26  * @throw std::runtime_error if the requested digest size is not divisible by 8 (full bytes)
27  *
28  * @mixinparams personalization, nonce, key
29  *
30  * @mixin{mixin::skein_mixin}
31  *
32  * @par Example:\n
33  * @code // Output a 256-bit Skein1024 digest of a string
34  * digestpp::skein1024 hasher(256);
35  * hasher.absorb("The quick brown fox jumps over the lazy dog");
36  * std::cout << hasher.hexdigest() << '\n';
37  * @endcode
38  *
39  * @par Example output:\n
40  * @code 054922d4393e36af62143986221555bee407671f6e57631bd7273e215a714833
41  * @endcode
42  *
43  * @sa hasher, mixin::skein_mixin, skein1024_xof
44  */
45 typedef hasher<detail::skein_provider<1024, false>, mixin::skein_mixin> skein1024;
46 
47 /**
48  * @brief Skein512 hash function
49  *
50  * Use this variant when the required hash size is known in advance. Otherwise, use \ref skein512_xof
51  *
52  * @hash
53  *
54  * @outputsize arbitrary
55  *
56  * @defaultsize 512 bits
57  *
58  * @throw std::runtime_error if the requested digest size is not divisible by 8 (full bytes)
59  *
60  * @mixinparams personalization, nonce, key
61  *
62  * @mixin{mixin::skein_mixin}
63  *
64  * @par Example:\n
65  * @code // Output a 256-bit Skein512 digest of a string
66  * digestpp::skein512 hasher(256);
67  * hasher.absorb("The quick brown fox jumps over the lazy dog");
68  * std::cout << hasher.hexdigest() << '\n';
69  * @endcode
70  *
71  * @par Example output:\n
72  * @code b3250457e05d3060b1a4bbc1428bc75a3f525ca389aeab96cfa34638d96e492a
73  * @endcode
74  *
75  * @sa hasher, mixin::skein_mixin, skein512_xof
76  */
77 typedef hasher<detail::skein_provider<512, false>, mixin::skein_mixin> skein512;
78 
79 /**
80  * @brief Skein256 hash function
81  *
82  * Use this variant when the required hash size is known in advance. Otherwise, use \ref skein256_xof
83  *
84  * @hash
85  *
86  * @outputsize arbitrary
87  *
88  * @defaultsize 256 bits
89  *
90  * @throw std::runtime_error if the requested digest size is not divisible by 8 (full bytes)
91  *
92  * @mixinparams personalization, nonce, key
93  *
94  * @mixin{mixin::skein_mixin}
95  *
96  * @par Example:\n
97  * @code // Output a 512-bit Skein256 digest of a string
98  * digestpp::skein256 hasher(512);
99  * hasher.absorb("The quick brown fox jumps over the lazy dog");
100  * std::cout << hasher.hexdigest() << '\n';
101  * @endcode
102  *
103  * @par Example output:\n
104  * @code f8138e72cdd9e11cf09e4be198c234acb0d21a9f75f936e989cf532f1fa9f4fb21d255811f0f1592fb3617d04704add875ae7bd16ddbbeaed4eca6eb9675d2c6
105  * @endcode
106  *
107  * @sa hasher, mixin::skein_mixin, skein256_xof
108  */
109 typedef hasher<detail::skein_provider<256, false>, mixin::skein_mixin> skein256;
110 
111 /**
112  * @brief Skein1024 in XOF mode
113  *
114  * Use this variant when the required hash size is not known in advance. Otherwise, use \ref skein1024
115  *
116  * @xof
117  *
118  * @mixinparams personalization, nonce, key
119  *
120  * @mixin{mixin::skein_mixin}
121  *
122  * @par Example:\n
123  * @code // Absorb a string and squeeze 32 bytes of output
124  * digestpp::skein1024_xof hasher;
125  * hasher.absorb("The quick brown fox jumps over the lazy dog");
126  * std::cout << hasher.hexsqueeze(32) << '\n';
127  * @endcode
128  *
129  * @par Example output:\n
130  * @code 20cd7366b0a3713037fdbf8c635ea190943261455689792a327d93a9fd74dedf
131  * @endcode
132  *
133  * @sa hasher, mixin::skein_mixin, skein1024
134  */
135 typedef hasher<detail::skein_provider<1024, true>, mixin::skein_mixin> skein1024_xof;
136 
137 /**
138  * @brief Skein512 in XOF mode
139  *
140  * Use this variant when the required hash size is not known in advance. Otherwise, use \ref skein512
141  *
142  * @xof
143  *
144  * @mixinparams personalization, nonce, key
145  *
146  * @mixin{mixin::skein_mixin}
147  *
148  * @par Example:\n
149  * @code // Absorb a string and squeeze 32 bytes of output
150  * digestpp::skein512_xof hasher;
151  * hasher.absorb("The quick brown fox jumps over the lazy dog");
152  * std::cout << hasher.hexsqueeze(32) << '\n';
153  * @endcode
154  *
155  * @par Example output:\n
156  * @code cd7447a48e387ca4461e75ede8424566f7ed816a80bfac5bed291ac107f96170
157  * @endcode
158  *
159  * @sa hasher, mixin::skein_mixin, skein512
160  */
161 typedef hasher<detail::skein_provider<512, true>, mixin::skein_mixin> skein512_xof;
162 
163 /**
164  * @brief Skein256 in XOF mode
165  *
166  * Use this variant when the required hash size is not known in advance. Otherwise, use \ref skein256
167  *
168  * @xof
169  *
170  * @mixinparams personalization, nonce, key
171  *
172  * @mixin{mixin::skein_mixin}
173  *
174  * @par Example:\n
175  * @code // Absorb a string and squeeze 32 bytes of output
176  * digestpp::skein256_xof hasher;
177  * hasher.absorb("The quick brown fox jumps over the lazy dog");
178  * std::cout << hasher.hexsqueeze(32) << '\n';
179  * @endcode
180  *
181  * @par Example output:\n
182  * @code 217021fbabe331c5753024fe4c17a005a698b037859ca8f4f0fb9112dce5605c
183  * @endcode
184  *
185  * @sa hasher, mixin::skein_mixin, skein256
186  */
187 typedef hasher<detail::skein_provider<256, true>, mixin::skein_mixin> skein256_xof;
188 
189 } // namespace digestpp
190 
191 #endif