What’s coming in .NET 9
.NET 9 introduces a new one-shot hash method on the CryptographicOperations
class. It also adds new classes that use the Keccak Message Authentication Code (KMAC) algorithm.
CryptographicOperations.HashData() method
One-shot APIs are preferable because they can provide the best possible performance and reduce or eliminate allocations. Examples of one-shot implementations of hash functions include SHA256.HashData
and HMACSHA256.HashData
.
The upcoming CryptographicOperations.HashData
API will let you produce a hash as a one-shot where the algorithm used is determined by a HashAlgorithmName
, as shown in the following code:
static void HashAndProcessData(HashAlgorithmName hashAlgorithmName, byte[] data)
{
byte[] hash = CryptographicOperations.HashData(hashAlgorithmName, data);
ProcessHash(hash);
}
KMAC algorithm
KMAC is a pseudorandom function and keyed hash function based on Keccak as specified by NIST SP-800-185. Four variations...