Generation of public and private keys is one of
the standard engines that can be provided by a Java security
provider. This operation is provided by the
Generate and provide information about public/private key pairs.
In Java 1.1, this class extends only the
class; in Java 1.2, this class extends the
java.security.KeyPairGeneratorSpi). As is usual
with this architecture, some of the methods we’re going to use
are methods of the
KeyPairGenerator class in
Java 1.1 and methods of the
class in 1.2; for the developer, the end result is the same.
Generating a key pair is a very time-consuming operation. Fortunately, it does not need to be performed often; much of the time, we obtain keys from a key management system rather than generating them. However, when we establish our own key management system in the next chapter, we’ll need to use this class; it is often easier to generate your own keys from scratch rather than use a key management system as well.
Like all engine classes, the
an abstract class for which there is no implementation in the core
API. However, it is possible to retrieve instances of the
KeyPairGenerator class via these methods: