SlideShare une entreprise Scribd logo
1  sur  17
CSCI 172/283
Fall 2010
Hash Functions, HMACs, and
Digital Signatures
What ciphers do
 Encryption ciphers
 Provide confidentiality
 Eve can’t see what Alice and Bob are saying
 Can Eve do anything?
Alice Bob
Eve
?
C= Encrypt(M)
What ciphers don’t do
 Suppose Eve can get between Alice and Bob
 What if Eve can manipulate the data?
Alice Bob
Eve
M
M’
I’ll
send
Bob M
Alice
sent me
M’
Now for a
few
changes
Eve replaces M with M’
How can Bob tell if
Alice’s message was
modified?
Hash functions
 Map a variable length message to a fixed length
message
 y = h(x)
 If h is a 64-bit hash function, then y always fits in 64
bits
 0 ≤ y < 264
 Actual hash value may be represented with fewer bits, since
0, 1, etc. are in the output range
 Should include leading zeros
 Pigeonhole principle
 If n+1 pigeons nest in n holes, at least one hole has
more than one pigeon
 Maybe each hole has one pigeon, except for one that has
two
Was the message modified?
 Alice sends Bob {C = Encrypt(M), h(M)}
 When Bob gets {C, h(M)} , he checks
 M’=Decrypt(C)
 Bob computes h(M’)
 h(M) = h(M’)?
 If Eve modifies the message, it probably won’t
match
 If it does match, assume that it is the
message Alice sent
What could go wrong?
 Suppose h(x) maps to 1 or 0 with
equal probability?
 Eve has a 50/50 chance of fooling
Bob
 Suppose h(x) does not map to
the entire range with equal
probability
 Forget about the encryption for a
moment
 What could Eve do? Suppose:
 Eve can calculate f(h(M)) = M
 Eve knows some M’, h(M’) = h(M)
Nice try!
We need some
properties that
provide security!
Cryptographic hash functions
 When security people talk about hash functions,
they mean cryptographic (or secure) hash
functions
 These should provide
 Collision resistance
 Difficult to find any M, M’≠ M s.t. h(M) = h(M’)
 Preimage resistance
 Given h(M), difficult to find M’ s.t. h(M’)=h(M)
 Second preimage resistance
 Given M, difficult to find M’ s.t. h(M’)=h(M), M’≠M
 If a hash function h does not meet these
requirements…
But what does it all mean?
 If h is secure
 Easy to compute in one direction
 Very difficult to compute in the other direction
 Computationally infeasible
 i.e. your grandchildren’s grandchildren’s grandchildren will
be long gone before that computation finishes
 Very difficult to find two messages that hash to the
same value
 Can anyone name any?
Secure Hash Algorithm (SHA)
 NIST standards
 Mandatory in US Government
 Adopted globally
 SHA (SHA-0) is no good anymore
 SHA-1 has attacks and is not recommended
 SHA-2 looks good for now
 What happens when there’s an attack?
 It takes years to create and analyze functions
SHA-3
 About halfway through the process of choosing
the next SHA family of hash functions
 International competition
 64 submissions
 Round 1: 54
 Round 2: 14
 Round 3: ~5
 And the winner is… ?
 Winner gets massive bragging rights
 A lot of new design techniques
 A lot of new attack techniques
Who can compute a hash?
 A hash is a keyless algorithm
 Anyone can compute h(x) if they know x
 Eve could replace M with M’ and h(M) with h(M’)
 The hash matches what Bob computes, so he
assumes that Alice sent him M’
 How could we stop Eve from doing this?
HMAC
 Hash-based Message Authentication Code
 Keyed hash
 y = HMAC(M, k)
 Provides some level of authentication
 If only and Alice and Bob know the key and the HMAC is
correct, it must have come from one of them
 Can make an HMAC algorithm from an unkeyed hash
algorithm
 Why not just make a keyed hash algorithm?
 Import/export restrictions
 Keyless algorithms are not restricted
How to key an unkeyed hash
 We have hash function h, which processes a
