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

KeyFactory.generatePublic() should accept RSAPublicKeySpec

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Not an Issue
    • Affects Version/s: 1.4.0
    • Fix Version/s: None
    • Component/s: security-libs
    • Labels:

      Description

      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)

        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: