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

KeyFactory.generatePublic() should accept RSAPublicKeySpec

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 1.4.0
    • security-libs

      KeyFactory.generatePublic(KeySpec ks) can not accept RSAPublicKeySpec as argument. The following program demonstrates this.

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

      public class test{

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

      BigInteger modulus=new BigInteger("77");
      BigInteger publicExponent=new BigInteger("7");
       
               RSAPublicKeySpec pubKeySpec= new RSAPublicKeySpec(modulus, publicExponent);

      Key pub = null;
      KeyFactory kf = KeyFactory.getInstance("RSA");
      System.out.println("The Provider is "+kf.getProvider());
      pub = kf.generatePublic(pubKeySpec);

      }
      }

      lwang:/home/lw129730/CCC/4478091( 109 )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.engineGeneratePublic(DashoA6275)
              at java.security.KeyFactory.generatePublic(KeyFactory.java:224)
              at test.main(test.java:18)

            valeriep Valerie Peng
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: