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

Typical Pages:

Mukiply two numbers together. If the lengths of the two numbers are M and N, the
length of the result is (M+N).

int AK_RSA_Mul(unsigned short int ul],
unsigned short int v[],
unsigned short int w[])
{

• short int m,n,i,j,su, sv;
• unsigned int k,t;
• n = u & 32767; su = u >> 15;
• m= v & 32767; sv = v >> 15;

if (m == 0 || n == 0)
{

• w = 0;
• return (0);

}
for (i = m+; i <= m+n; i++) wli] = 0; for (j =m; j > 0; j–)
{

• k= 0;
• for (i =n; i > 0; i–)
{
• t= u[i] * v[j] + wla + 5] +k;
• w [i + j] = t & 65535;
• k= t >> 16;

}
w[j] =k;
}

• w = m+n;
• AK_RSA_Normalise (w);
• if (su != sv} w |= 32768;
• return(m + n);

}

Test if a specific bit is on or off. This is needed by the modular power routine to
determine whether to square and multiply, or just square.

int AK_RSA_Test_Bit (unsigned short int [ul],
short int bit)
{
• unsigned int k;
• k = ull + (bit>>4)) & (32768>>(bit & 15));
• if (k ! = 0) return(1);
• return (0);

}

The modular power routine is the basis for RSA encryption and decryption, so all
we have to do now is compute RSA key pairs!

int AK_RSA Mod_Power(unsigned short int Bas[],
unsigned short int Pow[],
unsigned short int Mod[],
unsigned short int Res[])
{
• short int i,m,n;
• unsigned short int q,t,w;
• Res = 1;
• Res = 1;
• for (4 = 0; i <= Bas; i++) t[i] = Bas[i];
• n = (Pow << 4) - 1;
• m = 0;
• while (AK_RSA_Test_Bit(Pow,m) == 0) m++;
• for (i =n; i >= m; i–)
{
• if (AK_RSA_Test_Bit (Pow, i) == 1)
• {

• if (Res == 1) AK_RSA Short _Mul(t,Res,w); else
AK_RSA_ Mul (Res, t,w);
AK_RSA_Div(w,Mod,q,Res};
• }

• AK_RSA Mul(t,t,w);
• AK_RSA_Div (x, Mod, q, t);

}
return (0);

}  