Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4520601

KeyFactory.generatePrivate() should accept RSAMultiPrimePrivateCrtKeySpec

    XMLWordPrintable

    Details

      Description

      According to API, KeyFactory.generatePrivate should accept the RSAMultiPrimePrivateCrtKeySpec since RSAMultiPrimePrivateCrtKeySpec implements Keyspec. The following program demonstrates this.


      import java.security.spec.*;
      import java.security.interfaces.*;
      import java.math.*;
      import java.security.*;

      public class test{

      public static void main(String[] argv) throws Exception{

      BigInteger modulus=new BigInteger("385");
      BigInteger publicExponent=new BigInteger("7");
               BigInteger privateExponent=new BigInteger("43");
               BigInteger primeP=new BigInteger("5");
               BigInteger primeQ=new BigInteger("7");
               BigInteger primeExponentP=new BigInteger("3");
               BigInteger primeExponentQ=new BigInteger("1");
               BigInteger crtCoefficient=new BigInteger("3");
              
               //r3=11, d3=3, t3=6
               BigInteger r3=new BigInteger("11");
               BigInteger d3=new BigInteger("3");
               BigInteger t3=new BigInteger("6");
              
               RSAOtherPrimeInfo otherInfo=new RSAOtherPrimeInfo(r3, d3, t3);
               RSAOtherPrimeInfo[] otherPrimeInfo=new RSAOtherPrimeInfo[1];
               otherPrimeInfo[0]=otherInfo;

      RSAMultiPrimePrivateCrtKeySpec crtKeySpec =new RSAMultiPrimePrivateCrtKeySpec(modulus,
      publicExponent, privateExponent,primeP,primeQ,primeExponentP,primeExponentQ,
      crtCoefficient,otherPrimeInfo);

      Key priv = null;
      KeyFactory kf = KeyFactory.getInstance("RSA");
      System.out.println("The Provider is "+kf.getProvider());
      priv = kf.generatePrivate( crtKeySpec);

      }
      }

      lwang:/home/lw129730/CCC/4478091( 114 )%java test
      The Provider is SunJSSE version 1.4
      Exception in thread "main" java.security.spec.InvalidKeySpecException: Unknown key spec.
              at com.sun.net.ssl.internal.ssl.JS_KeyFactory.engineGeneratePrivate(DashoA6275)
              at java.security.KeyFactory.generatePrivate(KeyFactory.java:240)
              at test.main(test.java:38)

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              valeriep Valerie Peng
              Reporter:
              duke J. Duke (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: