Table of Contents

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

int

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

inputData byte[]

The data to hash.

blockSizeBytes int

Block size in bytes (default: 4 MiB).

Returns

byte[]

The 32-byte hash value.

Exceptions

ArgumentNullException

Thrown when inputData is 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

output Span<byte>

The output span to receive the hash.

inputData ReadOnlySpan<byte>

The data to hash.

blockSizeBytes int

Block size in bytes (default: 4 MiB).

customization ReadOnlySpan<byte>

Optional customization string S (default: empty).

Returns

Span<byte>

The computed hash value as a span.

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

inputData byte[]

The data to hash.

blockSizeBytes int

Block size in bytes (default: 4 MiB).

Returns

byte[]

The 64-byte hash value.

Exceptions

ArgumentNullException

Thrown when inputData is 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

output Span<byte>

The output span to receive the hash.

inputData ReadOnlySpan<byte>

The data to hash.

blockSizeBytes int

Block size in bytes (default: 4 MiB).

customization ReadOnlySpan<byte>

Optional customization string S (default: empty).

Returns

Span<byte>

The computed hash value as a span.