#include <abkMD5.h>
Collaboration diagram for MD5:
Public Member Functions | |
MD5 () | |
MD5 (const char *input, unsigned length, bool lastUpdate=true) | |
MD5 (const char *input, bool lastUpdate=true) | |
MD5 (const MD5 &) | |
~MD5 () | |
void | update (const char *input, unsigned inputLen, bool lastUpdate) |
void | update (const char *input, bool lastUpdate) |
operator unsigned () const | |
operator Wrap128 () const | |
MD5 & | operator= (const MD5 &) |
unsigned | getWord (unsigned idx) const |
void | finalize () |
Static Public Member Functions | |
void | encode (unsigned char *output, const unsigned *input, unsigned len) |
void | decode (unsigned *output, const unsigned char *input, unsigned len) |
Protected Member Functions | |
void | _update (const unsigned char *input, unsigned inputLen) |
void | _initState () |
void | _finalize () |
void | _transform (const unsigned char *block) |
Protected Attributes | |
unsigned | _state [4] |
unsigned | _count [2] |
unsigned char | _buffer [64] |
bool | _isFinalized |
Friends | |
ostream & | operator<< (ostream &os, const MD5 &md5) |
|
Definition at line 101 of file md5.cxx. References _initState().
00101 :_isFinalized(false) 00102 { 00103 _initState(); 00104 } |
Here is the call graph for this function:
|
Definition at line 107 of file md5.cxx. References _initState(), and update().
00107 :_isFinalized(false) 00108 { 00109 _initState(); 00110 update(input,length,lastUpdate); 00111 } |
Here is the call graph for this function:
|
Definition at line 113 of file md5.cxx. References _initState(), and update().
00113 :_isFinalized(false) 00114 { 00115 _initState(); 00116 update(input,lastUpdate); 00117 } |
Here is the call graph for this function:
|
Definition at line 96 of file abkMD5.h. References abkfatal.
00096 {abkfatal(0,"can't copy-ctruct MD5");} |
|
Definition at line 354 of file md5.cxx. References _state.
00355 {
00356 //zeroize sensitive info
00357 memset(_state,0,16);
00358 }
|
|
Definition at line 212 of file md5.cxx. References _count, _isFinalized, _update(), encode(), and PADDING. Referenced by finalize(), and update().
00213 { 00214 unsigned char bits[8]; 00215 unsigned int index, padLen; 00216 00217 /* Save number of bits */ 00218 encode (bits,_count, 8); 00219 00220 /* Pad out to 56 mod 64. 00221 00222 */ 00223 index = (unsigned int)((_count[0] >> 3) & 0x3f); 00224 padLen = (index < 56) ? (56 - index) : (120 - index); 00225 _update (PADDING, padLen); 00226 00227 /* Append length (before padding) */ 00228 _update (bits, 8); 00229 00230 /* Store state in digest */ 00231 //encode (digest, _state, 16); 00232 00233 /* Zeroize sensitive information. 00234 00235 */ 00236 //MD5_memset ((POINTER)context, 0, sizeof (*context)); //we'll do in dtor 00237 _isFinalized=true; 00238 } |
Here is the call graph for this function:
|
Definition at line 119 of file md5.cxx. References _count, and _state. Referenced by MD5().
|
|
Definition at line 240 of file md5.cxx. References _state, decode(), FF, GG, HH, II, S11, S12, S13, S14, S21, S22, S23, S24, S31, S32, S33, S34, S41, S42, S43, and S44. Referenced by _update().
00241 { 00242 unsigned a = _state[0], b = _state[1], c = _state[2], d = _state[3], x[16]; 00243 00244 decode (x, block, 64); 00245 00246 /* Round 1 */ 00247 FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */ 00248 FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */ 00249 FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */ 00250 FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */ 00251 FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */ 00252 FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */ 00253 FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */ 00254 FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */ 00255 FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */ 00256 FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */ 00257 FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ 00258 FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ 00259 FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ 00260 FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ 00261 FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ 00262 FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ 00263 00264 /* Round 2 */ 00265 GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */ 00266 GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */ 00267 GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ 00268 GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */ 00269 GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */ 00270 GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */ 00271 GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ 00272 GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */ 00273 GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */ 00274 GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ 00275 GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */ 00276 00277 00278 00279 GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */ 00280 GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ 00281 GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */ 00282 GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */ 00283 GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ 00284 00285 /* Round 3 */ 00286 HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */ 00287 HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */ 00288 HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ 00289 HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ 00290 HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */ 00291 HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */ 00292 HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */ 00293 HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ 00294 HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ 00295 HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */ 00296 HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */ 00297 HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */ 00298 HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */ 00299 HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ 00300 HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ 00301 HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */ 00302 00303 /* Round 4 */ 00304 II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */ 00305 II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */ 00306 II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ 00307 II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */ 00308 II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ 00309 II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */ 00310 II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ 00311 II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */ 00312 II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */ 00313 II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ 00314 II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */ 00315 II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ 00316 II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */ 00317 II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ 00318 II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */ 00319 II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */ 00320 00321 _state[0] += a; 00322 _state[1] += b; 00323 _state[2] += c; 00324 _state[3] += d; 00325 00326 /* Zeroize sensitive information. 00327 00328 00329 00330 */ 00331 memset (x, 0, sizeof (x)); 00332 } |
Here is the call graph for this function:
|
Definition at line 176 of file md5.cxx. References _buffer, _count, and _transform(). Referenced by _finalize(), and update().
00177 { 00178 unsigned i, index, partLen; 00179 00180 /* Compute number of bytes mod 64 */ 00181 index = (unsigned)((_count[0] >> 3) & 0x3F); 00182 00183 /* Update number of bits */ 00184 if ((_count[0] += ((unsigned)inputLen << 3)) 00185 < ((unsigned)inputLen << 3)) 00186 _count[1]++; 00187 _count[1] += ((unsigned)inputLen >> 29); 00188 00189 partLen = 64 - index; 00190 00191 //Transform as many times as possible. 00192 00193 00194 if (inputLen >= partLen) 00195 { 00196 memcpy(&_buffer[index],input, partLen); 00197 _transform (&_buffer[0]); 00198 00199 for (i = partLen; i + 63 < inputLen; i += 64) 00200 _transform (&input[i]); 00201 00202 index = 0; 00203 } 00204 else 00205 i = 0; 00206 00207 /* Buffer remaining input */ 00208 memcpy(&_buffer[index],&input[i],inputLen-i); 00209 00210 } |
Here is the call graph for this function:
|
Definition at line 143 of file md5.cxx. Referenced by _transform().
00144 { 00145 unsigned int i, j; 00146 00147 for (i = 0, j = 0; j < len; i++, j += 4) 00148 output[i] = ((unsigned)input[j]) | 00149 (((unsigned)input[j+1]) << 8) | 00150 (((unsigned)input[j+2]) << 16) | 00151 (((unsigned)input[j+3]) << 24); 00152 } |
|
Definition at line 130 of file md5.cxx. Referenced by _finalize(), and operator<<().
00131 { 00132 unsigned int i, j; 00133 00134 for (i = 0, j = 0; j < len; i++, j += 4) 00135 { 00136 output[j] = (unsigned char)(input[i] & 0xff); 00137 output[j+1] = (unsigned char)((input[i] >> 8) & 0xff); 00138 output[j+2] = (unsigned char)((input[i] >> 16) & 0xff); 00139 output[j+3] = (unsigned char)((input[i] >> 24) & 0xff); 00140 } 00141 } |
|
Definition at line 170 of file md5.cxx. References _finalize(), _isFinalized, and abkfatal.
|
Here is the call graph for this function:
|
Definition at line 360 of file md5.cxx. References _state, and abkassert. Referenced by Tausworthe::_encryptBufMultipartiteSeed().
|
|
Definition at line 336 of file md5.cxx. References _isFinalized, _state, and abkfatal.
|
|
Definition at line 343 of file md5.cxx. References _isFinalized, _state, abkfatal, and MD5::Wrap128::meat.
|
|
Definition at line 109 of file abkMD5.h. References abkfatal.
00109 {abkfatal(0,"can't assign MD5"); 00110 return *this;} |
|
Definition at line 154 of file md5.cxx. References _finalize(), _isFinalized, _update(), and abkfatal.
|
Here is the call graph for this function:
|
Definition at line 162 of file md5.cxx. References _finalize(), _isFinalized, _update(), and abkfatal. Referenced by Tausworthe::_encryptBufMultipartiteSeed(), and MD5().
|
Here is the call graph for this function:
|
Definition at line 368 of file md5.cxx.
00369 { 00370 abkfatal(md5._isFinalized,"Can't output state of MD5 before finalization"); 00371 int i; 00372 unsigned char digest[16]; 00373 char buf[3]; 00374 MD5::encode(&digest[0],md5._state,16); 00375 for (i=0;i<16;i++) 00376 { 00377 sprintf(buf,"%02x",digest[i]); 00378 os << buf; 00379 } 00380 return os; 00381 } |
|
Definition at line 135 of file abkMD5.h. Referenced by _update(). |
|
Definition at line 133 of file abkMD5.h. Referenced by _finalize(), _initState(), and _update(). |
|
Definition at line 136 of file abkMD5.h. Referenced by _finalize(), finalize(), operator unsigned(), operator Wrap128(), operator<<(), and update(). |
|
Definition at line 131 of file abkMD5.h. Referenced by _initState(), _transform(), getWord(), operator unsigned(), operator Wrap128(), operator<<(), and ~MD5(). |