Contents

HMAC

A hash-based message authentication algorithm.

Declaration

struct HMAC<H> where H : HashFunction

Overview

Use hash-based message authentication to create a code with a value that’s dependent on both a block of data and a symmetric cryptographic key. Another party with access to the data and the same secret key can compute the code again and compare it to the original to detect whether the data changed. This serves a purpose similar to digital signing and verification, but depends on a shared symmetric key instead of public-key cryptography.

As with digital signing, the data isn’t hidden by this process. When you need to encrypt the data as well as authenticate it, use a cipher like AES or ChaChaPoly to put the data into a sealed box (an instance of AES.GCM.SealedBox or ChaChaPoly.SealedBox).

Topics

Getting a key

Working with codes

Creating an authentication code with one call

Creating an authentication code iteratively

Checking an authentication code

See Also

Message authentication codes