SlideShare ist ein Scribd-Unternehmen logo
1 von 48
Downloaden Sie, um offline zu lesen
CNIT 141
Cryptography for Computer Networks
7. Keyed Hashing
Updated 10-8-2020
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
Known-Message Attack
• An attacker passively collects messages and
tags
• Tries to find the key
• This is a very weak attack
Chosen-Message Attacks
• An attacker can choose messages that get
authenticated
• And observe the authentication tags
• The standard model to test MAC algorithms
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 PRFs
• To generate cryptographic keys from a
master key or password
• Identification schemes use PRFs
• 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
block size
• ipad is a series of 0x36 bytes as long as the
block size
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 require 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 1417. Keyed Hashing

Weitere ähnliche Inhalte

Was ist angesagt?

CNIT 141 8. Authenticated Encryption
CNIT 141 8. Authenticated EncryptionCNIT 141 8. Authenticated Encryption
CNIT 141 8. Authenticated EncryptionSam Bowne
 
ChaCha20-Poly1305 Cipher Summary - AdaLabs SPARKAda OpenSSH Ciphers
ChaCha20-Poly1305 Cipher Summary - AdaLabs SPARKAda OpenSSH CiphersChaCha20-Poly1305 Cipher Summary - AdaLabs SPARKAda OpenSSH Ciphers
ChaCha20-Poly1305 Cipher Summary - AdaLabs SPARKAda OpenSSH CiphersAdaLabs
 
HES2011 - Tarjei Mandt – Kernel Pool Exploitation on Windows 7
HES2011 - Tarjei Mandt – Kernel Pool Exploitation on Windows 7HES2011 - Tarjei Mandt – Kernel Pool Exploitation on Windows 7
HES2011 - Tarjei Mandt – Kernel Pool Exploitation on Windows 7Hackito Ergo Sum
 
Block cipher modes of operations
Block cipher modes of operationsBlock cipher modes of operations
Block cipher modes of operationsAkashRanjandas1
 
History of cryptography
History of cryptographyHistory of cryptography
History of cryptographyFarah Shaikh
 
9. Hard Problems
9. Hard Problems9. Hard Problems
9. Hard ProblemsSam Bowne
 
Cipher techniques
Cipher techniquesCipher techniques
Cipher techniquessaqib1611
 
CNIT 127 Ch 8: Windows overflows (Part 1)
CNIT 127 Ch 8: Windows overflows (Part 1)CNIT 127 Ch 8: Windows overflows (Part 1)
CNIT 127 Ch 8: Windows overflows (Part 1)Sam Bowne
 
5 stream ciphers
5 stream ciphers5 stream ciphers
5 stream ciphersHarish Sahu
 
CNIT 141: 7. Keyed Hashing
CNIT 141: 7. Keyed HashingCNIT 141: 7. Keyed Hashing
CNIT 141: 7. Keyed HashingSam Bowne
 
Ch 6: Attacking Authentication
Ch 6: Attacking AuthenticationCh 6: Attacking Authentication
Ch 6: Attacking AuthenticationSam Bowne
 
Kriptoloji kriptolama teknikleri
Kriptoloji kriptolama teknikleriKriptoloji kriptolama teknikleri
Kriptoloji kriptolama teknikleriselimcihan
 
Topic20 The RC4 Algorithm.pptx
Topic20 The RC4 Algorithm.pptxTopic20 The RC4 Algorithm.pptx
Topic20 The RC4 Algorithm.pptxUrjaDhabarde
 
Hash Function & Analysis
Hash Function & AnalysisHash Function & Analysis
Hash Function & AnalysisPawandeep Kaur
 
CapĂ­tulo 3: Cifrado en flujo
CapĂ­tulo 3: Cifrado en flujoCapĂ­tulo 3: Cifrado en flujo
CapĂ­tulo 3: Cifrado en flujoJuan Manuel GarcĂ­a
 
Block Ciphers and the Data Encryption Standard
Block Ciphers and the Data Encryption StandardBlock Ciphers and the Data Encryption Standard
Block Ciphers and the Data Encryption StandardDr.Florence Dayana
 
Ch03 block-cipher-and-data-encryption-standard
Ch03 block-cipher-and-data-encryption-standardCh03 block-cipher-and-data-encryption-standard
Ch03 block-cipher-and-data-encryption-standardtarekiceiuk
 
Bilgi güvenliğinin tarihçesi ve şifreleme bilimi
Bilgi güvenliğinin tarihçesi ve şifreleme bilimiBilgi güvenliğinin tarihçesi ve şifreleme bilimi
Bilgi güvenliğinin tarihçesi ve şifreleme bilimiCavad Bağırov
 

