MD5 Source

CRYPTOGRAPHY MANAGEMENT KIT CONTENTS

A Guide to Cryptography

A complete introduction to cryptography and its application.

Training Presentation

A full 'executive' presentation explaining both background and practical issues.

Microgaming Security

The main Microgaming security technologies in gambling industry.

Cryptography Audit Kit

Designed specifically to help you audit a cryptographic based system or application.

Cryptography FAQ Sheets

A unique reference covering the full gamut of issues in simple Q&A style.

Source Library for Base Algorithms Example source code,for: Why re-invent the wheel?

NEXT STEP

The Cryptography Management Kit

Cryptography Tutorial and Management Kit

A comprehensive kit comprising an introductory presentation, a comprehensive guide, a detailed FAQ reference, an audit kit and base source for several algorithms.

Purchase and Download For

Only $199

The Cryptography Management Kit includes basic sample source code for the MD5 algorithm. The following samples help to illustrate the depth and quality of this:

Typical Pages:

    #define MDS_FLAG
    #ifndef SHA1_FLAG

  • Static unsigned char padding[64] = {128,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

  • void PutWrk(unsigned int state[7],
    unsigned char buffer[64],
    unsigned char Work_Area[96])
  • {
    • int i,j;
    • j = 0;
    • for (i = 0; i <7; i++)
    • {

    • Work_Area[jt+] = state[i] & 255;
    • Work_Area[jt+] = (state[i] >> 8) & 255;
    • Work_Area[jt+] = (state[i] >> 16) & 255;
    • Work_Area[jt+] = (state[i] >> 24) & 255;
    • }

    • for (i = 0; i < 64; i++) Work_Area[j++] = buffer[i];
    • for (i = 92; i < 96; i++) Work_Area[i] = 255;

    }

  • int GetWrk(unsigned int state[7],
    unsigned char buffer[64],
    unsigned char Work_Area[96])
  • {
    • int i,j;
    • j = 0;
    • for (i = 0; i <7; i++)
    • {
      • state[i] = Work_Area[j] |
      • (Work_Area[j+1] << 8) |
      • (Work_Area[j+2] << 16) |
      • (Work_Area[j+3] << 24);

      i+ 4;

    • }

    • for (i = 0; i < 64; i++) buffer[i] = Work_Area[j++];
    • return (0);

    }

  • void Hash_Init (unsigned int state[7])
    {
    state[0] = 0x67452301;
    state[1] = 0xefcdabs9;
    state[2] = 0x98badcfe;
    state[3] = 010325476;
    state[4] = 0xc3dze1£0;
    state[S] = 0; state[6] = 0;
    }
    #endift

void MDS_Transform(unsigned int state[7],
unsigned char blk[64])

{

  • unsigned int a,b,e,d,x[16];
    aint i;
    a = state[0]; b = state[1]; ¢ = state[2]; d = state[3];

  • x[0] = blk[0] | (blk[1]<<8) | (blk[2]<<16) | (blk[3]<<24);
  • x[1] = blk[4] | (blk[S]<<8) | (blk[6]<<16) | (blk[7]<<24);
  • x[2] = blk[6] | (blk[9]<<8) | (blk[10]<<16 | (blk[11]<<24);
  • x[3] = blk[12] | (blk[13]<<8) | (blk[14]<<16) | (blk[15]<<24);
  • x[4] = blk[16] | (blk[17]<<8) | (blk[18]<<16) | (blk[19]<<24);
  • x[5] = blk[20] | (blk[21]<<8) | (blk[22]<<16) | (blk[23]<<24);
  • x[6] = blk[24] | (blk[25]<<8) | (blk[26]<<16) | (blk[27]<<24);
  • x[7] = blk[28] | (blk[29]<<8) | (blk[30]<<16 | (blk[31]<<24);
  • x[8] = blk[32] | (blk[33]<<8) | (blk[34]<<16) | (blk[35]<<24);
  • x[9] = blk[36] | (blk[37]<<8) | (blk[36]<<16) | (blk[39]<<24);
  • x[10] = blk[40] | (blk[41]<<8) | (blk[42]<<16) | (blk[43]<<24);
  • x[11] = blk[44] | (blk[45]<<8) | (blk[46]<<16) | (blk[47]<<24);
  • x[12] = blk[48] | (blk[49]<<8) | (blk[50]<<16) | (blk[51]<<24);
  • x[13] = blk[52] | (blk[53]<<8) | (blk[54]<<16) | (blk[55]<<24);
  • x[14] = blk[56] | (blk[57]<<8) | (blk[58]<<16) | (blk[59]<<24);
  • x[15] = blk[60] | (blk[61]<<8) | (blk[EZ]<<16) | (blk[63]<<24);

  • FF(a,b,c,d,x[ 0],S11, 0xd76aa478) ;
    FF(d,a,b,c,x[ 1],S12, 0xe8c7b756) ;
    FF(c,d,a,b,x[ 2],S13, 0x242070db) ;
    FF(b,c,d,a,x[ 3],S14, 0xc1bdceee) ;
    FF(a,b,c,d,x[ 4],S11, 0xf57c0faf) ;
    FE(d,a,b,c,x[ 5],S12, 0x4787c62a) ;
    FF(c,d,a,b,x[ 6],S13, 0xa8304613) ;
    FF(b,c,d,a,x[ 7],S14, 0xfd469501) ;
    FF(a-b,c,d,x[ 8],S11, 0x698098d8) ;
    FF(d,asb,c,x[ 9],S12, 0x8b44f7af) ;
    FF(c,d,a,b,x[10],S13, 0xfffE5bb1) ;
    FF(b,c,d,a,x[11],S14, 0x895cd7be) ;
    FF(a,b,c,d,x[12],S11, 0x6b901122) ;
    FF(d,a,b,c,x[13],S12, 0xfd987193) ;
    FF(c,d,a,b,x[14],S13, 0xa679438e) ;
    FF(b,c,d,a,x[15],S14, 0x49b40821) ;

  • GG(a,b,c,d,x[ 1], S21, 0xf61e2562);
    GG(d,a,b,c,x[ 6], S22, 0xc040b340);
    GG(c,d,a,b,x[11], S23, 0x265e5a51);
    GG(b,c,d,a,x[ 0], S24, 0xe9b6c7aa);
    GG(a,b,c,d,x[ 5], S21, 0xd62f105d);
    GG(d,a,b,c,x[10], S22, 0x02441453);
    GG(c,d,a,b,x[15], S23, 0xd8a1e681);
    GG(b,c,d,a,x[ 4], S24, 0xe7d3fbc8);
    GG(asb,c,d,x[ 9], S21, 0x21e1cde6);
    GG(d,a,b,c,x[14], S22, 0xc33707d6);
    GG(c,d,a,b,x[ 3], S23, 0xf4d50d67);
    GG(b,c,d,a,x[ 8], S24, 0x455a14ed);
    GG(a,b,c,d,x[13], S21, 0xade3e905);
    GG(d,a,b,c,x[ 2], S22, 0xfcefa3f6);
    GG(c,d,a,b,x[ 7], S23, 0x676f02d9);
    GG(b,c,d,a,x[12], S24, 0x8d2a4c8a);

Return To Source Page