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

Private key and Public Key Pair Generation

This chapter provides tutorial notes and example codes on private key and public key pair generation. Topics include public key encryption algorithms, RSA, DSA and DiffieHellman; private key and public key pair generation class and sample program; RSA, DSA, and DiffieHellman key pair samples.

Private and Public Keys and Related Interfaces

KeyPair and KeyPairGenerator Classes

Key Pair Sample Program - JcaKeyPair.java

DSA Private Key and Public Key Pair Sample

Conclusion:

- JDK supports 3 algorithms to generate private and public pairs: RSA, DSA, and DiffieHellman.
- JDK allows you to store private keys in files with PKCS#8 encoded format.
- JDK allows you to store public keys in files with X.509 encoded format.

Sample programs listed in this chapter have been tested with JDK 1.3 to 1.6.

**Question**: Key pairs are used to encrypt and decrypt data.
But how to encrypt and decrypt data? Which classes and methods to use?

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

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)