# Problem with SecureRandom call

Jessica Mauvais (jessicam@llnl.gov)
Tue, 03 Feb 1998 14:04:09 -0800

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Jan Luehe: "Re: Problem with SecureRandom call"
- Previous message: Jan Luehe: "Re: java.security.Security.insertProviderAt() in appletviewer"
- Next in thread: Jan Luehe: "Re: Problem with SecureRandom call"

    Message-Id: <3.0.5.32.19980203140409.00979100@popeye.llnl.gov>

    Date: Tue, 03 Feb 1998 14:04:09 -0800

    To: java-security@web1.javasoft.com

    From: Jessica Mauvais <jessicam@llnl.gov>

    Subject: Problem with SecureRandom call

I've tried out the example ( see attched ) of the "Key Agreement Example"
from jce12-ea-dom/doc/guide/JceSpec.html. I got this error message:

java.lang.InternalError: internal error: SHA-1 not available.
at java.security.SecureRandom.<init>(SecureRandom.java:118)
at java.security.SecureRandom.nextSeed(SecureRandom.java:90)
at java.security.SecureRandom.<init>(SecureRandom.java:78)
at keyTest.main(keyTest.java:18)

It seems to fail on the SecureRandom call. I checked my PATH, CLASSPATH.
They point to the paths of JDK1.2, JCE12-ea-dom and my java.security
defines as "security.provider.1=com.sun.crypto.provider.SunJCE".

Please let me know if there's anything I need to correct to get this to work.
Thanks much!

Jessica

=============== cut here ==============
import java.security.*;
import java.security.spec.*;
import javax.crypto.KeyAgreement;
class keyTest {
public static void main( String args[] )
{
KeyPairGenerator dhKeyPairGenerator;
try
{
dhKeyPairGenerator = KeyPairGenerator.getInstance("DH");
dhKeyPairGenerator.initialize(1024, new SecureRandom() );
KeyPair dhKeyPair = dhKeyPairGenerator.generateKeyPair();
byte[] dhPubKeyEncoded = dhKeyPair.getPublic().getEncoded();
KeyAgreement dhKeyAgree = KeyAgreement.getInstance("DH");
dhKeyAgree.doPhase(1, dhKeyPair.getPrivate() );
KeyFactory dhKeyFactory = KeyFactory.getInstance("DH");
X509EncodedKeySpec dhBobPubKeySpec = new
X509EncodedKeySpec(dhPubKeyEncoded);
PublicKey dhBobPubKey =
dhKeyFactory.generatePublic(dhBobPubKeySpec);
dhKeyAgree.doPhase(2, dhBobPubKey);
byte[] secret = dhKeyAgree.generateSecret();
}
catch ( Exception e )
{
System.err.println("Caught exception " + e.toString() );
}
}
}

- Next message: Jan Luehe: "Re: Problem with SecureRandom call"
- Previous message: Jan Luehe: "Re: java.security.Security.insertProviderAt() in appletviewer"
- Next in thread: Jan Luehe: "Re: Problem with SecureRandom call"