# Q: using KeyPairGenerator with Cipher...

Kaan O. Erdener (kaan@cs.utexas.edu)
Wed, 23 Jul 1997 21:20:26 -0500 (CDT)

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Nitesh Varma: "JDK 1.1 signed applet example"
- Previous message: Fe Lisondra: "applet writing to a file"

    From: "Kaan O. Erdener" <kaan@cs.utexas.edu>

    Message-Id: <199707240220.VAA14169@roar.cs.utexas.edu>

    Subject: Q: using KeyPairGenerator with Cipher...

    To: java-security@web2.javasoft.com

    Date: Wed, 23 Jul 1997 21:20:26 -0500 (CDT)

I've got what seems to be a trivial problem. I want to generate a Cipher
object using a public key produced by KeyPairGenerator.

If I do:

KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance ("DSA");
keyPairGen.initialize (1024, new SecureRandom ());
KeyPair serverKeyPair = keyPairGen.generateKeyPair ();

then I'd like to do something like this:

Cipher ciph = Cipher.getInstance (serverPubKey.getAlgorithm ());
ciph.initEncrypt (serverPubKey);

but the Cipher.getInstance() throws a java.security.NoSuchAlgorithmException.

If I generate the key pair using "DES", the Cipher.getInstance() works
properly, but is never reached because KeyPairGenerator.getInstance() throws
a java.security.NoSuchAlgorithmException.

My goal is to create a Cipher object using a public key, and encrypt objects
across a socket. This is similar to an example by Marianne Mueller (JCE demo,
encrypt.java), but that example interestingly uses KeyGenerator, not
KeyPairGenerator.

Please advise of any misunderstandings or alternate steps I could follow.

Thank you,
Kaan Erdener

- Next message: Nitesh Varma: "JDK 1.1 signed applet example"
- Previous message: Fe Lisondra: "applet writing to a file"