I'm new to encryption with Python and am wondering which padding is the default one for its RSA module?
I get the key and decrypt the data by:
import rsa
(pub, priv) = rsa.newkeys(512)
# receive the encrypted data here
data = rsa.decrypt(encrypt_data, priv)
And as far as I am concerned, the padding methods include: RSA_PKCS1_PADDING, RSA_PKCS1_OAEP_PADDING, RSA_SSLV23_PADDING, RSA_NO_PADDING.
The rsa module (currently v3.4) supports only PKCS#1 v1.5 padding for encryption (randomized type 2 padding) and signing.
In rsa/__init__.py you can see that rsa.encrypt() is actually rsa.pkcs1.encrypt() which internally uses rsa.pkcs1._pad_for_encryption() which is an implementation of the previously mentioned PKCS#1 v1.5 padding.
Please note that nowadays (ref), this padding should not be used anymore. OAEP is recommended for encryption and PSS for signing, both from PKCS#1 v2.0. PyCrypto supports OAEP/PSS and PKCS#1 v1.5 paddings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With