Vous êtes sur la page 1sur 21

SECURE HASH

ALGORITHM

SHA 1
Zhella Anne V. Nisperos

Secure Hash Algorithm


a family of cryptographic hash functions published by
the National Institute of Standards and
Technology (NIST) as a U.S. Federal Information
Processing Standard (FIPS) for use with the Digital
Signature Algorithm (DSA)

Applications of Secure Hashing:


Online Banking
Online Shopping
E-Learning
Web servers
In short, wherever sensitive data's are handled and
wherever you need to log yourself in to access data
secure hashing is used there.

SHA: Variations
SHA
SHA-0
SHA-1
SHA-2
SHA-3

Secure Hash Algorithm 1 (SHA-1)


takes an input message of any length < 2^64 bits and
produces a 160-bit output as the message digest.

SHA-1
1. Message Padding
2. Initialize Buffers
3. Prepare Functions
4. Prepare Constants
5. Compute Message Digest

Step 1: Message Padding


The original message is always padded with one bit "1"
first.
Then zero or more bits "0" are padded to bring the
length of the message up to 64 bits fewer than a
multiple of 512.
A 64-bit integer is appended to the end of the zero
appended
message
to produce
a final padded
message
Padded 0s
64 bit (length)
Original Message
1
512 bits

Step 2: Initialize Buffers


The 160-bit buffer consists of five 32-bit registers
(A,B,C,D,E)
H0

67 45 23 01

H1

ef cd ab 89

H2

98 ba dc fe

H3

10 32 54 76

H4

c3 d2 e1 f0

Step 3: Prepare Processing Functions


SHA1 requires 80 processing functions defined as:
ft(B,C,D) = (B AND C) OR ((NOT B) AND D)
19)
ft(B,C,D) = B XOR C XOR D

( 0 <= t <=
(20 <= t <= 39)

ft(B,C,D) = (B AND C) OR (B AND D) OR (C AND D) (40 <= t <=


59)
ft(B,C,D) = B XOR C XOR D

(60 <= t <= 79)

Truth table of four nonlinear


functions for SHA-1

Step 4: Prepare Processing Constants


Kt = 5a827999
Kt = 6ed9eba1
Kt = 8f1bbcdc
Kt = ca62c1d6

0 t 19
20 t 39
40 t 59
60 t 79

Step 5: Compute the Message Digest


the message block is transformed from 16 32-bit words (M0 to M15) to 80
32-bit words (W0 to W79).
Input:
M[1, 2, ..., N]:

Blocks of the padded and appended message

f0(B,C,D), f0 (B,C,D), ..., f79 (B,C,D):


K0, K1, ..., K79:

Constants

H 0, H 1, H 2, H 3 , H 4, H 5:

Algorithm:

Functions

Word buffers with initial values

next slide

Output:
H0 , H 1 , H 2 , H 3 , H 4 , H 5 :

Word buffers with final message digest

Algorithm
For loop on k = 1 to N
W0,W1,...,W15 = M[k]

/* Divide M[k] into 16 words */

For t = 16 to 79 do:
Wt = S1(Wt-16 XOR Wt-14 XOR Wt-8 XOR Wt-3)

/*S=Circular left shift*/

A = H0, B = H1, C = H2, D = H3, E = H4


For t = 0 to 79 do:
TEMP = S5 (A) + ft(B,C,D) + E + Wt + Kt
E = D, D = C, C = S30 (B) , B = A, A = TEMP
End of for loop
H0 = H0 + A, H1 = H1 + B, H2 = H2 + C, H3 = H3 + D, H4 = H4 + E
End of for loop

Example
Original Message:

1a7fd53b4c

Padded Message:
1a7fd53b 4c800000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000028

Initial Values:
H0 = 67452301
H1 = efcdab89
H2 = 98badcfe
H3 = 10325476
H4 = c392e1f0

Constants:
Kt = 5a827999
Kt = 6ed9eba1
Kt = 8f1bbcdc
Kt = ca62c1d6

0 t 19
20 t 39
40 t 59
60 t 79

H0=
H1=
H2=
H3=
H4=

A+ Orig H0
B+ Orig H1
C+ Orig H2
D+ Orig H3
E+ Orig H4

H0 =
H1 =
H2 =
H3 =
H4 =

48878397 The 160-bit message digest is then the data


9801d679 concatenation of {H }:
394bd834 H ||H ||H ||H ||H =
28c28e41
2b8dee05
i

488783979801d6793
94bd83428c28e412b8

Thank you!