Class ParallelHash
- Namespace
- CryptoHives.Foundation.Security.Cryptography.Hash
- Assembly
- CryptoHives.Foundation.Security.Cryptography.dll
Computes a variable-length output using ParallelHash (NIST SP 800-185).
public static class ParallelHash
- Inheritance
-
ParallelHash
- Inherited Members
Remarks
ParallelHash divides input into fixed-size blocks, hashes each block with SHAKE128 or SHAKE256
(i.e. KECCAK[256](block ‖ 1111, 256) or KECCAK[512](block ‖ 1111, 512)),
concatenates those chaining values with encoding of the block count and output length, and
finalizes with cSHAKE128 or cSHAKE256 using function-name string "ParallelHash"
per NIST SP 800-185 Section 6.3 / Appendix A.4.
Use ComputeHash128(Span<byte>, ReadOnlySpan<byte>, int, ReadOnlySpan<byte>) for 128-bit security (SHAKE128 inner blocks, cSHAKE128 finalization) and ComputeHash256(Span<byte>, ReadOnlySpan<byte>, int, ReadOnlySpan<byte>) for 256-bit security (SHAKE256, cSHAKE256). For incremental or streaming computation, use IncrementalParallelHash.
Fields
DefaultBlockSizeBytes
Default block size in bytes (4 MiB).
public const int DefaultBlockSizeBytes = 1048576
Field Value
Methods
ComputeHash128(byte[], int)
Computes a hash using ParallelHash128, returning the result as an immutable byte array.
public static byte[] ComputeHash128(byte[] inputData, int blockSizeBytes = 1048576)
Parameters
Returns
- byte[]
The 32-byte hash value.
Exceptions
- ArgumentNullException
Thrown when
inputDatais null.
ComputeHash128(Span<byte>, ReadOnlySpan<byte>, int, ReadOnlySpan<byte>)
Computes a hash using ParallelHash128.
public static Span<byte> ComputeHash128(Span<byte> output, ReadOnlySpan<byte> inputData, int blockSizeBytes = 1048576, ReadOnlySpan<byte> customization = default)
Parameters
outputSpan<byte>The output span to receive the hash.
inputDataReadOnlySpan<byte>The data to hash.
blockSizeBytesintBlock size in bytes (default: 4 MiB).
customizationReadOnlySpan<byte>Optional customization string S (default: empty).
Returns
ComputeHash256(byte[], int)
Computes a hash using ParallelHash256, returning the result as an immutable byte array.
public static byte[] ComputeHash256(byte[] inputData, int blockSizeBytes = 1048576)
Parameters
Returns
- byte[]
The 64-byte hash value.
Exceptions
- ArgumentNullException
Thrown when
inputDatais null.
ComputeHash256(Span<byte>, ReadOnlySpan<byte>, int, ReadOnlySpan<byte>)
Computes a hash using ParallelHash256.
public static Span<byte> ComputeHash256(Span<byte> output, ReadOnlySpan<byte> inputData, int blockSizeBytes = 1048576, ReadOnlySpan<byte> customization = default)
Parameters
outputSpan<byte>The output span to receive the hash.
inputDataReadOnlySpan<byte>The data to hash.
blockSizeBytesintBlock size in bytes (default: 4 MiB).
customizationReadOnlySpan<byte>Optional customization string S (default: empty).