| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Gaudi::Math::MD5::md5_engine Class Reference

List of all members.

Public Member Functions

 md5_engine ()
 ~md5_engine ()
Gaudi::Math::MD5 digest (const char *a_data=0)

Private Member Functions

void update (const void *a_data, boost::uint32_t a_data_size)
void process_block (const boost::uint8_t(*a_block)[64])

Private Attributes

boost::uint32_t state [4]
boost::uint32_t count [2]
boost::uint8_t buffer [64]

Detailed Description

Definition at line 41 of file MD5.cpp.


Constructor & Destructor Documentation

Gaudi::Math::MD5::md5_engine::md5_engine (  )  [inline]

Definition at line 44 of file MD5.cpp.

00044 {}

Gaudi::Math::MD5::md5_engine::~md5_engine (  )  [inline]

Definition at line 45 of file MD5.cpp.

00045 {}


Member Function Documentation

Gaudi::Math::MD5 Gaudi::Math::MD5::md5_engine::digest ( const char *  a_data = 0  ) 

Definition at line 268 of file MD5.cpp.

00269 {
00270     count[0] = 0;
00271     count[1] = 0;
00272 
00273     state[0] = 0x67452301;
00274     state[1] = 0xefcdab89;
00275     state[2] = 0x98badcfe;
00276     state[3] = 0x10325476;
00277 
00278     if (a_data!=0) update(a_data,strlen(a_data));
00279 
00280     
00281     static const boost::uint8_t padding[64] =
00282     {
00283         0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00284         0x00, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00285         0x00, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00286         0x00, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
00287     };
00288 
00289     // Save number of bits.
00290     boost::uint8_t saved_count[8];
00291     pack(saved_count, count, 8);
00292 
00293     // Pad out to 56 mod 64.
00294     boost::uint32_t index = static_cast<boost::uint32_t>((count[0] >> 3) & 0x3f);
00295     boost::uint32_t padding_size = (index < 56) ? (56 - index) : (120 - index);
00296     update(padding, padding_size);
00297 
00298     // Append size before padding.
00299     update(saved_count, 8);
00300 
00301     // Store state in digest.
00302     MD5::value_type digest;
00303     pack(digest, state, sizeof(digest));
00304     return MD5(digest);
00305 }

void Gaudi::Math::MD5::md5_engine::update ( const void *  a_data,
boost::uint32_t  a_data_size 
) [private]

Definition at line 232 of file MD5.cpp.

00233 {
00234     // Compute number of bytes mod 64.
00235     boost::uint32_t buffer_index = static_cast<boost::uint32_t>((count[0] >> 3) & 0x3f);
00236 
00237     // Update number of bits.
00238     count[0] += (static_cast<boost::uint32_t>(a_data_size) << 3);
00239     if (count[0] < (static_cast<boost::uint32_t>(a_data_size) << 3))
00240         ++count[1];
00241 
00242     count[1] += (static_cast<boost::uint32_t>(a_data_size) >> 29);
00243 
00244     boost::uint32_t buffer_space = 64-buffer_index;  // Remaining buffer space.
00245 
00246     boost::uint32_t input_index;
00247 
00248     // Transform as many times as possible.
00249     if (a_data_size >= buffer_space) {
00250         memcpy(buffer+buffer_index, a_data, buffer_space);
00251         process_block(&buffer);
00252 
00253         for (input_index = buffer_space; input_index+63 < a_data_size; input_index += 64) {
00254             process_block(reinterpret_cast<const boost::uint8_t (*)[64]>(
00255                 reinterpret_cast<const boost::uint8_t*>(a_data)+input_index));
00256         }
00257 
00258         buffer_index = 0;
00259     } else {
00260         input_index = 0;
00261     }
00262 
00263     // Buffer remaining input.
00264     memcpy(buffer+buffer_index, reinterpret_cast<
00265         const boost::uint8_t*>(a_data)+input_index, a_data_size-input_index);
00266 }

void Gaudi::Math::MD5::md5_engine::process_block ( const boost::uint8_t *  a_block[64]  )  [private]

Definition at line 309 of file MD5.cpp.

00310 {
00311     boost::uint32_t a(state[0]);
00312     boost::uint32_t b(state[1]);
00313     boost::uint32_t c(state[2]);
00314     boost::uint32_t d(state[3]);
00315 
00316     /*volatile*/ boost::uint32_t x[16];
00317 
00318     unpack(x, reinterpret_cast<const boost::uint8_t*>(a_block), 64);
00319 
00320     // Round 1.
00321     FF(a, b, c, d, x[ 0], S11, 0xd76aa478); /*  1 */
00322     FF(d, a, b, c, x[ 1], S12, 0xe8c7b756); /*  2 */
00323     FF(c, d, a, b, x[ 2], S13, 0x242070db); /*  3 */
00324     FF(b, c, d, a, x[ 3], S14, 0xc1bdceee); /*  4 */
00325     FF(a, b, c, d, x[ 4], S11, 0xf57c0faf); /*  5 */
00326     FF(d, a, b, c, x[ 5], S12, 0x4787c62a); /*  6 */
00327     FF(c, d, a, b, x[ 6], S13, 0xa8304613); /*  7 */
00328     FF(b, c, d, a, x[ 7], S14, 0xfd469501); /*  8 */
00329     FF(a, b, c, d, x[ 8], S11, 0x698098d8); /*  9 */
00330     FF(d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
00331     FF(c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
00332     FF(b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
00333     FF(a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
00334     FF(d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
00335     FF(c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
00336     FF(b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
00337 
00338     // Round 2.
00339     GG(a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
00340     GG(d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
00341     GG(c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
00342     GG(b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
00343     GG(a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
00344     GG(d, a, b, c, x[10], S22,  0x2441453); /* 22 */
00345     GG(c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
00346     GG(b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
00347     GG(a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
00348     GG(d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
00349     GG(c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
00350     GG(b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
00351     GG(a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
00352     GG(d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
00353     GG(c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
00354     GG(b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
00355 
00356     // Round 3.
00357     HH(a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
00358     HH(d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
00359     HH(c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
00360     HH(b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
00361     HH(a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
00362     HH(d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
00363     HH(c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
00364     HH(b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
00365     HH(a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
00366     HH(d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
00367     HH(c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
00368     HH(b, c, d, a, x[ 6], S34,  0x4881d05); /* 44 */
00369     HH(a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
00370     HH(d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
00371     HH(c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
00372     HH(b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
00373 
00374     // Round 4.
00375     II(a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
00376     II(d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
00377     II(c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
00378     II(b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
00379     II(a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
00380     II(d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
00381     II(c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
00382     II(b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
00383     II(a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
00384     II(d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
00385     II(c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
00386     II(b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
00387     II(a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
00388     II(d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
00389     II(c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
00390     II(b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
00391 
00392     state[0] += a;
00393     state[1] += b;
00394     state[2] += c;
00395     state[3] += d;
00396 
00397     // Zeroize sensitive information.
00398     memset(reinterpret_cast<boost::uint8_t*>(x), 0, sizeof(x));
00399 }


Member Data Documentation

boost::uint32_t Gaudi::Math::MD5::md5_engine::state[4] [private]

Definition at line 58 of file MD5.cpp.

boost::uint32_t Gaudi::Math::MD5::md5_engine::count[2] [private]

Definition at line 59 of file MD5.cpp.

boost::uint8_t Gaudi::Math::MD5::md5_engine::buffer[64] [private]

Definition at line 60 of file MD5.cpp.


The documentation for this class was generated from the following file:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:02:58 2011 for LHCbMath by doxygen 1.4.7