Class KMac128
- Namespace
- CryptoHives.Foundation.Security.Cryptography.Mac
- Assembly
- CryptoHives.Foundation.Security.Cryptography.dll
Computes the KMAC128 (Keccak Message Authentication Code) for the input data.
public sealed class KMac128 : KeccakKMacCore, ICryptoTransform, IDisposable, IResettable, IExtendableOutput
- Inheritance
-
KMac128
- Implements
- Inherited Members
Remarks
This is a fully managed implementation of KMAC128 based on the Keccak sponge construction. It does not rely on OS or hardware cryptographic APIs, ensuring deterministic behavior across all platforms and runtimes.
KMAC128 is a MAC function based on Keccak (cSHAKE128) defined in NIST SP 800-185. It provides 128-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
KMac128(byte[], int, byte[])
Initializes a new instance of the KMac128 class.
public KMac128(byte[] key, int outputBytes, byte[] customization)
Parameters
keybyte[]The secret key.
outputBytesintThe desired output size in bytes.
customizationbyte[]Optional customization bytes S.
KMac128(byte[], int, string?)
Initializes a new instance of the KMac128 class.
public KMac128(byte[] key, int outputBytes = 32, 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 = 256
Field Value
RateBytes
The rate in bytes (1344 bits for KMAC128).
public const int RateBytes = 168
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 KMac128 class.
public static KMac128 Create(byte[] key, int outputBytes = 32, string? customization = null)
Parameters
keybyte[]The secret key.
outputBytesintThe desired output size in bytes.
customizationstringOptional customization string S.
Returns
- KMac128
A new KMAC128 instance.