SlideShare a Scribd company logo
1 of 47
Download to read offline
CNIT 141
Cryptography for Computer Networks
7. Keyed Hashing
Topics
• Message Authentication Codes (MACs)
• Pseudorandom Functions (PRFs)
• Creating Keyed Hashes from Unkeyed Hashes
• Creating Keyed Hashes from Block Ciphers:
CMAC
• Dedicated MAC Designs
• How Things Can Go Wrong
Keyed Hashing
• Anyone can calculate the SHA hash of a
message
• No secret value involved
• Keyed hashing forms the basis for two
algorithms
• Message Authentication Code (MAC)
• Pseudorandom Function (PRF)
Message Authentication
Codes (MACs)
MACs
• A MAC protects a message's integrity and
authenticity with a tag T
• T = MAC(K, M)
• Verifying the MAC proves both that the
message wasn't altered, and that it came from
the sender holding the key
MACs in Secure
Communication
• MACs are used in
• IPSec, SSH, and TLS
• 3G & 4G telephony encrypt packets but don't
use a MAC
• An attacker can modify the packets
• Causing static on the line
Forgery
• Attacker shouldn't be able to create a tag
without knowing the key
• Such a M, T pair is called a forgery
• A system is unforgeable if forgeries are
impossible to find
Chosen-Message Attacks
• An attacker can choose messages that get
authenticated
• The standard model to test MAC algoroithms
Replay Attacks
• MACs are not safe from replay attacks
• To detect them, protocols include a message
number in each message
• A replayed message will have an out-of-
order message number
Pseudorandom Functions
(PRFs)
PRFs
• Use a secret key to return PRF(K, M)
• Output looks random
• Key Derivation schemes use PDFs
• To generate cryptographic keys from a
master key or password
• Identification schemes use PDFs
• To generate a response from a random
challenge
Uses of PRFs
• 4G telephony uses PRFs
• To authenticate a SIM card
• To generate the encryption key and MAC
used during a phone call
• TLS uses a PRF
• To generate key material from a master
secret and a session-speciifc random value
PRF Security
• Has no pattern, looks random
• Indistinguishable from random bits
• Fundamentally stronger than MACs
• MACs are secure if they can't be forged
• But may not appear random
Creating Keyed Hashes
from Unkeyed Hashes
The Secret-Prefix
Construction
• Prepend key to the message, and return
• Hash(K || M)
• May be vulnerable to length-extension attacks
• Calculating Hash(K || M1 || M2) from 

