on 12-29-2011 5:53 PM
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
Hi ,
The above issue is resolved by restarting the Java stack.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.