SlideShare a Scribd company logo
Blockchain Technology
Week 6
Unit III – Role of Cryptography in Blockchain
Ferdin Joe John Joseph, PhD
Faculty of Information Technology
Thai-Nichi Institute of Technology, Bangkok
Venue: D603
Week 6 – Unit III
Agenda
• Role of Cryptography in Blockchain
• RSA and SHA
2
Faculty of Information Technology, Thai-Nichi Institute of
Technology
Blockchain’s Encryption
Faculty of Information Technology, Thai-Nichi Institute of
Technology
3
Faculty of Information Technology, Thai-Nichi Institute of
Technology
4
Faculty of Information Technology, Thai-Nichi Institute of
Technology
5
Faculty of Information Technology, Thai-Nichi Institute of
Technology
6
Bitcoin Hash
• The corresponding SHA-256 of the sentence “How to buy
Bitcoin?” looks like this:
156aedcfab1d49f73abddd89faf78d9930e4b523ab804026310c973bf
a707d37
• If we remove only one symbol – for example the question mark “?” –
the hash of “How to buy Bitcoin” looks like
this: 4314d903f04e90e4a5057685243c903fbcfa4f8ec75ec797e1780e
d5c891b1bf
Faculty of Information Technology, Thai-Nichi Institute of
Technology
7
What is hashing
• Hashing means taking an input string of any length and giving out an
output of a fixed length.
Faculty of Information Technology, Thai-Nichi Institute of
Technology
8
Properties of Hashing
• Deterministic
• Quick Computation
• Pre-image resistance
Faculty of Information Technology, Thai-Nichi Institute of
Technology
9
Properties of hashing - Deterministic
• No matter how many times you parse a particular input through a
hash function you will always get the same result.
• This is critical because if you get different hashes every single time it
will be impossible to keep track of the input.
Faculty of Information Technology, Thai-Nichi Institute of
Technology
10
Properties of hashing – Quick Computation
• The hash function should be capable of returning the hash of an input
quickly.
• If the process isn’t fast enough then the system simply won’t be
efficient.
Faculty of Information Technology, Thai-Nichi Institute of
Technology
11
Properties of hashing – Pre-image resistance
• It is infeasible to determine A, where A is the input and H(A) is the
output hash.
Faculty of Information Technology, Thai-Nichi Institute of
Technology
12
Faculty of Information Technology, Thai-Nichi Institute of
Technology
13
The RSA Algorithm
• Based on the idea that factorization of integers into their prime
factors is hard.
★ n=p.q, where p and q are distinct primes
• Proposed by Rivest, Shamir, and Adleman
in 1977 and a paper was published in The Communications of ACM in
1978
• A public-key cryptosystem
RSA Algorithm
• Bob chooses two primes p,q and compute n=pq
• Bob chooses e with gcd(e,(p-1)(q-1))=
gcd(e, ψ(n))=1
• Bob solves de≡1 (mod ψ(n))
• Bob makes (e,n) public and (p,q,d) secret
• Alice encrypts M as C≡Me (mod n)
• Bob decrypts by computing M≡Cd (mod n)
Proof for the RSA Algorithm
• Cd ≡ (Me)d ≡ Med ≡ M1+kφ(n) ≡M (mod n) by Euler’s theorem and
Exercise 19 on p.192
• p=885320963, q=238855417,
• n=p.q=211463707796206571
• Let e=9007, ∴ d=116402471153538991
• M=“cat”=30120, C=113535859035722866
Another Example
• n=127x193=24511, φ(n)=24192
• e=1307, d=10643
• Encrypt “box” with M=21524, then
C=?
Encrypt the following message
Formosa means a beautiful island
Selected Problems from P.192-200
(1) n=11413=101x113, so p=101, q=113
ψ(n)=(p-1)x(q-1)=100x112=11200
Choose e=7467, then gcd(e, ψ(n))=1
Solve de≡1 (mod ψ(n)) to get d=3
If the ciphertext C=5859, then the plaintext
M≡Cd ≡58593 ≡1415 (mod 11413)
Fast Computation of xd (mod n)
• 1235 mod 511
• 1235 ≡ 28153056843 mod 511
• 1232 ≡ 310 (mod 511)
• 1234 ≡ 32 (mod 511)
• 1235 ≡ 123101b ≡1234 ×123
≡ 359 (mod 511)
Fast Computation for xd (mod n)
y=1;
while (d != 0) {
if ((d%2) != 0) { y=(y*x)%n; d--; }
d>>1;
x=(x*x)%n; /* x^(2k) */
}
Fast Computation for xd (mod n)
Let t be the number of bits for integer d, e.g.,
If d=5=1012 , then t=3
y=1;
for (i=t; i≧0; i--) {
y=(y*y)%n;
if (d[i]==1) y=(y*x)%n;
}
The Concept and Criteria
1. Ek(Dk(m))=m and Dk(Ek(m))=m for every message m in M, the set of
possible messages, every key k in K, the set of possible keys
2. For every m and every k, then values of Ek(m) and Dk(m) are easy to
compute
3. For every k, if someone knows only the function Ek, it is
computationally infeasible to find an algorithm to compute Dk
4. Given k, it’s easy to find the functions Ek and Dk
Secure Hash Algorithm (SHA)
• SHA-0 1993
• SHA-1 1995
• SHA-2 2002
• SHA-224, SHA-256, SHA-384, SHA-512
SHA-1
A message
composed of
b bits
160-bit
message
digest
CS 450/650 Lecture 8: Secure Hash
Algorithm
23
Step 1 -- Padding
• Padding  the total length of a padded message is multiple of 512
• Every message is padded even if its length is already a multiple of 512
• Padding is done by appending to the input
• A single bit, 1
• Enough additional bits, all 0, to make the final 512 block exactly 448 bits long
• A 64-bit integer representing the length of the original message in bits
CS 450/650 Lecture 8: Secure Hash
Algorithm
24
Padding (cont.)
Message Message length1 0…0
64 bits
Multiple of 512
1 bit
CS 450/650 Lecture 8: Secure Hash
Algorithm
25
Example
• M = 01100010 11001010 1001 (20 bits)
• Padding is done by appending to the input
• A single bit, 1
• 427 0s
• A 64-bit integer representing 20
• Pad(M) = 01100010 11001010 10011000 … 00010100
Example
• Length of M = 500 bits
• Padding is done by appending to the input:
• A single bit, 1
• 459 0s
• A 64-bit integer representing 500
• Length of Pad(M) = 1024 bits
Step 2 -- Dividing Pad(M)
• Pad (M) = B1, B2, B3, …, Bn
• Each Bi denote a 512-bit block
• Each Bi is divided into 16 32-bit words
• W0, W1, …, W15
CS 450/650 Lecture 8: Secure Hash
Algorithm
28
Step 3 – Compute W16 – W79
• To Compute word Wj (16<=j<=79)
• Wj-3, Wj-8, Wj-14 , Wj-16 are XORed
• The result is circularly left shifted one bit
CS 450/650 Lecture 8: Secure Hash
Algorithm
29
Step 4 – Initialize A,B,C,D,E
• A = H0
• B = H1
• C = H2
• D = H3
• E = H4
CS 450/650 Lecture 8: Secure Hash
Algorithm
30
Initialize 32-bit words
• H0 = 67452301
• H1 = EFCDAB89
• H2 = 98BADCFE
• H3 = 10325476
• H4 = C3D2E1F0
• K0 – K19 = 5A827999
• K20 – K39 = 6ED9EBA1
• K40 – K49 = 8F1BBCDC
• K60 – K79 = CA62C1D6
CS 450/650 Lecture 8: Secure Hash
Algorithm
31
Step 5 – Loop
For j = 0 … 79
TEMP = CircLeShift_5 (A) + fj(B,C,D) + E + Wj + Kj
E = D; D = C;
C = CircLeShift_30(B);
B = A; A = TEMP
Done
+  addition (ignore overflow)
CS 450/650 Lecture 8: Secure Hash
Algorithm
32
Four functions
• For j = 0 … 19
• fj(B,C,D) = (B AND C) OR ( B AND D) OR (C AND D)
• For j = 20 … 39
• fj(B,C,D) = (B XOR C XOR D)
• For j = 40 … 59
• fj(B,C,D) = (B AND C) OR ((NOT B) AND D)
• For j = 60 … 79
• fj(B,C,D) = (B XOR C XOR D)
CS 450/650 Lecture 8: Secure Hash
Algorithm
33
Step 6 – Final
• H0 = H0 + A
• H1 = H1 + B
• H2 = H2 + C
• H3 = H3 + D
• H4 = H4 + E
CS 450/650 Lecture 8: Secure Hash
Algorithm
34
Done
• Once these steps have been performed on each 512-bit block (B1, B2,
…, Bn) of the padded message,
• the 160-bit message digest is given by
H0 H1 H2 H3 H4
CS 450/650 Lecture 8: Secure Hash
Algorithm
35
SHA
Output
size
(bits)
Internal
state size
(bits)
Block
size
(bits)
Max
message
size (bits)
Word
size
(bits)
Rounds Operations
Collisions
found
SHA-0 160 160 512 264 − 1 32 80
+, and, or,
xor, rot
Yes
SHA-1 160 160 512 264 − 1 32 80
+, and, or,
xor, rot
None
(252 attack)
SHA-2
256/224 256 512 264 − 1 32 64
+, and, or,
xor, shr, rot
None
512/384 512 1024 2128 − 1 64 80
+, and, or,
xor, shr, rot
None
CS 450/650 Lecture 8: Secure Hash
Algorithm
36
Next Week
• Fraud and Intrusion Detection
37
Faculty of Information Technology, Thai-Nichi Institute of
Technology