message in b-byte blocks
 Let k be a key, |k| ≤ b
 Pad k with zeros to form k’, |k’| = b
 Let ipad be 00110110, repeated b times
 Let opad be 01011100, repeated b times
 HMAC-h is formed by
HMAC-h(k,m) = h(k’  opad || h(k’  ipad || m))
Who sent it?
 For HMACs, the key is shared
 Fine for some applications
 What if instead of knowing if someone who knows
the key sent it, we want to know that Alice sent it?
Digital signatures
 Use public key cryptography
 Recall that only Alice knows Alice’s private key
 Alice digitally signs her message, M
 Alice computes h(M)
 Alice encrypts h(M) using her private key (signing)
 Alice sends Bob {M, Enc(h(M), Apriv)}
 Bob verifies the message was sent by Alice
 Computes y’ = h(M)
 Decrypts Enc(h(M), Apriv) with Alice’s public key
 y = Dec(Enc(h(M), Apriv), Apub)
 Does y’ = y?
 If yes, Alice must have sent it
Digital Signatures
 Digital signatures provide checks for integrity and
origin
 Because only Alice knows her private key, it must
have been her that sent it
 Non-repudiation
 Suppose Alice wants to encrypt M so that Eve
can’t see it Should she:
 Encrypt, then sign
 Sign, then encrypt
 Does it matter?
 Why?
Conclusion by xkcd
http://xkcd.com/177/

Contenu connexe

Similaire à CS283_hash.ppt

Hash Techniques in Cryptography
Hash Techniques in CryptographyHash Techniques in Cryptography
Hash Techniques in Cryptography
Basudev Saha
 
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
 

Similaire à CS283_hash.ppt (13)

crypto.ppt
crypto.pptcrypto.ppt
crypto.ppt
 
network security
network security network security
network security
 
Crypto2
Crypto2Crypto2
Crypto2
 
6.hash mac
6.hash mac6.hash mac
6.hash mac
 
Hash Techniques in Cryptography
Hash Techniques in CryptographyHash Techniques in Cryptography
Hash Techniques in Cryptography
 
public-key cryptography Shamir
public-key cryptography Shamirpublic-key cryptography Shamir
public-key cryptography Shamir
 
Cryptography Key Management.pptx
Cryptography Key Management.pptxCryptography Key Management.pptx
Cryptography Key Management.pptx
 
Computer Network Homework Help
Computer Network Homework HelpComputer Network Homework Help
Computer Network Homework Help
 
Network Security Lec5
Network Security  Lec5Network Security  Lec5
Network Security Lec5
 
Public-Key Protocols
Public-Key ProtocolsPublic-Key Protocols
Public-Key Protocols
 
Zero Knowledge Proofs: What they are and how they work
Zero Knowledge Proofs: What they are and how they workZero Knowledge Proofs: What they are and how they work
Zero Knowledge Proofs: What they are and how they work
 
A Good Hash Function is Hard to Find, and Vice Versa
A Good Hash Function is Hard to Find, and Vice VersaA Good Hash Function is Hard to Find, and Vice Versa
A Good Hash Function is Hard to Find, and Vice Versa
 
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
 

Plus de vicepy

Challenge supporting document by Priyanka Chatterjee (1).pdf
Challenge supporting document by Priyanka Chatterjee (1).pdfChallenge supporting document by Priyanka Chatterjee (1).pdf
Challenge supporting document by Priyanka Chatterjee (1).pdf
vicepy
 
NTA-NET-Computer-Science-Paper-2-July-2016.pdf
NTA-NET-Computer-Science-Paper-2-July-2016.pdfNTA-NET-Computer-Science-Paper-2-July-2016.pdf
NTA-NET-Computer-Science-Paper-2-July-2016.pdf
vicepy
 
SET computer science 26 March 2023.pdf
SET computer science 26 March 2023.pdfSET computer science 26 March 2023.pdf
SET computer science 26 March 2023.pdf
vicepy
 
NTA-NET-Computer-Science-Paper-3-Jan-2017.pdf
NTA-NET-Computer-Science-Paper-3-Jan-2017.pdfNTA-NET-Computer-Science-Paper-3-Jan-2017.pdf
NTA-NET-Computer-Science-Paper-3-Jan-2017.pdf
vicepy
 
