Cryptography Tutorials - Herong's Tutorial Examples - v5.42, by Herong Yang
Generating Private Keys
This section provides a tutorial example on how to use the 'keytool -genkey' command to generate a pair of private key and public key. This command also generates a self-signed certificate from the key pair.
The "keytool -genkey" command can be used to generate a pair of private key and public key. It can also be used to generate a self-signed certificate from the key pair.
In the first example, I want to try the "-genkey" command option:
herong> keytool -genkey -alias my_home -keystore herong.jks Enter keystore password: HerongJKS What is your first and last name? [Unknown]: Herong Yang What is the name of your organizational unit? [Unknown]: My Unit What is the name of your organization? [Unknown]: My Home What is the name of your City or Locality? [Unknown]: My City What is the name of your State or Province? [Unknown]: My State What is the two-letter country code for this unit? [Unknown]: US Is <CN=Herong Yang, OU=My Unit, O=My Home, L=My City, ST=My State, C=US> correct? [no]: yes Enter key password for <my_home> (RETURN if same as keystore password): My1stKey
Based on the documentation, the above example command did the following for me:
The following command shows that we do have a key entry in the keystore file:
herong> keytool -list -keystore herong.jks -storepass HerongJKS Keystore type: jks Keystore provider: SUN Your keystore contains 1 entry: my_home, Sat Jun 1 07:15:16 EDT 2002, keyEntry, Certificate fingerprint (MD5): BE:D2:AF:4E:A7:44:13:08:16:4C:68:3B:D1:99:79:55
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
Certificates and Certificate Chains
Exporting and Import Certificates
Generating CSR (Certificate Signing Request)
Cloning Certificates with New Identities
"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"