際際滷

際際滷Share a Scribd company logo
Message Authentication Code & HMAC
 Similar to Message Digest
 Shared Symmetric (Secret) key is used for
encryption
 Message authentication is concerned with:
 protecting the integrity of a message
 validating identity of originator
 non-repudiation of origin (dispute resolution)
 consider the security requirements
Message Authentication Code & HMAC
 MAC generation of message using shared
symmetric (secret) key.
 Sends original message and MAC(H1)
 At receiver end, it receives original message and
MAC
 Receiver calculate MAC(H2) using key and
original message.
 Compare H1 & H2
 If H1!=H2 then, Message altered
 If H1==H2 then, Message not changed
 Generated by an algorithm that creates a small
fixed-sized block
 depending on both message and some key
 like encryption though need not be reversible
 appended to message as a signature
 receiver performs same computation on message
and checks it matches the MAC
 provides assurance that message is unaltered and
comes from sender
Message Authentication Code & HMAC
 As shown the MAC provides confidentiality
 can also use encryption for secrecy
 generally use separate keys for each
 can compute MAC either before or after encryption
 is generally regarded as better done before
 why use a MAC?
 sometimes only authentication is needed
 sometimes need authentication to persist longer than
the encryption (eg. archival use)
 Note that a MAC is not a digital signature
 HMAC stands for -Hash Message
Authentication Code
 Mandatory for security implementation for
Internet Protocol security.
 Idea of HMAC is to reuse existing Message-
Digest algorithms(such as MD5,SHA-1..)
 Uses shared symmetric key to encrypt
message digest.
Message Authentication Code & HMAC
 Variables used in HMAC
 MD = the message digest/hash function used(e.g.
MD5,SHA-1,etc.)
 M = the input message whose MAC is to be
calculated.
 L = the number of blocks in the message M.
 b = the numbers of bits in each block.
 K = the shared symmetric key to be used in HMAC.
 ipad = A string 00110110 repeated b/8 times.
 opad = A string 01011010 repeated b/8 times.
 STEP-1 Make the length of K equal to b.
 STEP-2 XOR K with lpad to produce S1.
 STEP-3 Append M to S1.
 STEP-4 Message-digest algorithm.
 STEP-5 XOR K with opad to produce S2.
 STEP-6 Append H to S2.
 STEP-7 Message-digest algorithm.
 STEP-1 Make the length of K equal to b.
 If length of K<b : add 0 bit as required to the left of k
 If length of K=b : In this case, we do not take any action, and
proceed to step 2.
 If length of K>b : we need to trim k, for this, we pass K through
the message-digest algorithm(H) selected for this particular
instance of HMAC
 STEP-2 XOR K with lpad to produce S1
 XOR K (the output of step 1) and ipad to produce a variable
called S1.
 STEP-3 Append M to S1
 Take the original message (M) and simply append it to the end of
S1.
 STEP-4 Message-digest algorithm
 The selected message-digest algorithm (e.g. MD5,SHA-l, etc.) is
applied to the output of step 3.
 STEP-5 XOR K with opad to produce S2
 XOR K (the output of step 1) with opad to produce a variable
called as S2.
 STEP-6 Append H to S2
 Append the message digest calculated in step 4 to the end of S2.
 STEP-7 Message-digest algorithm
 the selected message-digest algorithm (e.g. MD5, SHA-I, etc.) is
applied to the output of step 6 (i.e. to the concatenation of S2 and
H). This is the Final MAC that we want
1. Key exchange is main issue
2. Somehow the key-exchange problem is resolved,
HMAC cannot be used if the number of receivers is
greater than one.
3. If multiple parties share the same symmetric key.
How does a receiver know that the message was
prepared and sent by the sender
4. Replay of Message
Message Authentication Code & HMAC

More Related Content

Message Authentication Code & HMAC

  • 2. Similar to Message Digest Shared Symmetric (Secret) key is used for encryption Message authentication is concerned with: protecting the integrity of a message validating identity of originator non-repudiation of origin (dispute resolution) consider the security requirements
  • 4. MAC generation of message using shared symmetric (secret) key. Sends original message and MAC(H1) At receiver end, it receives original message and MAC Receiver calculate MAC(H2) using key and original message. Compare H1 & H2 If H1!=H2 then, Message altered If H1==H2 then, Message not changed
  • 5. Generated by an algorithm that creates a small fixed-sized block depending on both message and some key like encryption though need not be reversible appended to message as a signature receiver performs same computation on message and checks it matches the MAC provides assurance that message is unaltered and comes from sender
  • 7. As shown the MAC provides confidentiality can also use encryption for secrecy generally use separate keys for each can compute MAC either before or after encryption is generally regarded as better done before why use a MAC? sometimes only authentication is needed sometimes need authentication to persist longer than the encryption (eg. archival use) Note that a MAC is not a digital signature
  • 8. HMAC stands for -Hash Message Authentication Code Mandatory for security implementation for Internet Protocol security. Idea of HMAC is to reuse existing Message- Digest algorithms(such as MD5,SHA-1..) Uses shared symmetric key to encrypt message digest.
  • 10. Variables used in HMAC MD = the message digest/hash function used(e.g. MD5,SHA-1,etc.) M = the input message whose MAC is to be calculated. L = the number of blocks in the message M. b = the numbers of bits in each block. K = the shared symmetric key to be used in HMAC. ipad = A string 00110110 repeated b/8 times. opad = A string 01011010 repeated b/8 times.
  • 11. STEP-1 Make the length of K equal to b. STEP-2 XOR K with lpad to produce S1. STEP-3 Append M to S1. STEP-4 Message-digest algorithm. STEP-5 XOR K with opad to produce S2. STEP-6 Append H to S2. STEP-7 Message-digest algorithm.
  • 12. STEP-1 Make the length of K equal to b. If length of K<b : add 0 bit as required to the left of k If length of K=b : In this case, we do not take any action, and proceed to step 2. If length of K>b : we need to trim k, for this, we pass K through the message-digest algorithm(H) selected for this particular instance of HMAC
  • 13. STEP-2 XOR K with lpad to produce S1 XOR K (the output of step 1) and ipad to produce a variable called S1.
  • 14. STEP-3 Append M to S1 Take the original message (M) and simply append it to the end of S1.
  • 15. STEP-4 Message-digest algorithm The selected message-digest algorithm (e.g. MD5,SHA-l, etc.) is applied to the output of step 3.
  • 16. STEP-5 XOR K with opad to produce S2 XOR K (the output of step 1) with opad to produce a variable called as S2.
  • 17. STEP-6 Append H to S2 Append the message digest calculated in step 4 to the end of S2.
  • 18. STEP-7 Message-digest algorithm the selected message-digest algorithm (e.g. MD5, SHA-I, etc.) is applied to the output of step 6 (i.e. to the concatenation of S2 and H). This is the Final MAC that we want
  • 19. 1. Key exchange is main issue 2. Somehow the key-exchange problem is resolved, HMAC cannot be used if the number of receivers is greater than one. 3. If multiple parties share the same symmetric key. How does a receiver know that the message was prepared and sent by the sender 4. Replay of Message

Editor's Notes

  • #10: Can also use block cipher chaining modes to create a separate authenticator, by just sending the last block. However this suffers from being a bit too small for acceptable use today.
  • #20: These are the specifications for good hash functions. Essentially it must be extremely difficult to find 2 messages with the same hash, and the hash should not be related to the message in any obvious way (ie it should be a complex non-linear function of the message). There are quite a few similarities in the evolution of hash functions &amp; block ciphers, and in the evolution of the design requirements on both.