#include <md5.h>
Collaboration diagram for MD5:

Definition at line 71 of file md5.h.
Public Member Functions | |
| MD5 () | |
| void | update (unsigned char *input, unsigned int input_length) |
| void | update (std::istream &stream) |
| void | update (FILE *file) |
| void | update (std::ifstream &stream) |
| void | finalize () |
| MD5 (unsigned char *string) | |
| MD5 (std::istream &stream) | |
| MD5 (FILE *file) | |
| MD5 (std::ifstream &stream) | |
| unsigned char * | raw_digest () |
| QString | hex_digest () |
Private Types | |
| typedef unsigned int | uint4 |
| typedef unsigned short int | uint2 |
| typedef unsigned char | uint1 |
Private Member Functions | |
| void | init () |
| void | transform (uint1 *buffer) |
Static Private Member Functions | |
| void | encode (uint1 *dest, uint4 *src, uint4 length) |
| void | decode (uint4 *dest, uint1 *src, uint4 length) |
| void | memcpy (uint1 *dest, uint1 *src, uint4 length) |
| void | memset (uint1 *start, uint1 val, uint4 length) |
| uint4 | rotate_left (uint4 x, uint4 n) |
| uint4 | F (uint4 x, uint4 y, uint4 z) |
| uint4 | G (uint4 x, uint4 y, uint4 z) |
| uint4 | H (uint4 x, uint4 y, uint4 z) |
| uint4 | I (uint4 x, uint4 y, uint4 z) |
| void | FF (uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) |
| void | GG (uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) |
| void | HH (uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) |
| void | II (uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) |
Private Attributes | |
| uint4 | state [4] |
| uint4 | count [2] |
| uint1 | buffer [64] |
| uint1 | digest [16] |
| uint1 | finalized |
|
|
Definition at line 99 of file md5.h. Referenced by decode(), encode(), finalize(), memcpy(), memset(), and raw_digest(). |
|
|
|
|
|
Definition at line 97 of file md5.h. Referenced by decode(), encode(), F(), FF(), finalize(), G(), GG(), H(), HH(), I(), II(), memcpy(), memset(), and rotate_left(). |
|
|
Definition at line 67 of file md5.cpp. References init().
00068 {
00069 init();
00070 }
|
|
|
|
|
|
Definition at line 242 of file md5.cpp. References finalize(), init(), and update().
|
|
|
Definition at line 232 of file md5.cpp. References finalize(), init(), and update().
|
|
|
Definition at line 251 of file md5.cpp. References finalize(), init(), and update().
|
|
||||||||||||||||
|
Definition at line 454 of file md5.cpp.
|
|
||||||||||||||||
|
Definition at line 437 of file md5.cpp. Referenced by finalize().
00437 {
00438
00439 unsigned int i, j;
00440
00441 for (i = 0, j = 0; j < len; i++, j += 4) {
00442 output[j] = (uint1) (input[i] & 0xff);
00443 output[j+1] = (uint1) ((input[i] >> 8) & 0xff);
00444 output[j+2] = (uint1) ((input[i] >> 16) & 0xff);
00445 output[j+3] = (uint1) ((input[i] >> 24) & 0xff);
00446 }
00447 }
|
|
||||||||||||||||
|
Definition at line 500 of file md5.cpp. References uint4. Referenced by FF().
00500 {
00501 return (x & y) | (~x & z);
00502 }
|
|
||||||||||||||||||||||||||||||||
|
Definition at line 522 of file md5.cpp. References F(), rotate_left(), and uint4.
00523 {
00524 a += F(b, c, d) + x + ac;
00525 a = rotate_left (a, s) +b;
00526 }
|
|
|
Definition at line 193 of file md5.cpp. References buffer, count, digest, encode(), finalized, memset(), state, uint1, uint4, and update(). Referenced by MD5().
00193 {
00194
00195 unsigned char bits[8];
00196 unsigned int index, padLen;
00197 static uint1 PADDING[64]={
00198 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00199 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00200 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
00201 };
00202
00203 if (finalized){
00204 std::cerr << "MD5::finalize: Already finalized this digest!" << std::endl;
00205 return;
00206 }
00207
00208 // Save number of bits
00209 encode (bits, count, 8);
00210
00211 // Pad out to 56 mod 64.
00212 index = (uint4) ((count[0] >> 3) & 0x3f);
00213 padLen = (index < 56) ? (56 - index) : (120 - index);
00214 update (PADDING, padLen);
00215
00216 // Append length (before padding)
00217 update (bits, 8);
00218
00219 // Store state in digest
00220 encode (digest, state, 16);
00221
00222 // Zeroize sensitive information
00223 memset (buffer, 0, sizeof(*buffer));
00224
00225 finalized=1;
00226
00227 }
|
|
||||||||||||||||
|
Definition at line 504 of file md5.cpp. References uint4. Referenced by GG().
00504 {
00505 return (x & z) | (y & ~z);
00506 }
|
|
||||||||||||||||||||||||||||||||
|
Definition at line 528 of file md5.cpp. References G(), rotate_left(), and uint4.
00529 {
00530 a += G(b, c, d) + x + ac;
00531 a = rotate_left (a, s) +b;
00532 }
|
|
||||||||||||||||
|
Definition at line 508 of file md5.cpp. References uint4. Referenced by HH().
00508 {
00509 return x ^ y ^ z;
00510 }
|
|
|
Definition at line 276 of file md5.cpp. References digest, and finalized. Referenced by filesMatch(), and getMD5().
00276 {
00277
00278 int i;
00279 char *s= new char[33];
00280
00281 if (!finalized){
00282 std::cerr << "MD5::hex_digest: Can't get digest if you haven't "<<
00283 "finalized the digest!" << std::endl;
00284 return "";
00285 }
00286
00287 for (i=0; i<16; i++)
00288 sprintf(s+i*2, "%02x", digest[i]);
00289
00290 s[32]='\0';
00291
00292 QString result(s);
00293 delete s;
00294 return result;
00295 }
|
|
||||||||||||||||||||||||||||||||
|
Definition at line 534 of file md5.cpp. References H(), rotate_left(), and uint4.
00535 {
00536 a += H(b, c, d) + x + ac;
00537 a = rotate_left (a, s) +b;
00538 }
|
|
||||||||||||||||
|
Definition at line 512 of file md5.cpp. References uint4. Referenced by II().
00512 {
00513 return y ^ (x | ~z);
00514 }
|
|
||||||||||||||||||||||||||||||||
|
Definition at line 540 of file md5.cpp. References I(), rotate_left(), and uint4.
00541 {
00542 a += I(b, c, d) + x + ac;
00543 a = rotate_left (a, s) +b;
00544 }
|
|
|
Definition at line 302 of file md5.cpp. References count, finalized, and state. Referenced by MD5().
00302 {
00303 finalized=0; // we just started!
00304
00305 // Nothing counted, so count=0
00306 count[0] = 0;
00307 count[1] = 0;
00308
00309 // Load magic initialization constants.
00310 state[0] = 0x67452301;
00311 state[1] = 0xefcdab89;
00312 state[2] = 0x98badcfe;
00313 state[3] = 0x10325476;
00314 }
|
|
||||||||||||||||
|
Definition at line 468 of file md5.cpp. Referenced by raw_digest().
00468 {
00469
00470 unsigned int i;
00471
00472 for (i = 0; i < len; i++)
00473 output[i] = input[i];
00474 }
|
|
||||||||||||||||
|
Definition at line 479 of file md5.cpp. Referenced by finalize().
00479 {
00480
00481 unsigned int i;
00482
00483 for (i = 0; i < len; i++)
00484 output[i] = value;
00485 }
|
|
|
Definition at line 260 of file md5.cpp. References digest, finalized, memcpy(), and uint1.
|
|
||||||||||||
|
Definition at line 491 of file md5.cpp. References uint4. Referenced by FF(), GG(), HH(), and II().
00491 {
00492 return (x << n) | (x >> (32-n)) ;
00493 }
|
|
|
|
|
|
Definition at line 171 of file md5.cpp. References buffer, and update().
|
|
|
Definition at line 124 of file md5.cpp. References buffer, and update().
|
|
|
Definition at line 150 of file md5.cpp. References buffer, and update().
|
|
||||||||||||
|
Referenced by finalize(), MD5(), and update(). |
|
|
Definition at line 104 of file md5.h. Referenced by finalize(), and update(). |
|
|
Definition at line 103 of file md5.h. Referenced by finalize(), and init(). |
|
|
Definition at line 105 of file md5.h. Referenced by finalize(), hex_digest(), and raw_digest(). |
|
|
Definition at line 106 of file md5.h. Referenced by finalize(), hex_digest(), init(), and raw_digest(). |
|
|
Definition at line 102 of file md5.h. Referenced by finalize(), and init(). |
1.3.4