1

I obtained iaik_jce.jar file from thirdparty. I am using it to decrypt a pfx file. When i am calling decrypt api then i am getting Unable to decrypt PrivateKey! exception. Below is the piece of code which i use for decryption.

    FileInputStream inStream = new FileInputStream(currentCredentialFile.getAbsoluteFile());
pkcs12 = new PKCS12(inStream);
pkcs12.decrypt(currentCredentialPassword.toCharArray());

Below is the exception stack trace

Caused by: iaik.pkcs.PKCSException: Unable to decrypt PrivateKey!
    at iaik.pkcs.pkcs12.AuthenticatedSafe.decrypt(Unknown Source)
    at iaik.pkcs.pkcs12.PKCS12.decrypt(Unknown Source)
    at com.raja.testapp.TestApplicatioin.main(TestApplicatioin.java:32)

Do i need to make any configuration changes for using iaik_jce.jar file for decryption.

  • PFX file is commonly used to bundle a private key with its X.509 certificate. Why would you want to decrypt that? You only decrypt cipher text. – parry Sep 05 '13 at 13:23

1 Answers1

0

I solved the issue myself. I needed to do some initialization which i did not do before.

iaik.security.provider.IAIK.addAsProvider(false);

Adding the above statement did the trick