Hash(K || M1)
• SHA-1 & SHA-2 are vulnerable to this, but not
SHA-3
Insecurity with Different
Key Lengths
• No way to tell key from message
• If K is 123abc and M is def00
• If K is 123a and M is bcdef00
• Result is Hash(123abcdef00)
• To fix this, BLAKE2 and SHA-3 include a
keyed mode
• Another fix is to include the key's length in
the hash: Hash(L || K || M)
Secret-Suffix Construction
• Tag is Hash(M || K)
• Prevents length-extension attack
• If you know Hash(M1 || K)
• You can calculate Hash(M1 || K || M2)
• But not Hash(M1 || M2 || K)
Secret-Suffix Construction
• But if there's a hash collision
• Hash(M1) = Hash(M2)
• The tags can collide too
• Hash(M1 || K) = Hash(M2 || K)
HMAC Construction
• More secure than secret prefix or secret suffix
• Used by IPSec, SSH, and TLS
• Specifed in NIST's FIPS 198-6 standard
• And RFC 2104
HMAC Construction
• Key K is usually shorter than block size
• Uses opad (outer padding) and ipad (inner
padding)
• opad is a series of 0x5c bytes as long as the
key, plus enough 0x00 bytes to fill the block
• ipad is a series of 0x36 bytes as long as the
key, plus enough 0x00 bytes to fill the block
Specifying Hash Function
• Must specify, as in HMAC-SHA256
A Generic Attack Against
Hash-Based MACs
• Can forge a HMAC tag from a hash collision
• Requires 2n/2 calculations
• n is length of digest
• Doesn't depend on a hash length extension
attack
• Works on all MACs based on an iterated hash
function
A Generic Attack Against
Hash-Based MACs
• Infeasible for n larger than 128 bits
Creating Keyed Hashes
from Block Ciphers: CMAC
CMAC and Block Ciphers
• The compression function in many hash
functions is built on a block cipher
• Ex: HMAC-SHA-256
• CMAC uses only a block cipher
• Less popular than HMAC
• Used in IKE (part of IPSec)
CBC-MAC
• CMAC was designed in 2005
• As an improved version of CBC-MAC
• CBC-MAC:
• Encrypt M with IV=0
• Discard all but the last ciphertext block
IV = 0
Breaking CBC-MAC
• Suppose attacker knows the tags T1 and T2
• For two single-block messages M1 and M2
M1
T1
IV = 0
M2
T2
IV = 0
Breaking CBC-MAC
• T2 is also the tag of this message:
• M1 || (M2 ^ T1)
• For two single-block messages M1 and M2
• Attacker can forge a message and tag
M1 M2 ^ T1
T1 T2
IV = 0
Fixing CBC-MAC
• Use key K to create K1 and K2
• Encrypt last block with a different key
K K K1
IV = 0
CBC-MAC
• If the message fills the last block exactly
• Uses K and K1
CBC-MAC
• If padding is needed
• Uses K and K2
Dedicated MAC Designs
Dedicated Design
• The preceding systems use hash functions
and block ciphers to build PRFs
• Convenient but inefficient
• Could be made faster by designing specifically
for MAC use case
Poly1305
• Designed in 2005
• Optimized to run fast on modern CPUs
• Used by Google for HTTPS and OpenSSH
Universal Hash Functions
• UHF is much weaker than a cryptographic
hash function
• But much faster
• Not collision-resistant
• Uses a secret key K
• UH(K, M)
• Only one security requirement
• For two messages M1 and M2
• Neglible probability that
• UH(K, M1) = UH(K, M2)
• For a random K
• Doesn't need to be pseudorandom
Universal Hash Functions
• Weakness:
• K can only be used once
• Otherwise an attacker can solve two equations
like this and gain information about the key
Universal Hash Functions
Wegman-Carter MACs
• Builds a MAC from a universal hash function
and a PRF
• Using two keys K1 and K2
• And a nonce N that is unique for each key,
K2
• Secure if
Wegman-Carter MACs
Poly1305-AES
• Much faster than HMAC-based MACSs or even CMACs
• Only computes one block of AES
• Poly1305 is a universal hash
• Remaining processing runs in parallel with simple
arithmetic operations
• Secure as long as AES is
SipHash
• Poly1305 is optimized for long messages
• Requires nonce, which must not be repeated
• For small messages, Poly1305 is overkill
• SipHash is best for short messages
• Less than 128 bytes
• Designed to resist DoS attacks on hash tables
• Uses XORs, additions, and word rotations
SipHash
How Things Can Go
Wrong
Timing Attacks on MAC
Verficiation
• Side-channel attacks
• Target the implementation
• Not the algorithm
• This code will return 

faster if the first byte 

is incorrect
• Solution: write 

constant-time code
When Sponges Leak
• If attacker gets the internal state
• Through a side-channel attack
• Permutation-based algorithms fail
• Allowing forgery
• Applies to SHA-3 and SipHash
• But not compression-function-based MACs
• Like HMAC-SHA-256 and BLAKE2
CNIT 141: 7. Keyed Hashing

More Related Content

What's hot

Hash function
Hash functionHash function
Hash functionHarry Potter
 
Computer Security Lecture 7: RSA
Computer Security Lecture 7: RSAComputer Security Lecture 7: RSA
Computer Security Lecture 7: RSAMohamed Loey
 
Hash Function.pdf
Hash Function.pdfHash Function.pdf
Hash Function.pdfSantosh Gupta
 
Email security presentation
Email security presentationEmail security presentation
Email security presentationSubhradeepMaji
 
Diffie hellman key exchange algorithm
Diffie hellman key exchange algorithmDiffie hellman key exchange algorithm
Diffie hellman key exchange algorithmSunita Kharayat
 
