pycrypto rsa decrypt does not work on long message (longer than half of modulus size)
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Python-Crypto |
Undecided
|
Unassigned |
Bug Description
When using RSA-1024 private key, the following code can not decrypt correctly for messages longer than 64 bytes.
But if we change the string data to be shorter than 64 bytes, the code works well.
BTW, the openssl private key decryption can work for any message less than 1024 bits.
-------
from Crypto.PublicKey import RSA
def main():
key = RSA.importKey(
publickey = key.publickey()
#data = "\0\0abcdeabcde
data = "abcdefghijklmn
enc_data = publickey.
print(
dec_data = key.decrypt(
print(dec_data)
main()
James Cao (jamesfengcao) wrote : | #1 |
Dwayne Litzenberger (dlitz) wrote : | #2 |
There was a bug in RSA.importKey in PyCrypto 2.3, which was fixed in PyCrypto 2.4.
fabrom (fabrom-jability) wrote : | #3 |
Also found in 2.5
Zviki Cohen (zvikico) wrote : | #4 |
Just wanted to confirm that this bug still exists in 2.4 as well as the latest 2.6. I tested it on my local system, OS X 10.8.2 running Python 2.7.2.
BTW, the pycrypto encrypt works well, for any message less than 1024 bits, I can decrypt it with openssl without any problem.
So the issue locates in pycrypto decryption implementation.