Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem creating RSA key pair > 2048 bits

843810Jun 5 2002 — edited Jul 8 2002
I've been wrestling with this problem on and off for a while and am finally admitting defeat and asking for assistance.

I'm using JDK 1.4.0 and have downloaded installed the unlimited strength policy files. However, I cannot generate RSA key pairs > 2048 bits or DSA > 1048 bits. The code I'm using is as follows:

try
{
// Get an RSA key pair generator
KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance("RSA");

// Generate RSA keypair
keyPairGen.initialize(4096);

KeyPair keyPair = keyPairGen.generateKeyPair();
}
catch (Exception ex)
{
ex.printStackTrace():
}

But I get this exception each time:

java.security.InvalidParameterException: Modulus size must range from 512 to 2048
at com.sun.net.ssl.internal.ssl.JS_KeyPairGenerator.initialize(DashoA6275)
at java.security.KeyPairGenerator$Delegate.initialize(KeyPairGenerator.java:463)

And where I try the same thing for DSA:

java.security.InvalidParameterException: Modulus size must range from 512 to 1024 and be a multiple of 64
at sun.security.provider.DSAKeyPairGenerator.initialize(DSAKeyPairGenerator.java:162)

I believe that I've installed the policy files correctly (to JAVA_HOME/lib/security).

Has anyone managed to get RSA/DSA key pair generation working for larger key sizes? Any assistance would be greatly appreciated.

Cheers,
- Wayne.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 5 2002
Added on Jun 5 2002
6 comments
1,887 views