Table of Contents

Interface IMac

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

Defines the interface for a Message Authentication Code (MAC) algorithm.

public interface IMac : IDisposable
Inherited Members

Remarks

A MAC takes a secret key and a message and produces a fixed-size tag that can be used to verify the authenticity and integrity of the message. Only parties that know the key can produce or verify valid tags.

Implementations support a streaming API: call Update(ReadOnlySpan<byte>) one or more times, then call Finalize(Span<byte>) to produce the tag. Call Reset() to reuse the instance with the same key.

Properties

AlgorithmName

Gets the name of the MAC algorithm.

string AlgorithmName { get; }

Property Value

string

MacSize

Gets the MAC output size in bytes.

int MacSize { get; }

Property Value

int

Methods

Finalize(Span<byte>)

Computes the final MAC tag and writes it to destination.

void Finalize(Span<byte> destination)

Parameters

destination Span<byte>

The buffer to receive the MAC tag. Must be at least MacSize bytes.

Exceptions

ArgumentException

destination is too small.

Reset()

Resets the MAC to its initial state so it can be reused with the same key.

void Reset()

Update(ReadOnlySpan<byte>)

Feeds input data into the MAC computation.

void Update(ReadOnlySpan<byte> input)

Parameters

input ReadOnlySpan<byte>

The data to process.