Keccak-f[1600]
Purpose
Keccak-f[1600] is the largest variant of the Keccak-f permutation, which is the building block for the SHA-3 family and KangarooTwelve family of constructions. It has a 1600-bit state and can be used to construct hash functions, XOFs, MACs, KDFs, stream ciphers, and AEAD schemes.
Usage
IncrementalKeccakf1600
Provides access to the Keccak-f[1600] permutation. Setting the state to all-zero, absorbing (XORing) data into the state, permuting the state (with 24 or 12 rounds), and squeezing output from the state are supported.
The entire state can be accessed, permuting the state is a separate function, and there's no concept of finalization. This enables flexibility for different custom constructions.
// Initialize the state to all-zero
using var keccak = new IncrementalKeccakf1600();
// IMPORTANT: Pad/domain separate the message (not shown here)
// Process the message in blocks
foreach (var messageBlock in messageBlocks) {
// Absorb (XOR) data into the state at offset (default of 0)
keccak.XorBytes(messageBlock, offset);
// Permute the state (full or half rounds)
if (fullRounds) {
keccak.Permute24(); // Like SHA-3/SHAKE
}
else {
keccak.Permute12(); // Like TurboSHAKE
}
}
// Squeeze output from the state (once or multiple blocks)
foreach (var outputBlock in output) {
keccak.ExtractBytes(outputBlock, offset);
// Permute the state (full or half rounds)
if (fullRounds) {
keccak.Permute24(); // Like SHA-3/SHAKE
}
else {
keccak.Permute12(); // Like TurboSHAKE
}
}
// Reset the state to all-zero
keccak.Reinitialize();Exceptions
offset is less than MinOffset or greater than MaxOffset.
bytes.Length + offset is greater than StateSize.
Methods cannot be called from multiple threads simultaneously.
The object has been disposed.
Constants
These are used for validation and/or save you defining your own constants.
Notes
Last updated