Used To Authenticate The Origin and Nature of A Message
Used To Authenticate The Origin and Nature of A Message
Used To Authenticate The Origin and Nature of A Message
- One-time MAC
- Carter-Wegman MAC
- HMAC
A one-time MAC is a lot like one-time encryption in that a MAC algorithm for a single use
is defined to secure the transmission of data. One-time MACs tend to be faster than
other authentication algorithms.
A Carter-Wegman MAC is similar to a one-time MAC, except it also incorporates a
pseudorandom function that makes it possible for a single key to be used many times
over.
The HMAC is based on an approved hash function. It performs a function similar to that
of the Rivest-Shamir-Adelman (RSA) cryptosystem, which is one of the oldest methods
of sending data securely. The functions that can be used in HMAC are outlined in the
following publications:
HMAC
HMAC can provide authentication using a shared secret instead of using digital
signatures with asymmetric cryptography. It trades off the need for a complex public key
infrastructure by delegating the key exchange to the communicating parties, who are responsible
for establishing and using a trusted channel to agree on the key prior to communication.
Any cryptographic hash function, such as SHA-2 or SHA-3, may be used in the calculation of an
HMAC; the resulting MAC algorithm is termed HMAC-X, where X is the hash function used (e.g.
HMAC-SHA256 or HMAC-SHA3-512). The cryptographic strength of the HMAC depends upon
the cryptographic strength of the underlying hash function, the size of its hash output, and the
size and quality of the key.[1]
HMAC uses two passes of hash computation. Before either pass, the secret key is used to derive
two keys – inner and outer. Next, the first pass of the hash algorithm produces an internal hash
derived from the message and the inner key. The second pass produces the final HMAC code
derived from the inner hash result and the outer key. Thus the algorithm provides better immunity
against length extension attacks.
An iterative hash function (one that uses the Merkle–Damgård construction) breaks up a
message into blocks of a fixed size and iterates over them with a compression function. For
example, SHA-256 operates on 512-bit blocks. The size of the output of HMAC is the same as
that of the underlying hash function (e.g., 256 and 512 bits in the case of SHA-256 and SHA3-
512, respectively), although it can be truncated if desired.
HMAC does not encrypt the message. Instead, the message (encrypted or not) must be sent
alongside the HMAC hash. Parties with the secret key will hash the message again themselves,
and if it is authentic, the received and computed hashes will match.
The definition and analysis of the HMAC construction was first published in 1996 in a paper
by Mihir Bellare, Ran Canetti, and Hugo Krawczyk,[1][2] and they also wrote RFC 2104 in 1997.
[3]
The 1996 paper also defined a nested variant called NMAC (Nested MAC). FIPS PUB 198
generalizes and standardizes the use of HMACs.[4] HMAC is used within the IPsec,
[2]
SSH and TLS protocols and for JSON Web Tokens.
where
Hash
b , bytes L , bytes
function H
MD5 64 16
SHA-1 64 20
SHA-224 64 28
SHA-256 64 32
SHA-512/224 128 28
SHA-512/256 128 32
SHA-384 128 48
SHA3-224 144 28
SHA3-256 136 32
SHA3-384 104 48
SHA3-512 72 64[6]
out = H( in )
L = length( out )
b = H's internal block length [3]
Limitations of MAC