Hash Functions: EJ Jung
Hash Functions: EJ Jung
EJ Jung
slide 1
Integrity checks
More on Integrity
VIRUS
badFile
goodFile
BigFirm
The Times
hash(goodFile)
User
! Password storage
safe against server problems
Hash Functions
! Purpose of the HASH function is to produce
a fingerprint.
! But, what do you mean by fingerprint??
Henric Johnson
Henric Johnson
Example
hash function H
message
. x .
message
digest
.y
. y
One-Way
! Intuition: hash should be hard to invert
Preimage resistance
Let h(x)=y"{0,1}n for a random x
Given y, it should be hard to find any x such that
h(x)=y
! How hard?
Brute-force: try every possible x, see if h(x)=y
SHA-1 (common hash function) has 160-bit output
Suppose have hardware thatll do 230 trials a pop
Assuming 234 trials per second, can do 289 trials per year
Will take 271 years to invert SHA-1 on a random image
slide 11
Birthday Paradox
! T people
! Suppose each birthday is a random number taken
from K days (K=365) how many possibilities?
KT (samples with replacement)
! Probability of no repetition?
(K)T/KT # 1 - T(T-1)/2K
! Probability of repetition?
O(T2)
Collision Resistance
! Should be hard to find x, x such that h(x)=h(x)
! Brute-force collision search is O(2n/2), not O(2n)
n = number of bits in the output of hash function
For SHA-1, this means O(280) vs. O(2160)
slide 15
! Auction bidding
Alice wants to bid B, sends H(B), later reveals B
One-wayness: rival bidders should not recover B
Collision resistance: Alice should not be able to change
her mind to bid B such that H(B)=H(B)
slide 16
! RIPEMD-160
160-bit variant of MD-5
Compression function
Applied to each 512-bit block
and current 160-bit buffer
This is the heart of SHA-1
slide 18
Block Ciphers
Block of plaintext
S
Key
For hashing, there is no KEY.
Use message as key and replace
plaintext with a fixed string.
(for example, Unix password hash is DES
applied to NULL with password as the key)
Block of ciphertext
slide 19
5 bitwise
left-rotate
(B$C)%(B$D)
B!C!D
(B$C)%(B$D)%(C$D)
B!C!D
ft
0..19
20..39
40..59
60..79
+
Current message block mixed in
30 bitwise
left-rotate
Wt
Kt
E
slide 21
slide 22
SHA-512 zoom in
Authentication
! Authenticity is identification and assurance of
origin of information
Well see many specific examples in different scenarios
network
slide 25
SECRET
msg, H(SECRET,msg)
Alice
Bob
Authentication Without
Encryption
KEY
MAC
KEY
message, MAC(KEY,message)
Alice
message
?
=
Bob
HMAC
! Construct MAC by applying a cryptographic hash
function to message and key
Structure of HMAC
magic value (flips half of key bits)
Secret key padded
to block size
hash(key,hash(key,message))
slide 29