#include "md_misc.h"
#include "dkcMD4.h"
#include "dkcStdio.h"
dkcMD4.cのインクルード依存関係図
マクロ定義 | |
#define | DKUTIL_C_MD4_C |
#define | F1(x, y, z) (z ^ (x & (y ^ z))) |
#define | F2(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z))) |
#define | F3(x, y, z) (x ^ y ^ z) |
#define | ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) |
#define | MD4STEP(f, a, b, c, d, x, s, data) |
This is the central step in the MD4 algorithm | |
関数 | |
DKC_MD4 *WINAPI | dkcAllocMD4 () |
int WINAPI | dkcFreeMD4 (DKC_MD4 **pp) |
void WINAPI | dkcMD4Init (DKC_MD4 *p) |
static DKC_INLINE void | MD4Transform (uint32 buf[4], uint32 const in[16]) |
void WINAPI | dkcMD4Load (DKC_MD4 *p, const BYTE *pBuffer, DWORD dwSize) |
void WINAPI | dkcMD4Final (DKC_MD4 *p) |
int WINAPI | dkcMD4Digest (DKC_MD4 *p, BYTE *buff, size_t size) |
int WINAPI | dkcMD4DigestStr (DKC_MD4 *p, char *buff, size_t size) |
int WINAPI | dkcMD4FinalDigestStr (DKC_MD4 *p, char *buff, size_t size) |
int WINAPI | dkcMD4FinalDigest (DKC_MD4 *p, BYTE *buff, size_t size) |
md4.cpp - modified by Wei Dai from Andrew M. Kuchling's md4.c The original code and all modifications are in the public domain.
/* md4.c : MD4 hash algorithm.
Part of the Python Cryptography Toolkit, version 1.1
Distribute and use freely; there are no restrictions on further dissemination and usage except those imposed by the laws of your country of residence.
dkcMD4.c で定義されています。
|
|
|
参照元 MD4Transform(), と MD5Transform(). |
|
参照元 MD4Transform(), と MD5Transform(). |
|
参照元 MD4Transform(), と MD5Transform(). |
|
値: (a) += f(b,c,d) + x + data;\ (a) = ROTATE_LEFT(a,s);
参照元 MD4Transform(). |
|
|
|
参照先 DKC_MD4, dkcAllocate(), dkcMD4Init(), と NULL. 参照元 dkcSHO_MD4Init(). 00033 { 00034 DKC_MD4 *p = dkcAllocate(sizeof(DKC_MD4)); 00035 if(NULL==p) return NULL; 00036 dkcMD4Init(p); 00037 return p; 00038 }
|
|
参照元 dkcFreeSHO(). 00041 { 00042 if(NULL==pp || NULL==*pp){ 00043 return edk_FAILED; 00044 } 00045 return dkcFree((void **)pp); 00046 }
|
|
参照先 dkc_memcpy(), と MD4_BIN_BUFFER_SIZE. 参照元 dkcMD4DigestStr(), dkcMD4FinalDigest(), と dkcSHO_MD4Init(). 00282 { 00283 00284 if(size < MD4_BIN_BUFFER_SIZE){ 00285 return edk_BufferOverFlow; 00286 } 00287 return dkc_memcpy(buff,size,p->abcd,sizeof(p->abcd)); 00288 }
|
|
参照先 dkcMD4Digest(), MD4_BIN_BUFFER_SIZE, MD4_STR_BUFFER_SIZE, と uint8. 参照元 dkcMD4FinalDigestStr(), と dkcSHO_MD4Init(). 00290 { 00291 register int i; 00292 uint8 temp[MD4_BIN_BUFFER_SIZE]; 00293 if(size < MD4_STR_BUFFER_SIZE){ 00294 return edk_BufferOverFlow; 00295 } 00296 i = dkcMD4Digest(p,temp,sizeof(temp)); 00297 if(DKUTIL_FAILED(i)){ 00298 return i; 00299 } 00300 for (i=0; i<16; i++){ 00301 sprintf(buff+i*2,"%02x", temp[i]); 00302 } 00303 buff[32]='\0'; 00304 return edk_SUCCEEDED; 00305 }
|
|
参照先 dkcMD_Final(), edkcMD_Finalized, と MD4Transform(). 参照元 dkcMD4FinalDigest(), dkcMD4FinalDigestStr(), と dkcSHO_MD4Init(). 00271 { 00272 //uint8 digest[MD4_BIN_BUFFER_SIZE]; 00273 if(p->flags & edkcMD_Finalized){ 00274 return; 00275 } 00276 //MD4Final(p); 00277 dkcMD_Final(p,MD4Transform); 00278 //memcpy(p->a8,digest,sizeof(digest)); 00279 p->flags |= edkcMD_Finalized; 00280 }
|
|
参照先 dkcMD4Digest(), と dkcMD4Final(). 00312 { 00313 dkcMD4Final(p); 00314 return dkcMD4Digest(p,buff,size); 00315 00316 }
|
|
参照先 dkcMD4DigestStr(), と dkcMD4Final(). 00307 { 00308 dkcMD4Final(p); 00309 return dkcMD4DigestStr(p,buff,size); 00310 }
|
|
参照元 dkcAllocMD4(), dkcMD4InitEx(), と dkcSHO_MD4Init(). 00050 { 00051 p->count[0] = p->count[1] = 0; 00052 00053 p->abcd[0] = 0x67452301; 00054 p->abcd[1] = 0xefcdab89; 00055 p->abcd[2] = 0x98badcfe; 00056 p->abcd[3] = 0x10325476; 00057 memset(p->a8,0,sizeof(p->a8)); 00058 //p->mByteOrder = (uint8)dkcGetByteOrder(); 00059 }
|
|
参照先 dkcMD_Update(), edkcMD_Finalized, と MD4Transform(). 参照元 dkcSHO_MD4Init(). 00261 { 00262 if(p->flags & edkcMD_Finalized){ 00263 return; 00264 } 00265 dkcMD_Update(p,pBuffer,dwSize,MD4Transform); 00266 //MD4Update(p,pBuffer,dwSize); 00267 }
|
|
参照先 F1, F2, F3, MD4STEP, と uint32. 参照元 dkcMD4Final(), と dkcMD4Load(). 00085 { 00086 register uint32 a, b, c, d; 00087 00088 a = buf[0]; 00089 b = buf[1]; 00090 c = buf[2]; 00091 d = buf[3]; 00092 00093 MD4STEP(F1,a,b,c,d, in[0], 3,0); 00094 MD4STEP(F1,d,a,b,c, in[1], 7,0); 00095 MD4STEP(F1,c,d,a,b, in[2],11,0); 00096 MD4STEP(F1,b,c,d,a, in[3],19,0); 00097 MD4STEP(F1,a,b,c,d, in[4], 3,0); 00098 MD4STEP(F1,d,a,b,c, in[5], 7,0); 00099 MD4STEP(F1,c,d,a,b, in[6],11,0); 00100 MD4STEP(F1,b,c,d,a, in[7],19,0); 00101 MD4STEP(F1,a,b,c,d, in[8], 3,0); 00102 MD4STEP(F1,d,a,b,c, in[9], 7,0); 00103 MD4STEP(F1,c,d,a,b,in[10],11,0); 00104 MD4STEP(F1,b,c,d,a,in[11],19,0); 00105 MD4STEP(F1,a,b,c,d,in[12], 3,0); 00106 MD4STEP(F1,d,a,b,c,in[13], 7,0); 00107 MD4STEP(F1,c,d,a,b,in[14],11,0); 00108 MD4STEP(F1,b,c,d,a,in[15],19,0); 00109 00110 MD4STEP(F2,a,b,c,d, in[0], 3,0x5a827999); 00111 MD4STEP(F2,d,a,b,c, in[4], 5,0x5a827999); 00112 MD4STEP(F2,c,d,a,b, in[8], 9,0x5a827999); 00113 MD4STEP(F2,b,c,d,a,in[12],13,0x5a827999); 00114 MD4STEP(F2,a,b,c,d, in[1], 3,0x5a827999); 00115 MD4STEP(F2,d,a,b,c, in[5], 5,0x5a827999); 00116 MD4STEP(F2,c,d,a,b, in[9], 9,0x5a827999); 00117 MD4STEP(F2,b,c,d,a,in[13],13,0x5a827999); 00118 MD4STEP(F2,a,b,c,d, in[2], 3,0x5a827999); 00119 MD4STEP(F2,d,a,b,c, in[6], 5,0x5a827999); 00120 MD4STEP(F2,c,d,a,b,in[10], 9,0x5a827999); 00121 MD4STEP(F2,b,c,d,a,in[14],13,0x5a827999); 00122 MD4STEP(F2,a,b,c,d, in[3], 3,0x5a827999); 00123 MD4STEP(F2,d,a,b,c, in[7], 5,0x5a827999); 00124 MD4STEP(F2,c,d,a,b,in[11], 9,0x5a827999); 00125 MD4STEP(F2,b,c,d,a,in[15],13,0x5a827999); 00126 00127 MD4STEP(F3,a,b,c,d, in[0], 3,0x6ed9eba1); 00128 MD4STEP(F3,d,a,b,c, in[8], 9,0x6ed9eba1); 00129 MD4STEP(F3,c,d,a,b, in[4],11,0x6ed9eba1); 00130 MD4STEP(F3,b,c,d,a,in[12],15,0x6ed9eba1); 00131 MD4STEP(F3,a,b,c,d, in[2], 3,0x6ed9eba1); 00132 MD4STEP(F3,d,a,b,c,in[10], 9,0x6ed9eba1); 00133 MD4STEP(F3,c,d,a,b, in[6],11,0x6ed9eba1); 00134 MD4STEP(F3,b,c,d,a,in[14],15,0x6ed9eba1); 00135 MD4STEP(F3,a,b,c,d, in[1], 3,0x6ed9eba1); 00136 MD4STEP(F3,d,a,b,c, in[9], 9,0x6ed9eba1); 00137 MD4STEP(F3,c,d,a,b, in[5],11,0x6ed9eba1); 00138 MD4STEP(F3,b,c,d,a,in[13],15,0x6ed9eba1); 00139 MD4STEP(F3,a,b,c,d, in[3], 3,0x6ed9eba1); 00140 MD4STEP(F3,d,a,b,c,in[11], 9,0x6ed9eba1); 00141 MD4STEP(F3,c,d,a,b, in[7],11,0x6ed9eba1); 00142 MD4STEP(F3,b,c,d,a,in[15],15,0x6ed9eba1); 00143 00144 00145 buf[0] += a; 00146 buf[1] += b; 00147 buf[2] += c; 00148 buf[3] += d; 00149 }
|