Table of Contents

Class AsconHashAlgorithm

Namespace
CryptoHives.Foundation.Security.Cryptography.Hash
Assembly
CryptoHives.Foundation.Security.Cryptography.dll

Base class for Ascon family hash algorithms, providing common sponge construction logic.

public abstract class AsconHashAlgorithm : HashAlgorithm, ICryptoTransform, IDisposable, IResettable
Inheritance
AsconHashAlgorithm
Implements
Derived
Inherited Members

Remarks

This base class eliminates code duplication across Ascon variants (AsconHash256, AsconXof128) by providing common implementations of HashCore, Initialize, and Dispose. Derived classes only need to provide IV constants and output squeezing logic.

Constructors

AsconHashAlgorithm()

Initializes a new instance of the AsconHashAlgorithm class.

protected AsconHashAlgorithm()

Fields

RateBytes

The rate in bytes (64 bits = 8 bytes) for all Ascon variants.

public const int RateBytes = 8

Field Value

int

Properties

BlockSize

Gets the block size in bytes used by the hash algorithm.

public override int BlockSize { get; }

Property Value

int

InitializationVector

Gets the initialization vector values for this variant.

protected abstract (ulong IV0, ulong IV1, ulong IV2, ulong IV3, ulong IV4) InitializationVector { get; }

Property Value

(ulong IV0, ulong IV1, ulong IV2, ulong IV3, ulong IV4)

OutputSizeBytes

Gets the output size in bytes for this variant.

protected abstract int OutputSizeBytes { get; }

Property Value

int

Methods

Dispose(bool)

Releases the unmanaged resources used by the HashAlgorithm and optionally releases the managed resources.

protected override sealed void Dispose(bool disposing)

Parameters

disposing bool

true to release both managed and unmanaged resources; false to release only unmanaged resources.

HashCore(ReadOnlySpan<byte>)

When overridden in a derived class, routes data written to the object into the hash algorithm for computing the hash.

protected override sealed void HashCore(ReadOnlySpan<byte> source)

Parameters

source ReadOnlySpan<byte>

The input to compute the hash code for.

Initialize()

Initializes an implementation of the HashAlgorithm class.

public override sealed void Initialize()

P12()

Applies the Ascon permutation p^12.

public void P12()

SqueezeOutput(Span<byte>)

Squeezes the output from the internal state.

protected abstract void SqueezeOutput(Span<byte> destination)

Parameters

destination Span<byte>

The destination span for the output.

TryHashFinal(Span<byte>, out int)

When overridden in a derived class, finalizes the hash computation and writes the result into the provided buffer.

protected override sealed bool TryHashFinal(Span<byte> destination, out int bytesWritten)

Parameters

destination Span<byte>

The target buffer to write the hash to.

bytesWritten int

The number of bytes written into the buffer.

Returns

bool

true if the destination buffer was large enough; otherwise false.