SlideShare a Scribd company logo
1 of 18
Download to read offline
Understanding Cryptography
by Christof Paar and Jan Pelzl
www.crypto-textbook.com
These slides were prepared by Christof Paar and Jan Pelzl

And modified by Sam Bowne
Chapter 12 – Message Authentication Codes
(MACs)
Updated 12-4-17
Chapter 12 of Understanding Cryptography by Christof Paar and Jan Pelzl
! Some legal stuff (sorry): Terms of Use
2
Chapter 12 of Understanding Cryptography by Christof Paar and Jan Pelzl3
12.1 Principles of Message Authentication Codes
12.2 MACs from Hash Functions: HMAC
12.3 MACs from Block Ciphers: CBC-MAC
12.4 Galois Counter Message Authentication Code: GMAC
Contents of this Chapter
Chapter 12 of Understanding Cryptography by Christof Paar and Jan Pelzl4
12.1 



Principles of Message Authentication
Codes
Chapter 12 of Understanding Cryptography by Christof Paar and Jan Pelzl
• Similar to digital signatures, MACs append an
authentication tag to a message
• MACs use a symmetric key k for generation and
verification
• Computation of a MAC: m = MACk(x)
Principle of MessageAuthentication Codes
5
Chapter 12 of Understanding Cryptography by Christof Paar and Jan Pelzl6
1. Cryptographic checksum
A MAC generates a cryptographically secure authentication tag for a given message.
2. Symmetric
MACs are based on secret symmetric keys. The signing and verifying parties must
share a secret key.
3. Arbitrary message size
MACs accept messages of arbitrary length.
4. Fixed output length
MACs generate fixed-size authentication tags.
5. Message integrity
MACs provide message integrity: Any manipulations of a message during transit will be
detected by the receiver.
6. Message authentication
The receiving party is assured of the origin of the message.
7. No nonrepudiation
Since MACs are based on symmetric principles, they do not provide nonrepudiation.
Properties of MessageAuthentication Codes
Chapter 12 of Understanding Cryptography by Christof Paar and Jan Pelzl7
12.2


MACs from Hash Functions: 

HMAC
Chapter 12 of Understanding Cryptography by Christof Paar and Jan Pelzl8
•MAC is realized with cryptographic hash
functions (e.g., SHA-1)
•HMAC is such a MAC built from hash functions
•Basic idea: Key is hashed together with the
message
•Two possible constructions:
•secret prefix MAC: m =MACk(x) = h(k||x)
•secret suffix MAC: m =MACk(x) = h(x||k)
MACs from Hash Functions
Chapter 12 of Understanding Cryptography by Christof Paar and Jan Pelzl9
•Secret prefix MAC: Attack MAC for the message x =
(x1,x2, . . . ,xn,xn+1), where xn+1 is an arbitrary
additional block, can be constructed from m without
knowing the secret key
•Secret suffix MAC: find collision x and xO such
that h(x) = h(xO), then m = h(x||k) = h(xO||k)
•Idea: Combine secret prefix and suffix: HMAC (cf.
next slide)
MACs from Hash Functions: Attacks
Chapter 12 of Understanding Cryptography by Christof Paar and Jan Pelzl
• Proposed by Mihir Bellare, 

Ran Canetti and Hugo Krawczyk 

in 1996
• Uses two hashes: inner & outer
• k+ is key k padded with 

zeroes to the block 

length of the hash function
• expanded key k+ is XORed

with the inner pad
• ipad = 00110110 repeated
• opad = 01011100 repeated
• HMACk(x) =
h [ (k+ ⊕ opad) || h[ (k+ ⊕ ipad)|| x ] ]
HMAC
10
Chapter 12 of Understanding Cryptography by Christof Paar and Jan Pelzl
• HMAC is provably secure
• The MAC can only be broken
if a collision for the hash
function can be found.
HMAC
11
Chapter 12 of Understanding Cryptography by Christof Paar and Jan Pelzl12
12.3



MACs from Block Ciphers: 

CBC-MAC
Chapter 12 of Understanding Cryptography by Christof Paar and Jan Pelzl
• MAC constructed from block ciphers (e.g. AES)
• Popular: Use AES in CBC mode
• CBC-MAC:
MACs from Block Ciphers
13
Chapter 12 of Understanding Cryptography by Christof Paar and Jan Pelzl14
• MAC Generation
• Divide the message x into blocks xi
• Compute first iteration y1 = ek(x1⊕IV)
• Compute yi = ek(xi⊕yi−1) for the next blocks
• Final block is the MAC value: m =MACk(x) = yn
• MAC Verification
• Repeat MAC computation (m‘)
• Compare results: In case m’ = m, the message is
verified as correct
• In case m’ ≠ m, the message and/or the MAC value m
has been altered during transmission
CBC-MAC
Chapter 12 of Understanding Cryptography by Christof Paar and Jan Pelzl15
12.4


