File: shake.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 (115 lines) | stat: -rw-r--r-- 3,007 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
/*
This code is written by kerukuro and released into public domain.
*/

#ifndef DIGESTPP_ALGORITHM_SHAKE_HPP
#define DIGESTPP_ALGORITHM_SHAKE_HPP

#include "../hasher.hpp"
#include "detail/shake_provider.hpp"
#include "mixin/cshake_mixin.hpp"

namespace digestpp
{

/**
 * @brief SHAKE128 function
 *
 * @xof
 *
 * @par Example:\n
 * @code // Absorb a string and squeeze 32 bytes of output
 * digestpp::shake128 hasher;
 * hasher.absorb("The quick brown fox jumps over the lazy dog");
 * std::cout << hasher.hexsqueeze(32) << '\n';
 * @endcode
 *
 * @par Example output:\n
 * @code f4202e3c5852f9182a0430fd8144f0a74b95e7417ecae17db0f8cfeed0e3e66e
 * @endcode
 *
 * @sa hasher, cshake128
 */
typedef hasher<detail::shake_provider<128, 24>> shake128;

/**
 * @brief SHAKE256 function
 *
 * @xof
 *
 * @par Example:\n
 * @code // Absorb a string and squeeze 32 bytes of output
 * digestpp::shake256 hasher;
 * hasher.absorb("The quick brown fox jumps over the lazy dog");
 * std::cout << hasher.hexsqueeze(32) << '\n';
 * @endcode
 *
 * @par Example output:\n
 * @code 2f671343d9b2e1604dc9dcf0753e5fe15c7c64a0d283cbbf722d411a0e36f6ca
 * @endcode
 *
 * @sa hasher, cshake256
 */
typedef hasher<detail::shake_provider<256, 24>> shake256;

/**
 * @brief Customizable cSHAKE128 function
 *
 * Extendable output function similar to SHAKE128 but with possibility to use a customization string.
 * When used without a customization string, the output is identical to \ref shake128.
 *
 * @xof
 *
 * @mixinparams function name, customization
 *
 * @mixin{mixin::cshake_mixin}
 *
 * @par Example:\n
 * @code // Absorb a string and squeeze 32 bytes of output
 * digestpp::cshake128 hasher;
 * hasher.set_customization("My Custom SHAKE");
 * hasher.absorb("The quick brown fox jumps over the lazy dog");
 * std::cout << hasher.hexsqueeze(32) << '\n';
 * @endcode
 *
 * @par Example output:\n
 * @code 5b831bfe752f7f05d81f18f0e83a92eb48b9e3d460c10022ecb4852aa8b1f9d4
 * @endcode
 *
 * @sa hasher, mixin::cshake_mixin
 */
typedef hasher<detail::shake_provider<128, 24>, mixin::cshake_mixin> cshake128;

/**
 * @brief Customizable cSHAKE256 function
 *
 * Extendable output function similar to SHAKE256 but with possibility to use a customization string.
 * When used without a customization string, the output is identical to \ref shake256.
 *
 * @xof
 *
 * @mixinparams function name, customization
 *
 * @mixin{mixin::cshake_mixin}
 *
 * @par Example:\n
 * @code // Absorb a string and squeeze 32 bytes of output
 * digestpp::cshake256 hasher;
 * hasher.set_customization("My Custom SHAKE");
 * hasher.absorb("The quick brown fox jumps over the lazy dog");
 * std::cout << hasher.hexsqueeze(32) << '\n';
 * @endcode
 *
 * @par Example output:\n
 * @code bcebde2c2e18f6efd99ee9e0def1383e86595d72e49b4754f7f727a962c3cd3d
 * @endcode
 *
 * @sa hasher, mixin::cshake_mixin
 */
typedef hasher<detail::shake_provider<256, 24>, mixin::cshake_mixin> cshake256;

} // namespace digestpp

#endif // DIGESTPP_ALGORITHM_SHAKE_HPP