More Related Content

PDF
Blockchain Technology - Week 5 - Cryptography and Steganography
PDF
Week 1: Programming for Data Analysis
PDF
Programming for Data Analysis: Week 4
PDF
Programming for Data Analysis: Week 3
PDF
Blockchain Technology - Week 11 - Thai-Nichi Institute of Technology
PDF
Blockchain Technology - Week 4 - Hyperledger and Smart Contracts
PDF
Week 10: Programming for Data Analysis
PDF
Blockchain Technology - Week 2 - Blockchain Terminologies
Blockchain Technology - Week 5 - Cryptography and Steganography
Week 1: Programming for Data Analysis
Programming for Data Analysis: Week 4
Programming for Data Analysis: Week 3
Blockchain Technology - Week 11 - Thai-Nichi Institute of Technology
Blockchain Technology - Week 4 - Hyperledger and Smart Contracts
Week 10: Programming for Data Analysis
Blockchain Technology - Week 2 - Blockchain Terminologies

What's hot (20)

PDF
Week2: Programming for Data Analysis
PDF
Blockchain Technology - Week 10 - CAP Teorem, Byzantines General Problem
PDF
Week 8: Programming for Data Analysis
PDF
Week 11: Programming for Data Analysis
PDF
Blockchain Technology - Week 9 - Blockciphers
PDF
Blockchain Technology - Week 1 - Introduction to Blockchain
PDF
Week 9: Programming for Data Analysis
PDF
Data Wrangling Week 4
PDF
Data wrangling week 6
PDF
Blockchain Technology - Week 3 - FinTech and Cryptocurrencies
PDF
Data wrangling week2
PDF
Data wrangling week 10
PDF
Data wrangling week3
PDF
Week 2: Virtualization and VM Ware - DSA 441 Cloud Computing
PDF
Week 1: Introduction to Cloud Computing - DSA 441 Cloud Computing
PDF
Deep learning - Introduction
PDF
DataCamp investor pitch deck April 2017
PDF
Week 9: Relational Database Service Alibaba Cloud- DSA 441 Cloud Computing
PDF
Week 4: Big Data and Hadoop in Alibaba Cloud - DSA 441 Cloud Computing
PDF
Week 10: Cloud Security- DSA 441 Cloud Computing
Week2: Programming for Data Analysis
Blockchain Technology - Week 10 - CAP Teorem, Byzantines General Problem
Week 8: Programming for Data Analysis
Week 11: Programming for Data Analysis
Blockchain Technology - Week 9 - Blockciphers
Blockchain Technology - Week 1 - Introduction to Blockchain
Week 9: Programming for Data Analysis
Data Wrangling Week 4
Data wrangling week 6
Blockchain Technology - Week 3 - FinTech and Cryptocurrencies
Data wrangling week2
Data wrangling week 10
Data wrangling week3
Week 2: Virtualization and VM Ware - DSA 441 Cloud Computing
Week 1: Introduction to Cloud Computing - DSA 441 Cloud Computing
Deep learning - Introduction
DataCamp investor pitch deck April 2017
Week 9: Relational Database Service Alibaba Cloud- DSA 441 Cloud Computing
Week 4: Big Data and Hadoop in Alibaba Cloud - DSA 441 Cloud Computing
Week 10: Cloud Security- DSA 441 Cloud Computing
Ad