Galois Counter 

Message Authentication Code:

GMAC
Chapter 12 of Understanding Cryptography by Christof Paar and Jan Pelzl16
• MAC Generation
• Divide the message x into blocks xi
• Compute first iteration y1 = ek(x1⊕IV)
• Compute yi = ek( xi ⊕ yi−1 ) for the next blocks
• Final block is the MAC value: m =MACk(x) = yn
• MAC Verification
• Repeat MAC computation (m‘)
• Compare results:In case m’ = m, the message is verified as
correct
• In case m’ ≠ m, the message and/or the MAC value m have
been altered during transmission
CBC-MAC
Chapter 12 of Understanding Cryptography by Christof Paar and Jan Pelzl17
• MACs provide two security services, message integrity and message
authentication, using symmetric techniques. MACs are widely used in
protocols.
• Both of these services also provided by digital signatures, but MACs are much
faster as they are based on symmetric algorithms.
• MACs do not provide nonrepudiation.
• In practice, MACs are either based on block ciphers or on hash functions.
• HMAC is a popular and very secure MAC, used in many practical protocols
such as TLS.
! Lessons Learned
CNIT 141: 12. Message Authentication Codes (MACs)

More Related Content

More from Sam Bowne

9 Writing Secure Android Applications
9 Writing Secure Android Applications9 Writing Secure Android Applications
9 Writing Secure Android ApplicationsSam Bowne
 
12 Investigating Windows Systems (Part 2 of 3)
12 Investigating Windows Systems (Part 2 of 3)12 Investigating Windows Systems (Part 2 of 3)
12 Investigating Windows Systems (Part 2 of 3)Sam Bowne
 
