资源简介
这个例子描述了MD4碰撞,很有研究价值,大家可以仔细研究下...这个例子描述了MD4碰撞,很有研究价值,大家可以仔细研究下
代码片段和文件信息
// md4-collision.cpp: 定义控制台应用程序的入口点。
//
#include “stdafx.h“
#define _CRT_SECURE_NO_WARNINGS
# include
# include
# define F(xyz) ((x&y)|((~x)&z))
# define G(xyz) ((x&y)|(x&z)|(y&z))
# define H(xyz) (x^y^z)
# define LROT(xs) (((x)<>(32-s)))
# define RROT(xs) (((x)>>s)|((x)<<(32-s)))
# define bit(xn) ((x<<(32-n))>>31)
int main()
{
unsigned long a[13] b[13] c[13] d[13];
unsigned long a1[13] b1[13] c1[13] d1[13];
unsigned long k1 k2 i;
a[0] = a1[0] = 0x67452301;
b[0] = b1[0] = 0xefcdab89;
c[0] = c1[0] = 0x98badcfe;
d[0] = d1[0] = 0x10325476;
k1 = 0x5a827999;
k2 = 0x6ed9eba1;
unsigned long z1[16] = { 0481215913261014371115 };
unsigned long z2[16] = { 0841221061419513311715 };
unsigned long s0[16] = { 371119371119371119371119 };
unsigned long s1[16] = { 35913359133591335913 };
unsigned long s2[16] = { 391115391115391115391115 };
unsigned long x[16] = { 0xbcdd26740x53fce1ed0x25d202ce0xe87d102e
0xf45be7280xacc992cc0x6acfb3ea0x7dbb29d4
0xed03bf750xc6aedc450xd442b7100xfca27d99
0xa5f5eff10xfb2ee79b0x0f590d680x4989f380 };
unsigned long M[48];
unsigned long M1[48];
for (i = 0; i<16; i++)
{
M[i] = x[i];
}
a[1] = LROT((a[0] + F(b[0] c[0] d[0]) + M[0]) 3);
d[1] = LROT((d[0] + F(a[1] b[0] c[0]) + M[1]) 7);
c[1] = LROT((c[0] + F(d[1] a[1] b[0]) + M[2]) 11);
b[1] = LROT((b[0] + F(c[1] d[1] a[1]) + M[3]) 19);
//第5
a[2] = LROT((a[1] + F(b[1] c[1] d[1]) + M[4]) 3);
d[2] = LROT((d[1] + F(a[2] b[1] c[1]) + M[5]) 7);
c[2] = LROT((c[1] + F(d[2] a[2] b[1]) + M[6]) 11);
b[2] = LROT((b[1] + F(c[2] d[2] a[2]) + M[7]) 19);
//第9
a[3] = LROT((a[2] + F(b[2] c[2] d[2]) + M[8]) 3);
d[3] = LROT((d[2] + F(a[3] b[2] c[2]) + M[9]) 7);
c[3] = LROT((c[2] + F(d[3] a[3] b[2]) + M[10]) 11);
b[3] = LROT((b[2] + F(c[3] d[3] a[3]) + M[11]) 19);
a[4] = LROT((a[3] + F(b[3] c[3] d[3]) + M[12]) 3);
d[4] = LROT((d[3] + F(a[4] b[3] c[3]) + M[13]) 7);
c[4] = LROT((c[3] + F(d[4] a[4] b[3]) + M[14]) 11);
b[4] = LROT((b[3] + F(c[4] d[4] a[4]) + M[15]) 19);
//第17个
a[5] = LROT((a[4] + G(b[4] c[4] d[4]) + M[0] + k1) 3);
if (bit(a[5] 20) ^ bit(b[4] 20))
{
M[15] = M[15] + 0x20000000;
b[4] = LROT((b[3] + F(c[4] d[4] a[4]) + M[15]) 19);
printf(“b[4]=%d\n“ bit(b[4] 16));
a[5] = LROT((a[4] + G(b[4] c[4] d[4]) + M[0] + k1) 3);
}
if (bit(a[5] 29))
{
M[0] = M[0] + 0x2000000;
a[1] = LROT((a[0] + F(b[0] c[0] d[0]) + M[0]) 3);
d[1] = LROT((d[0] + F(a[1] b[0] c[0]) + M[1]) 7);
c[1] = LROT((c[0] + F(d[1] a[1] b[0]) + M[2]) 11);
b[1] = LROT((b[0] + F(c[1] d[1] a[1]) + M[3]) 19);
M[4] = M[4] - 0x10000000;
a[2] = LROT((a[1] + F(b[1] c[1] d[1]) + M[4]) 3);
a[5] = LROT((a[4] + G(b[4] c[4] d[4]) + M[0] + k1) 3);
}
if (bit(a[5] 3
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-11-07 15:07 md4-collision\
文件 1453 2017-11-06 23:25 md4-collision.sln
文件 28934 2017-11-06 23:32 md4-collision\md4-collision.cpp
文件 8090 2017-11-06 23:32 md4-collision\md4-collision.vcxproj
文件 1254 2017-11-06 23:25 md4-collision\md4-collision.vcxproj.filters
文件 165 2017-11-06 23:26 md4-collision\md4-collision.vcxproj.user
文件 328 2017-11-06 23:25 md4-collision\stdafx.cpp
文件 366 2017-11-06 23:25 md4-collision\stdafx.h
文件 370 2017-11-06 23:25 md4-collision\targetver.h
评论
共有 条评论