Message digest 5
Message digest 5Message digest 5
Message digest 5Tirthika Bandi
 
Public Key Encryption & Hash functions
Public Key Encryption & Hash functionsPublic Key Encryption & Hash functions
Public Key Encryption & Hash functionsDr.Florence Dayana
 
Digital Signature Standard
Digital Signature StandardDigital Signature Standard
Digital Signature StandardSou Jana
 
6. cryptography
6. cryptography6. cryptography
6. cryptography7wounders
 
Authentication Protocols
Authentication ProtocolsAuthentication Protocols
Authentication ProtocolsTrinity Dwarka
 
DISCRETE LOGARITHM PROBLEM
DISCRETE LOGARITHM PROBLEMDISCRETE LOGARITHM PROBLEM
DISCRETE LOGARITHM PROBLEMMANISH KUMAR
 
Message authentication
Message authenticationMessage authentication
Message authenticationCAS
 
MAC-Message Authentication Codes
MAC-Message Authentication CodesMAC-Message Authentication Codes
MAC-Message Authentication CodesDarshanPatil82
 
RSA algorithm
RSA algorithmRSA algorithm
RSA algorithmArpana shree
 
Network security cryptographic hash function
Network security  cryptographic hash functionNetwork security  cryptographic hash function
Network security cryptographic hash functionMijanur Rahman Milon
 

What's hot (20)

Hash function
Hash functionHash function
Hash function
 
Computer Security Lecture 7: RSA
Computer Security Lecture 7: RSAComputer Security Lecture 7: RSA
Computer Security Lecture 7: RSA
 
Hash Function.pdf
Hash Function.pdfHash Function.pdf
Hash Function.pdf
 
Email security presentation
Email security presentationEmail security presentation
Email security presentation
 
Diffie hellman key exchange algorithm
Diffie hellman key exchange algorithmDiffie hellman key exchange algorithm
Diffie hellman key exchange algorithm
 
Hashing
HashingHashing
Hashing
 
Message digest 5
Message digest 5Message digest 5
Message digest 5
 
Public Key Encryption & Hash functions
Public Key Encryption & Hash functionsPublic Key Encryption & Hash functions
Public Key Encryption & Hash functions
 
Digital Signature Standard
Digital Signature StandardDigital Signature Standard
Digital Signature Standard
 
Rsa rivest shamir adleman
Rsa rivest shamir adlemanRsa rivest shamir adleman
Rsa rivest shamir adleman
 
6. cryptography
6. cryptography6. cryptography
6. cryptography
 
Unit 3
Unit 3Unit 3
Unit 3
 
Authentication Protocols
Authentication ProtocolsAuthentication Protocols
Authentication Protocols
 
DISCRETE LOGARITHM PROBLEM
DISCRETE LOGARITHM PROBLEMDISCRETE LOGARITHM PROBLEM
DISCRETE LOGARITHM PROBLEM
 
Message authentication
Message authenticationMessage authentication
Message authentication
 
MAC-Message Authentication Codes
MAC-Message Authentication CodesMAC-Message Authentication Codes
MAC-Message Authentication Codes
 
RSA algorithm
RSA algorithmRSA algorithm
RSA algorithm
 
Elgamal & schnorr digital signature scheme copy
Elgamal & schnorr digital signature scheme   copyElgamal & schnorr digital signature scheme   copy
Elgamal & schnorr digital signature scheme copy
 
Network security cryptographic hash function
Network security  cryptographic hash functionNetwork security  cryptographic hash function
Network security cryptographic hash function
 
DES
DESDES
DES
 

Similar to CNIT 141: 7. Keyed Hashing

CNIT 1417. Keyed Hashing
CNIT 1417. Keyed HashingCNIT 1417. Keyed Hashing
CNIT 1417. Keyed HashingSam Bowne
 
CNIT 141 7. Keyed Hashing
CNIT 141 7. Keyed HashingCNIT 141 7. Keyed Hashing
CNIT 141 7. Keyed HashingSam Bowne
 
Information and network security 42 security of message authentication code
Information and network security 42 security of message authentication codeInformation and network security 42 security of message authentication code
Information and network security 42 security of message authentication codeVaibhav Khanna
 