12 Investigating Windows Systems (Part 1 of 3
12 Investigating Windows Systems (Part 1 of 312 Investigating Windows Systems (Part 1 of 3
12 Investigating Windows Systems (Part 1 of 3Sam Bowne
 
9. Hard Problems
9. Hard Problems9. Hard Problems
9. Hard ProblemsSam Bowne
 
8 Android Implementation Issues (Part 1)
8 Android Implementation Issues (Part 1)8 Android Implementation Issues (Part 1)
8 Android Implementation Issues (Part 1)Sam Bowne
 
11 Analysis Methodology
11 Analysis Methodology11 Analysis Methodology
11 Analysis MethodologySam Bowne
 
8. Authenticated Encryption
8. Authenticated Encryption8. Authenticated Encryption
8. Authenticated EncryptionSam Bowne
 
7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 2)7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 2)Sam Bowne
 
7. Attacking Android Applications (Part 1)
7. Attacking Android Applications (Part 1)7. Attacking Android Applications (Part 1)
7. Attacking Android Applications (Part 1)Sam Bowne
 
5. Stream Ciphers
5. Stream Ciphers5. Stream Ciphers
5. Stream CiphersSam Bowne
 
6 Scope & 7 Live Data Collection
6 Scope & 7 Live Data Collection6 Scope & 7 Live Data Collection
6 Scope & 7 Live Data CollectionSam Bowne
 
4. Block Ciphers
4. Block Ciphers 4. Block Ciphers
4. Block Ciphers Sam Bowne
 
6 Analyzing Android Applications (Part 2)
6 Analyzing Android Applications (Part 2)6 Analyzing Android Applications (Part 2)
6 Analyzing Android Applications (Part 2)Sam Bowne
 
4 Getting Started & 5 Leads
4 Getting Started & 5 Leads4 Getting Started & 5 Leads
4 Getting Started & 5 LeadsSam Bowne
 
3. Cryptographic Security
3. Cryptographic Security3. Cryptographic Security
3. Cryptographic SecuritySam Bowne
 
Bitcoin and Blockchains
Bitcoin and BlockchainsBitcoin and Blockchains
Bitcoin and BlockchainsSam Bowne
 
Ch 18: Source Code Auditing
Ch 18: Source Code AuditingCh 18: Source Code Auditing
Ch 18: Source Code AuditingSam Bowne
 
Ch 16 & 17 Fault Injection & Fuzzing
Ch 16 & 17 Fault Injection & FuzzingCh 16 & 17 Fault Injection & Fuzzing
Ch 16 & 17 Fault Injection & FuzzingSam Bowne
 
Ch 13: Attacking Users: Other Techniques (Part 2)
Ch 13: Attacking Users: Other Techniques (Part 2)Ch 13: Attacking Users: Other Techniques (Part 2)
Ch 13: Attacking Users: Other Techniques (Part 2)Sam Bowne
 

More from Sam Bowne (20)

9 Writing Secure Android Applications
9 Writing Secure Android Applications9 Writing Secure Android Applications
9 Writing Secure Android Applications
 
12 Investigating Windows Systems (Part 2 of 3)
12 Investigating Windows Systems (Part 2 of 3)12 Investigating Windows Systems (Part 2 of 3)
12 Investigating Windows Systems (Part 2 of 3)
 
10 RSA
10 RSA10 RSA
10 RSA
 
12 Investigating Windows Systems (Part 1 of 3
12 Investigating Windows Systems (Part 1 of 312 Investigating Windows Systems (Part 1 of 3
12 Investigating Windows Systems (Part 1 of 3
 
9. Hard Problems
9. Hard Problems9. Hard Problems
9. Hard Problems
 
8 Android Implementation Issues (Part 1)
8 Android Implementation Issues (Part 1)8 Android Implementation Issues (Part 1)
8 Android Implementation Issues (Part 1)
 
11 Analysis Methodology
11 Analysis Methodology11 Analysis Methodology
11 Analysis Methodology
 
8. Authenticated Encryption
8. Authenticated Encryption8. Authenticated Encryption
8. Authenticated Encryption
 
7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 2)7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 2)
 
7. Attacking Android Applications (Part 1)
7. Attacking Android Applications (Part 1)7. Attacking Android Applications (Part 1)
7. Attacking Android Applications (Part 1)
 
5. Stream Ciphers
5. Stream Ciphers5. Stream Ciphers
5. Stream Ciphers
 
6 Scope & 7 Live Data Collection
6 Scope & 7 Live Data Collection6 Scope & 7 Live Data Collection
6 Scope & 7 Live Data Collection
 
4. Block Ciphers
4. Block Ciphers 4. Block Ciphers
4. Block Ciphers
 
6 Analyzing Android Applications (Part 2)
6 Analyzing Android Applications (Part 2)6 Analyzing Android Applications (Part 2)
6 Analyzing Android Applications (Part 2)
 
4 Getting Started & 5 Leads
4 Getting Started & 5 Leads4 Getting Started & 5 Leads
4 Getting Started & 5 Leads
 
3. Cryptographic Security
3. Cryptographic Security3. Cryptographic Security
3. Cryptographic Security
 
Bitcoin and Blockchains
Bitcoin and BlockchainsBitcoin and Blockchains
Bitcoin and Blockchains
 
Ch 18: Source Code Auditing
Ch 18: Source Code AuditingCh 18: Source Code Auditing
Ch 18: Source Code Auditing
 
Ch 16 & 17 Fault Injection & Fuzzing
Ch 16 & 17 Fault Injection & FuzzingCh 16 & 17 Fault Injection & Fuzzing
Ch 16 & 17 Fault Injection & Fuzzing
 
Ch 13: Attacking Users: Other Techniques (Part 2)
Ch 13: Attacking Users: Other Techniques (Part 2)Ch 13: Attacking Users: Other Techniques (Part 2)
Ch 13: Attacking Users: Other Techniques (Part 2)
 

Recently uploaded

Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 

Recently uploaded (20)

Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 

CNIT 141: 12. Message Authentication Codes (MACs)

  • 1. Understanding Cryptography by Christof Paar and Jan Pelzl www.crypto-textbook.com These slides were prepared by Christof Paar and Jan Pelzl
 And modified by Sam Bowne Chapter 12 – Message Authentication Codes (MACs) Updated 12-4-17
  • 2. Chapter 12 of Understanding Cryptography by Christof Paar and Jan Pelzl ! Some legal stuff (sorry): Terms of Use 2
  • 3. Chapter 12 of Understanding Cryptography by Christof Paar and Jan Pelzl3 12.1 Principles of Message Authentication Codes 12.2 MACs from Hash Functions: HMAC 12.3 MACs from Block Ciphers: CBC-MAC 12.4 Galois Counter Message Authentication Code: GMAC Contents of this Chapter
  • 4. Chapter 12 of Understanding Cryptography by Christof Paar and Jan Pelzl4 12.1 
 
 Principles of Message Authentication Codes
  • 5. Chapter 12 of Understanding Cryptography by Christof Paar and Jan Pelzl • Similar to digital signatures, MACs append an authentication tag to a message • MACs use a symmetric key k for generation and verification • Computation of a MAC: m = MACk(x) Principle of MessageAuthentication Codes 5
  • 6. Chapter 12 of Understanding Cryptography by Christof Paar and Jan Pelzl6 1. Cryptographic checksum A MAC generates a cryptographically secure authentication tag for a given message. 2. Symmetric MACs are based on secret symmetric keys. The signing and verifying parties must share a secret key. 3. Arbitrary message size MACs accept messages of arbitrary length. 4. Fixed output length MACs generate fixed-size authentication tags. 5. Message integrity MACs provide message integrity: Any manipulations of a message during transit will be detected by the receiver. 6. Message authentication The receiving party is assured of the origin of the message. 7. No nonrepudiation Since MACs are based on symmetric principles, they do not provide nonrepudiation. Properties of MessageAuthentication Codes
  • 7. Chapter 12 of Understanding Cryptography by Christof Paar and Jan Pelzl7 12.2 
 MACs from Hash Functions: 
 HMAC
  • 8. Chapter 12 of Understanding Cryptography by Christof Paar and Jan Pelzl8 •MAC is realized with cryptographic hash functions (e.g., SHA-1) •HMAC is such a MAC built from hash functions •Basic idea: Key is hashed together with the message •Two possible constructions: •secret prefix MAC: m =MACk(x) = h(k||x) •secret suffix MAC: m =MACk(x) = h(x||k) MACs from Hash Functions
  • 9. Chapter 12 of Understanding Cryptography by Christof Paar and Jan Pelzl9 •Secret prefix MAC: Attack MAC for the message x = (x1,x2, . . . ,xn,xn+1), where xn+1 is an arbitrary additional block, can be constructed from m without knowing the secret key •Secret suffix MAC: find collision x and xO such that h(x) = h(xO), then m = h(x||k) = h(xO||k) •Idea: Combine secret prefix and suffix: HMAC (cf. next slide) MACs from Hash Functions: Attacks
  • 10. Chapter 12 of Understanding Cryptography by Christof Paar and Jan Pelzl • Proposed by Mihir Bellare, 
 Ran Canetti and Hugo Krawczyk 
 in 1996 • Uses two hashes: inner & outer • k+ is key k padded with 
 zeroes to the block 
 length of the hash function • expanded key k+ is XORed
 with the inner pad • ipad = 00110110 repeated • opad = 01011100 repeated • HMACk(x) = h [ (k+ ⊕ opad) || h[ (k+ ⊕ ipad)|| x ] ] HMAC 10
  • 11. Chapter 12 of Understanding Cryptography by Christof Paar and Jan Pelzl • HMAC is provably secure • The MAC can only be broken if a collision for the hash function can be found. HMAC 11
  • 12. Chapter 12 of Understanding Cryptography by Christof Paar and Jan Pelzl12 12.3
 
 MACs from Block Ciphers: 
 CBC-MAC
  • 13. Chapter 12 of Understanding Cryptography by Christof Paar and Jan Pelzl • MAC constructed from block ciphers (e.g. AES) • Popular: Use AES in CBC mode • CBC-MAC: MACs from Block Ciphers 13
  • 14. Chapter 12 of Understanding Cryptography by Christof Paar and Jan Pelzl14 • MAC Generation • Divide the message x into blocks xi • Compute first iteration y1 = ek(x1⊕IV) • Compute yi = ek(xi⊕yi−1) for the next blocks • Final block is the MAC value: m =MACk(x) = yn • MAC Verification • Repeat MAC computation (m‘) • Compare results: In case m’ = m, the message is verified as correct • In case m’ ≠ m, the message and/or the MAC value m has been altered during transmission CBC-MAC
  • 15. Chapter 12 of Understanding Cryptography by Christof Paar and Jan Pelzl15 12.4 
 Galois Counter 
 Message Authentication Code:
 GMAC
  • 16. Chapter 12 of Understanding Cryptography by Christof Paar and Jan Pelzl16 • MAC Generation • Divide the message x into blocks xi • Compute first iteration y1 = ek(x1⊕IV) • Compute yi = ek( xi ⊕ yi−1 ) for the next blocks • Final block is the MAC value: m =MACk(x) = yn • MAC Verification • Repeat MAC computation (m‘) • Compare results:In case m’ = m, the message is verified as correct • In case m’ ≠ m, the message and/or the MAC value m have been altered during transmission CBC-MAC
  • 17. Chapter 12 of Understanding Cryptography by Christof Paar and Jan Pelzl17 • MACs provide two security services, message integrity and message authentication, using symmetric techniques. MACs are widely used in protocols. • Both of these services also provided by digital signatures, but MACs are much faster as they are based on symmetric algorithms. • MACs do not provide nonrepudiation. • In practice, MACs are either based on block ciphers or on hash functions. • HMAC is a popular and very secure MAC, used in many practical protocols such as TLS. ! Lessons Learned