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

Private and Public Keys and Related Interfaces

This section describes private and public key pairs used in RSA and DSA encryption algorithms. JDK supports private and public keys with the java.security.Key interface.

What a private and public key pair? A private and public key pair is a private key and a public key used in a public key encryption algorithm.

Known private and public key pair generation algorithms are:

- RSA - Developed by MIT professors: Ronald L. Rivest, Adi Shamir, and Leonard M. Adleman in 1977.
- DSA - The Digital Signature Algorithm.
- DiffieHellman

JDK supports private and pubic key pairs with 3 interfaces.

1. java.security.Key is the interface acting as a base to support common features of both private key and public key. Major methods include:

getAlgorithm() - Returns the algorithm name used to generate the key.

getEncoded() - Returns the key as a byte array in its primary encoding format, or null if this key does not support encoding.

getFormat() - Returns the name of the primary encoding format of this key, or null if this key does not support encoding.

2. java.security.PrivateKey is the interface representing a private key. It extends java.security.Key interface with no additional methods.

3. java.security.PublicKey is the interface representing a public key. It extends java.security.Key interface with no additional methods.

*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

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

►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

RSA Private Key and Public Key Pair Sample

DiffieHellman Private Key and Public Key Pair Sample

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)