# Generating Keys?

Chris Bergstresser (chris@subtlety.com)
Mon, 23 Feb 1998 17:54:55 -0500

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Previous message: Wen Yong: "Java Applet Source Code protection"

    Date: Mon, 23 Feb 1998 17:54:55 -0500

    To: java-security@web1.javasoft.com

    From: Chris Bergstresser <chris@subtlety.com>

    Subject: Generating Keys?

Hi all --

I'm having no luck following the RMI SSL directions on Sun's pages
(they're just wrong, among other problems) so I'm trying to write my own
socket class that encrypts and decrypts the data coming across it. I think
I've got how to do it worked out, but I'm having a terrible time figuring
out how to get a key pair. Here are my questions:

* I've run keytool, with "keytool -genkey -alias test -keypass password"
and there's now a key listed when I do "keytool -list". However, my code:

KeyStore keyStore = KeyStore.getInstance();
Key key = keyStore.getPrivateKey("test", "password");

returns null for the key. Should it? How do I get the key stored there?

* Does DES requires a public/private key pair? If so, how do I get the
public key from keytool? If not, how do I generate a single key?

* Trying to generate a key pair in code, I did the following:

Provider sunJce = new com.sun.crypto.provider.SunJCE();
Security.addProvider(sunJce);

KeyPairGenerator kpg = KeyPairGenerator.getInstance("DES");
KeyPair keyPair = kpg.generateKeyPair();

This throws a No Such Algorithm Exception. What am I doing wrong?

-- Chris Bergstresser
chris@subtlety.com

- Previous message: Wen Yong: "Java Applet Source Code protection"