SlideShare a Scribd company logo
CS526 Topic 5: Hash Functions and
Message Authentication
1
Computer Security
CS 526
Topic 5
Cryptography: Cryptographic Hash
Functions And Message Authentication Code
Announcements
• HW1 due on Sept 5
• Quiz 1 will be on Sept 10, covering topics 1-5
• Both projects will be allow a team of two
– May want to start forming teams
• Mid-term exam tentatively scheduled to be Tuesday
Oct 15, during lecture time
CS526 Topic 5: Hash Functions and
Message Authentication
2
CS526 Topic 5: Hash Functions and
Message Authentication
3
Readings for This Lecture
• Wikipedia
• Cryptographic Hash Function
s
• Message Authentication Cod
e
CS526 Topic 5: Hash Functions and
Message Authentication
4
Data Integrity and Source
Authentication
• Encryption does not protect data from modification
by another party.
• Why?
• Need a way to ensure that data arrives at destination
in its original form as sent by the sender and it is
coming from an authenticated source.
Hash Functions
• A hash function maps a message of an arbitrary length to
a m-bit output
– output known as the fingerprint or the message digest
• What is an example of hash functions?
– Give a hash function that maps Strings to integers in [0,2^{32}-1]
• Cryptographic hash functions are hash functions with
additional security requirements
CS526 Topic 5: Hash Functions and
Message Authentication
5
CS526 Topic 5: Hash Functions and
Message Authentication
6
Using Hash Functions for Message
Integrity
• Method 1: Uses a Hash Function h, assuming an
authentic (adversary cannot modify) channel for short
messages
– Transmit a message M over the normal (insecure) channel
– Transmit the message digest h(M) over the secure channel
– When receiver receives both M’ and h, how does the receiver
check to make sure the message has not been modified?
• This is insecure. How to attack it?
• A hash function is a many-to-one function, so collisions
can happen.
CS526 Topic 5: Hash Functions and
Message Authentication
7
Security Requirements for
Cryptographic Hash Functions
Given a function h:X Y, then we say that h is:
• preimage resistant (one-way):
if given y Y it is computationally infeasible to find a
value x X s.t. h(x) = y
• 2-nd preimage resistant (weak collision resistant):
if given x  X it is computationally infeasible to find a
value x’  X, s.t. x’x and h(x’) = h(x)
• collision resistant (strong collision resistant):
if it is computationally infeasible to find two distinct
values x’,x  X, s.t. h(x’) = h(x)
CS526 Topic 5: Hash Functions and
Message Authentication
8
Usages of Cryptographic Hash
Functions
• Software integrity
– E.g., tripwire
• Timestamping
– How to prove that you have discovered a secret on an
earlier date without disclosing it?
• Covered later
– Message authentication
– One-time passwords
– Digital signature
CS526 Topic 5: Hash Functions and
Message Authentication
9
Bruteforce Attacks on Hash Functions
• Attacking one-wayness
– Goal: given h:XY, yY, find x such that h(x)=y
– Algorithm:
• pick a random value x in X, check if h(x)=y, if
h(x)=y, returns x; otherwise iterate
• after failing q iterations, return fail
– The average-case success probability is
– Let |Y|=2m
, to get  to be close to 0.5, q 2m-1
|
|
|
|
1
1
1
Y
q
Y
q






 



