Вы находитесь на странице: 1из 22

Shelley Kandola, CS380 Final Project, Spring 2012

SHA1 ENCRYPTION ALGORITHM

Background

Vocabulary
Map a data structure that associates keys

with values Hash Function a map that sends a key to the value generated by the key Collision when two keys map to the same value

One-Way Hash Functions


1. The hash is computable for any given input 2. A message cannot be generated given a certain hash 3. A message cannot be

Yellow paint

changed without changing the hash 4. It is difficult to find two messages with the same hash

Colors cant be unmixed


Blue paint

History
SHA-1
Secure Hash Algorithm 1 One-way Hash Function

1993

SHA-0 Introduced Certain collisions found

NSA, 1995 Replaced SHA-0 for

definite chance of collisions Replaced by SHA-2 for high collision probability Retired from government use

1995
2001

SHA-1 Introduced Theoretical Collisions found

SHA-2 Introduced No known collisions

Why SHA1?
CS332: Web Programming
Myslu/~sbkand09/SLURoomReview

REU: Trustable Computing Systems and

Efficient Implementations of Cryptographic Algorithms Conference: IEEE Hardware Oriented Security & Trust Symposium, San Francisco

What is it?
160-bit SHA1 encrypted string

<264 bit string

My secret message.

9216 429B 2812 8C6D 2C04 D700 6BA4 1B5B D946 44F8 94D0 68BF BCA6 CAE3 E394 3820 4458 58F8 EA60 6FC7

My secret message!

SHA-1 as an Algorithm
Successes
Maps variable-length input

Failures
Far more possible inputs

to fixed-length output No function to unencrypt output Avalanche Effect


80 iterations

than outputs
Collisions can lead to data

corruption
Legal disputes over meaning of encrypted documents

SHA1 password databases


Dont use dictionary words!

Documents are

compressed
No need for key

File preparation not

complicated enough

Why are collisions so frequent?


Input
Length: Possibilities: Which is Whose length is 264 bits 2(2^64) = ??? 5,553,023,288,523,357,133 digits long 19 digits

Output
160 bits (~27) 2160 = 1 quindecillion 49 digits long 2 digits

there are approximately 144 quadrillion times more inputs than outputs. The birthday problem says theres a ~50% chance of a collision occurring in a collection of 280 messages.

Uses
File Checksum
Programs Seeds

Integrity Verifier (Windows) Pseudorandom string generation Password encryption

Passwords

SHA1 Checksum/

Random hex string/


Encrypted password

The Algorithm
Example: Hello world!

Overview

Functions and Constants


Functions

f(t; B, C, D)=
f(t; B, C, D)= f(t; B, C, D)= f(t; B, C, D)=

(B and C) or ((not B) and D)


B xor C xor D (B and C) or (B and D) or (C and D) B xor C xor D

00 <= t <= 19
20 <= t <= 39 40 <= t <= 59 60 <= t <= 79

Constants K(t)= K(t)= K(t)= K(t)= 5A827999 6ED9EBA1 8F1BBCDC CA62C1D6 00 <= t <= 19 20 <= t <= 39 40 <= t <= 59 60 <= t <= 79

Initial H-Buffer Values


H0 = 67452301 H1 = EFCDAB89 H2 = 98BADCFE H3 = 10325476 H4 = C3D2E1F0

Padding Hello World


Hex
4865 6c6c 6f20 776f 726c 6421 24*16 = 384 bits

Pad with 1 and 0s


4865 6c6c 6f20 776f 726c 6421 1000 0000

Adding the original length


4865 6c6c 6f20 776f 726c 6421 1000 0018

512 bits ready for processing!


4865 6c6c 6f20 776f 726c 6421 1000 0018

Splitting Hello World!


4865 6c6c 6f20 776f 726c 6421 1000 0018

W[0] = 48, W[1] = 65, , W[14] = 00, W[15] =

18 For t=16: W[16] =


(W[t-3] xor W[t-8] xor W[t-14] xor W[t-16])<<<1 = (W[13] xor W[8] xor W[2] xor W[0]) <<<1 = (10 xor 72 xor 6c xor 48) <<<1

Setting up the temp Buffer


Since this is the first iteration, for both the

general and Hello world! case, we will have: A = 67452301 B = EFCDAB89 C = 98BADCFE D = 10325476 E = C3D2E1F0

Applying the Algorithm


For t=0: temp =
A<<<5 + f(t;B,C,D) + E + W(t) + K(t) = A <<<5 + ((B and C) or ((not B) and D)) + E + W[0] +

5A827999

A=temp, B=A, C=B<<<30, D=C, E=D

Temp

B<<<30

Setting the Final Values


General
H0 = H0 + A
H1 = H1 + B H2 = H2 + C

Hello world!
H0 = D3486ae9
H1 = 136e7856 H2 = Bc422123

H3 = H3 + D
H4 = H4 + E

H3 = 85ea7970
H4 = 94475802

Sha1(Hello world!) = D3486AE9136E7856BC42212385EA797094475802

Password Hacking
SHA1-Encrypted Passwords

d0be 2dc4 21be 4fcd 0172

Password
apple
d0be 2dc4 21be 4fcd 0172

e5af ceea 3970 e2f3 d940 5baa 61e4 c9b9 3f3f 0682 250b 6cf8 331b 7ee6 8fd8

e5af ceea 3970 e2f3 d940

password
5baa 61e4 c9b9 3f3f 0682

250b 6cf8 331b 7ee6 8fd8

Algorithm at a Glance
Divide string M(i) into 16 words: W(0) W(15)

For t=16 to t=79


W(t) =

(W(t-3) xor W(t-8) xor W(t-14) xor W(t-16))<<<1

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


For t=0 to t=79
temp = A<<<5 + f(t;B,C,D) + E + W(t) + K(t) Set E=D, D=C, C=B<<<30, B=A, A=temp

Thank you!
Questions?

Вам также может понравиться