Cns
CnsCns
CnsArthyR3
 
Cs8792 cns - unit iv
Cs8792   cns - unit ivCs8792   cns - unit iv
Cs8792 cns - unit ivArthyR3
 
Cs8792 cns - unit iv
Cs8792   cns - unit ivCs8792   cns - unit iv
Cs8792 cns - unit ivArthyR3
 
UNIT3_class (1).ppt CRYPTOGRAPHY NOTES AND NETWORK
UNIT3_class (1).ppt CRYPTOGRAPHY NOTES AND NETWORKUNIT3_class (1).ppt CRYPTOGRAPHY NOTES AND NETWORK
UNIT3_class (1).ppt CRYPTOGRAPHY NOTES AND NETWORKjeevasreemurali
 
MACs based on Hash Functions, MACs based on Block Ciphers
MACs based on Hash Functions, MACs based on Block CiphersMACs based on Hash Functions, MACs based on Block Ciphers
MACs based on Hash Functions, MACs based on Block CiphersMaitree Patel
 
CNIT 141: 6. Hash Functions
CNIT 141: 6. Hash FunctionsCNIT 141: 6. Hash Functions
CNIT 141: 6. Hash FunctionsSam Bowne
 
CNIT 141 6. Hash Functions
CNIT 141 6. Hash FunctionsCNIT 141 6. Hash Functions
CNIT 141 6. Hash FunctionsSam Bowne
 
CNIT 141: 6. Hash Functions
CNIT 141: 6. Hash FunctionsCNIT 141: 6. Hash Functions
CNIT 141: 6. Hash FunctionsSam Bowne
 
Distribution of public keys and hmac
Distribution of public keys and hmacDistribution of public keys and hmac
Distribution of public keys and hmacanuragjagetiya
 
Message auth. code Based on Hash Functions.pptx
Message auth. code Based on Hash Functions.pptxMessage auth. code Based on Hash Functions.pptx
Message auth. code Based on Hash Functions.pptxaribariaz507
 
ch11.ppt
ch11.pptch11.ppt
ch11.pptSomuPatil8
 
Message Authentication
Message AuthenticationMessage Authentication
Message Authenticationchauhankapil
 
Message Authentication Requirement-MAC
Message Authentication Requirement-MACMessage Authentication Requirement-MAC
Message Authentication Requirement-MACSou Jana
 
IS413 Topic 5.pptx
IS413 Topic 5.pptxIS413 Topic 5.pptx
IS413 Topic 5.pptxWarrenPhiri4
 
Information and data security cryptography and network security
Information and data security cryptography and network securityInformation and data security cryptography and network security
Information and data security cryptography and network securityMazin Alwaaly
 
Message Authentication and Hash Function.pdf
Message Authentication and Hash Function.pdfMessage Authentication and Hash Function.pdf
Message Authentication and Hash Function.pdfsunil sharma
 

Similar to CNIT 141: 7. Keyed Hashing (20)

CNIT 1417. Keyed Hashing
CNIT 1417. Keyed HashingCNIT 1417. Keyed Hashing
CNIT 1417. Keyed Hashing
 
CNIT 141 7. Keyed Hashing
CNIT 141 7. Keyed HashingCNIT 141 7. Keyed Hashing
CNIT 141 7. Keyed Hashing
 
Information and network security 42 security of message authentication code
Information and network security 42 security of message authentication codeInformation and network security 42 security of message authentication code
Information and network security 42 security of message authentication code
 
Cns
CnsCns
Cns
 
Cs8792 cns - unit iv
Cs8792   cns - unit ivCs8792   cns - unit iv
Cs8792 cns - unit iv
 
Cs8792 cns - unit iv
Cs8792   cns - unit ivCs8792   cns - unit iv
Cs8792 cns - unit iv
 
UNIT3_class (1).ppt CRYPTOGRAPHY NOTES AND NETWORK
UNIT3_class (1).ppt CRYPTOGRAPHY NOTES AND NETWORKUNIT3_class (1).ppt CRYPTOGRAPHY NOTES AND NETWORK
UNIT3_class (1).ppt CRYPTOGRAPHY NOTES AND NETWORK
 
