SlideShare a Scribd company logo
1 of 12
Announcements:
Questions?
This week:
 Discrete Logs, Diffie-Hellman, ElGamal
 Hash Functions and SHA-1
 Birthday attacks
DTTF/NB479: Dszquphsbqiz Day 27
Hash Functions
Goal: to provide a unique “fingerprint” of the message.
How? Must demonstrate 3 properties:
1. Fast to compute y from m.
2. One-way: given y = h(m), can’t find any m’ satisfying h(m’) = y
easily.
3. Strongly collision-free: Can’t find any m1 != m2 such that
h(m1)=h(m2) easily
4. (Sometimes we can settle for weakly collision-free: given m, can’t
find m’ != m with h(m) = h(m’).
Message m
(long)
Message digest, y
(Shorter fixed length)
Cryptographic hash
Function, h
Shrinks data, so 2 messages can
have the same digest: m1 != m2, but
H(m1) = h(m2)
EHA: Easy Hash Algorithm
Break m into n-bit blocks,
append zeros to get a
multiple of n.
There are L of them,
where L =|m|/n
Fast! But not very secure.
Doing a left shift on the
rows helps a little:
 Define as left-
shifting m by y bits
 Then


























ln
2
1
2
22
21
1
12
11
2
1
...
m
m
m
m
m
m
m
m
m
m
m
m
m
l
l
n
n
l 






 
n
c
c
c ...
2
1








y
m
y
m
m i
i 


=h(m)













 1
,
1
,
21
23
22
1
12
11
...
...
l
l
l
l
ll
n
m
m
m
m
m
m
m
m
m





EHA: Easy Hash Algorithm
 
n
c
c
c ...
2
1








=h(m)
Exercise:
1. Show that the basic (unrotated) version doesn’t satisfy properties 2 and 3.
2. Show that the rotated version doesn’t satisfy properties 2 and 3 either.
Conclusion: Need nonlinearity!
3 properties:
1. Fast to compute
2. One-way: given y =
h(m), can’t find any
m’ satisfying h(m’) =
y easily.
3. Strongly collision-
free: Can’t find m1 !=
m2 such that
h(m1)=h(m2)


























ln
2
1
2
22
21
1
12
11
2
1
...
m
m
m
m
m
m
m
m
m
m
m
m
m
l
l
n
n
l 






SHA-1: Secure Hash Algorithm
NSA  NIST
“This standard specifies a Secure Hash Algorithm (SHA), which is
necessary to ensure the security of the Digital Signature Algorithm (DSA).
When a message of any length < 264 bits is input, the SHA produces a 160-
bit output called a message digest. The message digest is then input to the
DSA, which computes the signature for the message. Signing the message
digest rather than the message often improves the efficiency of the process,
because the message digest is usually much smaller than the message.
The same message digest should be obtained by the verifier of the
signature when the received version of the message is used as input to
SHA. The SHA is called secure because it is designed to be computationally
infeasible to recover a message corresponding to the message digest. Any
change to the message in transit will, with a very high probability, result in a
different message digest, and the signature will fail to verify. The SHA is
based on principles similar to those used by Professor Ronald L. Rivest of
MIT when designing the MD4 message digest algorithm, and is closely
modelled after that algorithm.”
(Proposed Federal Information Processing Standard for Secure Hash
Standard,” Federal Register, v. 57, n. 177, 11 Sep 1992, p. 41727)
…how?
SHA-1: Prepare the message
1. Prepare the message.
Given m, create mmm…m1000…000xxxxx….x:
Append a 1 and then enough zeros to make the total congruent
to 448 (mod 512) bits (to leave room for the length)
Append the length of m (≤ 264, so can be written in 64 bits)
Break into L 512-bit chunks. Each will be used to compress
into a 160- bit total message digest.
Example: Encode m with length 5000 bits.
What is L?
1
SHA-1: Notation
Bitwise AND
Bitwise OR
Bitwise XOR
Bitwise NOT
Left-shift, with wrap-around
Addition, mod 232






2
SHA-1: Iterative compression
Idea: iterate over all of the L blocks, outputting a value
that is a function of the previous output and the current
block:
Now, the function h’…
m1 m2
X0 X1 X2
h’ h’
m3
X3
h’
mL
XL
h’
=h(m)
3
(X0 is constant)
SHA-1: Compression function: h’
Input: X0 (160 bits), m1 (512 bits): Output: X1 (160 bits)
  1
16
14
8
3 



 


 t
t
t
t
t W
W
W
W
W
Expand m1 from
5122560 bits.
m1=(W0..W15) (32 bits each)
Initialization
4 rounds of 20
iterations
each:
Each round uses
a different K
and different
nonlinear
mixing
function f
W79
…
W16 …
W19
m1
W0 W1 W15
…


















































a
b
c
d
e
a
b
c
d
e
H
H
H
H
H
X
0
1
2
3
4
0
K0..19=0x5A827999
Round 1
K20..39=6ED9EBA1
K40..59=8F1BBCDC
K60..79=CA62C1D6
Round 2 Round 3 Round 4
… (20 iters) 1
0 X
X
a
b
c
d
e


















4-5
SHA-1: Iterative compression
Repeat the algorithm on the previous slide L times until
you’ve compressed the whole message into a single
160-bit vector.
Each can be implemented in hardware.
m1 m2
X0 X1 X2
h’ h’
m3
X3
h’
mL
XL
h’
=h(m)
6
Interesting trivia
The NSA added the left shift in w after the
fact. The change “corrects a technical flaw
that made the standard less secure than
have been thought”.
(Proposed Revision of Federal Information Processing Standard (FIPS) 180,
for Secure Hash Standard,” Federal Register, v. 59, n. 131, 11 Jul 1994, p.
35317-35318)
7-9
Summary
What’s an attack on SHA-1 look like?
In other words, how do we find collisions?
Stay tuned…
 Next time we’ll learn what birthdays have to do with collisions
How long before SHA-1 will be broken?

More Related Content

Similar to Hash Functions and SHA-1 (20)

Hash crypto
Hash cryptoHash crypto
Hash crypto
 
Hash crypto
Hash cryptoHash crypto
Hash crypto
 
Hash crypto
Hash cryptoHash crypto
Hash crypto
 
Hash crypto
Hash cryptoHash crypto
Hash crypto
 
Hash crypto
Hash cryptoHash crypto
Hash crypto
 
Hash crypto
Hash cryptoHash crypto
Hash crypto
 
Hash crypto
Hash cryptoHash crypto
Hash crypto
 
CS6701 CRYPTOGRAPHY AND NETWORK SECURITY
CS6701 CRYPTOGRAPHY AND NETWORK SECURITYCS6701 CRYPTOGRAPHY AND NETWORK SECURITY
CS6701 CRYPTOGRAPHY AND NETWORK SECURITY
 
18CS2005 Cryptography and Network Security
18CS2005 Cryptography and Network Security 18CS2005 Cryptography and Network Security
18CS2005 Cryptography and Network Security
 
Hashfunction
HashfunctionHashfunction
Hashfunction
 
Hashfunction
HashfunctionHashfunction
Hashfunction
 
Hash function
Hash functionHash function
Hash function
 
Hashfunction
HashfunctionHashfunction
Hashfunction
 
Hashfunction
HashfunctionHashfunction
Hashfunction
 
Hashfunction
HashfunctionHashfunction
Hashfunction
 
Hashfunction
HashfunctionHashfunction
Hashfunction
 
Unit 3
Unit 3Unit 3
Unit 3
 
Stallings Kurose and Ross
Stallings Kurose and RossStallings Kurose and Ross
Stallings Kurose and Ross
 
lecture13.pdf
lecture13.pdflecture13.pdf
lecture13.pdf
 
Sha
ShaSha
Sha
 

Recently uploaded

How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinojohnmickonozaleda
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 

Recently uploaded (20)

How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipino
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 

Hash Functions and SHA-1

  • 1. Announcements: Questions? This week:  Discrete Logs, Diffie-Hellman, ElGamal  Hash Functions and SHA-1  Birthday attacks DTTF/NB479: Dszquphsbqiz Day 27
  • 2. Hash Functions Goal: to provide a unique “fingerprint” of the message. How? Must demonstrate 3 properties: 1. Fast to compute y from m. 2. One-way: given y = h(m), can’t find any m’ satisfying h(m’) = y easily. 3. Strongly collision-free: Can’t find any m1 != m2 such that h(m1)=h(m2) easily 4. (Sometimes we can settle for weakly collision-free: given m, can’t find m’ != m with h(m) = h(m’). Message m (long) Message digest, y (Shorter fixed length) Cryptographic hash Function, h Shrinks data, so 2 messages can have the same digest: m1 != m2, but H(m1) = h(m2)
  • 3. EHA: Easy Hash Algorithm Break m into n-bit blocks, append zeros to get a multiple of n. There are L of them, where L =|m|/n Fast! But not very secure. Doing a left shift on the rows helps a little:  Define as left- shifting m by y bits  Then                           ln 2 1 2 22 21 1 12 11 2 1 ... m m m m m m m m m m m m m l l n n l          n c c c ... 2 1         y m y m m i i    =h(m)               1 , 1 , 21 23 22 1 12 11 ... ... l l l l ll n m m m m m m m m m     
  • 4. EHA: Easy Hash Algorithm   n c c c ... 2 1         =h(m) Exercise: 1. Show that the basic (unrotated) version doesn’t satisfy properties 2 and 3. 2. Show that the rotated version doesn’t satisfy properties 2 and 3 either. Conclusion: Need nonlinearity! 3 properties: 1. Fast to compute 2. One-way: given y = h(m), can’t find any m’ satisfying h(m’) = y easily. 3. Strongly collision- free: Can’t find m1 != m2 such that h(m1)=h(m2)                           ln 2 1 2 22 21 1 12 11 2 1 ... m m m m m m m m m m m m m l l n n l       
  • 5. SHA-1: Secure Hash Algorithm NSA  NIST “This standard specifies a Secure Hash Algorithm (SHA), which is necessary to ensure the security of the Digital Signature Algorithm (DSA). When a message of any length < 264 bits is input, the SHA produces a 160- bit output called a message digest. The message digest is then input to the DSA, which computes the signature for the message. Signing the message digest rather than the message often improves the efficiency of the process, because the message digest is usually much smaller than the message. The same message digest should be obtained by the verifier of the signature when the received version of the message is used as input to SHA. The SHA is called secure because it is designed to be computationally infeasible to recover a message corresponding to the message digest. Any change to the message in transit will, with a very high probability, result in a different message digest, and the signature will fail to verify. The SHA is based on principles similar to those used by Professor Ronald L. Rivest of MIT when designing the MD4 message digest algorithm, and is closely modelled after that algorithm.” (Proposed Federal Information Processing Standard for Secure Hash Standard,” Federal Register, v. 57, n. 177, 11 Sep 1992, p. 41727) …how?
  • 6. SHA-1: Prepare the message 1. Prepare the message. Given m, create mmm…m1000…000xxxxx….x: Append a 1 and then enough zeros to make the total congruent to 448 (mod 512) bits (to leave room for the length) Append the length of m (≤ 264, so can be written in 64 bits) Break into L 512-bit chunks. Each will be used to compress into a 160- bit total message digest. Example: Encode m with length 5000 bits. What is L? 1
  • 7. SHA-1: Notation Bitwise AND Bitwise OR Bitwise XOR Bitwise NOT Left-shift, with wrap-around Addition, mod 232       2
  • 8. SHA-1: Iterative compression Idea: iterate over all of the L blocks, outputting a value that is a function of the previous output and the current block: Now, the function h’… m1 m2 X0 X1 X2 h’ h’ m3 X3 h’ mL XL h’ =h(m) 3 (X0 is constant)
  • 9. SHA-1: Compression function: h’ Input: X0 (160 bits), m1 (512 bits): Output: X1 (160 bits)   1 16 14 8 3          t t t t t W W W W W Expand m1 from 5122560 bits. m1=(W0..W15) (32 bits each) Initialization 4 rounds of 20 iterations each: Each round uses a different K and different nonlinear mixing function f W79 … W16 … W19 m1 W0 W1 W15 …                                                   a b c d e a b c d e H H H H H X 0 1 2 3 4 0 K0..19=0x5A827999 Round 1 K20..39=6ED9EBA1 K40..59=8F1BBCDC K60..79=CA62C1D6 Round 2 Round 3 Round 4 … (20 iters) 1 0 X X a b c d e                   4-5
  • 10. SHA-1: Iterative compression Repeat the algorithm on the previous slide L times until you’ve compressed the whole message into a single 160-bit vector. Each can be implemented in hardware. m1 m2 X0 X1 X2 h’ h’ m3 X3 h’ mL XL h’ =h(m) 6
  • 11. Interesting trivia The NSA added the left shift in w after the fact. The change “corrects a technical flaw that made the standard less secure than have been thought”. (Proposed Revision of Federal Information Processing Standard (FIPS) 180, for Secure Hash Standard,” Federal Register, v. 59, n. 131, 11 Jul 1994, p. 35317-35318) 7-9
  • 12. Summary What’s an attack on SHA-1 look like? In other words, how do we find collisions? Stay tuned…  Next time we’ll learn what birthdays have to do with collisions How long before SHA-1 will be broken?