2
votes

I need help using Bouncy Castle RSA Libraries for a school assignment, but it looks very complicated and I'm trying to learn and need some guidance.

For my assignment I need to just generate a public and private key. Then encrypt a block of message and do timing measurements. Then do the same for decryption.

Could someone point me in the right direction? The Crypto Library is huge and I'm confused on how to go about this.

Thank you very much.

PS: Basically I need to generate the Key Pairs, Execute the encryption and decryption using different key pairs that are randomly generated.

I would appreaciate any guidance, thanks

1
Do you absolutely need to use Bouncy castle? because I'd recommend GNU Crypto, is more easy to learn and manage, and there's lots of tutorials on GoogleAlvin Baena
You're required to use Bouncy Castle? Given your requirements standard Java libs should work as well. Please add the 'homework' tag.home
No bouncy castle isnt a requirement. Is GNU Crypto for java? Java is sort of required because my team members dont know C/C++ or scripting languages like Python. Also thanks for the reply. Also I added the homework tag, my apologies.kal
Did you have a look at this. Maybe this is all you need...home
@home Thank you. This looks more comfortable to work with for a beginner like me. I greatly appreciate your help.kal

1 Answers

2
votes

Normally with Java you would use the Java Cryptography API's, in the java.security.* and javax.crypto.* packages.

BouncyCastle includes a provider (i.e. an implementation) for this API, but for RSA the one delivered with your JRE should be fine, too. (BouncyCastle additionally also has an own API which does things in other ways.)

You would need the KeyPair and KeyPairGenerator classes for the key generation, and the Cipher class for the actual encryption and decryption operation.

For the timing measurement, repeat the encryption/decryption some thousand times to get reliable data.