Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Used To Authenticate The Origin and Nature of A Message

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

MAC

Message Authentication Code (MAC), also referred to as a tag,


is used to authenticate the origin and nature of a message. MACs
use authentication cryptography to verify the legitimacy of data sent
through a network or transferred from one person to another.

MAC algorithm is a symmetric key cryptographic technique to


provide message authentication. For establishing MAC process,
the sender and receiver share a symmetric key K.

Essentially, a MAC is an encrypted checksum generated on the


underlying message that is sent along with a message to ensure
message authentication.
 The sender uses some publicly known MAC algorithm, inputs
the message and the secret key K and produces a MAC
value.
 Similar to hash, MAC function also compresses an arbitrary
long input into a fixed length output. The major difference
between hash and MAC is that MAC uses secret key during
the compression.
 The sender forwards the message along with the MAC. Here,
we assume that the message is sent in the clear, as we are
concerned of providing message origin authentication, not
confidentiality. If confidentiality is required then the
message needs encryption.
 On receipt of the message and the MAC, the receiver feeds
the received message and the shared secret key K into the
MAC algorithm and re-computes the MAC value.
 The receiver now checks equality of freshly computed MAC
with the MAC received from the sender. If they match, then
the receiver accepts the message and assures himself that
the message has been sent by the intended sender.
 If the computed MAC does not match the MAC sent by the
sender, the receiver cannot determine whether it is the
message that has been altered or it is the origin that has
been falsified. As a bottom-line, a receiver safely assumes
that the message is not the genuine.
There are different types of models Of Message Authentication Code (MAC)
as following below:

1. MAC without encryption –


This model can provide authentication but not confidentiality as anyone
can see the message.

2. Internal Error Code –


In this model of MAC, sender encrypts the content before sending it
through network for confidentiality. Thus this model provides
confidentiality as well as authentication.
M' = MAC(M, k)

3. External Error Code –


For cases when there is an alteration in message, we decrypt it for
waste, to overcome that problem, we opt for external error code. Here
we first apply MAC on the encrypted message ‘c’ and compare it with
received MAC value on the receiver’s side and then decrypt ‘c’ if they
both are same, else we simply discard the content received. Thus it
saves time.
c = E(M, k')
M' = MAC(c, k)
Although all MAC's accomplish the same end objective, there are a few different types.

- 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:

1. FIPS 180-4, Secure Hash Standard


2. FIPS 202, SHA-3 Standard: Permutation-Based Hash and Extendable-Output Functions

HMAC

With a Keyed-Hash Message Authentication Code (HMAC) system, a one-way hash is


used to create a unique MAC value for every message sent. The input parameters can
have various values assigned, and making them very different from each other may
produce a higher level of security.

In cryptography, an HMAC (sometimes expanded as either keyed-hash message


authentication code or hash-based message authentication code) is a specific type
of message authentication code (MAC) involving a cryptographic hash function and a secret
cryptographic key. As with any MAC, it may be used to simultaneously verify both the data
integrity and authenticity of a message. An HMAC is a type of keyed hash function that can also
be used in a key derivation scheme or a key stretching scheme.

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.

This definition is taken from RFC 2104:

where

H is a cryptographic hash function.


m is the message to be authenticated.
K is the secret key.
K’ is a block-sized key derived from the secret key, K; either by padding to the right with
0s up to the block size, or by hashing down to less than or equal to the block size first
and then padding to the right with zeros.
|| denotes concatenation.
+ denotes bitwise exclusive or (XOR).
opad is the block-sized outer padding, consisting of repeated bytes valued 0x5c.
ipad is the block-sized inner padding, consisting of repeated bytes valued 0x36. [3]

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

SHA-512 128 64[5]

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

There are two major limitations of MAC, both due to its


symmetric nature of operation −

 Establishment of Shared Secret.


o It can provide message authentication among pre-
decided legitimate users who have shared key.
o This requires establishment of shared secret prior to
use of MAC.
 Inability to Provide Non-Repudiation
o Non-repudiation is the assurance that a message
originator cannot deny any previously sent messages
and commitments or actions.
o MAC technique does not provide a non-repudiation
service. If the sender and receiver get involved in a
dispute over message origination, MACs cannot provide
a proof that a message was indeed sent by the sender.
o Though no third party can compute the MAC, still
sender could deny having sent the message and claim
that the receiver forged it, as it is impossible to
determine which of the two parties computed the MAC.

Both these limitations can be overcome by using the public key


based digital signature.

You might also like