#include <md5.h>
Collaboration diagram for MD5:
Definition at line 65 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 93 of file md5.h. Referenced by finalize(), and raw_digest(). |
|
|
|
|
|
Definition at line 62 of file md5.cpp. References init(). 00063 { 00064 init(); 00065 }
|
|
|
|
Definition at line 237 of file md5.cpp. References finalize(), init(), and update(). 00237 { 00238 00239 init(); // must called by all constructors 00240 update (stream); 00241 finalize(); 00242 }
|
|
Definition at line 227 of file md5.cpp. References finalize(), init(), and update(). 00227 { 00228 00229 init(); // must be called be all constructors 00230 update(file); 00231 finalize (); 00232 }
|
|
Definition at line 246 of file md5.cpp. References finalize(), init(), and update(). 00246 { 00247 00248 init(); // must called by all constructors 00249 update (stream); 00250 finalize(); 00251 }
|
|
Definition at line 449 of file md5.cpp. 00449 { 00450 00451 unsigned int i, j; 00452 00453 for (i = 0, j = 0; j < len; i++, j += 4) 00454 output[i] = ((uint4)input[j]) | (((uint4)input[j+1]) << 8) | 00455 (((uint4)input[j+2]) << 16) | (((uint4)input[j+3]) << 24); 00456 }
|
|
Definition at line 432 of file md5.cpp. Referenced by finalize(). 00432 { 00433 00434 unsigned int i, j; 00435 00436 for (i = 0, j = 0; j < len; i++, j += 4) { 00437 output[j] = (uint1) (input[i] & 0xff); 00438 output[j+1] = (uint1) ((input[i] >> 8) & 0xff); 00439 output[j+2] = (uint1) ((input[i] >> 16) & 0xff); 00440 output[j+3] = (uint1) ((input[i] >> 24) & 0xff); 00441 } 00442 }
|
|
Definition at line 495 of file md5.cpp. Referenced by FF(). 00495 {
00496 return (x & y) | (~x & z);
00497 }
|
|
Definition at line 517 of file md5.cpp. References b, F(), and rotate_left(). 00518 { 00519 a += F(b, c, d) + x + ac; 00520 a = rotate_left (a, s) +b; 00521 }
|
|
Definition at line 188 of file md5.cpp. References buffer, count, digest, encode(), finalized, memset(), state, uint1, and update(). Referenced by MD5(). 00188 { 00189 00190 unsigned char bits[8]; 00191 unsigned int index, padLen; 00192 static uint1 PADDING[64]={ 00193 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 00194 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 00195 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 00196 }; 00197 00198 if (finalized){ 00199 std::cerr << "MD5::finalize: Already finalized this digest!" << std::endl; 00200 return; 00201 } 00202 00203 // Save number of bits 00204 encode (bits, count, 8); 00205 00206 // Pad out to 56 mod 64. 00207 index = (uint4) ((count[0] >> 3) & 0x3f); 00208 padLen = (index < 56) ? (56 - index) : (120 - index); 00209 update (PADDING, padLen); 00210 00211 // Append length (before padding) 00212 update (bits, 8); 00213 00214 // Store state in digest 00215 encode (digest, state, 16); 00216 00217 // Zeroize sensitive information 00218 memset (buffer, 0, sizeof(*buffer)); 00219 00220 finalized=1; 00221 00222 }
|
|
Definition at line 499 of file md5.cpp. Referenced by GG(). 00499 {
00500 return (x & z) | (y & ~z);
00501 }
|
|
Definition at line 523 of file md5.cpp. References b, G(), and rotate_left(). 00524 { 00525 a += G(b, c, d) + x + ac; 00526 a = rotate_left (a, s) +b; 00527 }
|
|
Definition at line 503 of file md5.cpp. Referenced by HH(). 00503 {
00504 return x ^ y ^ z;
00505 }
|
|
Definition at line 271 of file md5.cpp. References digest. Referenced by filesMatch(), and getMD5(). 00271 { 00272 00273 int i; 00274 char *s= new char[33]; 00275 00276 if (!finalized){ 00277 std::cerr << "MD5::hex_digest: Can't get digest if you haven't "<< 00278 "finalized the digest!" << std::endl; 00279 return ""; 00280 } 00281 00282 for (i=0; i<16; i++) 00283 sprintf(s+i*2, "%02x", digest[i]); 00284 00285 s[32]='\0'; 00286 00287 QString result(s); 00288 delete s; 00289 return result; 00290 }
|
|
Definition at line 529 of file md5.cpp. References b, H(), and rotate_left(). 00530 { 00531 a += H(b, c, d) + x + ac; 00532 a = rotate_left (a, s) +b; 00533 }
|
|
Definition at line 507 of file md5.cpp. Referenced by II(). 00507 {
00508 return y ^ (x | ~z);
00509 }
|
|
Definition at line 535 of file md5.cpp. References b, I(), and rotate_left(). 00536 { 00537 a += I(b, c, d) + x + ac; 00538 a = rotate_left (a, s) +b; 00539 }
|
|
Definition at line 297 of file md5.cpp. References count, finalized, and state. Referenced by MD5(). 00297 { 00298 finalized=0; // we just started! 00299 00300 // Nothing counted, so count=0 00301 count[0] = 0; 00302 count[1] = 0; 00303 00304 // Load magic initialization constants. 00305 state[0] = 0x67452301; 00306 state[1] = 0xefcdab89; 00307 state[2] = 0x98badcfe; 00308 state[3] = 0x10325476; 00309 }
|
|
Definition at line 463 of file md5.cpp. Referenced by raw_digest(). 00463 { 00464 00465 unsigned int i; 00466 00467 for (i = 0; i < len; i++) 00468 output[i] = input[i]; 00469 }
|
|
Definition at line 474 of file md5.cpp. Referenced by finalize(). 00474 { 00475 00476 unsigned int i; 00477 00478 for (i = 0; i < len; i++) 00479 output[i] = value; 00480 }
|
|
Definition at line 255 of file md5.cpp. References digest, memcpy(), and uint1. 00255 { 00256 00257 uint1 *s = new uint1[16]; 00258 00259 if (!finalized){ 00260 std::cerr << "MD5::raw_digest: Can't get digest if you haven't "<< 00261 "finalized the digest!" << std::endl; 00262 return ( (unsigned char*) ""); 00263 } 00264 00265 memcpy(s, digest, 16); 00266 return s; 00267 }
|
|
Definition at line 486 of file md5.cpp. Referenced by FF(), GG(), HH(), and II(). 00486 {
00487 return (x << n) | (x >> (32-n)) ;
00488 }
|
|
|
|
Definition at line 166 of file md5.cpp. References buffer, buffer, and update(). 00166 { 00167 00168 unsigned char buffer[1024]; 00169 int len; 00170 00171 while (stream.good()){ 00172 stream.read((char*)buffer, 1024); // note that return value of read is unusable. 00173 len=stream.gcount(); 00174 update(buffer, len); 00175 } 00176 00177 }
|
|
Definition at line 119 of file md5.cpp. References buffer, buffer, and update(). 00119 { 00120 00121 unsigned char buffer[1024]; 00122 int len; 00123 00124 while (true) 00125 { 00126 len=fread(buffer, 1, 1024, file); 00127 if(!len) 00128 { break; } 00129 00130 update(buffer, len); 00131 } 00132 00133 fclose (file); 00134 00135 }
|
|
Definition at line 145 of file md5.cpp. References buffer, buffer, and update(). 00145 { 00146 00147 unsigned char buffer[1024]; 00148 int len; 00149 00150 while (stream.good()){ 00151 stream.read((char*)buffer, 1024); // note that return value of read is unusable. 00152 len=stream.gcount(); 00153 update(buffer, len); 00154 } 00155 00156 }
|
|
Referenced by finalize(), MD5(), and update(). |
|
Definition at line 98 of file md5.h. Referenced by finalize(), and update(). |
|
Definition at line 97 of file md5.h. Referenced by finalize(), and init(). |
|
Definition at line 99 of file md5.h. Referenced by finalize(), hex_digest(), and raw_digest(). |
|
Definition at line 100 of file md5.h. Referenced by finalize(), and init(). |
|
Definition at line 96 of file md5.h. Referenced by finalize(), and init(). |