Cryptography Tutorials - Herong's Tutorial Examples - Version 5.33, 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:
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