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
MacSize
Gets the MAC output size in bytes.
int MacSize { get; }
Property Value
Methods
Finalize(Span<byte>)
Computes the final MAC tag and writes it to destination.
void Finalize(Span<byte> destination)
Parameters
Exceptions
- ArgumentException
destinationis 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
inputReadOnlySpan<byte>The data to process.