<div dir="ltr"><table><tbody><tr><td class="">
<br></td>
<td class="">
<div>
<div class="" itemprop="description">
<p>Hi, I am attempting to wrap a key like so, but getting the below error. Any help is appreciated. I am using SoftHSM provider. Is there a configuration entry that i can make to provide support for this key? Thanks</p>
<p>
Sitaraman</p><code>
keyGen.initialize(1024, sr);
KeyPair keyPair = keyGen.generateKeyPair();
PrivateKey pk = keyPair.getPrivate();
aesCipher.init(WRAP_MODE, keyPair.getPrivate());
byte[] wrappedPk = aesCipher.wrap(pk);
</code>
<p>I get an error statingjava.security.InvalidKeyException: No installed
provider supports this key: sun.security.pkcs11.P11Key$P11RSAPublicKey
at javax.crypto.Cipher.chooseProvider(Cipher.java:878)
at javax.crypto.Cipher.init(Cipher.java:1213)
at javax.crypto.Cipher.init(Cipher.java:1153)
at softhsm.SoftHSM.main(SoftHSM.java:96)</p>
</div></div></td></tr></tbody></table></div>