MD5 - PowerPoint PPT Presentation

About This Presentation
Title:

MD5

Description:

00000010 2f ca b5 87 12 46 7e ab 40 04 58 3e b8 fb 7f 89 ... Hash Trees - Shurety digital notary. S/KEY. SecureID. Password Challenge-Response ... – PowerPoint PPT presentation

Number of Views:849
Avg rating:3.0/5.0
Slides: 45
Provided by: sim1
Category:
Tags: md5

less

Transcript and Presenter's Notes

Title: MD5


1
CSCI E-170L06 Crypto 1October 25, 2004
  • MD5
  • SHA-1
  • HMAC

2
Administrivia
  • HW3 returned.
  • AOL Survey

3
(No Transcript)
4
(No Transcript)
5
Computing Hash Functions
ls -l total 58 -rw-r--r-- 1 simsong wheel
47990 Jul 13 1990 Constitution -rw-r--r-- 1
simsong wheel 9949 Jul 13 1990 Declaration
md5 Constitution MD5 (Constitution)
bab1c005bad1ac7d58d54d0e5d0e5f3f sha1
Constitution SHA1 (Constitution)
ff3881c932e7591e674e2d9d772817746e8d983f
openssl sha1 lt Constitution ff3881c932e7591e674e2
d9d772817746e8d983f openssl sha1
Constitution SHA1(Constitution)
ff3881c932e7591e674e2d9d772817746e8d983f
6
Properties of a good Message Digest
  • Digest f (Input)
  • Digest cannot be predicted from the input
  • Hard or impossible to find two inputs with the
    same digest.
  • Changing one bit of input changes 50 of the
    output bits.

7
Message Digest Example
8
Key Points
  • Any change in the input changes the digest
  • Adding a space
  • Changing a line break
  • Capitalizing a word

9
Message Digest Algorithms
  • Rivest Functions
  • MD2 (RFC 1319), MD4 (RFC 1320), MD5NIST
    Functions
  • SHA, SHA-1, SHA-512, SHA-1024
  • Other Functions
  • Snerfu, N-Hash, RIPE-MD, HAVAL

10
Comparing Message Digest Functions
11
Breaking a message digest
  • Brute-force attack
  • Search for two messages that have the same digest
    (they should be many of them)
  • Create a message with a desired message digest

12
Breaking a message digest
  • Algorithm attack
  • Create two documents with the same digest.
  • Create one document with the same digest as
    another document.

13
MD5 Broken
  • Collisions for Hash Functions MD4, MD5, HAVAL-128
    and RIPEMD, Xiaoyun Wang and Dengguo Feng and
    Xuejia Lai and Hongbo Yu, August 16, 2004
  • http//eprint.iacr.org/2004/199/

14
file1.dat 00000000 d1 31 dd 02 c5 e6 ee c4
69 3d 9a 06 98 af f9 5c 00000010 2f ca b5 87
12 46 7e ab 40 04 58 3e b8 fb 7f 89 00000020
55 ad 34 06 09 f4 b3 02 83 e4 88 83 25 71 41 5a
00000030 08 51 25 e8 f7 cd c9 9f d9 1d bd f2
80 37 3c 5b 00000040 96 0b 1d d1 dc 41 7b 9c
e4 d8 97 f4 5a 65 55 d5 00000050 35 73 9a c7
f0 eb fd 0c 30 29 f1 66 d1 09 b1 8f 00000060
75 27 7f 79 30 d5 5c eb 22 e8 ad ba 79 cc 15 5c
00000070 ed 74 cb dd 5f c5 d3 6d b1 9b 0a d8
35 cc a7 e3 MD5(file1.dat)
a4c0d35c95a63a805915367dcfe6b751 file2.dat
00000000 d1 31 dd 02 c5 e6 ee c4 69 3d 9a 06 98
af f9 5c 00000010 2f ca b5 07 12 46 7e ab 40
04 58 3e b8 fb 7f 89 00000020 55 ad 34 06 09
f4 b3 02 83 e4 88 83 25 f1 41 5a 00000030 08
51 25 e8 f7 cd c9 9f d9 1d bd 72 80 37 3c 5b
00000040 96 0b 1d d1 dc 41 7b 9c e4 d8 97 f4 5a
65 55 d5 00000050 35 73 9a 47 f0 eb fd 0c 30
29 f1 66 d1 09 b1 8f 00000060 75 27 7f 79 30
d5 5c eb 22 e8 ad ba 79 4c 15 5c 00000070 ed
74 cb dd 5f c5 d3 6d b1 9b 0a 58 35 cc a7 e3
MD5(file2.dat) a4c0d35c95a63a805915367dcfe6b751
15
Documents with Tunable Digests
  • We the people citizens of the US United States,
    in order to form make a more perfect union,
    establish justice, insure domestic tranquility,
    provide for the common defense, promote the
    general welfare, and secure the blessing of
    liberty to ourselves and our posterity children,
    do ordain and establish the Constitution of the
    United States of America.
  • 4 choices 24 different SHA-1 codes.
  • Still a long way from 2160 --- or even from 2128
  • Real problem is finding the match --- 280 vs 2128

16
Just how big is 2128?
  • 2128 340,282,366,920,938,463,463,374,
    607,431,768,211,456
  • If you could try a billion2 combinations a
    second, it would take 10,790 billion years
  • (2128 / 109 / 109 / (606024365) / 109)

