*/ #ifndef PROTOTYPES #define PROTOTYPES 0 #endif /* POINTER defines a generic pointer type */ typedef unsigned char *POINTER; /* UINT2 defines a two byte word */ typedef unsigned short
Trang 1II dta,dtb,dtc,dtd,dword ptr [edi+00*4],06,0f4292244h
II dtd,dta,dtb,dtc,dword ptr [edi+07*4],10,0432aff97h
II dtc,dtd,dta,dtb,dword ptr [edi+14*4],15,0ab9423a7h
II dtb,dtc,dtd,dta,dword ptr [edi+05*4],21,0fc93a039h
II dta,dtb,dtc,dtd,dword ptr [edi+12*4],06,0655b59c3h
II dtd,dta,dtb,dtc,dword ptr [edi+03*4],10,08f0ccc92h
II dtc,dtd,dta,dtb,dword ptr [edi+10*4],15,0ffeff47dh
II dtb,dtc,dtd,dta,dword ptr [edi+01*4],21,085845dd1h
II dta,dtb,dtc,dtd,dword ptr [edi+08*4],06,06fa87e4fh
II dtd,dta,dtb,dtc,dword ptr [edi+15*4],10,0fe2ce6e0h
II dtc,dtd,dta,dtb,dword ptr [edi+06*4],15,0a3014314h
II dtb,dtc,dtd,dta,dword ptr [edi+13*4],21,04e0811a1h
II dta,dtb,dtc,dtd,dword ptr [edi+04*4],06,0f7537e82h
II dtd,dta,dtb,dtc,dword ptr [edi+11*4],10,0bd3af235h
II dtc,dtd,dta,dtb,dword ptr [edi+02*4],15,02ad7d2bbh
II dtb,dtc,dtd,dta,dword ptr [edi+09*4],21,0eb86d391h
mov eax,dta
add [esi].dtA,eax
mov eax,dtb
add [esi].dtB,eax
mov eax,dtc
add [esi].dtC,eax
mov eax,dtd
add [esi].dtD,eax
add edi,64
sub edx,64
jnz hashloop
; phase IV · results
mov ecx,4
@@: mov eax,dword ptr [esi]
xchg al,ah
rol eax,16
xchg al,ah
mov dword ptr [esi],eax
Trang 2add esi,4
loop @b
ret
MD5hash endp
4 Tóm lại :
Thuật tóan MD5 rất đơn giản để bổ sung và cung cấp “dấu lăn tay” (fingerprint) hay message digest của một message có chiều dài bất kỳ Nó được phỏng đóan là rất khó có 2 messages có cùng 1 hashes 128 bits Với sự giới thiệu gắn gọn này , thật ra cũng chưa đầy đủ về MD5 Nhưng đáp ứng được phần nào cho ta cách nhìn tổng quát về nó
5 Sự khác nhau giữa MD4 và MD5:
Phần này các bạn đọc qua cho biết sơ sơ
Sau đây là sự khác nhau giữa MD4 và MD5:
1 Vòng round 4 được thêm vào
2 Mỗi bước bây giờ có một hằng số thêm vào duy nhất
3 Hàm g trong vòng 2 đã thay đổi từ (XY v XZ v YZ) thành (XZ v Y not(Z)), để làm cho g “cân đối” ít hơn ( về mặt ma trận trong các bit)
4 Mỗi bước bây giờ cộng vào trong kết quả của bước trước Điều này đẩy mạnh
“avalanche effect” (hiệu ứng dồn dập)một cách nhanh hơn
5 Để input words được access trong vòng 2 và 3 đã thay đổi, thì patterns của chúng phải giống mỗi cái khác hơn
6 Số lượng luân phiên trong mỗi vòng phải được optimized chừng mực, để cung cấp “avalanche effect” (hiệu ứng dồn dập)một cách nhanh hơn Sự luân phiên trong các vòng khác thì độc lập nhau
6.Phụ lục :
Đây là bản gốc của tài liệu tham khảo md5, các bạn tham khảo thêm nguồn code
Trang 3trong C về thuật tóan MD5
This appendix contains the following files taken from RSAREF: A
Cryptographic Toolkit for Privacy-Enhanced Mail:
global.h global header file
md5.h header file for MD5
md5c.c source code for MD5
For more information on RSAREF, send email to <rsaref@rsa.com> The appendix also includes the following file:
mddriver.c test driver for MD2, MD4 and MD5
The driver compiles for MD5 by default but can compile for MD2 or MD4
if the symbol MD is defined on the C compiler command line as 2 or 4
The implementation is portable and should work on many different
plaforms However, it is not difficult to optimize the implementation
on particular platforms, an exercise left to the reader For example,
on "little-endian" platforms where the lowest-addressed byte in a 32- bit word is the least significant and there are no alignment
restrictions, the call to Decode in MD5Transform can be replaced with
a typecast
A.1 global.h
/* GLOBAL.H - RSAREF types and constants
*/
/* PROTOTYPES should be set to one if and only if the compiler supports
Trang 4function argument prototyping
The following makes PROTOTYPES default to 0 if it has not already
been defined with C compiler flags
*/
#ifndef PROTOTYPES
#define PROTOTYPES 0
#endif
/* POINTER defines a generic pointer type */
typedef unsigned char *POINTER;
/* UINT2 defines a two byte word */
typedef unsigned short int UINT2;
/* UINT4 defines a four byte word */
typedef unsigned long int UINT4;
/* PROTO_LIST is defined depending on how PROTOTYPES is defined above
If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
returns an empty list
*/
#if PROTOTYPES
#define PROTO_LIST(list) list
#else
#define PROTO_LIST(list) ()
#endif
A.2 md5.h
/* MD5.H - header file for MD5C.C
*/
/* Copyright (C) 1991-2, RSA Data Security, Inc Created 1991 All
Trang 5rights reserved
License to copy and use this software is granted provided that it
is identified as the "RSA Data Security, Inc MD5 Message-Digest Algorithm" in all material mentioning or referencing this software
or this function
License is also granted to make and use derivative works provided that such works are identified as "derived from the RSA Data
Security, Inc MD5 Message-Digest Algorithm" in all material
mentioning or referencing the derived work
RSA Data Security, Inc makes no representations concerning either the merchantability of this software or the suitability of this
software for any particular purpose It is provided "as is"
without express or implied warranty of any kind
These notices must be retained in any copies of any part of this
documentation and/or software
*/
/* MD5 context */
typedef struct {
UINT4 state[4]; /* state (ABCD) */
UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */
unsigned char buffer[64]; /* input buffer */
} MD5_CTX;
void MD5Init PROTO_LIST ((MD5_CTX *));
void MD5Update PROTO_LIST
((MD5_CTX *, unsigned char *, unsigned int));
void MD5Final PROTO_LIST ((unsigned char [16], MD5_CTX *)); A.3 md5c.c
/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
Trang 6*/
/* Copyright (C) 1991-2, RSA Data Security, Inc Created 1991 All rights reserved
License to copy and use this software is granted provided that it
is identified as the "RSA Data Security, Inc MD5 Message-Digest Algorithm" in all material mentioning or referencing this software
or this function
License is also granted to make and use derivative works provided that such works are identified as "derived from the RSA Data
Security, Inc MD5 Message-Digest Algorithm" in all material mentioning or referencing the derived work
RSA Data Security, Inc makes no representations concerning either the merchantability of this software or the suitability of this
software for any particular purpose It is provided "as is"