Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Replacing Bouncy Castle With JsafeJCE Provider

977049Nov 29 2012
Hi,
I have replaced bouncy castle provider with JsafeJCE, got an exception saying InvalidKeySpecException


java.security.spec.InvalidKeySpecException: Could not decode key from BER. (Invalid encoding: expected tag not there.)
com.rsa.cryptoj.f.eW.b(Unknown Source)
com.rsa.cryptoj.f.eW.engineGeneratePrivate(Unknown Source)
java.security.KeyFactory.generatePrivate(KeyFactory.java:336)


Same code works fine with BouncyCastle...

below is the snippet


KeyFactory fact = KeyFactory.getInstance("RSA",JsafeJCE.BASE_PROVIDER_NAME);
PrivateKey privateKey = fact.generatePrivate(new PKCS8EncodedKeySpec(Base64.decodeBase64(privateKeyString.getBytes())) );
PublicKey publicKey = certificate.getPublicKey();


Any Help is appreciated... Thanks in advance
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 27 2012
Added on Nov 29 2012
0 comments
1,334 views