# 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 A comprehensive kit comprising an introductory presentation, a comprehensive guide, a detailed FAQ reference, an audit kit and base source for several algorithms.

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 += a; state += b; state += c;
state += d; state += e;
}

state += a; state += b; state += c;
state += d; state += e;
}

void Prepare_SH1 (

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

{

• int i;
• unsigned int state;
• unsigned char buffer ;
• 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.  