aspose file tools*
The moose likes Security and the fly likes Problem in adding Bouncy Castle library to Project Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Security
Bookmark "Problem in adding Bouncy Castle library to Project" Watch "Problem in adding Bouncy Castle library to Project" New topic
Author

Problem in adding Bouncy Castle library to Project

Tarun Khandelwal
Greenhorn

Joined: Feb 23, 2012
Posts: 19
Hello All,

I am doing development in an embedded project and i am using Bouncy Castle for AES Encryption.
Now when i am adding Bouncy Castle as Security Provider, i am getting error in initializing the Cipher.
This is happening when i deploy my project on device.
When i am running my code in eclipse its working fine.
When i investigated further, i found that while deploying i am extracting the jar provided by the BC.
So code is not getting correct signature.

So can anyone can tell me how to use Bouncy Castle jar library in embedded device as i cannot access root of the device and add that to Class Path.

library i am using is jce-jdk13-146.jar and i am using Java JDK 1.3.

Please find the code inline



It would be Great to have a solution as soon as possible.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
You can add the BC classes in the same way you'd add your own classes. I *think* (not quite sure) that it would be OK if they are loaded by the same classloader. You'd then need to call "Security.addProvider(new BouncyCastleProvider());"

It goes without saying that you should run, not walk, to replace Java 1.3 with Java 6.
Tarun Khandelwal
Greenhorn

Joined: Feb 23, 2012
Posts: 19
Hello Tim,

Thanks for your reply.
I didn't got you. Are you saying that i should all the BC classes at run time that are being used by my code?
Adding Bouncy Castle will do the task?

Can you provide with a code snippet.
It would be great.

And i have constraint to JDK version.
As device on which i am working is having that version only.

Thanks and Regards,
Tarun Khandelwal
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Nothing gets installed at runtime. You can install BC along with your application. It's just Java class files (or a jar file), after all.

What code snippet? This is an installation issue. And I already posted the code you need to set BC as the security provider.
Tarun Khandelwal
Greenhorn

Joined: Feb 23, 2012
Posts: 19
Thank you for your response. But i am not getting how to add a jar file as dependency to class path of the device.
And if i am extracting the jar its signature is lost and than i could not use its class files.


Thanks and Regards,
Tarun Khandelwal
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
We still don't know what "the device" is, but I'd guess that its developer documentation covers that.
Tarun Khandelwal
Greenhorn

Joined: Feb 23, 2012
Posts: 19
Hello Everyone,

I have the solution to add jar files to my project. But Now when i am adding the Bouncy Castle Library :- jce-jdk13-146.jar, i am getting an error :-
.

Can anyone tell me why this issue is coming as now am using the jar itself.
Now what i am doing is,


classes folder :- myClasses
BC lib lib/jce-jdk13-146.jar

Now i am creating a jar for both, setting Classpath as lib in Manifest file.

So Final Structure is myJar.jar
myClasses
lib
jce-jdk13-146.jar
META-INF
Manifest.MF
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in adding Bouncy Castle library to Project
 
Similar Threads
using bouncy castle jce provider??
javax.crypto.Cipher.a (DashoA6275) noClassDefFoundError
crypto with jce / without jce (jurisdiction policy)
Bouncy Castle encryption examples and tutorials
Encrypted values all contain same final characters