Final Supporing Docment to challenge with Question Id.pdf
Final Supporing Docment to challenge with Question Id.pdfFinal Supporing Docment to challenge with Question Id.pdf
Final Supporing Docment to challenge with Question Id.pdf
vicepy
 
tf33780407_win32.potx
tf33780407_win32.potxtf33780407_win32.potx
tf33780407_win32.potx
vicepy
 

Plus de vicepy (11)

Challenge supporting document by Priyanka Chatterjee (1).pdf
Challenge supporting document by Priyanka Chatterjee (1).pdfChallenge supporting document by Priyanka Chatterjee (1).pdf
Challenge supporting document by Priyanka Chatterjee (1).pdf
 
NTA-NET-Computer-Science-Paper-2-July-2016.pdf
NTA-NET-Computer-Science-Paper-2-July-2016.pdfNTA-NET-Computer-Science-Paper-2-July-2016.pdf
NTA-NET-Computer-Science-Paper-2-July-2016.pdf
 
ugcnet-1_merged.pdf
ugcnet-1_merged.pdfugcnet-1_merged.pdf
ugcnet-1_merged.pdf
 
SET computer science 26 March 2023.pdf
SET computer science 26 March 2023.pdfSET computer science 26 March 2023.pdf
SET computer science 26 March 2023.pdf
 
Response Sheet.pdf
Response Sheet.pdfResponse Sheet.pdf
Response Sheet.pdf
 
2023032314 (1).pdf
2023032314 (1).pdf2023032314 (1).pdf
2023032314 (1).pdf
 
DI (2).pdf
DI (2).pdfDI (2).pdf
DI (2).pdf
 
NTA-NET-Computer-Science-Paper-3-Jan-2017.pdf
NTA-NET-Computer-Science-Paper-3-Jan-2017.pdfNTA-NET-Computer-Science-Paper-3-Jan-2017.pdf
NTA-NET-Computer-Science-Paper-3-Jan-2017.pdf
 
Final Supporing Docment to challenge with Question Id.pdf
Final Supporing Docment to challenge with Question Id.pdfFinal Supporing Docment to challenge with Question Id.pdf
Final Supporing Docment to challenge with Question Id.pdf
 
Voip.pdf
Voip.pdfVoip.pdf
Voip.pdf
 
tf33780407_win32.potx
tf33780407_win32.potxtf33780407_win32.potx
tf33780407_win32.potx
 

Dernier

Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
jaanualu31
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
Kamal Acharya
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
MayuraD1
 
Verification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptxVerification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptx
chumtiyababu
 

Dernier (20)

Wadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptxWadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptx
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Moment Distribution Method For Btech Civil
Moment Distribution Method For Btech CivilMoment Distribution Method For Btech Civil
Moment Distribution Method For Btech Civil
 
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEGEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
Verification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptxVerification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptx
 

