Skip to Content
Java Security
book

Java Security

by Scott Oaks
May 1998
Intermediate to advanced
469 pages
14h 57m
English
O'Reilly Media, Inc.
Content preview from Java Security

The KeyPairGenerator Class

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 KeyPairGenerator class (java.security.KeyPairGenerator):

public abstract class KeyPairGenerator

Generate and provide information about public/private key pairs.

In Java 1.1, this class extends only the Object class; in Java 1.2, this class extends the KeyPairGeneratorSpi class (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 KeyPairGeneratorSpi 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.

Using the KeyPairGenerator Class

Like all engine classes, the KeyPairGenerator is 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:

public static KeyPairGenerator getInstance(String algorithm), public static KeyPairGenerator getInstance(String algorithm, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java Security Handbook

Java Security Handbook

Jamie Jaworski, Paul J. Perrone, Venkata S.R. Krishna Chaganti

Publisher Resources

ISBN: 1565924037Supplemental ContentCatalog PageErrata