CS526 Topic 5: Hash Functions and
Message Authentication
10
Bruteforce Attacks on Hash Functions
• Attacking collision resistance
– Goal: given h, find x, x’ such that h(x)=h(x’)
– Algorithm: pick a random set X0 of q values in X for
each xX0, computes yx=h(x) if yx=yx’ for some x’x
then return (x,x’) else fail
– The average success probability is
– Let |Y|=2m
, to get  to be close to 0.5, q 2m/2
– This is known as the birthday attack.
1
|
|
1
1
1 |
|
2
)
1
(
2
)
1
(
Y
q
q
q
q
e
Y















CS526 Topic 5: Hash Functions and
Message Authentication
11
Well Known Hash Functions
• MD5
– output 128 bits
– collision resistance completely broken by researchers in China in
2004
• SHA1
– output 160 bits
– no collision found yet, but method exist to find collisions in less than
2^80
– considered insecure for collision resistance
– one-wayness still holds
• SHA2 (SHA-224, SHA-256, SHA-384, SHA-512)
– outputs 224, 256, 384, and 512 bits, respectively
– No real security concerns yet
Merkle-Damgard Construction for
Hash Functions
CS526 Topic 5: Hash Functions and
Message Authentication
12
• Message is divided into fixed-size blocks and padded
• Uses a compression function f, which takes a chaining variable (of
size of hash output) and a message block, and outputs the next
chaining variable
• Final chaining variable is the hash value
M=m1m2…mn; C0=IV, Ci+1=f(Ci,mi); H(M)=Cn
NIST SHA-3 Competition
• NIST is having an ongoing competition for SHA-3, the next generation of
standard hash algorithms
• 2007: Request for submissions of new hash functions
• 2008: Submissions deadline. Received 64 entries. Announced first-round
selections of 51 candidates.
• 2009: After First SHA-3 candidate conference in Feb, announced 14
Second Round Candidates in July.
• 2010: After one year public review of the algorithms, hold second SHA-3
candidate conference in Aug. Announced 5 Third-round candidates in Dec.
• 2011: Public comment for final round
• 2012: October 2, NIST selected SHA3
– Keccak (pronounced “catch-ack”) created by Guido Bertoni, Joan Daemen and Gilles Van
Assche, Michaël Peeters
CS526 Topic 5: Hash Functions and
Message Authentication
13
The Sponge Construction: Used by
SHA-3
CS526 Topic 5: Hash Functions and
Message Authentication
14
• Each round, the next r bits of message is XOR’ed into the first r bits of the
state, and a function f is applied to the state.
• After message is consumed, output r bits of each round as the hash
output; continue applying f to get new states
• SHA-3 uses 1600 bits for state size
CS526 Topic 5: Hash Functions and
Message Authentication
15
Choosing the length of Hash outputs
• The Weakest Link Principle:
– A system is only as secure as its weakest link.
• Hence all links in a system should have similar levels of
security.
• Because of the birthday attack, the length of hash outputs
in general should double the key length of block ciphers
– SHA-224 matches the 112-bit strength of triple-DES (encryption
3 times using DES)
– SHA-256, SHA-384, SHA-512 match the new key lengths
(128,192,256) in AES
CS526 Topic 5: Hash Functions and
Message Authentication
16
Limitation of Using Hash Functions
for Authentication
• Require an authentic channel to transmit the
hash of a message
– Without such a channel, it is insecure, because
anyone can compute the hash value of any message,
as the hash function is public
– Such a channel may not always exist
• How to address this?
– use more than one hash functions
– use a key to select which one to use
CS526 Topic 5: Hash Functions and
Message Authentication
17
Hash Family
• A hash family is a four-tuple (X,Y,K,H ), where
– X is a set of possible messages
– Y is a finite set of possible message digests
– K is the keyspace
– For each KK, there is a hash function hKH . Each
hK: X Y
• Alternatively, one can think of H as a function
KXY
CS526 Topic 5: Hash Functions and
Message Authentication
18
Message Authentication Code
• A MAC scheme is a hash family, used for
message authentication
• MAC(K,M) = HK(M)
• The sender and the receiver share secret K
• The sender sends (M, Hk(M))
• The receiver receives (X,Y) and verifies that
HK(X)=Y, if so, then accepts the message as from
the sender
• To be secure, an adversary shouldn’t be able to
come up with (X’,Y’) such that HK(X’)=Y’.
Security Requirements for MAC
• Resist the Existential Forgery under Chosen Plaintext
Attack
– Challenger chooses a random key K
– Adversary chooses a number of messages M1, M2, .., Mn, and
obtains tj=MAC(K,Mj) for 1jn
– Adversary outputs M’ and t’
– Adversary wins if j M’≠Mj, and t’=MAC(K,M’)
• Basically, adversary cannot create the MAC for a
message for which it hasn’t seen an MAC
CS526 Topic 5: Hash Functions and
Message Authentication
19
Constructing MAC from Hash
Functions
• Let h be a one-way hash function
• MAC(K,M) = h(K || M), where || denote
concatenation
– Insecure as MAC
– Because of the Merkle-Damgard construction for hash
functions, given M and t=h(K || M), adversary can
compute M’=M||Pad(M)||X and t’, such that h(K||M’) =
t’
CS526 Topic 5: Hash Functions and
Message Authentication
20
CS526 Topic 5: Hash Functions and
Message Authentication
21
HMAC: Constructing MAC from
Cryptographic Hash Functions
• K+
is the key padded (with 0) to B bytes, the
input block size of the hash function
• ipad = the byte 0x36 repeated B times
• opad = the byte 0x5C repeated B times.
HMACK[M] = Hash[(K+
 opad) || Hash[(K+
 ipad)||M)]]
