**Cryptography Tutorials - Herong's Tutorial Examples** - Version 5.34, by Dr. Herong Yang

Illustration of RSA Algorithm: p,q=5,7

This section provides a tutorial example to illustrate how RSA public key encryption algorithm works with 2 small prime numbers 5 and 7.

To demonstrate the RSA public key encryption algorithm, let's start it with 2 smaller prime numbers 5 and 7.

Generation the public key and private key with prime numbers of 5 and 7 can be illustrated as:

Given p as 5 Given q as 7 Compute n = p*q: n = 5*7 = 35 Compute m = (p-1)*(q-1): m = 4*6 = 24 Select e, such that e and m are coprime numbers: e = 5 Compute d, such that d*e mod m = 1: d = 29 The public key {n,e} is = {35,5} The private key {n,d} is = {35,29}

With the public key of {35,5}, encryption of a cleartext M represented as number 23 can be illustrated as:

Given public key {n,e} as {35,5} Given cleartext M represented in number as 23 Divide B into blocks: 1 block is enough Compute encrypted block C = M**e mod n: C = 23**5 mod 35 = 6436343 mod 35 = 18 The ciphertext C represented in number is 18

With the private key of {35,29}, decryption of the ciphertext C represented as number 18 can be illustrated as:

Given private key {n,e} as {35,29} Given ciphertext C represented in number as 18 Divide C into blocks: 1 block is enough Compute encrypted block M = C**d mod n: M = 18**29 mod 35 = 18*18**28 mod 35 = 18*(18**4)**7 mod 35 = 18*(104976)**7 mode 35 = 18*(104976 mod 35)**7 mod 35 = 18*(11)**7 mod 35 = 18*19487171 mod 35 = 350769078 mod 35 = 23 The cleartext M represented in number is 23

Cool. RSA public key encryption algorithm works. We are getting the original cleartext 23 back using the decryption algorithm and private key!

Notice that I had to compute "18**29 mod 35" in multiple steps, because 18**29 is too big to be computed directly.

*Last update: 2013.*

Table of Contents

Introduction to AES (Advanced Encryption Standard)

DES Algorithm - Illustrated with Java Programs

DES Algorithm Java Implementation

DES Algorithm - Java Implementation in JDK JCE

DES Encryption Operation Modes

PHP Implementation of DES - mcrypt

Blowfish - 8-Byte Block Cipher

Secret Key Generation and Management

Cipher - Secret Key Encryption and Decryption

►Introduction of RSA Algorithm

What Is Public Key Encryption?

RSA Public Key Encryption Algorithm

►Illustration of RSA Algorithm: p,q=5,7

Illustration of RSA Algorithm: p,q=7,19

Proof of RSA Public Key Encryption

Efficient RSA Encryption and Decryption Operations

Proof of RSA Encryption Operation Algorithm

RSA Implementation using java.math.BigInteger Class

Introduction of DSA (Digital Signature Algorithm)

Java Default Implementation of DSA

Private key and Public Key Pair Generation

PKCS#8/X.509 Private/Public Encoding Standards

Cipher - Public Key Encryption and Decryption

OpenSSL Introduction and Installation

OpenSSL Generating and Managing RSA Keys

OpenSSL Generating and Signing CSR

OpenSSL Validating Certificate Path

"keytool" and "keystore" from JDK

"OpenSSL" Signing CSR Generated by "keytool"

Migrating Keys from "keystore" to "OpenSSL" Key Files

Certificate X.509 Standard and DER/PEM Formats

Migrating Keys from "OpenSSL" Key Files to "keystore"

Using Certificates in IE (Internet Explorer)