Class KMac256
- Namespace
- CryptoHives.Foundation.Security.Cryptography.Mac
- Assembly
- CryptoHives.Foundation.Security.Cryptography.dll
Computes the KMAC256 (Keccak Message Authentication Code) for the input data.
public sealed class KMac256 : KeccakKMacCore, ICryptoTransform, IDisposable, IResettable, IExtendableOutput
- Inheritance
-
KMac256
- Implements
- Inherited Members
Remarks
This is a fully managed implementation of KMAC256 based on the Keccak sponge construction. It does not rely on OS or hardware cryptographic APIs, ensuring deterministic behavior across all platforms and runtimes.
KMAC256 is a MAC function based on Keccak (cSHAKE256) defined in NIST SP 800-185. It provides 256-bit security strength and supports variable-length output.
KMAC can be used as both a traditional MAC (fixed output length) or as a pseudorandom function (XOF mode with arbitrary output length).
Constructors
KMac256(byte[], int, byte[])
Initializes a new instance of the KMac256 class.
public KMac256(byte[] key, int outputBytes, byte[] customization)
Parameters
keybyte[]The secret key.
outputBytesintThe desired output size in bytes.
customizationbyte[]Optional customization bytes S.
KMac256(byte[], int, string?)
Initializes a new instance of the KMac256 class.
public KMac256(byte[] key, int outputBytes = 64, string? customization = null)
Parameters
keybyte[]The secret key.
outputBytesintThe desired output size in bytes.
customizationstringOptional customization string S.
Fields
DefaultOutputBits
The default output size in bits.
public const int DefaultOutputBits = 512
Field Value
RateBytes
The rate in bytes (1088 bits for KMAC256).
public const int RateBytes = 136
Field Value
Properties
AlgorithmName
Gets the name of the hash algorithm.
public override string AlgorithmName { get; }
Property Value
BlockSize
Gets the block size in bytes used by the hash algorithm.
public override int BlockSize { get; }
Property Value
Methods
Create(byte[], int, string?)
Creates a new instance of the KMac256 class.
public static KMac256 Create(byte[] key, int outputBytes = 64, string? customization = null)
Parameters
keybyte[]The secret key.
outputBytesintThe desired output size in bytes.
customizationstringOptional customization string S.
Returns
- KMac256
A new KMAC256 instance.