MD5
| 概述 | |
|---|---|
| 设计者 | Ron Rivest |
| 首次发布 | 1992年4月 |
| 系列 | MD, MD2, MD3, MD4, MD5, MD6 |
| 细节 | |
| 编码长度 | 128位 |
| 结构 | Merkle–Damgård construction |
| 重复回数 | 2009年Tao Xie和Dengguo Feng仅用了220.96的时间即破解了MD5的碰撞抵抗,该攻击在普通计算机上运行只需要数秒钟[1]。 |
MD5即Message-Digest Algorithm 5(消息摘要算法第五版)的简称,是当前计算机领域用于确保信息传输完整一致而广泛使用的雜湊算法之一(又译哈希算法、摘要算法等),主流编程语言普遍已有MD5的实现。
将数据(如一段文字)运算变为另一固定长度值,是雜湊算法的基础原理,MD5的前身有MD2、MD3和MD4。
目录 |
历史与密码学[编辑]
1992年8月Ronald L. Rivest向IETF提交了一份重要文件,描述了这种算法的原理,由于这种算法的公开性和安全性,在90年代被广泛使用在各种程序语言中,用以確保资料傳遞無誤等。
MD5由MD4、MD3、MD2改进而来,主要增强算法复杂度和不可逆性。
MD5一度被广泛应用于计算机安全领域。但由于近年来MD5的弱点不断被发现,以及当今计算机运算能力的不断提升,现在已经可能人为构造出两个具有相同MD5校验值的信息[2],使本算法不再适合现今的安全领域。目前,MD5算法因其普遍、稳定、快速的特点,仍广泛应用于普通数据的错误检查领域。例如在一些BitTorrent下载中,软件将通过计算MD5检验下载到的文件片段的完整性。
弱点[编辑]
MD5算法较老,散列长度固定为128位元,随着计算机运算能力提高,更快地找到“碰撞”是有可能的。因此,在安全要求高的场合不应再使用MD5。
2004年,王小云证明MD5数字签名算法可能被快速生成“碰撞”[3]。2007年,Marc Stevens,Arjen K. Lenstra和Benne de Weger进一步指出通过伪造软件签名,可重复性攻击MD5算法[4]。研究者使用前缀碰撞法(chosen-prefix collision),使程序前端包含恶意程序,利用后面的空间添上垃圾代码凑出同样的MD5散列值。
2007年,荷兰埃因霍芬技术大学科学家成功把2个可执行文件进行了MD5碰撞,使得这两个运行结果不同的程序会被计算出同一个MD5值[5]。2008年12月一组科研人员通过MD5碰撞成功生成了伪造的SSL证书,这使得在https协议中服务器可以伪造一些根CA的签名。[6]
应用[编辑]
| 当前條目或章節需要更新。 |
MD5已经广泛使用在为文件传输提供一定的可靠性方面。例如,服务器预先提供一个MD5校验和,用户下载完文件以后,用MD5算法计算下载文件的MD5校验和,然后通过检查这两个校验和是否一致,就能判断下载的文件是否出错。
算法[编辑]
MD5是輸入不定長度信息,輸出固定長度128-bits的演算法。经过程序流程,生成四个32位数据,最后联合起来成为一个128-bits散列。基本方式为,求余、取余、调整长度、与链接变量进行循环运算。得出结果。
是 XOR, AND, OR , NOT 的符号。
伪代码[编辑]
//Note: All variables are unsigned 32 bits and wrap modulo 2^32 when calculating var int[64] r, k //r specifies the per-round shift amounts r[ 0..15]:= {7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22} r[16..31]:= {5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20} r[32..47]:= {4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23} r[48..63]:= {6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21} //Use binary integer part of the sines of integers as constants: for i from 0 to 63 k[i] := floor(abs(sin(i + 1)) × 2^32) //Initialize variables: var int h0 := 0x67452301 var int h1 := 0xEFCDAB89 var int h2 := 0x98BADCFE var int h3 := 0x10325476 //Pre-processing: append "1" bit to message append "0" bits until message length in bits ≡ 448 (mod 512) append bit length of message as 64-bit little-endian integer to message //Process the message in successive 512-bit chunks: for each 512-bit chunk of message break chunk into sixteen 32-bit little-endian words w[i], 0 ≤ i ≤ 15 //Initialize hash value for this chunk: var int a := h0 var int b := h1 var int c := h2 var int d := h3 //Main loop: for i from 0 to 63 if 0 ≤ i ≤ 15 then f := (b and c) or ((not b) and d) g := i else if 16 ≤ i ≤ 31 f := (d and b) or ((not d) and c) g := (5×i + 1) mod 16 else if 32 ≤ i ≤ 47 f := b xor c xor d g := (3×i + 5) mod 16 else if 48 ≤ i ≤ 63 f := c xor (b or (not d)) g := (7×i) mod 16 temp := d d := c c := b b := leftrotate((a + f + k[i] + w[g]),r[i]) + b a := temp Next i //Add this chunk's hash to result so far: h0 := h0 + a h1 := h1 + b h2 := h2 + c h3 := h3 + d End ForEach var int digest := h0 append h1 append h2 append h3 //(expressed as little-endian)
MD5散列[编辑]
一般128位的MD5散列被表示为32位十六进制数字。以下是一个43位长的仅ASCII字母列的MD5散列:
MD5("The quick brown fox jumps over the lazy dog")
= 9e107d9d372bb6826bd81d3542a419d6
即使在原文中作一个小变化(比如用c取代d)其散列也会发生巨大的变化:
MD5("The quick brown fox jumps over the lazy cog")
= 1055d3e698d289f2af8663725127bd4b
空文的散列为:
MD5("")
= d41d8cd98f00b204e9800998ecf8427e
参见[编辑]
参考文献[编辑]
- ^ Tao Xie and Dengguo Feng. How To Find Weak Input Differences For MD5 Collision Attacks. 30 May 2009.
- ^ http://www.mscs.dal.ca/~selinger/md5collision/
- ^ Xiaoyun Wang; Hongbo Yu. How to Break MD5 and Other Hash Functions. EUROCRYPT. 2005. ISBN 3-540-25910-4.
- ^ Marc Stevens,Arjen K. Lenstra和Benne de Weger. Vulnerability of software integrity and code signing applications to chosen-prefix collisions for MD5. November 30, 2007 [2007-12-03].
- ^ [1], Vulnerability of software integrity and code signing applications to chosen-prefix collisions for MD5
- ^ Sotirov, Alexander; Marc Stevens, Jacob Appelbaum, Arjen Lenstra, David Molnar, Dag Arne Osvik, Benne de Weger. MD5 considered harmful today. 2008-12-30 [2008-12-30].
- Berson, Thomas A.. Differential Cryptanalysis Mod 232 with Applications to MD5. EUROCRYPT. 1992: pp. 71–80. ISBN 3-540-56413-6.
- Bert den Boer; Antoon Bosselaers. Collisions for the Compression Function of MD5//EUROCRYPT. 1993: 293–304. ISBN 3-540-57600-2.
- Hans Dobbertin, Cryptanalysis of MD5 compress. Announcement on Internet, May 1996 [2].
- Dobbertin, Hans. The Status of MD5 After a Recent Attack. CryptoBytes. 1996, 2 (2).
- Cong, Zijie. 提高哈希安全性的一些错误做法. Clifton Labratory. 2009.
外部链接[编辑]
- RFC 1321 The MD5 Message-Digest Algorithm
- Annotated bibliography of MD5 cryptanalysis
- Hash Collision Q&A
- MD5 Lookup - reverses some MD5 hashes
- MD5 Unofficial homepage contains links to implementations in various programming languages.
碰撞[编辑]
- Two colliding Postscript files with the same size
- Two colliding executable files
- MD5 Collision, Visualised
- Exploiting MD5 collisions, in C#
- Fast MD5 Collision Generator
- Hash Collisions within a Minute
工具[编辑]
- MD5 在线计算器 - 使用 JavaScript 技术制作的 MD5 安全计算器,含Android, Chrome 版本。
- MD5 的VC++实现代码 CSDN 下载频道:MD5 的VC++实现代码
- www.cmd5.com - 应用MD5散列数据库查询
- www.md5.com.cn - MD5反向查询破解
- MD5 Crack online - Passwords Recovery by MD5 Rainbow Tables
- md5.rednoize.com- MD5转换
- us.md5.crysm.net - MD5 Reverse lookup
- md5.mmkey.com - MD5搜集,相关程序源码
- xmd5.org - MD5转换
- MD5 Hash Example/Generator
- MD5 Checksums for Linux and BSD Distributions
- winMd5Sum - MD5值计算
- MD4/MD5/SHA-1 加密
- Pascal Unit