ch11.ppt
ch11.pptch11.ppt
ch11.ppt
 
MACs based on Hash Functions, MACs based on Block Ciphers
MACs based on Hash Functions, MACs based on Block CiphersMACs based on Hash Functions, MACs based on Block Ciphers
MACs based on Hash Functions, MACs based on Block Ciphers
 
CNIT 141: 6. Hash Functions
CNIT 141: 6. Hash FunctionsCNIT 141: 6. Hash Functions
CNIT 141: 6. Hash Functions
 
CNIT 141 6. Hash Functions
CNIT 141 6. Hash FunctionsCNIT 141 6. Hash Functions
CNIT 141 6. Hash Functions
 
CNIT 141: 6. Hash Functions
CNIT 141: 6. Hash FunctionsCNIT 141: 6. Hash Functions
CNIT 141: 6. Hash Functions
 
Distribution of public keys and hmac
Distribution of public keys and hmacDistribution of public keys and hmac
Distribution of public keys and hmac
 
Message auth. code Based on Hash Functions.pptx
Message auth. code Based on Hash Functions.pptxMessage auth. code Based on Hash Functions.pptx
Message auth. code Based on Hash Functions.pptx
 
ch11.ppt
ch11.pptch11.ppt
ch11.ppt
 
Message Authentication
Message AuthenticationMessage Authentication
Message Authentication
 
Message Authentication Requirement-MAC
Message Authentication Requirement-MACMessage Authentication Requirement-MAC
Message Authentication Requirement-MAC
 
IS413 Topic 5.pptx
IS413 Topic 5.pptxIS413 Topic 5.pptx
IS413 Topic 5.pptx
 
Information and data security cryptography and network security
Information and data security cryptography and network securityInformation and data security cryptography and network security
Information and data security cryptography and network security
 
Message Authentication and Hash Function.pdf
Message Authentication and Hash Function.pdfMessage Authentication and Hash Function.pdf
Message Authentication and Hash Function.pdf
 

More from Sam Bowne

Cyberwar
CyberwarCyberwar
CyberwarSam Bowne
 
3: DNS vulnerabilities
3: DNS vulnerabilities 3: DNS vulnerabilities
3: DNS vulnerabilities Sam Bowne
 
8. Software Development Security
8. Software Development Security8. Software Development Security
8. Software Development SecuritySam Bowne
 
4 Mapping the Application
4 Mapping the Application4 Mapping the Application
4 Mapping the ApplicationSam Bowne
 
3. Attacking iOS Applications (Part 2)
 3. Attacking iOS Applications (Part 2) 3. Attacking iOS Applications (Part 2)
3. Attacking iOS Applications (Part 2)Sam Bowne
 
12 Elliptic Curves
12 Elliptic Curves12 Elliptic Curves
12 Elliptic CurvesSam Bowne
 
11. Diffie-Hellman
11. Diffie-Hellman11. Diffie-Hellman
11. Diffie-HellmanSam Bowne
 
2a Analyzing iOS Apps Part 1
2a Analyzing iOS Apps Part 12a Analyzing iOS Apps Part 1
2a Analyzing iOS Apps Part 1Sam 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
 
10 RSA
10 RSA10 RSA
10 RSASam 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
 

More from Sam Bowne (20)

Cyberwar
CyberwarCyberwar
Cyberwar
 
3: DNS vulnerabilities
3: DNS vulnerabilities 3: DNS vulnerabilities
3: DNS vulnerabilities
 
8. Software Development Security
8. Software Development Security8. Software Development Security
8. Software Development Security
 
4 Mapping the Application
4 Mapping the Application4 Mapping the Application
4 Mapping the Application
 
3. Attacking iOS Applications (Part 2)
 3. Attacking iOS Applications (Part 2) 3. Attacking iOS Applications (Part 2)
3. Attacking iOS Applications (Part 2)
 
12 Elliptic Curves
12 Elliptic Curves12 Elliptic Curves
12 Elliptic Curves
 
11. Diffie-Hellman
11. Diffie-Hellman11. Diffie-Hellman
11. Diffie-Hellman
 
