-
Bug
-
Resolution: Fixed
-
P3
-
1.4.0
-
1.0.3
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2110156 | 1.4.0 | Bradford Wetmore | P3 | Resolved | Fixed | beta3 |
Name: nt126004 Date: 09/14/2001
java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)
When converting between RSAPrivateCrtKey and RSAPrivateCrtKeySpec objects, you
can get private keys that throw ArrayIndexOutOfBoundsException when calling
getPublicExponent().
A test program:
import java.security.*;
import java.security.interfaces.*;
import java.security.spec.*;
import java.math.BigInteger;
public class JCATestCase
{
public static void main(String[] args)
{
try
{
KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA");
generator.initialize(512);
KeyPair pair = generator.generateKeyPair();
RSAPrivateCrtKey privatekey = (RSAPrivateCrtKey) pair.getPrivate();
RSAPrivateCrtKeySpec spec
= new RSAPrivateCrtKeySpec(privatekey.getModulus(),
privatekey.getPublicExponent(),
privatekey.getPrivateExponent(),
privatekey.getPrimeP(),
privatekey.getPrimeQ(),
privatekey.getPrimeExponentP(),
privatekey.getPrimeExponentQ(),
privatekey.getCrtCoefficient());
KeyFactory factory = KeyFactory.getInstance("RSA");
PrivateKey privatekey2 = factory.generatePrivate(spec);
BigInteger pe = ((RSAPrivateCrtKey) privatekey2).getPublicExponent();
System.out.print("public exponent: " + pe);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
Output:
java.lang.ArrayIndexOutOfBoundsException
at
com.sun.rsajca.JSA_RSAPrivateKey.getPublicExponent([DashoPro-V1.2-120198])
at JCATestCase.main(JCATestCase.java:33)
(Review ID: 131697)
======================================================================
- backported by
-
JDK-2110156 default RSA KeyFactory can return broken RSAPrivateCrtKey objects
-
- Resolved
-
- relates to
-
JDK-4413634 ArrayIndexOutOfBoundsException in RSAPrivateCrtKey.getEncoded() & other methods
-
- Resolved
-