At high level, HMACK[M] = H(K || H(K || M))
CS526 Topic 5: Hash Functions and
Message Authentication
22
HMAC Security
• If used with a secure hash functions (e.g.,
SHA-256) and according to the specification
(key size, and use correct output), no known
practical attacks against HMAC
CS526 Topic 5: Hash Functions and
Message Authentication
23
Coming Attractions …
• Cryptography: Public Key
Cryptography
Ad

More Related Content

Similar to SHA New Revised Version - SHA-512 Syllabus Module 3 (20)

Message Authentication and Hash Function.pdf
Message Authentication and Hash Function.pdfMessage Authentication and Hash Function.pdf
Message Authentication and Hash Function.pdf
sunil sharma
 
Cryptography and network_security
Cryptography and network_securityCryptography and network_security
Cryptography and network_security
Janani Satheshkumar
 
NSC_Unit-III_final.ppt
NSC_Unit-III_final.pptNSC_Unit-III_final.ppt
NSC_Unit-III_final.ppt
DrVASAVIBANDE
 
cryptography and network security cns.pptx
cryptography and network security cns.pptxcryptography and network security cns.pptx
cryptography and network security cns.pptx
gkumar610
 
CS6701 CRYPTOGRAPHY AND NETWORK SECURITY
CS6701 CRYPTOGRAPHY AND NETWORK SECURITYCS6701 CRYPTOGRAPHY AND NETWORK SECURITY
CS6701 CRYPTOGRAPHY AND NETWORK SECURITY
Kathirvel Ayyaswamy
 
Lecture 3b public key_encryption
Lecture 3b public key_encryptionLecture 3b public key_encryption
Lecture 3b public key_encryption
rajakhurram
 
18CS2005 Cryptography and Network Security
18CS2005 Cryptography and Network Security 18CS2005 Cryptography and Network Security
18CS2005 Cryptography and Network Security
Kathirvel Ayyaswamy
 
Ch_07 (1).pptx
Ch_07 (1).pptxCh_07 (1).pptx
Ch_07 (1).pptx
siddhusid10
 
Hash Function & Analysis
Hash Function & AnalysisHash Function & Analysis
Hash Function & Analysis
Pawandeep Kaur
 
Distribution of public keys and hmac
Distribution of public keys and hmacDistribution of public keys and hmac
Distribution of public keys and hmac
anuragjagetiya
 
cryptography and network security by william stallings
cryptography and network security by william stallingscryptography and network security by william stallings
cryptography and network security by william stallings
HimaniP19CSE013
 
ch11.ppt
ch11.pptch11.ppt
ch11.ppt
ssuser4198c4
 
Message Authentication
Message AuthenticationMessage Authentication
Message Authentication
chauhankapil
 
2.15 Message Authentication Code and Hash Functions.pptx
2.15 Message Authentication Code and Hash Functions.pptx2.15 Message Authentication Code and Hash Functions.pptx
2.15 Message Authentication Code and Hash Functions.pptx
girilogu2
 
Cryptography and Message Authentication NS3
Cryptography and Message Authentication NS3Cryptography and Message Authentication NS3
Cryptography and Message Authentication NS3
koolkampus
 
