"keytool" Generating Maria's Private Key

This section provides a tutorial example on how to use 'keytool' to generate a pair of private key and public key.

In this section, let's assume that Maria is using the "keytool". She wants to have her own private key to sign documents. But she needs her public key certificate to be signed by me, Herong, because other people trust me instead of Maria.

So Maria starts to generate her own private key and store it in a "keystore" file. This can be done by a single "keytool -genkeypair" command as shown in the following command session:

herong> java -version

javaversion "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode,
  sharing)
  
herong> keytool -genkeypair -alias maria_key -keysize 1024 
   -keystore maria.jks -storepass jkspass -keypass keypass
What is your first and last name?
  [Unknown]:  Maria Teresa
What is the name of your organizational unit?
  [Unknown]:  Maria Unit
What is the name of your organization?
  [Unknown]:  Maria Company
What is the name of your City or Locality?
  [Unknown]:  Maria City
What is the name of your State or Province?
  [Unknown]:  Maria State
What is the two-letter country code for this unit?
  [Unknown]:  AT
Is CN=Maria Teresa, OU=Maria Unit, O=Maria Company, L=Maria City, 
ST=Maria State, C=AT correct?
  [no]:  yes

Here is what Maria did:

Want to confirm that Maria's key pair is in the keystore file? Try this command:

herong> keytool -list -keystore maria.jks -storepass jkspass

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 1 entry

maria_key, Apr 1, 2007, PrivateKeyEntry,
Certificate fingerprint (MD5): 54:5A:E8:77:30:82:B4:EB:C...

Now Maria is ready to generate a CSR (Certificate Sign Request) to ask me as a CA to sign it as described in the next section.

Table of Contents

 About This Book

 Cryptography Terminology

 Cryptography Basic Concepts

 Introduction to AES (Advanced Encryption Standard)

 Introduction to DES Algorithm

 DES Algorithm - Illustrated with Java Programs

 DES Algorithm Java Implementation

 DES Algorithm - Java Implementation in JDK JCE

 DES Encryption Operation Modes

 DES in Stream Cipher 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

 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

 MD5 Mesasge Digest Algorithm

 SHA1 Mesasge Digest Algorithm

 OpenSSL Introduction and Installation

 OpenSSL Generating and Managing RSA Keys

 OpenSSL Managing Certificates

 OpenSSL Generating and Signing CSR

 OpenSSL Validating Certificate Path

 "keytool" and "keystore" from JDK

"OpenSSL" Signing CSR Generated by "keytool"

 "OpenSSL" Acting as a CA (Certificate Authority)

 "OpenSSL" Generating CA's Private Key

 "OpenSSL" Self-Signing CA's Public Key

"keytool" Generating Maria's Private Key

 "keytool" Generating Maria's CSR

 "OpenSSL" Signing Maria's CSR

 "OpenSSL" Managing Serial Numbers when Signing CSR

 "keytool" Importing CA's Own Certificate

 ""keytool" Importing Maria's Certificate Signed by CA

 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

 Using Certificates in Google Chrome

 Using Certificates in Firefox

 Archived Tutorials

 References

 Full Version in PDF/EPUB