cancel
Showing results for 
Search instead for 
Did you mean: 

"Exception creating cipher" exception

Former Member
0 Kudos

Hi Experts,

I'm getting "Exception creating cipher" exception while decrypting a file using Bouncy castle api.

I'm using RSA pubic and private keys

Here is the piece of decryption code where in the exception is coming .

PGPPrivateKey sKey = null;

PGPPublicKeyEncryptedData pbe = null;

PGPSecretKeyRingCollection pgpSec;

Iterator it1;

try {

in = PGPUtil.getDecoderStream(in);

pgpF = new PGPObjectFactory(in);

Object o = pgpF.nextObject();

if (o instanceof PGPEncryptedDataList) {

enc = (PGPEncryptedDataList) o;

} else {

enc = (PGPEncryptedDataList) pgpF.nextObject();

}

Iterator it = enc.getEncryptedDataObjects();

PGPPrivateKey sKey = null;

PGPPublicKeyEncryptedData pbe = null;

while (sKey == null && it.hasNext()) {

pbe = (PGPPublicKeyEncryptedData) it.next();

sKey = findSecretKey(keyIn, pbe.getKeyID(), passwd);

-


-


}

PGPPrivateKey findSecretKey(InputStream keyIn, long keyID,

char[] pass) throws IOException, PGPException,

NoSuchProviderException {

PGPSecretKeyRingCollection pgpSec = new PGPSecretKeyRingCollection(PGPUtil.getDecoderStream(keyIn));

PGPSecretKey pgpSecKey = pgpSec.getSecretKey(keyID);

if (pgpSecKey == null) {

return null;

}

return pgpSecKey.extractPrivateKey(pass, "BC");-->//Here i'm getting "Exception creating the cipher" }

Could you please advice me ?

Thanks in Advance

Regards

Venkat

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi.

Please check the below thread.

Regards.

Luis.

Former Member
0 Kudos

Hi Luis,

Thanks for your suggestions.

But the link provided was not helpfull to my problem.

1) install the JCE Policy files (local_policy.jar, US_export_policy.jar) -->I have already done this.

2)I'm using latest bouncycastle jarfiles for my jdk1.5(146 series)

FYI:The same code that i used in module is working in standalone .But it's not working in module throwing above exception while decrypting?

Regards

Venkat

Edited by: Venkat Ramaiah on Jan 1, 2012 12:56 PM

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi ,

The above issue is resolved by restarting the Java stack.