Cryptographic Hash Functions in Security.pptx
Cryptographic Hash Functions in Security.pptxCryptographic Hash Functions in Security.pptx
Cryptographic Hash Functions in Security.pptx
VivekanandaGN1
 
Unit 3
Unit 3Unit 3
Unit 3
tamil arasan
 
Unit 3_Secure Hash Algorithm_SHA_Working.pdf
Unit 3_Secure Hash Algorithm_SHA_Working.pdfUnit 3_Secure Hash Algorithm_SHA_Working.pdf
Unit 3_Secure Hash Algorithm_SHA_Working.pdf
KanchanPatil34
 
Message Digest message digest ppttsx.pptx
Message Digest message digest ppttsx.pptxMessage Digest message digest ppttsx.pptx
Message Digest message digest ppttsx.pptx
LaxmipujaBiradar
 
TLS/SSL Protocol Design 201006
TLS/SSL Protocol Design 201006TLS/SSL Protocol Design 201006
TLS/SSL Protocol Design 201006
Nate Lawson
 
Message Authentication and Hash Function.pdf
Message Authentication and Hash Function.pdfMessage Authentication and Hash Function.pdf
Message Authentication and Hash Function.pdf
sunil sharma
 
Cryptography and network_security
Cryptography and network_securityCryptography and network_security
Cryptography and network_security
Janani Satheshkumar
 
NSC_Unit-III_final.ppt
NSC_Unit-III_final.pptNSC_Unit-III_final.ppt
NSC_Unit-III_final.ppt
DrVASAVIBANDE
 
cryptography and network security cns.pptx
cryptography and network security cns.pptxcryptography and network security cns.pptx
cryptography and network security cns.pptx
gkumar610
 
CS6701 CRYPTOGRAPHY AND NETWORK SECURITY
CS6701 CRYPTOGRAPHY AND NETWORK SECURITYCS6701 CRYPTOGRAPHY AND NETWORK SECURITY
CS6701 CRYPTOGRAPHY AND NETWORK SECURITY
Kathirvel Ayyaswamy
 
Lecture 3b public key_encryption
Lecture 3b public key_encryptionLecture 3b public key_encryption
Lecture 3b public key_encryption
rajakhurram
 
18CS2005 Cryptography and Network Security
18CS2005 Cryptography and Network Security 18CS2005 Cryptography and Network Security
18CS2005 Cryptography and Network Security
Kathirvel Ayyaswamy
 
Hash Function & Analysis
Hash Function & AnalysisHash Function & Analysis
Hash Function & Analysis
Pawandeep Kaur
 
Distribution of public keys and hmac
Distribution of public keys and hmacDistribution of public keys and hmac
Distribution of public keys and hmac
anuragjagetiya
 
cryptography and network security by william stallings
cryptography and network security by william stallingscryptography and network security by william stallings
cryptography and network security by william stallings
HimaniP19CSE013
 
Message Authentication
Message AuthenticationMessage Authentication
Message Authentication
chauhankapil
 
2.15 Message Authentication Code and Hash Functions.pptx
2.15 Message Authentication Code and Hash Functions.pptx2.15 Message Authentication Code and Hash Functions.pptx
2.15 Message Authentication Code and Hash Functions.pptx
girilogu2
 
Cryptography and Message Authentication NS3
Cryptography and Message Authentication NS3Cryptography and Message Authentication NS3
Cryptography and Message Authentication NS3
koolkampus
 
Cryptographic Hash Functions in Security.pptx
Cryptographic Hash Functions in Security.pptxCryptographic Hash Functions in Security.pptx
Cryptographic Hash Functions in Security.pptx
VivekanandaGN1
 
Unit 3_Secure Hash Algorithm_SHA_Working.pdf
Unit 3_Secure Hash Algorithm_SHA_Working.pdfUnit 3_Secure Hash Algorithm_SHA_Working.pdf
Unit 3_Secure Hash Algorithm_SHA_Working.pdf
KanchanPatil34
 
Message Digest message digest ppttsx.pptx
Message Digest message digest ppttsx.pptxMessage Digest message digest ppttsx.pptx
Message Digest message digest ppttsx.pptx
LaxmipujaBiradar
 
