Class IncrementalParallelHash
- Namespace
- CryptoHives.Foundation.Security.Cryptography.Hash
- Assembly
- CryptoHives.Foundation.Security.Cryptography.dll
Provides incremental ParallelHash computation.
public sealed class IncrementalParallelHash : IDisposable
- Inheritance
-
IncrementalParallelHash
- Implements
- Inherited Members
Remarks
Absorbing is streaming: each block is fed straight into a reused inner XOF and, once full, collapsed to a chaining value that goes directly into the final cSHAKE. Nothing but the sponge states and a byte counter is retained, so the instance is O(1) in the message length.
Constructors
IncrementalParallelHash(ShakeType, int, ReadOnlySpan<byte>)
Initializes a new instance of the IncrementalParallelHash class.
public IncrementalParallelHash(IncrementalParallelHash.ShakeType type = ShakeType.Shake128, int blockSizeBytes = 1048576, ReadOnlySpan<byte> customization = default)
Parameters
typeIncrementalParallelHash.ShakeTypeThe SHAKE variant used for the ParallelHash construction.
blockSizeBytesintThe block size in bytes.
customizationReadOnlySpan<byte>Optional customization string S (default: empty).
Fields
DefaultBlockSizeBytes
The default block size in bytes (1 MiB).
public const int DefaultBlockSizeBytes = 1048576
Field Value
Methods
Absorb(ReadOnlySpan<byte>)
Absorbs data into the ParallelHash instance.
public void Absorb(ReadOnlySpan<byte> data)
Parameters
dataReadOnlySpan<byte>The data to absorb.
Exceptions
- InvalidOperationException
Thrown after the hash has been squeezed.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Reset()
Resets the instance for reuse.
public void Reset()
Squeeze(Span<byte>)
Squeezes the final hash output.
public Span<byte> Squeeze(Span<byte> output)
Parameters
Returns
Remarks
ParallelHash encodes the requested output length into the digest, so this may be called only once per message; use Reset() to start another.
Exceptions
- InvalidOperationException
Thrown when called more than once.