on 11-30-2011 4:15 PM
Hi Experts,
While encrypting the input message using public key we are getting the below error exception .
" java.security.NoSuchAlgorithmException: No such algorithm: RSA/ECB/PKCS1Padding" .
Here is the small piece of code we used for encryption .
inKey = PGPUtil.getDecoderStream(inKey); // inKey contains public key info
PGPPublicKeyRingCollection pkCol = new PGPPublicKeyRingCollection(inKey);
Iterator it = pkCol.getKeyRings();
while (it.hasNext()) {pkRing = (PGPPublicKeyRing) it.next();
Iterator pkIt = pkRing.getPublicKeys();
while (pkIt.hasNext()) {
temp = (PGPPublicKey) pkIt.next();
if (temp.isEncryptionKey()) {
pubkey = temp;
break; } }
out = new DataOutputStream(out);
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
PGPCompressedDataGenerator comData = new PGPCompressedDataGenerator(PGPCompressedDataGenerator.ZIP);
PGPLiteralDataGenerator lData = new PGPLiteralDataGenerator();
OutputStream pOut = lData.open(comData.open(bOut),PGPLiteralData.BINARY, "", inputString.length(),new Date());
pOut.write(inputString.getBytes());
lData.close();
comData.close();
cPk.close(); out.close();
PGPEncryptedDataGenerator cPk = new PGPEncryptedDataGenerator(PGPEncryptedDataGenerator.CAST5, new SecureRandom(),"BC");
cPk.addMethod(pubkey);
byte[] bytes = bOut.toByteArray();
OutputStream cOut = cPk.open(out, bytes.length); //<-- Here we are getting the above exception
cOut.write(bytes);
cPk.close();
out.close();
Could any one plz guide us ???
Hi,
The above exception has 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.
This exception usually means that the chosen enc algorithm (CAST5) is not available on the Bouncy Castle provider. Therefore, please try:
1. Update the JDK to latest hotfix. For example, if using JDK 1.4.2_11, install 1.4.2_30.
2. Apply Sarah's recommendation of updating the policy files;
3. Change the BC provider. Try using SUN's provider, for example.
BR,
Lucas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sarah/Lucas,
We are using below java version
java version "1.5.0_14"
Java(TM) 2 Runtime Environment, Standard Edition (build 5.1.027)
SAP Java 64-Bit Server VM (build 5.1.027, Dec 12 2008 04:31:57 - 51_REL - optU - aix ppc64 - bas2:113000 (mixed mode))
u2022Below mentioned jar files are downloaded from http://www.bouncycastle.org/latest_releases.html
u2022bcpg-jdk15-146 , bcprov-ext-jdk15-146, bcprov-jdk15-146
As you guys suggested we have checked for security file access .
There is no restriction to any algorithm.
cat default_US_export.policy
// Manufacturing policy file.
grant {
// There is no restriction to any algorithms.
permission javax.crypto.CryptoAllPermission;
};
pwd
/usr/java14_64/jre/lib/security
We are getting the below exception while we are doing encryption.Could you please suggest?
Error: javax.ejb.TransactionRolledbackLocalException: (Failed in component: sap.com/PGPEncryptionEAR) Exception raised from invocation of public com.sap.aii.af.lib.mp.module.ModuleData com.ngrid.sap.module.crypto.PGPDecryptionBean.process(com.sap.aii.af.lib.mp.module.ModuleContext,com.sap.aii.af.lib.mp.module.ModuleData) throws com.sap.aii.af.lib.mp.module.ModuleException method on bean instance com.ngrid.sap.module.crypto.PGPDecryptionBean-53db2a8 for bean sap.com/PGPEncryptionEARxml|PGPEncryption.jarxml|PGPDecryptionBean in application sap.com/PGPEncryptionEAR.; nested exception is: java.lang.ClassCastException: class java.lang.NullPointerException:null incompatible with class org.bouncycastle.openpgp.PGPException:sap.com/PGPEncryptionEAR-com.sap.engine.boot.loader.ResourceMultiParentClassLoader-3ac72a8c-alive; nested exception is: javax.ejb.EJBException: (Failed in component: sap.com/PGPEncryptionEAR) Exception raised from invocation of public com.sap.aii.af.lib.mp.module.ModuleData com.ngrid.sap.module.crypto.PGPDecryptionBean.process(com.sap.aii.af.lib.mp.module.ModuleContext,com.sap.aii.af.lib.mp.module.ModuleData) throws com.sap.aii.af.lib.mp.module.ModuleException method on bean instance com.ngrid.sap.module.crypto.PGPDecryptionBean-53db2a8 for bean sap.com/PGPEncryptionEARxml|PGPEncryption.jarxml|PGPDecryptionBean in application sap.com/PGPEncryptionEAR.; nested exception is: java.lang.ClassCastException: class java.lang.NullPointerException:null incompatible with class org.bouncycastle.openpgp.PGPException:sap.com/PGPEncryptionEAR-com.sap.engine.boot.loader.ResourceMultiParentClassLoader-3ac72a8c-alive; nested exception is: javax.ejb.EJBTransactionRolledbackException: (Failed in component: sap.com/PGPEncryptionEAR) Exception raised from invocation of public com.sap.aii.af.lib.mp.module.ModuleData com.ngrid.sap.module.crypto.PGPDecryptionBean.process(com.sap.aii.af.lib.mp.module.ModuleContext,com.sap.aii.af.lib.mp.module.ModuleData) throws com.sap.aii.af.lib.mp.module.ModuleException method on bean instance com.ngrid.sap.module.crypto.PGPDecryptionBean-53db2a8 for bean sap.com/PGPEncryptionEARxml|PGPEncryption.jarxml|PGPDecryptionBean in application sap.com/PGPEncryptionEAR.; nested exception is: java.lang.ClassCastException: class java.lang.NullPointerException:null incompatible with class org.bouncycastle.openpgp.PGPException:sap.com/PGPEncryptionEAR-com.sap.engine.boot.loader.ResourceMultiParentClassLoader-3ac72a8c-alive; nested exception is: javax.ejb.EJBException: (Failed in component: sap.com/PGPEncryptionEAR) Exception raised from invocation of public com.sap.aii.af.lib.mp.module.ModuleData com.ngrid.sap.module.crypto.PGPDecryptionBean.process(com.sap.aii.af.lib.mp.module.ModuleContext,com.sap.aii.af.lib.mp.module.ModuleData) throws com.sap.aii.af.lib.mp.module.ModuleException method on bean instance com.ngrid.sap.module.crypto.PGPDecryptionBean-53db2a8 for bean sap.com/PGPEncryptionEARxml|PGPEncryption.jarxml|PGPDecryptionBean in application sap.com/PGPEncryptionEAR.; nested exception is: java.lang.ClassCastException: class java.lang.NullPointerException:null incompatible with class org.bouncycastle.openpgp.PGPException:sap.com/PGPEncryptionEAR-com.sap.engine.boot.loader.ResourceMultiParentClassLoader-3ac72a8c-alive
At this below step it is going to catch block and throwing above exception
OutputStream cOut = cPk.open(out, bytes.length);// Return an output stream which will encrypt the data as it is written to it.
Thanks in Advance
Regards
Venkat
Hello,
You could check if you are using the unlimited strength jurisdiction policy files.
#739043 How to Check for Full Strength Jurisdiction Policies:
Regards,
Sarah
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.