File: skein.hpp

package info (click to toggle)
salmon 1.10.2%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 35,580 kB
  • sloc: cpp: 199,285; ansic: 171,082; sh: 859; python: 792; makefile: 235
file content (196 lines) | stat: -rw-r--r-- 5,163 bytes parent folder | download | duplicates (8)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/*
This code is written by kerukuro and released into public domain.
*/

#ifndef DIGESTPP_ALGORITHM_SKEIN_HPP
#define DIGESTPP_ALGORITHM_SKEIN_HPP

#include "../hasher.hpp"
#include "detail/skein_provider.hpp"
#include "mixin/skein_mixin.hpp"

namespace digestpp
{

/**
 * @brief Skein1024 hash function
 *
 * Use this variant when the required hash size is known in advance. Otherwise, use \ref skein1024_xof
 *
 * @hash
 *
 * @outputsize arbitrary
 *
 * @defaultsize 1024 bits
 *
 * @throw std::runtime_error if the requested digest size is not divisible by 8 (full bytes)
 *
 * @mixinparams personalization, nonce, key
 *
 * @mixin{mixin::skein_mixin}
 *
 * @par Example:\n
 * @code // Output a 256-bit Skein1024 digest of a string
 * digestpp::skein1024 hasher(256);
 * hasher.absorb("The quick brown fox jumps over the lazy dog");
 * std::cout << hasher.hexdigest() << '\n';
 * @endcode
 *
 * @par Example output:\n
 * @code 054922d4393e36af62143986221555bee407671f6e57631bd7273e215a714833
 * @endcode
 *
 * @sa hasher, mixin::skein_mixin, skein1024_xof
 */
typedef hasher<detail::skein_provider<1024, false>, mixin::skein_mixin> skein1024;

/**
 * @brief Skein512 hash function
 *
 * Use this variant when the required hash size is known in advance. Otherwise, use \ref skein512_xof
 *
 * @hash
 *
 * @outputsize arbitrary
 *
 * @defaultsize 512 bits
 *
 * @throw std::runtime_error if the requested digest size is not divisible by 8 (full bytes)
 *
 * @mixinparams personalization, nonce, key
 *
 * @mixin{mixin::skein_mixin}
 *
 * @par Example:\n
 * @code // Output a 256-bit Skein512 digest of a string
 * digestpp::skein512 hasher(256);
 * hasher.absorb("The quick brown fox jumps over the lazy dog");
 * std::cout << hasher.hexdigest() << '\n';
 * @endcode
 *
 * @par Example output:\n
 * @code b3250457e05d3060b1a4bbc1428bc75a3f525ca389aeab96cfa34638d96e492a
 * @endcode
 *
 * @sa hasher, mixin::skein_mixin, skein512_xof
 */
typedef hasher<detail::skein_provider<512, false>, mixin::skein_mixin> skein512;

/**
 * @brief Skein256 hash function
 *
 * Use this variant when the required hash size is known in advance. Otherwise, use \ref skein256_xof
 *
 * @hash
 *
 * @outputsize arbitrary
 *
 * @defaultsize 256 bits
 *
 * @throw std::runtime_error if the requested digest size is not divisible by 8 (full bytes)
 *
 * @mixinparams personalization, nonce, key
 *
 * @mixin{mixin::skein_mixin}
 *
 * @par Example:\n
 * @code // Output a 512-bit Skein256 digest of a string
 * digestpp::skein256 hasher(512);
 * hasher.absorb("The quick brown fox jumps over the lazy dog");
 * std::cout << hasher.hexdigest() << '\n';
 * @endcode
 *
 * @par Example output:\n
 * @code f8138e72cdd9e11cf09e4be198c234acb0d21a9f75f936e989cf532f1fa9f4fb21d255811f0f1592fb3617d04704add875ae7bd16ddbbeaed4eca6eb9675d2c6
 * @endcode
 *
 * @sa hasher, mixin::skein_mixin, skein256_xof
 */
typedef hasher<detail::skein_provider<256, false>, mixin::skein_mixin> skein256;

/**
 * @brief Skein1024 in XOF mode
 *
 * Use this variant when the required hash size is not known in advance. Otherwise, use \ref skein1024
 *
 * @xof
 *
 * @mixinparams personalization, nonce, key
 *
 * @mixin{mixin::skein_mixin}
 *
 * @par Example:\n
 * @code // Absorb a string and squeeze 32 bytes of output
 * digestpp::skein1024_xof hasher;
 * hasher.absorb("The quick brown fox jumps over the lazy dog");
 * std::cout << hasher.hexsqueeze(32) << '\n';
 * @endcode
 *
 * @par Example output:\n
 * @code 20cd7366b0a3713037fdbf8c635ea190943261455689792a327d93a9fd74dedf
 * @endcode
 *
 * @sa hasher, mixin::skein_mixin, skein1024
 */
typedef hasher<detail::skein_provider<1024, true>, mixin::skein_mixin> skein1024_xof;

/**
 * @brief Skein512 in XOF mode
 *
 * Use this variant when the required hash size is not known in advance. Otherwise, use \ref skein512
 *
 * @xof
 *
 * @mixinparams personalization, nonce, key
 *
 * @mixin{mixin::skein_mixin}
 *
 * @par Example:\n
 * @code // Absorb a string and squeeze 32 bytes of output
 * digestpp::skein512_xof hasher;
 * hasher.absorb("The quick brown fox jumps over the lazy dog");
 * std::cout << hasher.hexsqueeze(32) << '\n';
 * @endcode
 *
 * @par Example output:\n
 * @code cd7447a48e387ca4461e75ede8424566f7ed816a80bfac5bed291ac107f96170
 * @endcode
 *
 * @sa hasher, mixin::skein_mixin, skein512
 */
typedef hasher<detail::skein_provider<512, true>, mixin::skein_mixin> skein512_xof;

/**
 * @brief Skein256 in XOF mode
 *
 * Use this variant when the required hash size is not known in advance. Otherwise, use \ref skein256
 *
 * @xof
 *
 * @mixinparams personalization, nonce, key
 *
 * @mixin{mixin::skein_mixin}
 *
 * @par Example:\n
 * @code // Absorb a string and squeeze 32 bytes of output
 * digestpp::skein256_xof hasher;
 * hasher.absorb("The quick brown fox jumps over the lazy dog");
 * std::cout << hasher.hexsqueeze(32) << '\n';
 * @endcode
 *
 * @par Example output:\n
 * @code 217021fbabe331c5753024fe4c17a005a698b037859ca8f4f0fb9112dce5605c
 * @endcode
 *
 * @sa hasher, mixin::skein_mixin, skein256
 */
typedef hasher<detail::skein_provider<256, true>, mixin::skein_mixin> skein256_xof;

} // namespace digestpp

#endif