17
Brute force attacks on smaller digests
Assuming 1 million tries per second DES Cracker
can do 88 billion keys per second with
Distributed.NET it could cracking 245 billion
keys per sec in 1999
18
MD5 vs. SHA-1
People are moving to SHA-1
19
Uses of Digest Functions
  • Integrity
  • Verifying downloaded code
  • Use Digest to determine if two files are
    identical
  • Verifying SSL streams
  • Authentication
  • verifying a shared secret w/o encryption

20
Class Discussion
  • What are the practical implications of it being
    broken?
  • Is it really broken?

21
MD5s for Downloaded Code
22
(No Transcript)
23
Question
  • Does MD5 being broken matter for this
    application?

24
Storing Passwords
  • Instead of storing the password, store the hash
    of the password.
  • Cracking the password requires hashing every
    password entry to see if it matches the hash.
  • Unix originally used a DES-based hash, now it
    uses an MD5 hash

gigawaltfURfuu4.4hY0U129129Walter
Belgers/home/gigawalt/bin/csh root1zlC9.Vfl
9rXSaQqe1HWDaNNOSTJzh.0000Nitroba
/root/bin/tcsh
25
password file has both salt and encrypted pw
Hash (Rfuu4.4hY0U)
gigawaltfURfuu4.4hY0U129129Walter
Belgers/home/gigawalt/bin/csh
Salt (fU)
26
Hash
Algorithm 1
root1zlC9.Vfl9rXSaQqe1HWDaNNOSTJzh.0000N
itroba /root/bin/tcsh
Salt
27
Whats the point of the salt?
28
MACs and HMACs
  • MAC Message Authentication Code
  • HMAC Keyed Hashing for Message Authentication
    (RFC 2104)
  • http//www.ietf.org/rfc/rfc2404.txt
  • http//www.cs.ucsd.edu/users/mihir/papers/hmac.htm
    l

29
(No Transcript)
30
RFC 2104 HMAC
  • HMAC(f,K,M) f(K?0x5c64 f(K?0x3664 M))
  • More complicated than concatenating the key and
    taking the hash, but more secure!

31
Uses of HMACs
  • Data integrity and authentication
  • BGP uses HMAC
  • IPsec Authentication Header and Encapsulating
    Security Payload use HMAC as a digital
    signature.
  • Password protocols

32
(No Transcript)
33
MD5 API Perl
man DigestMD5 ... Functional style
use DigestMD5 qw(md5 md5_hex
md5_base64) digest md5(data)
digest md5_hex(data) digest
md5_base64(data) OO style
use DigestMD5 ctx
DigestMD5-gtnew ctx-gtadd(data)
ctx-gtaddfile(FILE) digest
ctx-gtdigest digest ctx-gthexdigest
digest ctx-gtb64digest
34
md5.pl
!/usr/bin/perl use DigestMD5 qw(md5) use
strict open J,ARGV0 die "Cannot open
ARGV0," my ctx DigestMD5-gtnew ctx-gtaddf
ile(J) print "md5(ARGV0)
",ctx-gthexdigest,"\n"
35
calc_md5.py
!/usr/bin/python import md5 import sys m
md5.new() m.update(open(sys.argv1,"r").read()) p
rint "md5(s) s" (sys.argv1,m.hexdigest())
Note be careful not to call this file md5.py!
36
calc_md5.py
!/usr/bin/python import md5 import sys f
open(sys.argv1,r) data f.read() m
md5.new() m.update(data) print "md5(s) s"
(sys.argv1,m.hexdigest())
37
MD5 HMAC API
NAME DigestHMAC_MD5 - Keyed-Hashing for
Message Authentication SYNOPSIS
Functional style use DigestHMAC_MD5
qw(hmac_md5 hmac_md5_hex) digest
hmac_md5(data, key) print
hmac_md5_hex(data, key) OO style
use DigestHMAC_MD5 hmac
DigestHMAC_MD5-gtnew(key)
hmac-gtadd(data) hmac-gtaddfile(FILE)
digest hmac-gtdigest digest
hmac-gthexdigest digest
hmac-gtb64digest
38
(No Transcript)
39
OpenSSL C API
include ltopenssl/md5.hgt
unsigned char MD5(const unsigned char d,
unsigned long n,
unsigned char md) void
MD5_Init(MD5_CTX c) void
MD5_Update(MD5_CTX c, const void data,
unsigned long len) void
MD5_Final(unsigned char md, MD5_CTX c)
40
OpenSSL C API
include ltopenssl/sha.hgt
unsigned char SHA1(const unsigned char d,
unsigned long n,
unsigned char md) void
SHA1_Init(SHA_CTX c) void
SHA1_Update(SHA_CTX c, const void data,
unsigned long len) void
SHA1_Final(unsigned char md, SHA_CTX c)
41
void MD5_Init(MD5_CTX c)void SHA1_Init(SHA_CTX
c)
  • A context is used for a process that needs to be
    repeated over many blocks of data
  • Stream cipher
  • Encryption of many blocks
  • Calculation of a message digest
  • Similar to instance variables in object oriented
    programming.

42
(No Transcript)
43
char buf vs. unsigned char buf
  • Technically, binary data should be unsigned char
  • Many C routines take char
  • (e.g. read(), write(), etc.)
  • Expect frequent casts or compiler warnings

44
Other uses of MACs
  • Hash Trees - Shurety digital notary
  • S/KEY
  • SecureID
  • Password Challenge-Response
Write a Comment
User Comments (0)
About PowerShow.com