TLS/SSL Protocol Design 201006
TLS/SSL Protocol Design 201006TLS/SSL Protocol Design 201006
TLS/SSL Protocol Design 201006
Nate Lawson
 

Recently uploaded (20)

ATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ATAL 6 Days Online FDP Scheme Document 2025-26.pdfATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ssuserda39791
 
hypermedia_system_revisit_roy_fielding .
hypermedia_system_revisit_roy_fielding .hypermedia_system_revisit_roy_fielding .
hypermedia_system_revisit_roy_fielding .
NABLAS株式会社
 
SICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introductionSICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introduction
fabienklr
 
Using the Artificial Neural Network to Predict the Axial Strength and Strain ...
Using the Artificial Neural Network to Predict the Axial Strength and Strain ...Using the Artificial Neural Network to Predict the Axial Strength and Strain ...
Using the Artificial Neural Network to Predict the Axial Strength and Strain ...
Journal of Soft Computing in Civil Engineering
 
Machine foundation notes for civil engineering students
Machine foundation notes for civil engineering studentsMachine foundation notes for civil engineering students
Machine foundation notes for civil engineering students
DYPCET
 
Construction Materials (Paints) in Civil Engineering
Construction Materials (Paints) in Civil EngineeringConstruction Materials (Paints) in Civil Engineering
Construction Materials (Paints) in Civil Engineering
Lavish Kashyap
 
Modeling the Influence of Environmental Factors on Concrete Evaporation Rate
Modeling the Influence of Environmental Factors on Concrete Evaporation RateModeling the Influence of Environmental Factors on Concrete Evaporation Rate
Modeling the Influence of Environmental Factors on Concrete Evaporation Rate
Journal of Soft Computing in Civil Engineering
 
22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf
22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf
22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf
Guru Nanak Technical Institutions
 
Agents chapter of Artificial intelligence
Agents chapter of Artificial intelligenceAgents chapter of Artificial intelligence
Agents chapter of Artificial intelligence
DebdeepMukherjee9
 
Applications of Centroid in Structural Engineering
Applications of Centroid in Structural EngineeringApplications of Centroid in Structural Engineering
Applications of Centroid in Structural Engineering
suvrojyotihalder2006
 
Modelling of Concrete Compressive Strength Admixed with GGBFS Using Gene Expr...
Modelling of Concrete Compressive Strength Admixed with GGBFS Using Gene Expr...Modelling of Concrete Compressive Strength Admixed with GGBFS Using Gene Expr...
Modelling of Concrete Compressive Strength Admixed with GGBFS Using Gene Expr...
Journal of Soft Computing in Civil Engineering
 
DED KOMINFO detail engginering design gedung
DED KOMINFO detail engginering design gedungDED KOMINFO detail engginering design gedung
DED KOMINFO detail engginering design gedung
nabilarizqifadhilah1
 
Slide share PPT of NOx control technologies.pptx
Slide share PPT of  NOx control technologies.pptxSlide share PPT of  NOx control technologies.pptx
Slide share PPT of NOx control technologies.pptx
vvsasane
 
Mode-Wise Corridor Level Travel-Time Estimation Using Machine Learning Models
Mode-Wise Corridor Level Travel-Time Estimation Using Machine Learning ModelsMode-Wise Corridor Level Travel-Time Estimation Using Machine Learning Models
Mode-Wise Corridor Level Travel-Time Estimation Using Machine Learning Models
Journal of Soft Computing in Civil Engineering
 
Water Industry Process Automation & Control Monthly May 2025
Water Industry Process Automation & Control Monthly May 2025Water Industry Process Automation & Control Monthly May 2025
Water Industry Process Automation & Control Monthly May 2025
Water Industry Process Automation & Control
 
Slide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptxSlide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptx
vvsasane
 
Working with USDOT UTCs: From Conception to Implementation
Working with USDOT UTCs: From Conception to ImplementationWorking with USDOT UTCs: From Conception to Implementation
Working with USDOT UTCs: From Conception to Implementation
Alabama Transportation Assistance Program
 