Was ist angesagt? (20)

CNIT 141 8. Authenticated Encryption
CNIT 141 8. Authenticated EncryptionCNIT 141 8. Authenticated Encryption
CNIT 141 8. Authenticated Encryption
 
ChaCha20-Poly1305 Cipher Summary - AdaLabs SPARKAda OpenSSH Ciphers
ChaCha20-Poly1305 Cipher Summary - AdaLabs SPARKAda OpenSSH CiphersChaCha20-Poly1305 Cipher Summary - AdaLabs SPARKAda OpenSSH Ciphers
ChaCha20-Poly1305 Cipher Summary - AdaLabs SPARKAda OpenSSH Ciphers
 
HES2011 - Tarjei Mandt – Kernel Pool Exploitation on Windows 7
HES2011 - Tarjei Mandt – Kernel Pool Exploitation on Windows 7HES2011 - Tarjei Mandt – Kernel Pool Exploitation on Windows 7
HES2011 - Tarjei Mandt – Kernel Pool Exploitation on Windows 7
 
Block cipher modes of operations
Block cipher modes of operationsBlock cipher modes of operations
Block cipher modes of operations
 
Symmetric encryption
Symmetric encryptionSymmetric encryption
Symmetric encryption
 
History of cryptography
History of cryptographyHistory of cryptography
History of cryptography
 
9. Hard Problems
9. Hard Problems9. Hard Problems
9. Hard Problems
 
Cipher techniques
Cipher techniquesCipher techniques
Cipher techniques
 
CNIT 127 Ch 8: Windows overflows (Part 1)
CNIT 127 Ch 8: Windows overflows (Part 1)CNIT 127 Ch 8: Windows overflows (Part 1)
CNIT 127 Ch 8: Windows overflows (Part 1)
 
5 stream ciphers
5 stream ciphers5 stream ciphers
5 stream ciphers
 
CNIT 141: 7. Keyed Hashing
CNIT 141: 7. Keyed HashingCNIT 141: 7. Keyed Hashing
CNIT 141: 7. Keyed Hashing
 
Key management
Key managementKey management
Key management
 
Ch 6: Attacking Authentication
Ch 6: Attacking AuthenticationCh 6: Attacking Authentication
Ch 6: Attacking Authentication
 
Kriptoloji kriptolama teknikleri
Kriptoloji kriptolama teknikleriKriptoloji kriptolama teknikleri
Kriptoloji kriptolama teknikleri
 
Topic20 The RC4 Algorithm.pptx
Topic20 The RC4 Algorithm.pptxTopic20 The RC4 Algorithm.pptx
Topic20 The RC4 Algorithm.pptx
 
Hash Function & Analysis
Hash Function & AnalysisHash Function & Analysis
Hash Function & Analysis
 
CapĂ­tulo 3: Cifrado en flujo
CapĂ­tulo 3: Cifrado en flujoCapĂ­tulo 3: Cifrado en flujo
CapĂ­tulo 3: Cifrado en flujo
 
Block Ciphers and the Data Encryption Standard
Block Ciphers and the Data Encryption StandardBlock Ciphers and the Data Encryption Standard
Block Ciphers and the Data Encryption Standard
 
Ch03 block-cipher-and-data-encryption-standard
Ch03 block-cipher-and-data-encryption-standardCh03 block-cipher-and-data-encryption-standard
Ch03 block-cipher-and-data-encryption-standard
 
Bilgi güvenliğinin tarihçesi ve şifreleme bilimi
Bilgi güvenliğinin tarihçesi ve şifreleme bilimiBilgi güvenliğinin tarihçesi ve şifreleme bilimi
Bilgi güvenliğinin tarihçesi ve şifreleme bilimi
 

Ă„hnlich wie CNIT 1417. 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 codeVaibhav Khanna
 
Message authentication
Message authenticationMessage authentication
Message authenticationCAS
 
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
 
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
 
Cns
CnsCns
CnsArthyR3
 
Distribution of public keys and hmac
Distribution of public keys and hmacDistribution of public keys and hmac
Distribution of public keys and hmacanuragjagetiya
 
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
 
Message authentication and hash function
Message authentication and hash functionMessage authentication and hash function
Message authentication and hash functionomarShiekh1
 
ASRG SOS 2022 Encrypted messaging on CAN bus
ASRG SOS 2022 Encrypted messaging on CAN busASRG SOS 2022 Encrypted messaging on CAN bus
ASRG SOS 2022 Encrypted messaging on CAN busKenTindell
 
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
 
IS413 Topic 5.pptx
IS413 Topic 5.pptxIS413 Topic 5.pptx
IS413 Topic 5.pptxWarrenPhiri4
 
