74 MD5 (
unsigned char* buffer,
unsigned long len);
78 void update (
unsigned char *
input,
unsigned int input_length);
83 void raw_digest (
unsigned char *buff);
92 unsigned int state[4];
93 unsigned int count[2];
94 unsigned char buffer[64];
95 unsigned char digest[16];
96 unsigned char finalized;
100 void transform (
unsigned char *buffer);
103 static void encode (
unsigned char *
dest,
unsigned int *
src,
unsigned int length);
104 static void decode (
unsigned int *dest,
unsigned char *src,
unsigned int length);
107 static inline unsigned int rotate_left (
unsigned int x,
unsigned int n)
108 {
return (x << n) | (x >> (32-
n)); }
110 static inline unsigned int F(
unsigned int x,
unsigned int y,
unsigned int z)
111 {
return (x & y) | (~x &
z); }
112 static inline unsigned int G(
unsigned int x,
unsigned int y,
unsigned int z)
113 {
return (x & z) | (y & ~z); }
114 static inline unsigned int H(
unsigned int x,
unsigned int y,
unsigned int z)
115 {
return x ^ y ^
z; }
116 static inline unsigned int I(
unsigned int x,
unsigned int y,
unsigned int z)
117 {
return y ^ (x | ~z); }
121 static inline void FF (
unsigned int&
a,
unsigned int b,
unsigned int c,
unsigned int d,
unsigned int x,
unsigned int s,
unsigned int ac)
123 a += F(b, c, d) + x + ac;
124 a = rotate_left(a, s) +
b;
126 static inline void GG (
unsigned int& a,
unsigned int b,
unsigned int c,
unsigned int d,
unsigned int x,
unsigned int s,
unsigned int ac)
128 a += G(b, c, d) + x + ac;
129 a = rotate_left(a, s) +
b;
131 static inline void HH (
unsigned int& a,
unsigned int b,
unsigned int c,
unsigned int d,
unsigned int x,
unsigned int s,
unsigned int ac)
133 a += H(b, c, d) + x + ac;
134 a = rotate_left(a, s) +
b;
136 static inline void II (
unsigned int& a,
unsigned int b,
unsigned int c,
unsigned int d,
unsigned int x,
unsigned int s,
unsigned int ac)
138 a +=
I(b, c, d) + x + ac;
139 a = rotate_left(a, s) +
b;
150 MD5::MD5(
unsigned char* buffer,
unsigned long len) {
160 unsigned int idx,
index, space;
162 cerr <<
"MD5::update: Can't update a finalized digest!" << endl;
166 index = (
unsigned int)((
count[0] >> 3) & 0x3F);
168 if ( (
count[0] += ((
unsigned int) input_length << 3))<((
unsigned int) input_length << 3) )
171 count[1] += ((
unsigned int)input_length >> 29);
174 if (input_length >= space) {
176 memcpy (buffer + index, input, space);
179 for (idx = space; idx + 63 < input_length; idx += 64)
180 transform (input+idx);
189 memcpy(buffer+index, input+idx, input_length-idx);
194 void MD5::finalize () {
195 unsigned char bits[8];
196 unsigned int index, padLen;
197 static unsigned char PADDING[64]={
198 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
199 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
200 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
203 cerr <<
"MD5::finalize: Already finalized this digest!" << endl;
209 index = (
unsigned int) ((
count[0] >> 3) & 0x3f);
210 padLen = (index < 56) ? (56 - index) : (120 -
index);
217 memset (buffer, 0,
sizeof(*buffer));
222 void MD5::raw_digest(
unsigned char *
s){
224 memcpy(s, digest, 16);
227 cerr <<
"MD5::raw_digest: Can't get digest if you haven't "<<
228 "finalized the digest!" << endl;
231 string MD5::hex_digest() {
234 cerr <<
"MD5::hex_digest: Can't get digest if you haven't "<<
235 "finalized the digest!" <<endl;
238 for (
int i=0;
i<16;
i++)
239 sprintf(s+
i*2,
"%02x", digest[
i]);
251 state[0] = 0x67452301;
252 state[1] = 0xefcdab89;
253 state[2] = 0x98badcfe;
254 state[3] = 0x10325476;
258 void MD5::transform (
unsigned char*
block){
263 FF (a, b, c, d, x[ 0],
S11, 0xd76aa478);
264 FF (d, a, b, c, x[ 1],
S12, 0xe8c7b756);
265 FF (c, d, a, b, x[ 2],
S13, 0x242070db);
266 FF (b, c, d, a, x[ 3],
S14, 0xc1bdceee);
267 FF (a, b, c, d, x[ 4],
S11, 0xf57c0faf);
268 FF (d, a, b, c, x[ 5],
S12, 0x4787c62a);
269 FF (c, d, a, b, x[ 6],
S13, 0xa8304613);
270 FF (b, c, d, a, x[ 7],
S14, 0xfd469501);
271 FF (a, b, c, d, x[ 8],
S11, 0x698098d8);
272 FF (d, a, b, c, x[ 9],
S12, 0x8b44f7af);
273 FF (c, d, a, b, x[10],
S13, 0xffff5bb1);
274 FF (b, c, d, a, x[11],
S14, 0x895cd7be);
275 FF (a, b, c, d, x[12],
S11, 0x6b901122);
276 FF (d, a, b, c, x[13],
S12, 0xfd987193);
277 FF (c, d, a, b, x[14],
S13, 0xa679438e);
278 FF (b, c, d, a, x[15],
S14, 0x49b40821);
280 GG (a, b, c, d, x[ 1],
S21, 0xf61e2562);
281 GG (d, a, b, c, x[ 6],
S22, 0xc040b340);
282 GG (c, d, a, b, x[11],
S23, 0x265e5a51);
283 GG (b, c, d, a, x[ 0],
S24, 0xe9b6c7aa);
284 GG (a, b, c, d, x[ 5],
S21, 0xd62f105d);
285 GG (d, a, b, c, x[10],
S22, 0x2441453);
286 GG (c, d, a, b, x[15],
S23, 0xd8a1e681);
287 GG (b, c, d, a, x[ 4],
S24, 0xe7d3fbc8);
288 GG (a, b, c, d, x[ 9],
S21, 0x21e1cde6);
289 GG (d, a, b, c, x[14],
S22, 0xc33707d6);
290 GG (c, d, a, b, x[ 3],
S23, 0xf4d50d87);
291 GG (b, c, d, a, x[ 8],
S24, 0x455a14ed);
292 GG (a, b, c, d, x[13],
S21, 0xa9e3e905);
293 GG (d, a, b, c, x[ 2],
S22, 0xfcefa3f8);
294 GG (c, d, a, b, x[ 7],
S23, 0x676f02d9);
295 GG (b, c, d, a, x[12],
S24, 0x8d2a4c8a);
297 HH (a, b, c, d, x[ 5],
S31, 0xfffa3942);
298 HH (d, a, b, c, x[ 8],
S32, 0x8771f681);
299 HH (c, d, a, b, x[11],
S33, 0x6d9d6122);
300 HH (b, c, d, a, x[14],
S34, 0xfde5380c);
301 HH (a, b, c, d, x[ 1],
S31, 0xa4beea44);
302 HH (d, a, b, c, x[ 4],
S32, 0x4bdecfa9);
303 HH (c, d, a, b, x[ 7],
S33, 0xf6bb4b60);
304 HH (b, c, d, a, x[10],
S34, 0xbebfbc70);
305 HH (a, b, c, d, x[13],
S31, 0x289b7ec6);
306 HH (d, a, b, c, x[ 0],
S32, 0xeaa127fa);
307 HH (c, d, a, b, x[ 3],
S33, 0xd4ef3085);
308 HH (b, c, d, a, x[ 6],
S34, 0x4881d05);
309 HH (a, b, c, d, x[ 9],
S31, 0xd9d4d039);
310 HH (d, a, b, c, x[12],
S32, 0xe6db99e5);
311 HH (c, d, a, b, x[15],
S33, 0x1fa27cf8);
312 HH (b, c, d, a, x[ 2],
S34, 0xc4ac5665);
314 II (a, b, c, d, x[ 0],
S41, 0xf4292244);
315 II (d, a, b, c, x[ 7],
S42, 0x432aff97);
316 II (c, d, a, b, x[14],
S43, 0xab9423a7);
317 II (b, c, d, a, x[ 5],
S44, 0xfc93a039);
318 II (a, b, c, d, x[12],
S41, 0x655b59c3);
319 II (d, a, b, c, x[ 3],
S42, 0x8f0ccc92);
320 II (c, d, a, b, x[10],
S43, 0xffeff47d);
321 II (b, c, d, a, x[ 1],
S44, 0x85845dd1);
322 II (a, b, c, d, x[ 8],
S41, 0x6fa87e4f);
323 II (d, a, b, c, x[15],
S42, 0xfe2ce6e0);
324 II (c, d, a, b, x[ 6],
S43, 0xa3014314);
325 II (b, c, d, a, x[13],
S44, 0x4e0811a1);
326 II (a, b, c, d, x[ 4],
S41, 0xf7537e82);
327 II (d, a, b, c, x[11],
S42, 0xbd3af235);
328 II (c, d, a, b, x[ 2],
S43, 0x2ad7d2bb);
329 II (b, c, d, a, x[ 9],
S44, 0xeb86d391);
335 memset ( (
unsigned char *) x, 0,
sizeof(x));
340 void MD5::encode (
unsigned char *
output,
unsigned int *input,
unsigned int len) {
341 for (
unsigned int i = 0,
j = 0;
j < len;
i++,
j += 4) {
342 output[
j] = (
unsigned char) (input[
i] & 0xff);
343 output[j+1] = (
unsigned char) ((input[
i] >> 8) & 0xff);
344 output[j+2] = (
unsigned char) ((input[
i] >> 16) & 0xff);
345 output[j+3] = (
unsigned char) ((input[
i] >> 24) & 0xff);
351 void MD5::decode (
unsigned int *output,
unsigned char *input,
unsigned int len){
352 for (
unsigned int i = 0, j = 0; j < len;
i++, j += 4)
353 output[
i] = ((
unsigned int)input[j]) | (((
unsigned int)input[j+1]) << 8) |
354 (((
unsigned int)input[j+2]) << 16) | (((
unsigned int)input[j+3]) << 24);
358 void*
genMD5(
void* buffer,
unsigned long len,
void* code) {
359 MD5 checkSum((
unsigned char*)buffer, len);
360 checkSum.raw_digest((
unsigned char*)code);
363 void genMD5(
const string& s,
void* code) {
364 MD5 checkSum((
unsigned char*)s.c_str(), s.length());
365 checkSum.raw_digest((
unsigned char*)code);
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision bits
void * genMD5(void *buffer, unsigned long len, void *code)
bool decode(bool &, std::string const &)
const std::complex< double > I
block
Formating index page's pieces.