1Compatibility with standards 2============================ 3 4.. index:: OpenSSL 5.. index:: compatibility 6 7Python-RSA implements encryption and signatures according to PKCS#1 8version 1.5. This makes it compatible with the OpenSSL RSA module. 9 10Keys are stored in PEM or DER format according to PKCS#1 v1.5. Private 11keys are compatible with OpenSSL. However, OpenSSL uses X.509 for its 12public keys, which are not supported. 13 14Encryption: 15 PKCS#1 v1.5 with at least 8 bytes of random padding 16 17Signatures: 18 PKCS#1 v1.5 using the following hash methods: 19 MD5, SHA-1, SHA-224, SHA-256, SHA-384, SHA-512 20 21Private keys: 22 PKCS#1 v1.5 in PEM and DER format, ASN.1 type RSAPrivateKey 23 24Public keys: 25 PKCS#1 v1.5 in PEM and DER format, ASN.1 type RSAPublicKey 26 27:ref:`VARBLOCK <bigfiles>` encryption: 28 Deprecated in Python-RSA 3.4 and removed from Python-RSA 4.0. 29 Was Python-RSA only, not compatible with any other known application. 30 31.. _openssl: 32 33Interoperability with OpenSSL 34----------------------------- 35 36You can create a 512-bit RSA key in OpenSSL as follows:: 37 38 openssl genrsa -out myprivatekey.pem 512 39 40To get a Python-RSA-compatible public key from OpenSSL, you need the 41private key first, then run it through the ``pyrsa-priv2pub`` 42command:: 43 44 pyrsa-priv2pub -i myprivatekey.pem -o mypublickey.pem 45 46Encryption and decryption is also compatible:: 47 48 $ echo hello there > testfile.txt 49 $ pyrsa-encrypt -i testfile.txt -o testfile.rsa publickey.pem 50 $ openssl rsautl -in testfile.rsa -inkey privatekey.pem -decrypt 51 hello there 52 53Interoperability with PKCS#8 54---------------------------- 55 56The standard PKCS#8 is widely used, and more complex than the PKCS#1 57v1.5 supported by Python-RSA. In order to extract a key from the 58PKCS#8 format you need an external tool such as OpenSSL:: 59 60 openssl rsa -in privatekey-pkcs8.pem -out privatekey.pem 61 62You can then extract the corresponding public key as described above. 63