开发者

PyCrypto: How much random data is considered secure?

开发者 https://www.devze.com 2023-03-31 18:24 出处:网络
I\'m using the RSA implementation in PyCrypto. With regard to the encrypt(self, plaintext, K) method K is a parameter of random data. I want to know how much random data needs to be passed in order fo

I'm using the RSA implementation in PyCrypto. With regard to the encrypt(self, plaintext, K) method K is a parameter of random data. I want to know how much random data needs to be passed in order for the encryted data to be considered secure. For example in my implementation I am passing a strong prime number of 1024 bits via the Crypto.开发者_JS百科Util.number module like so:

enc_data = public_key.encrypt(data, number.getPrime(1024))

Is this considered 'secure enough'?

Thanks


The RSA implementation does not use the K parameter. You may ignore it; the RSA implemention does.

Looking at lines 59-60 of pycrypto-2.3/lib/Crypto/PublicKey/RSA.py you see the following:

def _encrypt(self, c, K):
    return (self.key._encrypt(c),)

Which proves that K, if supplied, is ignored.

Official documentation

Plus, the developers declare this explicitly in the documentation. In fact, if you create a public key public_key and you type

help(public_key.encrypt)

you will obtain their documentation, which explicitly says:

encrypt(self, plaintext, K) method of Crypto.PublicKey.RSA._RSAobj instance
Encrypt a piece of data with RSA.

...
...

:Parameter K: A random parameter (*for compatibility only. This
 value will be ignored*)
:Type K: byte string or long
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号