Bouncy城​​堡RSA关键产品使用轻量级API [英] Bouncy Castle RSA keypair generation using Lightweight API

查看:153
本文介绍了Bouncy城​​堡RSA关键产品使用轻量级API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

令人惊讶的是,网络上关于使用Bouncy Castle轻量级API的信息很少。查看周围一段时间后,我可以组织一个基本的例子:

  RSAKeyPairGenerator generator = new RSAKeyPairGenerator(); 
generator.init(new RSAKeyGenerationParameters

new BigInteger(10001,16),// publicExponent
SecureRandom.getInstance(SHA1PRNG),// prng
1024,// strength
80 //确定
));

AsymmetricCipherKeyPair keyPair = generator.generateKeyPair();

我对RSA和幕后的数学有一个基本的了解,所以我明白什么 publicExponent strength 是。我假定 publicExponent 指的是 phi(pq)的互质,从我收集的可以是小的(如3 ),只要使用适当的填充。但是,我不知道什么确定性引用(有些地方提到它可能是指一个百分比,但我想要确定)。使用 SecureRandom 是不言自明的。 RSAKeyGenerationParameters 的文档是完全没有价值的(没有惊喜)。我唯一的猜测是它与生成的键的准确性有关,但我又想确定。所以我的问题是对于确定性 publicExponent



PS
请不要回复这取决于上下文 - 您希望信息的安全性。假设最高安全性(即4096位RSA密钥或更大)是非常安全的,除非另有规定...我也会欣赏到提供使用Bouncy Castle的轻量级API的良好示例的链接(我不在所有对JCA实施感兴趣的任何实例或与之相关的任何示例)。

解决方案

您正在使用正确的值。 >

publicExponent应该是费马数字。 0x10001(F4)是当前推荐值。已知3(F1)也是安全的。



RSA密钥生成需要素数。然而,不可能产生绝对素数。像任何其他加密库一样,BC使用可能的素数。确定性表明你希望数字如何确定。 80以上的任何事情都会大大减缓关键时代的发展。



请注意,RSA算法仍然工作在不太可能的情况下,素数不是真正的素数,因为BC检查相对原始。


Surprisingly enough there's very little information on the Web about using Bouncy Castle's lightweight API. After looking around for a while I was able to put together a basic example:

RSAKeyPairGenerator generator = new RSAKeyPairGenerator();
generator.init(new RSAKeyGenerationParameters
    (
        new BigInteger("10001", 16),//publicExponent
        SecureRandom.getInstance("SHA1PRNG"),//prng
        1024,//strength
        80//certainty
    ));

AsymmetricCipherKeyPair keyPair = generator.generateKeyPair();

I have a basic understanding of RSA and the math that happens behind the scenes, so I understand what publicExponent and strength are. I presume publicExponent refers to a coprime of phi(pq) and from what I gather it can be small (like 3) as long as appropriate padding is used. However, I have no idea what certainty refers to (some place mentioned that it might refer to a percentage but I want to be sure). The use of SecureRandom is self-explanatory. The documentation of RSAKeyGenerationParameters is completely worthless (no surprise there). My only guess is that it has something to do with the accuracy of the generated keys, but again I want to be sure. So my question is what are appropriate values for certainty and publicExponent?

P.S. Please don't reply with "it depends on the context - how secure you want the information to be". It's pretty safe to assume highest degree of security (i.e. 4096-bit RSA key or greater) unless otherwise specified... I would also appreciate links to sources that give good example of the use of Bouncy Castle's Lightweight API (I'm not at all interested in the JCA implementation or any examples pertaining to it).

解决方案

You are using correct values for both.

The publicExponent should be a Fermat Number. 0x10001 (F4) is current recommended value. 3 (F1) is known to be safe also.

The RSA key generation requires prime numbers. However, it's impossible to generate absolute prime numbers. Like any other crypto libraries, BC uses probable prime numbers. The certainty indicate how certain you want the number to be prime. Anything above 80 will slow down key generation considerably.

Please note that RSA algorithm still works in the unlikely event that the prime number is not true prime because BC checks for relative primeness.

这篇关于Bouncy城​​堡RSA关键产品使用轻量级API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