SHA-1 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 SHA-1 algorithm. The following samples help to illustrate the depth and quality of this:

Typical Pages:

  • for (i = 20; i < 40; i++) {
    • x = ((a << 5) | (a >> 27)) + (b ^ c ^ d)
    • +e + W[i] + 0x6ed9ebal;
    • e=d;
    • d=c;
    • c = (b << 30) | (b >> 2);
    • b= a;
    • a= x;

    }

  • for (i = 40; i < 60; i++) {
    • x = ((a << 5) | (a >> 27)) + (b ^ c ^ d)
    • +e + W[i] + 0x8f1bbcdc;
    • e=d;
    • d=c;
    • c = (b << 30) | (b >> 2);
    • b= a;
    • a= x;

    }

  • for (i = 60; i < 80; i++) {
      x = ((a << 5) | (a >> 27)) + (b ^ c ^ d)

    • +e + W[i] + 0xca62c1d6;
    • e=d;
    • d=c;
    • c = (b << 30) | (b >> 2);
    • b= a;
    • a= x;

    }

state[0] += a; state[1] += b; state[2] += c;
state[3] += d; state[4] += e;
}

state[0] += a; state[1] += b; state[2] += c;
state[3] += d; state[4] += e;
}

void Prepare_SH1 (

  • unsigned int Key_Length,
    unsigned char Key[],
    unsigned char Pad,
    unsigned char KeyBlock[64],
    unsigned char Work_Area[96])

{

  • int i;
  • unsigned int state[7];
  • unsigned char buffer [64];
  • for (i = 0; i < 64; i++) KeyBlock[i] = 9;
  • if (Key_Length > 64)
    {
    • Hash_Init (state) ;
    • SHA1_Update (state, buffer, Key, Key_Length) ;
    • SHA1_Final (state, buffer, KeyBlock) ;

    }
    else

    • for (i = 0; i < (int) Key Length; i++)
    • ReyBlock[i] = Key[i];
    • for (i = 0; i < 64; i++) KeyBlock[i] ^= Pad;

    }

The next section shows how the various routines are combined into a convenient
implementation of the SHA-1 algorithm.

Notice how the message can be specified either in its entirety or as a sequence of
segments. Notice also how a segment length of zero is valid.

Return To Source Page