Message Authentication Requirement-MAC
Message Authentication Requirement-MACMessage Authentication Requirement-MAC
Message Authentication Requirement-MACSou Jana
 
CISSP Week 20
CISSP Week 20CISSP Week 20
CISSP Week 20jemtallon
 
ch11.ppt
ch11.pptch11.ppt
ch11.pptSomuPatil8
 
8. Authenticated Encryption
8. Authenticated Encryption8. Authenticated Encryption
8. Authenticated EncryptionSam Bowne
 

Ă„hnlich wie CNIT 1417. Keyed Hashing (20)

Hash Function
Hash FunctionHash Function
Hash Function
 
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
 
Message authentication
Message authenticationMessage authentication
Message authentication
 
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
 
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
 
Cns
CnsCns
Cns
 
Distribution of public keys and hmac
Distribution of public keys and hmacDistribution of public keys and hmac
Distribution of public keys and hmac
 
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
 
Message authentication and hash function
Message authentication and hash functionMessage authentication and hash function
Message authentication and hash function
 
ASRG SOS 2022 Encrypted messaging on CAN bus
ASRG SOS 2022 Encrypted messaging on CAN busASRG SOS 2022 Encrypted messaging on CAN bus
ASRG SOS 2022 Encrypted messaging on CAN bus
 
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
 
IS413 Topic 5.pptx
IS413 Topic 5.pptxIS413 Topic 5.pptx
IS413 Topic 5.pptx
 
Unit - 4.pptx
Unit - 4.pptxUnit - 4.pptx
Unit - 4.pptx
 
Message Authentication Requirement-MAC
Message Authentication Requirement-MACMessage Authentication Requirement-MAC
Message Authentication Requirement-MAC
 
CISSP Week 20
CISSP Week 20CISSP Week 20
CISSP Week 20
 
ch11.ppt
ch11.pptch11.ppt
ch11.ppt
 
8. Authenticated Encryption
8. Authenticated Encryption8. Authenticated Encryption
8. Authenticated Encryption
 

Mehr von 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
 
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
 
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
 

Mehr von 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
 
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
 
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)
 

KĂĽrzlich hochgeladen

Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 đź’ž Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 đź’ž Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 đź’ž Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 đź’ž Full Nigh...Pooja Nehwal
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 

KĂĽrzlich hochgeladen (20)

Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 đź’ž Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 đź’ž Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 đź’ž Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 đź’ž Full Nigh...
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 

CNIT 1417. Keyed Hashing

  • 1. CNIT 141 Cryptography for Computer Networks 7. Keyed Hashing Updated 10-8-2020
  • 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. Known-Message Attack • An attacker passively collects messages and tags • Tries to find the key • This is a very weak attack
  • 9. Chosen-Message Attacks • An attacker can choose messages that get authenticated • And observe the authentication tags • The standard model to test MAC algorithms
  • 10. 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
  • 12. PRFs • Use a secret key to return PRF(K, M) • Output looks random • Key Derivation schemes use PRFs • To generate cryptographic keys from a master key or password • Identification schemes use PRFs • To generate a response from a random challenge
  • 13. 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
  • 14. 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
  • 15. Creating Keyed Hashes from Unkeyed Hashes
  • 16. 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
  • 17. 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)
  • 18. 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)
  • 19. 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)
  • 20. 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
  • 21. 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 block size • ipad is a series of 0x36 bytes as long as the block size
  • 22. Specifying Hash Function • Must specify, as in HMAC-SHA256
  • 23. 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 require a hash length extension attack • Works on all MACs based on an iterated hash function
  • 24. A Generic Attack Against Hash-Based MACs • Infeasible for n larger than 128 bits
  • 25.
  • 26. Creating Keyed Hashes from Block Ciphers: CMAC
  • 27. 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)
  • 28. 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
  • 29. 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
  • 30. 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
  • 31. Fixing CBC-MAC • Use key K to create K1 and K2 • Encrypt last block with a different key K K K1 IV = 0
  • 32. CBC-MAC • If the message fills the last block exactly • Uses K and K1
  • 33. CBC-MAC • If padding is needed • Uses K and K2
  • 35. 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
  • 36. Poly1305 • Designed in 2005 • Optimized to run fast on modern CPUs • Used by Google for HTTPS and OpenSSH
  • 37. 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)
  • 38. • 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
  • 39. • 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
  • 40. 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
  • 42. 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
  • 43. 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
  • 44. • Designed to resist DoS attacks on hash tables • Uses XORs, additions, and word rotations SipHash
  • 45. How Things Can Go Wrong
  • 46. 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
  • 47. 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