0 Replies Latest reply on Nov 29, 2012 4:39 PM by 977049

    Replacing Bouncy Castle With JsafeJCE Provider

      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)

      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