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.