# jce1.2 public-key encryption

Charles, Patrick (Patrick.Charles@fmr.com)
Wed, 11 Feb 1998 16:35:34 -0500

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Previous message: Jeff Nisewanger: "Re: Oracle Developer2000 and Java SSL ..."

    Message-Id: <199802112136.QAA23167@gate3.fmr.com>

    From: "Charles, Patrick" <Patrick.Charles@fmr.com>

    To: "'java-security@java.sun.com'" <java-security@web1.javasoft.com>

    Subject: jce1.2 public-key encryption

    Date: Wed, 11 Feb 1998 16:35:34 -0500

Where can I find a public-key encryption example using jce1.2?

Generating a key pair with default settings from a Diffie-Hellman
KeyPairGenerator
seems to lock up the vm indefinitely. Perhaps the default key is 'too'
long?

i.e.

public static void main(String[] args) throws Exception
{
String algorithmName = "DH";

try {
System.out.println("algorithmName: " + algorithmName);
KeyPairGenerator keyPairGenerator =
KeyPairGenerator.getInstance(algorithmName);
System.out.println("keyPairGenerator: " + keyPairGenerator);
KeyPair keyPair = keyPairGenerator.genKeyPair();
System.out.println("keyPair: " + keyPair);

// performASymmetricTest(algorithmName, keyPair, plainText);
}
catch(NoSuchAlgorithmException e) {
}

manually initializing the generator:
i.e. keyPairGenerator.initialize(1024, new SecureRandom());
avoids this problem, but it seems like the defaults should be more
reasonable.

(or is this not feasible because the key family parameters vary from
public-key algorithm to
algorithm?)

Anyway...

Second question: Cipher throws a NoSuchAlgorithmException when
requesting a "DH" or
"DSA" instance.
If Cipher is for use only with symmetric algorithms, how does one create
a
CipherInputStream for doing a public key encryption?

thanks,
-pat
Patrick.Charles@fmr.com

- Previous message: Jeff Nisewanger: "Re: Oracle Developer2000 and Java SSL ..."