Generative AI & Large Language Models Agents
Generative AI & Large Language Models AgentsGenerative AI & Large Language Models Agents
Generative AI & Large Language Models Agents
aasgharbee22seecs
 
Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...
Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...
Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...
AI Publications
 
2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt
rakshaiya16
 
ATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ATAL 6 Days Online FDP Scheme Document 2025-26.pdfATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ssuserda39791
 
hypermedia_system_revisit_roy_fielding .
hypermedia_system_revisit_roy_fielding .hypermedia_system_revisit_roy_fielding .
hypermedia_system_revisit_roy_fielding .
NABLAS株式会社
 
SICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introductionSICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introduction
fabienklr
 
Machine foundation notes for civil engineering students
Machine foundation notes for civil engineering studentsMachine foundation notes for civil engineering students
Machine foundation notes for civil engineering students
DYPCET
 
Construction Materials (Paints) in Civil Engineering
Construction Materials (Paints) in Civil EngineeringConstruction Materials (Paints) in Civil Engineering
Construction Materials (Paints) in Civil Engineering
Lavish Kashyap
 
Agents chapter of Artificial intelligence
Agents chapter of Artificial intelligenceAgents chapter of Artificial intelligence
Agents chapter of Artificial intelligence
DebdeepMukherjee9
 
Applications of Centroid in Structural Engineering
Applications of Centroid in Structural EngineeringApplications of Centroid in Structural Engineering
Applications of Centroid in Structural Engineering
suvrojyotihalder2006
 
DED KOMINFO detail engginering design gedung
DED KOMINFO detail engginering design gedungDED KOMINFO detail engginering design gedung
DED KOMINFO detail engginering design gedung
nabilarizqifadhilah1
 
Slide share PPT of NOx control technologies.pptx
Slide share PPT of  NOx control technologies.pptxSlide share PPT of  NOx control technologies.pptx
Slide share PPT of NOx control technologies.pptx
vvsasane
 
Slide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptxSlide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptx
vvsasane
 
Generative AI & Large Language Models Agents
Generative AI & Large Language Models AgentsGenerative AI & Large Language Models Agents
Generative AI & Large Language Models Agents
aasgharbee22seecs
 
Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...
Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...
Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...
AI Publications
 
2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt
rakshaiya16
 
Ad

