#include <md5.h>
Definition at line 73 of file md5.h.
Public Member Functions | |
MD5 () | |
void | update (unsigned char *input, unsigned int input_length) |
void | update (istream &stream) |
void | update (FILE *file) |
void | update (ifstream &stream) |
void | finalize () |
MD5 (unsigned char *string) | |
MD5 (istream &stream) | |
MD5 (FILE *file) | |
MD5 (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 101 of file md5.h. Referenced by encode(), finalize(), and raw_digest(). |
|
|
|
Definition at line 99 of file md5.h. Referenced by decode(), and finalize(). |
|
Definition at line 65 of file md5.cpp. References init().
00066 { 00067 init(); 00068 } |
|
|
|
Definition at line 240 of file md5.cpp. References finalize(), init(), and update().
|
|
Definition at line 230 of file md5.cpp. References finalize(), init(), and update().
|
|
Definition at line 249 of file md5.cpp. References finalize(), init(), and update().
|
|
Definition at line 452 of file md5.cpp. References uint4.
|
|
Definition at line 435 of file md5.cpp. References uint1. Referenced by finalize().
00435 { 00436 00437 unsigned int i, j; 00438 00439 for (i = 0, j = 0; j < len; i++, j += 4) { 00440 output[j] = (uint1) (input[i] & 0xff); 00441 output[j+1] = (uint1) ((input[i] >> 8) & 0xff); 00442 output[j+2] = (uint1) ((input[i] >> 16) & 0xff); 00443 output[j+3] = (uint1) ((input[i] >> 24) & 0xff); 00444 } 00445 } |
|
Definition at line 498 of file md5.cpp. Referenced by FF().
00498 {
00499 return (x & y) | (~x & z);
00500 }
|
|
Definition at line 520 of file md5.cpp. References F(), and rotate_left().
00521 { 00522 a += F(b, c, d) + x + ac; 00523 a = rotate_left (a, s) +b; 00524 } |
|
Definition at line 191 of file md5.cpp. References buffer, count, digest, encode(), finalized, memset(), state, uint1, uint4, and update(). Referenced by MD5().
00191 { 00192 00193 unsigned char bits[8]; 00194 unsigned int index, padLen; 00195 static uint1 PADDING[64]={ 00196 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 00197 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 00198 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 00199 }; 00200 00201 if (finalized){ 00202 cerr << "MD5::finalize: Already finalized this digest!" << endl; 00203 return; 00204 } 00205 00206 // Save number of bits 00207 encode (bits, count, 8); 00208 00209 // Pad out to 56 mod 64. 00210 index = (uint4) ((count[0] >> 3) & 0x3f); 00211 padLen = (index < 56) ? (56 - index) : (120 - index); 00212 update (PADDING, padLen); 00213 00214 // Append length (before padding) 00215 update (bits, 8); 00216 00217 // Store state in digest 00218 encode (digest, state, 16); 00219 00220 // Zeroize sensitive information 00221 memset (buffer, 0, sizeof(*buffer)); 00222 00223 finalized=1; 00224 00225 } |
|
Definition at line 502 of file md5.cpp. Referenced by GG().
00502 {
00503 return (x & z) | (y & ~z);
00504 }
|
|
Definition at line 526 of file md5.cpp. References G(), and rotate_left().
00527 { 00528 a += G(b, c, d) + x + ac; 00529 a = rotate_left (a, s) +b; 00530 } |
|
Definition at line 506 of file md5.cpp. Referenced by HH().
00506 {
00507 return x ^ y ^ z;
00508 }
|
|
Definition at line 274 of file md5.cpp. References digest, and finalized. Referenced by filesMatch(), and getMD5().
00274 { 00275 00276 int i; 00277 char *s= new char[33]; 00278 00279 if (!finalized){ 00280 cerr << "MD5::hex_digest: Can't get digest if you haven't "<< 00281 "finalized the digest!" <<endl; 00282 return ""; 00283 } 00284 00285 for (i=0; i<16; i++) 00286 sprintf(s+i*2, "%02x", digest[i]); 00287 00288 s[32]='\0'; 00289 00290 QString result(s); 00291 delete s; 00292 return result; 00293 } |
|
Definition at line 532 of file md5.cpp. References H(), and rotate_left().
00533 { 00534 a += H(b, c, d) + x + ac; 00535 a = rotate_left (a, s) +b; 00536 } |
|
Definition at line 510 of file md5.cpp. Referenced by II().
00510 {
00511 return y ^ (x | ~z);
00512 }
|
|
Definition at line 538 of file md5.cpp. References I(), and rotate_left().
00539 { 00540 a += I(b, c, d) + x + ac; 00541 a = rotate_left (a, s) +b; 00542 } |
|
Definition at line 300 of file md5.cpp. References count, finalized, and state. Referenced by MD5().
00300 { 00301 finalized=0; // we just started! 00302 00303 // Nothing counted, so count=0 00304 count[0] = 0; 00305 count[1] = 0; 00306 00307 // Load magic initialization constants. 00308 state[0] = 0x67452301; 00309 state[1] = 0xefcdab89; 00310 state[2] = 0x98badcfe; 00311 state[3] = 0x10325476; 00312 } |
|
Definition at line 466 of file md5.cpp. Referenced by raw_digest().
00466 { 00467 00468 unsigned int i; 00469 00470 for (i = 0; i < len; i++) 00471 output[i] = input[i]; 00472 } |
|
Definition at line 477 of file md5.cpp. Referenced by finalize().
00477 { 00478 00479 unsigned int i; 00480 00481 for (i = 0; i < len; i++) 00482 output[i] = value; 00483 } |
|
Definition at line 258 of file md5.cpp. References digest, finalized, memcpy(), and uint1.
|
|
Definition at line 489 of file md5.cpp. Referenced by FF(), GG(), HH(), and II().
00489 {
00490 return (x << n) | (x >> (32-n)) ;
00491 }
|
|
|
|
Definition at line 169 of file md5.cpp. References buffer, and update().
|
|
Definition at line 122 of file md5.cpp. References buffer, and update().
|
|
Definition at line 148 of file md5.cpp. References buffer, and update().
|
|
Referenced by finalize(), MD5(), and update(). |
|
Definition at line 106 of file md5.h. Referenced by finalize(), and update(). |
|
Definition at line 105 of file md5.h. Referenced by finalize(), and init(). |
|
Definition at line 107 of file md5.h. Referenced by finalize(), hex_digest(), and raw_digest(). |
|
Definition at line 108 of file md5.h. Referenced by finalize(), hex_digest(), init(), and raw_digest(). |
|
Definition at line 104 of file md5.h. Referenced by finalize(), and init(). |