CS283_hash.ppt

  • 1. CSCI 172/283 Fall 2010 Hash Functions, HMACs, and Digital Signatures
  • 2. What ciphers do  Encryption ciphers  Provide confidentiality  Eve can’t see what Alice and Bob are saying  Can Eve do anything? Alice Bob Eve ? C= Encrypt(M)
  • 3. What ciphers don’t do  Suppose Eve can get between Alice and Bob  What if Eve can manipulate the data? Alice Bob Eve M M’ I’ll send Bob M Alice sent me M’ Now for a few changes Eve replaces M with M’ How can Bob tell if Alice’s message was modified?
  • 4. Hash functions  Map a variable length message to a fixed length message  y = h(x)  If h is a 64-bit hash function, then y always fits in 64 bits  0 ≤ y < 264  Actual hash value may be represented with fewer bits, since 0, 1, etc. are in the output range  Should include leading zeros  Pigeonhole principle  If n+1 pigeons nest in n holes, at least one hole has more than one pigeon  Maybe each hole has one pigeon, except for one that has two
  • 5. Was the message modified?  Alice sends Bob {C = Encrypt(M), h(M)}  When Bob gets {C, h(M)} , he checks  M’=Decrypt(C)  Bob computes h(M’)  h(M) = h(M’)?  If Eve modifies the message, it probably won’t match  If it does match, assume that it is the message Alice sent
  • 6. What could go wrong?  Suppose h(x) maps to 1 or 0 with equal probability?  Eve has a 50/50 chance of fooling Bob  Suppose h(x) does not map to the entire range with equal probability  Forget about the encryption for a moment  What could Eve do? Suppose:  Eve can calculate f(h(M)) = M  Eve knows some M’, h(M’) = h(M) Nice try! We need some properties that provide security!
  • 7. Cryptographic hash functions  When security people talk about hash functions, they mean cryptographic (or secure) hash functions  These should provide  Collision resistance  Difficult to find any M, M’≠ M s.t. h(M) = h(M’)  Preimage resistance  Given h(M), difficult to find M’ s.t. h(M’)=h(M)  Second preimage resistance  Given M, difficult to find M’ s.t. h(M’)=h(M), M’≠M  If a hash function h does not meet these requirements…
  • 8. But what does it all mean?  If h is secure  Easy to compute in one direction  Very difficult to compute in the other direction  Computationally infeasible  i.e. your grandchildren’s grandchildren’s grandchildren will be long gone before that computation finishes  Very difficult to find two messages that hash to the same value  Can anyone name any?
  • 9. Secure Hash Algorithm (SHA)  NIST standards  Mandatory in US Government  Adopted globally  SHA (SHA-0) is no good anymore  SHA-1 has attacks and is not recommended  SHA-2 looks good for now  What happens when there’s an attack?  It takes years to create and analyze functions
  • 10. SHA-3  About halfway through the process of choosing the next SHA family of hash functions  International competition  64 submissions  Round 1: 54  Round 2: 14  Round 3: ~5  And the winner is… ?  Winner gets massive bragging rights  A lot of new design techniques  A lot of new attack techniques
  • 11. Who can compute a hash?  A hash is a keyless algorithm  Anyone can compute h(x) if they know x  Eve could replace M with M’ and h(M) with h(M’)  The hash matches what Bob computes, so he assumes that Alice sent him M’  How could we stop Eve from doing this?
  • 12. HMAC  Hash-based Message Authentication Code  Keyed hash  y = HMAC(M, k)  Provides some level of authentication  If only and Alice and Bob know the key and the HMAC is correct, it must have come from one of them  Can make an HMAC algorithm from an unkeyed hash algorithm  Why not just make a keyed hash algorithm?  Import/export restrictions  Keyless algorithms are not restricted
  • 13. How to key an unkeyed hash  We have hash function h, which processes a message in b-byte blocks  Let k be a key, |k| ≤ b  Pad k with zeros to form k’, |k’| = b  Let ipad be 00110110, repeated b times  Let opad be 01011100, repeated b times  HMAC-h is formed by HMAC-h(k,m) = h(k’  opad || h(k’  ipad || m))
  • 14. Who sent it?  For HMACs, the key is shared  Fine for some applications  What if instead of knowing if someone who knows the key sent it, we want to know that Alice sent it?
  • 15. Digital signatures  Use public key cryptography  Recall that only Alice knows Alice’s private key  Alice digitally signs her message, M  Alice computes h(M)  Alice encrypts h(M) using her private key (signing)  Alice sends Bob {M, Enc(h(M), Apriv)}  Bob verifies the message was sent by Alice  Computes y’ = h(M)  Decrypts Enc(h(M), Apriv) with Alice’s public key  y = Dec(Enc(h(M), Apriv), Apub)  Does y’ = y?  If yes, Alice must have sent it
  • 16. Digital Signatures  Digital signatures provide checks for integrity and origin  Because only Alice knows her private key, it must have been her that sent it  Non-repudiation  Suppose Alice wants to encrypt M so that Eve can’t see it Should she:  Encrypt, then sign  Sign, then encrypt  Does it matter?  Why?