19 static const int S11=7;
20 static const int S12=12;
21 static const int S13=17;
22 static const int S14=22;
23 static const int S21=5;
24 static const int S22=9;
25 static const int S23=14;
26 static const int S24=20;
27 static const int S31=4;
28 static const int S32=11;
29 static const int S33=16;
30 static const int S34=23;
31 static const int S41=6;
32 static const int S42=10;
33 static const int S43=15;
34 static const int S44=21;
47 FF(a, b, c, d, x[ 0], S11, 0xd76aa478);
48 FF(d, a, b, c, x[ 1], S12, 0xe8c7b756);
49 FF(c, d, a, b, x[ 2], S13, 0x242070db);
50 FF(b, c, d, a, x[ 3], S14, 0xc1bdceee);
51 FF(a, b, c, d, x[ 4], S11, 0xf57c0faf);
52 FF(d, a, b, c, x[ 5], S12, 0x4787c62a);
53 FF(c, d, a, b, x[ 6], S13, 0xa8304613);
54 FF(b, c, d, a, x[ 7], S14, 0xfd469501);
55 FF(a, b, c, d, x[ 8], S11, 0x698098d8);
56 FF(d, a, b, c, x[ 9], S12, 0x8b44f7af);
57 FF(c, d, a, b, x[10], S13, 0xffff5bb1);
58 FF(b, c, d, a, x[11], S14, 0x895cd7be);
59 FF(a, b, c, d, x[12], S11, 0x6b901122);
60 FF(d, a, b, c, x[13], S12, 0xfd987193);
61 FF(c, d, a, b, x[14], S13, 0xa679438e);
62 FF(b, c, d, a, x[15], S14, 0x49b40821);
65 GG(a, b, c, d, x[ 1], S21, 0xf61e2562);
66 GG(d, a, b, c, x[ 6], S22, 0xc040b340);
67 GG(c, d, a, b, x[11], S23, 0x265e5a51);
68 GG(b, c, d, a, x[ 0], S24, 0xe9b6c7aa);
69 GG(a, b, c, d, x[ 5], S21, 0xd62f105d);
70 GG(d, a, b, c, x[10], S22, 0x2441453);
71 GG(c, d, a, b, x[15], S23, 0xd8a1e681);
72 GG(b, c, d, a, x[ 4], S24, 0xe7d3fbc8);
73 GG(a, b, c, d, x[ 9], S21, 0x21e1cde6);
74 GG(d, a, b, c, x[14], S22, 0xc33707d6);
75 GG(c, d, a, b, x[ 3], S23, 0xf4d50d87);
76 GG(b, c, d, a, x[ 8], S24, 0x455a14ed);
77 GG(a, b, c, d, x[13], S21, 0xa9e3e905);
78 GG(d, a, b, c, x[ 2], S22, 0xfcefa3f8);
79 GG(c, d, a, b, x[ 7], S23, 0x676f02d9);
80 GG(b, c, d, a, x[12], S24, 0x8d2a4c8a);
83 HH(a, b, c, d, x[ 5], S31, 0xfffa3942);
84 HH(d, a, b, c, x[ 8], S32, 0x8771f681);
85 HH(c, d, a, b, x[11], S33, 0x6d9d6122);
86 HH(b, c, d, a, x[14], S34, 0xfde5380c);
87 HH(a, b, c, d, x[ 1], S31, 0xa4beea44);
88 HH(d, a, b, c, x[ 4], S32, 0x4bdecfa9);
89 HH(c, d, a, b, x[ 7], S33, 0xf6bb4b60);
90 HH(b, c, d, a, x[10], S34, 0xbebfbc70);
91 HH(a, b, c, d, x[13], S31, 0x289b7ec6);
92 HH(d, a, b, c, x[ 0], S32, 0xeaa127fa);
93 HH(c, d, a, b, x[ 3], S33, 0xd4ef3085);
94 HH(b, c, d, a, x[ 6], S34, 0x4881d05);
95 HH(a, b, c, d, x[ 9], S31, 0xd9d4d039);
96 HH(d, a, b, c, x[12], S32, 0xe6db99e5);
97 HH(c, d, a, b, x[15], S33, 0x1fa27cf8);
98 HH(b, c, d, a, x[ 2], S34, 0xc4ac5665);
101 II(a, b, c, d, x[ 0], S41, 0xf4292244);
102 II(d, a, b, c, x[ 7], S42, 0x432aff97);
103 II(c, d, a, b, x[14], S43, 0xab9423a7);
104 II(b, c, d, a, x[ 5], S44, 0xfc93a039);
105 II(a, b, c, d, x[12], S41, 0x655b59c3);
106 II(d, a, b, c, x[ 3], S42, 0x8f0ccc92);
107 II(c, d, a, b, x[10], S43, 0xffeff47d);
108 II(b, c, d, a, x[ 1], S44, 0x85845dd1);
109 II(a, b, c, d, x[ 8], S41, 0x6fa87e4f);
110 II(d, a, b, c, x[15], S42, 0xfe2ce6e0);
111 II(c, d, a, b, x[ 6], S43, 0xa3014314);
112 II(b, c, d, a, x[13], S44, 0x4e0811a1);
113 II(a, b, c, d, x[ 4], S41, 0xf7537e82);
114 II(d, a, b, c, x[11], S42, 0xbd3af235);
115 II(c, d, a, b, x[ 2], S43, 0x2ad7d2bb);
116 II(b, c, d, a, x[ 9], S44, 0xeb86d391);
130 for (
uint4 i=0, j=0; j<len; i++, j+=4){
131 output[j]=
uint1(input[i] & 0xff);
132 output[j+1]=
uint1((input[i]>>8) & 0xff);
133 output[j+2]=
uint1((input[i]>>16) & 0xff);
134 output[j+3]=
uint1((input[i]>>24) & 0xff);
141 for (
uint4 i=0, j=0; j<len; i++, j+=4){
143 ((
uint4)input[j]) | (((
uint4)input[j+1]) << 8) |
144 (((
uint4)input[j+2]) << 16) | (((
uint4)input[j+3]) << 24);
158 uint4 BfSpace=64-BfX;
162 if (
uint(InBfL)>=BfSpace) {
167 for (InX=BfSpace; InX+63<
uint(InBfL); InX+=64){
Transform(InBf+InX);}
179 while (SIn->
Len()>0){
181 if (SIn->
Len()<BfL){BfL=SIn->
Len();}
188 unsigned char bits[8];
189 static uint1 PADDING[64]={
190 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
191 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
192 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
199 uint padLen=(index<56) ? (56-index) : (120-index);
200 Add(PADDING, padLen);
211 for (
int CdN=0; CdN<16; CdN++){Mem+=
Sig[CdN];}
217 for (
int CdN=0; CdN<16; CdN++){
230 (
TMd5::GetMd5SigStr(
"abcdefghijklmnopqrstuvwxyz")==
"C3FCD3D76192E4007DFB496CCA67E13B")&&
231 (
TMd5::GetMd5SigStr(
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")==
232 "D174AB98D277D9F5A5611C2C9F419D9F")&&
233 (
TMd5::GetMd5SigStr(
"12345678901234567890123456789012345678901234567890123456789012345678901234567890")==
234 "57EDF4A22BE3C955AC49DA2E2107B67A");
241 memcpy(
CdT, Md5->Sig, 16);
246 memcpy(
CdT, Md5->Sig, 16);
261 memcpy(
CdT, Md5->Sig, 16);
266 memcpy(&HashCd, &
CdT[0], 4);
273 memcpy(&HashCd, &
CdT[3], 4);
280 for (
int CdN=0; CdN<16; CdN++){
void Gen(const int &_BfL)
static PSIn New(const TMem &Mem)
static void GG(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
static char GetHexCh(const int &Val)
static void II(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
virtual int GetBf(const void *Bf, const TSize &BfL)=0
void Add(uchar *InBf, const int &InBfL)
static void Decode(uint4 *Dst, uint1 *Src, uint4 Len)
static PSIn New(const TStr &Str)
void Transform(uint1 *buffer)
void GetSigMem(TMem &Mem) const
static void FF(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
static void MemCpy(uint1 *Dst, uint1 *Src, uint4 Len)
virtual int Len() const =0
static void HH(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
static TStr GetMd5SigStr(const PSIn &SIn)
static void MemSet(uint1 *Start, uint1 Val, uint4 Len)
static void Encode(uint1 *Dst, uint4 *Src, uint4 Len)
int GetPrimHashCd() const