SHAKE

Implementation of the SHAKE extendable output function (XOF). Standard: FIPS 202, SHA 3, Section 6.3

struct SHAKE (
uint bitsize
bool raw = false
) if (
bitsize == 128 ||
bitsize == 256
) {
enum name;
}

Examples

Test SHAKE128

1 import std.stdio;
2 
3 SHAKE128 shake;
4 ubyte[32] buf;
5 
6 shake.nextBytes(buf);
7 
8 assert(buf == x"7f9c2ba4e88f827d616045507605853ed73b8093f6efbc88eb1a6eacfa66ef26", shake.name~" failed.");
9 
10 shake.start();
11 shake.put(cast(const ubyte[]) "The quick brown fox jumps over the lazy dog");
12 shake.nextBytes(buf);
13 assert(buf == x"f4202e3c5852f9182a0430fd8144f0a74b95e7417ecae17db0f8cfeed0e3e66e", shake.name~" failed.");

Test SHAKE256

1 import std.stdio;
2 
3 SHAKE256 shake;
4 ubyte[64] buf;
5 
6 shake.nextBytes(buf);
7 
8 assert(buf == x"46b9dd2b0ba88d13233b3feb743eeb243fcd52ea62b81b82b50c27646ed5762fd75dc4ddd8c0f200cb05019d67b592f6fc821c49479ab48640292eacb3b7c4be", shake.name~" failed.");

Meta