Similar to Blockchain Technology - Week 6 - Role of Cryptography in Blockchain (20)

PDF
cryptography summary hash function slides
PDF
Public Key Encryption & Hash functions
PPTX
Blockchain Technology Explained: A Beginner's Guide to the Future of the Inte...
PPTX
Public key cryptography and message authentication
 
PPTX
Data streaming algorithms
PPT
introduction to cryptography
PPTX
Information system security wk4-cryptography-2
PPTX
Hash algorithms in IT security
PPTX
Cryptography and PKI
PPT
needed.ppt
PPT
introduction to cryptography (basics of it)
PPT
crypto1.ppt
PPT
crypto.ppt
PPTX
Message Digest message digest ppttsx.pptx
PPT
Lecture6 rsa
PDF
Sha
PPT
Hash mac algorithms
PPT
Hash mac algorithms
PPT
Hash mac algorithms
PPT
Hash mac algorithms
cryptography summary hash function slides
Public Key Encryption & Hash functions
Blockchain Technology Explained: A Beginner's Guide to the Future of the Inte...
Public key cryptography and message authentication
 
Data streaming algorithms
introduction to cryptography
Information system security wk4-cryptography-2
Hash algorithms in IT security
Cryptography and PKI
needed.ppt
introduction to cryptography (basics of it)
crypto1.ppt
crypto.ppt
Message Digest message digest ppttsx.pptx
Lecture6 rsa
Sha
Hash mac algorithms
Hash mac algorithms
Hash mac algorithms
Hash mac algorithms
Ad