2a Analyzing iOS Apps Part 1
2a Analyzing iOS Apps Part 12a Analyzing iOS Apps Part 1
2a Analyzing iOS Apps Part 1
 
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
 

Recently uploaded

Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
Unraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptxUnraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptx
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptxDhatriParmar
 
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxMan or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxDhatriParmar
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseCeline George
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Association for Project Management
 
4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptxmary850239
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfPrerana Jadhav
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataBabyAnnMotar
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSMae Pangan
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxSayali Powar
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research DiscourseAnita GoswamiGiri
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operationalssuser3e220a
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdfMr Bounab Samir
 

Recently uploaded (20)

Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
Unraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptxUnraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptx
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
 
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxMan or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 Database
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Paradigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTAParadigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTA
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
 
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
 
4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdf
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped data
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHS
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research Discourse
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operational
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdf
 

CNIT 141: 7. Keyed Hashing

  • 1. CNIT 141 Cryptography for Computer Networks 7. Keyed Hashing
  • 2. Topics • Message Authentication Codes (MACs) • Pseudorandom Functions (PRFs) • Creating Keyed Hashes from Unkeyed Hashes • Creating Keyed Hashes from Block Ciphers: CMAC • Dedicated MAC Designs • How Things Can Go Wrong
  • 3. Keyed Hashing • Anyone can calculate the SHA hash of a message • No secret value involved • Keyed hashing forms the basis for two algorithms • Message Authentication Code (MAC) • Pseudorandom Function (PRF)
  • 5. MACs • A MAC protects a message's integrity and authenticity with a tag T • T = MAC(K, M) • Verifying the MAC proves both that the message wasn't altered, and that it came from the sender holding the key
  • 6. MACs in Secure Communication • MACs are used in • IPSec, SSH, and TLS • 3G & 4G telephony encrypt packets but don't use a MAC • An attacker can modify the packets • Causing static on the line
  • 7. Forgery • Attacker shouldn't be able to create a tag without knowing the key • Such a M, T pair is called a forgery • A system is unforgeable if forgeries are impossible to find
  • 8. Chosen-Message Attacks • An attacker can choose messages that get authenticated • The standard model to test MAC algoroithms
  • 9. Replay Attacks • MACs are not safe from replay attacks • To detect them, protocols include a message number in each message • A replayed message will have an out-of- order message number
  • 11. PRFs • Use a secret key to return PRF(K, M) • Output looks random • Key Derivation schemes use PDFs • To generate cryptographic keys from a master key or password • Identification schemes use PDFs • To generate a response from a random challenge
  • 12. Uses of PRFs • 4G telephony uses PRFs • To authenticate a SIM card • To generate the encryption key and MAC used during a phone call • TLS uses a PRF • To generate key material from a master secret and a session-speciifc random value
  • 13. PRF Security • Has no pattern, looks random • Indistinguishable from random bits • Fundamentally stronger than MACs • MACs are secure if they can't be forged • But may not appear random
  • 14. Creating Keyed Hashes from Unkeyed Hashes
  • 15. The Secret-Prefix Construction • Prepend key to the message, and return • Hash(K || M) • May be vulnerable to length-extension attacks • Calculating Hash(K || M1 || M2) from 
 Hash(K || M1) • SHA-1 & SHA-2 are vulnerable to this, but not SHA-3
  • 16. Insecurity with Different Key Lengths • No way to tell key from message • If K is 123abc and M is def00 • If K is 123a and M is bcdef00 • Result is Hash(123abcdef00) • To fix this, BLAKE2 and SHA-3 include a keyed mode • Another fix is to include the key's length in the hash: Hash(L || K || M)
  • 17. Secret-Suffix Construction • Tag is Hash(M || K) • Prevents length-extension attack • If you know Hash(M1 || K) • You can calculate Hash(M1 || K || M2) • But not Hash(M1 || M2 || K)
  • 18. Secret-Suffix Construction • But if there's a hash collision • Hash(M1) = Hash(M2) • The tags can collide too • Hash(M1 || K) = Hash(M2 || K)
  • 19. HMAC Construction • More secure than secret prefix or secret suffix • Used by IPSec, SSH, and TLS • Specifed in NIST's FIPS 198-6 standard • And RFC 2104
  • 20. HMAC Construction • Key K is usually shorter than block size • Uses opad (outer padding) and ipad (inner padding) • opad is a series of 0x5c bytes as long as the key, plus enough 0x00 bytes to fill the block • ipad is a series of 0x36 bytes as long as the key, plus enough 0x00 bytes to fill the block
  • 21. Specifying Hash Function • Must specify, as in HMAC-SHA256
  • 22. A Generic Attack Against Hash-Based MACs • Can forge a HMAC tag from a hash collision • Requires 2n/2 calculations • n is length of digest • Doesn't depend on a hash length extension attack • Works on all MACs based on an iterated hash function
  • 23. A Generic Attack Against Hash-Based MACs • Infeasible for n larger than 128 bits
  • 24.
  • 25. Creating Keyed Hashes from Block Ciphers: CMAC
  • 26. CMAC and Block Ciphers • The compression function in many hash functions is built on a block cipher • Ex: HMAC-SHA-256 • CMAC uses only a block cipher • Less popular than HMAC • Used in IKE (part of IPSec)
  • 27. CBC-MAC • CMAC was designed in 2005 • As an improved version of CBC-MAC • CBC-MAC: • Encrypt M with IV=0 • Discard all but the last ciphertext block IV = 0
  • 28. Breaking CBC-MAC • Suppose attacker knows the tags T1 and T2 • For two single-block messages M1 and M2 M1 T1 IV = 0 M2 T2 IV = 0
  • 29. Breaking CBC-MAC • T2 is also the tag of this message: • M1 || (M2 ^ T1) • For two single-block messages M1 and M2 • Attacker can forge a message and tag M1 M2 ^ T1 T1 T2 IV = 0
  • 30. Fixing CBC-MAC • Use key K to create K1 and K2 • Encrypt last block with a different key K K K1 IV = 0
  • 31. CBC-MAC • If the message fills the last block exactly • Uses K and K1
  • 32. CBC-MAC • If padding is needed • Uses K and K2
  • 34. Dedicated Design • The preceding systems use hash functions and block ciphers to build PRFs • Convenient but inefficient • Could be made faster by designing specifically for MAC use case
  • 35. Poly1305 • Designed in 2005 • Optimized to run fast on modern CPUs • Used by Google for HTTPS and OpenSSH
  • 36. Universal Hash Functions • UHF is much weaker than a cryptographic hash function • But much faster • Not collision-resistant • Uses a secret key K • UH(K, M)
  • 37. • Only one security requirement • For two messages M1 and M2 • Neglible probability that • UH(K, M1) = UH(K, M2) • For a random K • Doesn't need to be pseudorandom Universal Hash Functions
  • 38. • Weakness: • K can only be used once • Otherwise an attacker can solve two equations like this and gain information about the key Universal Hash Functions
  • 39. Wegman-Carter MACs • Builds a MAC from a universal hash function and a PRF • Using two keys K1 and K2 • And a nonce N that is unique for each key, K2
  • 41. Poly1305-AES • Much faster than HMAC-based MACSs or even CMACs • Only computes one block of AES • Poly1305 is a universal hash • Remaining processing runs in parallel with simple arithmetic operations • Secure as long as AES is
  • 42. SipHash • Poly1305 is optimized for long messages • Requires nonce, which must not be repeated • For small messages, Poly1305 is overkill • SipHash is best for short messages • Less than 128 bytes
  • 43. • Designed to resist DoS attacks on hash tables • Uses XORs, additions, and word rotations SipHash
  • 44. How Things Can Go Wrong
  • 45. Timing Attacks on MAC Verficiation • Side-channel attacks • Target the implementation • Not the algorithm • This code will return 
 faster if the first byte 
 is incorrect • Solution: write 
 constant-time code
  • 46. When Sponges Leak • If attacker gets the internal state • Through a side-channel attack • Permutation-based algorithms fail • Allowing forgery • Applies to SHA-3 and SipHash • But not compression-function-based MACs • Like HMAC-SHA-256 and BLAKE2