我需要帮助使用 Bouncy Castle RSA 库完成学校作业,但它看起来非常复杂,我正在尝试学习并需要一些指导。
对于我的作业,我只需要生成公钥和私钥。然后加密消息块并进行计时测量。然后执行相同的解密操作。
有人能指出我正确的方向吗?
加密库很大,我对如何处理它感到困惑。
非常感谢。
PS:基本上我需要生成密钥对,使用随机生成的不同密钥对执行加密和解密。
我将不胜感激任何指导,谢谢
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)
通常,对于 Java,您将使用
java.security.*
和javax.crypto.*
包中的 Java Cryptography API。BouncyCastle 包含该 API 的提供程序(即实现),但对于 RSA,与 JRE 一起提供的提供程序也应该没问题。 (BouncyCastle 另外还有一个自己的 API,可以以其他方式执行操作。)
您将需要
KeyPair
和KeyPairGenerator
用于密钥生成的类,以及Cipher
类用于实际的加密和解密操作。对于定时测量,重复加密/解密数千次以获得可靠的数据。
Normally with Java you would use the Java Cryptography API's, in the
java.security.*
andjavax.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
andKeyPairGenerator
classes for the key generation, and theCipher
class for the actual encryption and decryption operation.For the timing measurement, repeat the encryption/decryption some thousand times to get reliable data.