Re: JCE 1.2, KeyPairGenerator

Sharon Liu (Sharon.Liu@Eng)
Mon, 4 Jan 1999 16:13:41 -0800 (PST)

Paul,

The class "KeyPairGenerator" is in the package java.security
in JDK - it isn't in JCE.

> In the list of all interfaces and classes, "KeyPairGenerator" is not
> listed, ...

I guess you only checked the APIs for JCE 1.2. Please check the
APIs for JDK 1.2, you will see "KeyPairGenerator" class in the
java.security package.

If you are using the default security provider from Sun, that provider
has implemented a KeyPairGenerator for DSA. You can do the following
to get a key pair for DSA:

KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA");
// There are several methods for initializing a key pair generator.
// Check out the doc to pick the one you want.
keyGen.initialize(1024);
KeyPair pair = keyGen.generateKeyPair();

If you'd like to get a RSA key pair, make sure at least one of your security
providers has implemented a RSA key pair generator; otherwise, you'll get
"NoSuchAlgorithmException".

Sharon

> To: "'java-security@java.sun.com'" <java-security@java.sun.com>
> Subject: JCE 1.2, KeyPairGenerator
> X-Priority: 3
> MIME-Version: 1.0
>
> Dear Sir or Madam:
>
> I have noticed a slight inconsistency in your documentation, and I
> need a
> clarification:
>
> In the list of all interfaces and classes, "KeyPairGenerator" is not
> listed, and any
> code I compile making reference to "KeyPairGenerator" says that the
> class isn't
> available; this leads me to believe that KeyPairGenerator is no longer
> supported.
>
> However, there are numerous references to KeyPairGenerator throughout
> other
> sections of the documentation, even in the sample source code.
>
> Is KeyPairGenerator still implemented, and if so, how do I go about
> implementing
> it?
>
> Sincerest thanks for your time,
> Paul Wright
>
>
> ----------------
> "We mathematicians are all a little bit crazy." -Edmund Landau