SHA New Revised Version - SHA-512 Syllabus Module 3

  • 1. CS526 Topic 5: Hash Functions and Message Authentication 1 Computer Security CS 526 Topic 5 Cryptography: Cryptographic Hash Functions And Message Authentication Code
  • 2. Announcements • HW1 due on Sept 5 • Quiz 1 will be on Sept 10, covering topics 1-5 • Both projects will be allow a team of two – May want to start forming teams • Mid-term exam tentatively scheduled to be Tuesday Oct 15, during lecture time CS526 Topic 5: Hash Functions and Message Authentication 2
  • 3. CS526 Topic 5: Hash Functions and Message Authentication 3 Readings for This Lecture • Wikipedia • Cryptographic Hash Function s • Message Authentication Cod e
  • 4. CS526 Topic 5: Hash Functions and Message Authentication 4 Data Integrity and Source Authentication • Encryption does not protect data from modification by another party. • Why? • Need a way to ensure that data arrives at destination in its original form as sent by the sender and it is coming from an authenticated source.
  • 5. Hash Functions • A hash function maps a message of an arbitrary length to a m-bit output – output known as the fingerprint or the message digest • What is an example of hash functions? – Give a hash function that maps Strings to integers in [0,2^{32}-1] • Cryptographic hash functions are hash functions with additional security requirements CS526 Topic 5: Hash Functions and Message Authentication 5
  • 6. CS526 Topic 5: Hash Functions and Message Authentication 6 Using Hash Functions for Message Integrity • Method 1: Uses a Hash Function h, assuming an authentic (adversary cannot modify) channel for short messages – Transmit a message M over the normal (insecure) channel – Transmit the message digest h(M) over the secure channel – When receiver receives both M’ and h, how does the receiver check to make sure the message has not been modified? • This is insecure. How to attack it? • A hash function is a many-to-one function, so collisions can happen.
  • 7. CS526 Topic 5: Hash Functions and Message Authentication 7 Security Requirements for Cryptographic Hash Functions Given a function h:X Y, then we say that h is: • preimage resistant (one-way): if given y Y it is computationally infeasible to find a value x X s.t. h(x) = y • 2-nd preimage resistant (weak collision resistant): if given x  X it is computationally infeasible to find a value x’  X, s.t. x’x and h(x’) = h(x) • collision resistant (strong collision resistant): if it is computationally infeasible to find two distinct values x’,x  X, s.t. h(x’) = h(x)
  • 8. CS526 Topic 5: Hash Functions and Message Authentication 8 Usages of Cryptographic Hash Functions • Software integrity – E.g., tripwire • Timestamping – How to prove that you have discovered a secret on an earlier date without disclosing it? • Covered later – Message authentication – One-time passwords – Digital signature
  • 9. CS526 Topic 5: Hash Functions and Message Authentication 9 Bruteforce Attacks on Hash Functions • Attacking one-wayness – Goal: given h:XY, yY, find x such that h(x)=y – Algorithm: • pick a random value x in X, check if h(x)=y, if h(x)=y, returns x; otherwise iterate • after failing q iterations, return fail – The average-case success probability is – Let |Y|=2m , to get  to be close to 0.5, q 2m-1 | | | | 1 1 1 Y q Y q           
  • 10. CS526 Topic 5: Hash Functions and Message Authentication 10 Bruteforce Attacks on Hash Functions • Attacking collision resistance – Goal: given h, find x, x’ such that h(x)=h(x’) – Algorithm: pick a random set X0 of q values in X for each xX0, computes yx=h(x) if yx=yx’ for some x’x then return (x,x’) else fail – The average success probability is – Let |Y|=2m , to get  to be close to 0.5, q 2m/2 – This is known as the birthday attack. 1 | | 1 1 1 | | 2 ) 1 ( 2 ) 1 ( Y q q q q e Y               
  • 11. CS526 Topic 5: Hash Functions and Message Authentication 11 Well Known Hash Functions • MD5 – output 128 bits – collision resistance completely broken by researchers in China in 2004 • SHA1 – output 160 bits – no collision found yet, but method exist to find collisions in less than 2^80 – considered insecure for collision resistance – one-wayness still holds • SHA2 (SHA-224, SHA-256, SHA-384, SHA-512) – outputs 224, 256, 384, and 512 bits, respectively – No real security concerns yet
  • 12. Merkle-Damgard Construction for Hash Functions CS526 Topic 5: Hash Functions and Message Authentication 12 • Message is divided into fixed-size blocks and padded • Uses a compression function f, which takes a chaining variable (of size of hash output) and a message block, and outputs the next chaining variable • Final chaining variable is the hash value M=m1m2…mn; C0=IV, Ci+1=f(Ci,mi); H(M)=Cn
  • 13. NIST SHA-3 Competition • NIST is having an ongoing competition for SHA-3, the next generation of standard hash algorithms • 2007: Request for submissions of new hash functions • 2008: Submissions deadline. Received 64 entries. Announced first-round selections of 51 candidates. • 2009: After First SHA-3 candidate conference in Feb, announced 14 Second Round Candidates in July. • 2010: After one year public review of the algorithms, hold second SHA-3 candidate conference in Aug. Announced 5 Third-round candidates in Dec. • 2011: Public comment for final round • 2012: October 2, NIST selected SHA3 – Keccak (pronounced “catch-ack”) created by Guido Bertoni, Joan Daemen and Gilles Van Assche, Michaël Peeters CS526 Topic 5: Hash Functions and Message Authentication 13
  • 14. The Sponge Construction: Used by SHA-3 CS526 Topic 5: Hash Functions and Message Authentication 14 • Each round, the next r bits of message is XOR’ed into the first r bits of the state, and a function f is applied to the state. • After message is consumed, output r bits of each round as the hash output; continue applying f to get new states • SHA-3 uses 1600 bits for state size
  • 15. CS526 Topic 5: Hash Functions and Message Authentication 15 Choosing the length of Hash outputs • The Weakest Link Principle: – A system is only as secure as its weakest link. • Hence all links in a system should have similar levels of security. • Because of the birthday attack, the length of hash outputs in general should double the key length of block ciphers – SHA-224 matches the 112-bit strength of triple-DES (encryption 3 times using DES) – SHA-256, SHA-384, SHA-512 match the new key lengths (128,192,256) in AES
  • 16. CS526 Topic 5: Hash Functions and Message Authentication 16 Limitation of Using Hash Functions for Authentication • Require an authentic channel to transmit the hash of a message – Without such a channel, it is insecure, because anyone can compute the hash value of any message, as the hash function is public – Such a channel may not always exist • How to address this? – use more than one hash functions – use a key to select which one to use
  • 17. CS526 Topic 5: Hash Functions and Message Authentication 17 Hash Family • A hash family is a four-tuple (X,Y,K,H ), where – X is a set of possible messages – Y is a finite set of possible message digests – K is the keyspace – For each KK, there is a hash function hKH . Each hK: X Y • Alternatively, one can think of H as a function KXY
  • 18. CS526 Topic 5: Hash Functions and Message Authentication 18 Message Authentication Code • A MAC scheme is a hash family, used for message authentication • MAC(K,M) = HK(M) • The sender and the receiver share secret K • The sender sends (M, Hk(M)) • The receiver receives (X,Y) and verifies that HK(X)=Y, if so, then accepts the message as from the sender • To be secure, an adversary shouldn’t be able to come up with (X’,Y’) such that HK(X’)=Y’.
  • 19. Security Requirements for MAC • Resist the Existential Forgery under Chosen Plaintext Attack – Challenger chooses a random key K – Adversary chooses a number of messages M1, M2, .., Mn, and obtains tj=MAC(K,Mj) for 1jn – Adversary outputs M’ and t’ – Adversary wins if j M’≠Mj, and t’=MAC(K,M’) • Basically, adversary cannot create the MAC for a message for which it hasn’t seen an MAC CS526 Topic 5: Hash Functions and Message Authentication 19
  • 20. Constructing MAC from Hash Functions • Let h be a one-way hash function • MAC(K,M) = h(K || M), where || denote concatenation – Insecure as MAC – Because of the Merkle-Damgard construction for hash functions, given M and t=h(K || M), adversary can compute M’=M||Pad(M)||X and t’, such that h(K||M’) = t’ CS526 Topic 5: Hash Functions and Message Authentication 20
  • 21. CS526 Topic 5: Hash Functions and Message Authentication 21 HMAC: Constructing MAC from Cryptographic Hash Functions • K+ is the key padded (with 0) to B bytes, the input block size of the hash function • ipad = the byte 0x36 repeated B times • opad = the byte 0x5C repeated B times. HMACK[M] = Hash[(K+  opad) || Hash[(K+  ipad)||M)]] At high level, HMACK[M] = H(K || H(K || M))
  • 22. CS526 Topic 5: Hash Functions and Message Authentication 22 HMAC Security • If used with a secure hash functions (e.g., SHA-256) and according to the specification (key size, and use correct output), no known practical attacks against HMAC
  • 23. CS526 Topic 5: Hash Functions and Message Authentication 23 Coming Attractions … • Cryptography: Public Key Cryptography

Editor's Notes

  • #4: Modified ciphertext can often still be decrypted into plaintexts?
  • #5: Example hash function: v:=1; for each character c, v=v*(c+1)+2 mod 2^{32};
  • #6: An authenticated channel for short messages bootstraps authenticity. A short secret key in encryption boostraps confidentiality.
  • #10: Assuming |Y|=N. With q choices, the Prob that there is no collision is P = (N-1)/N * (N-2)/N * … * (N-q+1)/N = [i=1 to q-1] (1 – i/N) 1-i/N  e^{-i/N} P  e^{-  [i=1 to q-1] i/N} = e^{-q(q-1) / 2N }
  • #15: Which hash function to use?
  • #19: Good homework problem, break simple MAC constructions. MAC uses shared secret key to bootstrap integrity/authenticity.
  翻译: