title: InvalidKeyException while wrapping and unwrapping using RSA algorithm
body: <p>I am new to Java and want to wrap a symmetric key using RSA algorithm. In my case I am not generating the public key for wrapping, but retrieving the public key from Microsoft Keystore.</p>
  
  <pre><code>// Encrypt the generated Symmetric AES Key using RSA cipher     
  Cipher rsaCipher = Cipher.getInstance("RSA/ECB/PKCS1Padding", 
         ks.getProvider().getName()); rsaCipher.init(Cipher.WRAP_MODE, RSAPubKey);
  byte[] encryptedSymmKey = rsaCipher.wrap(aeskey);
  </code></pre>
  
  <p>I am getting an InvalidKeyException as shown below:</p>
  
  <pre><code>Exception in thread "main" java.security.InvalidKeyException: Unsupported key type: Sun RSA public key, 1024 bits
    modulus: 171871587533146191561538456391418351861663300588728159334223437391061141885590024223283480319626015611710315581642512941578588886825766256507714725820048129123720143461110410353346492039350478625370269565346566901446816729164309038944197418238814947654954590754593726047828813400082450341775203029183105860831
    public exponent: 65537
      at sun.security.mscapi.RSACipher.init(RSACipher.java:176)
      at sun.security.mscapi.RSACipher.engineInit(RSACipher.java:129)
      at javax.crypto.Cipher.init(DashoA13*..)
      at javax.crypto.Cipher.init(DashoA13*..)
      at com.sap.srm.crpto.client.applet.CryptoClass.main(CryptoClass.java:102)
  </code></pre>
  
  <p>Please let me know if anyone has any suggestion how to use the SunMSCAPI appropriate?</p>