More from Ferdin Joe John Joseph PhD (15)

PDF
Invited Talk DGTiCon 2022
PDF
Week 12: Cloud AI- DSA 441 Cloud Computing
PDF
Week 11: Cloud Native- DSA 441 Cloud Computing
PDF
Week 7: Object Storage Service Alibaba Cloud- DSA 441 Cloud Computing
PDF
Week 6: Server Load Balancer and Auto Scaling Alibaba Cloud- DSA 441 Cloud Co...
PDF
Week 5: Elastic Compute Service (ECS) with Alibaba Cloud- DSA 441 Cloud Compu...
PDF
Week 3: Virtual Private Cloud, On Premise, IaaS, PaaS, SaaS - DSA 441 Cloud C...
PDF
Sept 6 2021 BTech Artificial Intelligence and Data Science curriculum
PDF
Hadoop in Alibaba Cloud
PDF
Cloud Computing Essentials in Alibaba Cloud
PDF
Transforming deep into transformers – a computer vision approach
PDF
Data wrangling week 11
PDF
Data wrangling week 9
PDF
Data Wrangling Week 7
PDF
Deep Learning and CNN Architectures
Invited Talk DGTiCon 2022
Week 12: Cloud AI- DSA 441 Cloud Computing
Week 11: Cloud Native- DSA 441 Cloud Computing
Week 7: Object Storage Service Alibaba Cloud- DSA 441 Cloud Computing
Week 6: Server Load Balancer and Auto Scaling Alibaba Cloud- DSA 441 Cloud Co...
Week 5: Elastic Compute Service (ECS) with Alibaba Cloud- DSA 441 Cloud Compu...
Week 3: Virtual Private Cloud, On Premise, IaaS, PaaS, SaaS - DSA 441 Cloud C...
Sept 6 2021 BTech Artificial Intelligence and Data Science curriculum
Hadoop in Alibaba Cloud
Cloud Computing Essentials in Alibaba Cloud
Transforming deep into transformers – a computer vision approach
Data wrangling week 11
Data wrangling week 9
Data Wrangling Week 7
Deep Learning and CNN Architectures

Recently uploaded (20)

PPTX
Data_Analytics_and_PowerBI_Presentation.pptx
PPTX
Qualitative Qantitative and Mixed Methods.pptx
PDF
Introduction to Data Science and Data Analysis
PDF
Data Engineering Interview Questions & Answers Cloud Data Stacks (AWS, Azure,...
PPT
DATA COLLECTION METHODS-ppt for nursing research
PPTX
01_intro xxxxxxxxxxfffffffffffaaaaaaaaaaafg
PDF
Galatica Smart Energy Infrastructure Startup Pitch Deck
PPTX
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
PPTX
mbdjdhjjodule 5-1 rhfhhfjtjjhafbrhfnfbbfnb
PDF
Transcultural that can help you someday.
PDF
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
PDF
Capcut Pro Crack For PC Latest Version {Fully Unlocked 2025}
PPTX
Microsoft-Fabric-Unifying-Analytics-for-the-Modern-Enterprise Solution.pptx
PPTX
Modelling in Business Intelligence , information system
PPTX
STERILIZATION AND DISINFECTION-1.ppthhhbx
PPTX
A Complete Guide to Streamlining Business Processes
PPTX
climate analysis of Dhaka ,Banglades.pptx
PDF
Oracle OFSAA_ The Complete Guide to Transforming Financial Risk Management an...
PPTX
Acceptance and paychological effects of mandatory extra coach I classes.pptx
PDF
REAL ILLUMINATI AGENT IN KAMPALA UGANDA CALL ON+256765750853/0705037305
Data_Analytics_and_PowerBI_Presentation.pptx
Qualitative Qantitative and Mixed Methods.pptx
Introduction to Data Science and Data Analysis
Data Engineering Interview Questions & Answers Cloud Data Stacks (AWS, Azure,...
DATA COLLECTION METHODS-ppt for nursing research
01_intro xxxxxxxxxxfffffffffffaaaaaaaaaaafg
Galatica Smart Energy Infrastructure Startup Pitch Deck
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
mbdjdhjjodule 5-1 rhfhhfjtjjhafbrhfnfbbfnb
Transcultural that can help you someday.
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
Capcut Pro Crack For PC Latest Version {Fully Unlocked 2025}
Microsoft-Fabric-Unifying-Analytics-for-the-Modern-Enterprise Solution.pptx
Modelling in Business Intelligence , information system
STERILIZATION AND DISINFECTION-1.ppthhhbx
A Complete Guide to Streamlining Business Processes
climate analysis of Dhaka ,Banglades.pptx
Oracle OFSAA_ The Complete Guide to Transforming Financial Risk Management an...
Acceptance and paychological effects of mandatory extra coach I classes.pptx
REAL ILLUMINATI AGENT IN KAMPALA UGANDA CALL ON+256765750853/0705037305

Blockchain Technology - Week 6 - Role of Cryptography in Blockchain

  • 1. Blockchain Technology Week 6 Unit III – Role of Cryptography in Blockchain Ferdin Joe John Joseph, PhD Faculty of Information Technology Thai-Nichi Institute of Technology, Bangkok Venue: D603
  • 2. Week 6 – Unit III Agenda • Role of Cryptography in Blockchain • RSA and SHA 2 Faculty of Information Technology, Thai-Nichi Institute of Technology
  • 3. Blockchain’s Encryption Faculty of Information Technology, Thai-Nichi Institute of Technology 3
  • 4. Faculty of Information Technology, Thai-Nichi Institute of Technology 4
  • 5. Faculty of Information Technology, Thai-Nichi Institute of Technology 5
  • 6. Faculty of Information Technology, Thai-Nichi Institute of Technology 6
  • 7. Bitcoin Hash • The corresponding SHA-256 of the sentence “How to buy Bitcoin?” looks like this: 156aedcfab1d49f73abddd89faf78d9930e4b523ab804026310c973bf a707d37 • If we remove only one symbol – for example the question mark “?” – the hash of “How to buy Bitcoin” looks like this: 4314d903f04e90e4a5057685243c903fbcfa4f8ec75ec797e1780e d5c891b1bf Faculty of Information Technology, Thai-Nichi Institute of Technology 7
  • 8. What is hashing • Hashing means taking an input string of any length and giving out an output of a fixed length. Faculty of Information Technology, Thai-Nichi Institute of Technology 8
  • 9. Properties of Hashing • Deterministic • Quick Computation • Pre-image resistance Faculty of Information Technology, Thai-Nichi Institute of Technology 9
  • 10. Properties of hashing - Deterministic • No matter how many times you parse a particular input through a hash function you will always get the same result. • This is critical because if you get different hashes every single time it will be impossible to keep track of the input. Faculty of Information Technology, Thai-Nichi Institute of Technology 10
  • 11. Properties of hashing – Quick Computation • The hash function should be capable of returning the hash of an input quickly. • If the process isn’t fast enough then the system simply won’t be efficient. Faculty of Information Technology, Thai-Nichi Institute of Technology 11
  • 12. Properties of hashing – Pre-image resistance • It is infeasible to determine A, where A is the input and H(A) is the output hash. Faculty of Information Technology, Thai-Nichi Institute of Technology 12
  • 13. Faculty of Information Technology, Thai-Nichi Institute of Technology 13
  • 14. The RSA Algorithm • Based on the idea that factorization of integers into their prime factors is hard. ★ n=p.q, where p and q are distinct primes • Proposed by Rivest, Shamir, and Adleman in 1977 and a paper was published in The Communications of ACM in 1978 • A public-key cryptosystem
  • 15. RSA Algorithm • Bob chooses two primes p,q and compute n=pq • Bob chooses e with gcd(e,(p-1)(q-1))= gcd(e, ψ(n))=1 • Bob solves de≡1 (mod ψ(n)) • Bob makes (e,n) public and (p,q,d) secret • Alice encrypts M as C≡Me (mod n) • Bob decrypts by computing M≡Cd (mod n)
  • 16. Proof for the RSA Algorithm • Cd ≡ (Me)d ≡ Med ≡ M1+kφ(n) ≡M (mod n) by Euler’s theorem and Exercise 19 on p.192 • p=885320963, q=238855417, • n=p.q=211463707796206571 • Let e=9007, ∴ d=116402471153538991 • M=“cat”=30120, C=113535859035722866
  • 17. Another Example • n=127x193=24511, φ(n)=24192 • e=1307, d=10643 • Encrypt “box” with M=21524, then C=? Encrypt the following message Formosa means a beautiful island
  • 18. Selected Problems from P.192-200 (1) n=11413=101x113, so p=101, q=113 ψ(n)=(p-1)x(q-1)=100x112=11200 Choose e=7467, then gcd(e, ψ(n))=1 Solve de≡1 (mod ψ(n)) to get d=3 If the ciphertext C=5859, then the plaintext M≡Cd ≡58593 ≡1415 (mod 11413)
  • 19. Fast Computation of xd (mod n) • 1235 mod 511 • 1235 ≡ 28153056843 mod 511 • 1232 ≡ 310 (mod 511) • 1234 ≡ 32 (mod 511) • 1235 ≡ 123101b ≡1234 ×123 ≡ 359 (mod 511)
  • 20. Fast Computation for xd (mod n) y=1; while (d != 0) { if ((d%2) != 0) { y=(y*x)%n; d--; } d>>1; x=(x*x)%n; /* x^(2k) */ }
  • 21. Fast Computation for xd (mod n) Let t be the number of bits for integer d, e.g., If d=5=1012 , then t=3 y=1; for (i=t; i≧0; i--) { y=(y*y)%n; if (d[i]==1) y=(y*x)%n; }
  • 22. The Concept and Criteria 1. Ek(Dk(m))=m and Dk(Ek(m))=m for every message m in M, the set of possible messages, every key k in K, the set of possible keys 2. For every m and every k, then values of Ek(m) and Dk(m) are easy to compute 3. For every k, if someone knows only the function Ek, it is computationally infeasible to find an algorithm to compute Dk 4. Given k, it’s easy to find the functions Ek and Dk
  • 23. Secure Hash Algorithm (SHA) • SHA-0 1993 • SHA-1 1995 • SHA-2 2002 • SHA-224, SHA-256, SHA-384, SHA-512 SHA-1 A message composed of b bits 160-bit message digest CS 450/650 Lecture 8: Secure Hash Algorithm 23
  • 24. Step 1 -- Padding • Padding  the total length of a padded message is multiple of 512 • Every message is padded even if its length is already a multiple of 512 • Padding is done by appending to the input • A single bit, 1 • Enough additional bits, all 0, to make the final 512 block exactly 448 bits long • A 64-bit integer representing the length of the original message in bits CS 450/650 Lecture 8: Secure Hash Algorithm 24
  • 25. Padding (cont.) Message Message length1 0…0 64 bits Multiple of 512 1 bit CS 450/650 Lecture 8: Secure Hash Algorithm 25
  • 26. Example • M = 01100010 11001010 1001 (20 bits) • Padding is done by appending to the input • A single bit, 1 • 427 0s • A 64-bit integer representing 20 • Pad(M) = 01100010 11001010 10011000 … 00010100
  • 27. Example • Length of M = 500 bits • Padding is done by appending to the input: • A single bit, 1 • 459 0s • A 64-bit integer representing 500 • Length of Pad(M) = 1024 bits
  • 28. Step 2 -- Dividing Pad(M) • Pad (M) = B1, B2, B3, …, Bn • Each Bi denote a 512-bit block • Each Bi is divided into 16 32-bit words • W0, W1, …, W15 CS 450/650 Lecture 8: Secure Hash Algorithm 28
  • 29. Step 3 – Compute W16 – W79 • To Compute word Wj (16<=j<=79) • Wj-3, Wj-8, Wj-14 , Wj-16 are XORed • The result is circularly left shifted one bit CS 450/650 Lecture 8: Secure Hash Algorithm 29
  • 30. Step 4 – Initialize A,B,C,D,E • A = H0 • B = H1 • C = H2 • D = H3 • E = H4 CS 450/650 Lecture 8: Secure Hash Algorithm 30
  • 31. Initialize 32-bit words • H0 = 67452301 • H1 = EFCDAB89 • H2 = 98BADCFE • H3 = 10325476 • H4 = C3D2E1F0 • K0 – K19 = 5A827999 • K20 – K39 = 6ED9EBA1 • K40 – K49 = 8F1BBCDC • K60 – K79 = CA62C1D6 CS 450/650 Lecture 8: Secure Hash Algorithm 31
  • 32. Step 5 – Loop For j = 0 … 79 TEMP = CircLeShift_5 (A) + fj(B,C,D) + E + Wj + Kj E = D; D = C; C = CircLeShift_30(B); B = A; A = TEMP Done +  addition (ignore overflow) CS 450/650 Lecture 8: Secure Hash Algorithm 32
  • 33. Four functions • For j = 0 … 19 • fj(B,C,D) = (B AND C) OR ( B AND D) OR (C AND D) • For j = 20 … 39 • fj(B,C,D) = (B XOR C XOR D) • For j = 40 … 59 • fj(B,C,D) = (B AND C) OR ((NOT B) AND D) • For j = 60 … 79 • fj(B,C,D) = (B XOR C XOR D) CS 450/650 Lecture 8: Secure Hash Algorithm 33
  • 34. Step 6 – Final • H0 = H0 + A • H1 = H1 + B • H2 = H2 + C • H3 = H3 + D • H4 = H4 + E CS 450/650 Lecture 8: Secure Hash Algorithm 34
  • 35. Done • Once these steps have been performed on each 512-bit block (B1, B2, …, Bn) of the padded message, • the 160-bit message digest is given by H0 H1 H2 H3 H4 CS 450/650 Lecture 8: Secure Hash Algorithm 35
  • 36. SHA Output size (bits) Internal state size (bits) Block size (bits) Max message size (bits) Word size (bits) Rounds Operations Collisions found SHA-0 160 160 512 264 − 1 32 80 +, and, or, xor, rot Yes SHA-1 160 160 512 264 − 1 32 80 +, and, or, xor, rot None (252 attack) SHA-2 256/224 256 512 264 − 1 32 64 +, and, or, xor, shr, rot None 512/384 512 1024 2128 − 1 64 80 +, and, or, xor, shr, rot None CS 450/650 Lecture 8: Secure Hash Algorithm 36
  • 37. Next Week • Fraud and Intrusion Detection 37 Faculty of Information Technology, Thai-Nichi Institute of Technology