blob: aedfcb690139bbe787e0451ea0a5b080ac6fbca4 [file] [log] [blame]
Sybren A. Stüvel062b1322011-08-03 14:46:49 +02001Compatibility with standards
Sybren A. Stüvel3934ab42016-02-05 16:01:20 +01002============================
Sybren A. Stüvela3fd61a2011-07-31 00:22:31 +02003
Sybren A. Stüvelc1c455d2011-08-01 23:04:30 +02004.. index:: OpenSSL
5.. index:: compatibility
6
Sybren A. Stüvela3fd61a2011-07-31 00:22:31 +02007Python-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
Sybren A. Stüveldbea2132011-08-03 13:31:57 +020014Encryption:
Sybren A. Stüvela3fd61a2011-07-31 00:22:31 +020015 PKCS#1 v1.5 with at least 8 bytes of random padding
16
Sybren A. Stüveldbea2132011-08-03 13:31:57 +020017Signatures:
Sybren A. Stüvela3fd61a2011-07-31 00:22:31 +020018 PKCS#1 v1.5 using the following hash methods:
19 MD5, SHA-1, SHA-256, SHA-384, SHA-512
20
Sybren A. Stüveldbea2132011-08-03 13:31:57 +020021Private keys:
Sybren A. Stüvela3fd61a2011-07-31 00:22:31 +020022 PKCS#1 v1.5 in PEM and DER format, ASN.1 type RSAPrivateKey
23
Sybren A. Stüveldbea2132011-08-03 13:31:57 +020024Public keys:
Sybren A. Stüvela3fd61a2011-07-31 00:22:31 +020025 PKCS#1 v1.5 in PEM and DER format, ASN.1 type RSAPublicKey
26
Sybren A. Stüveldbea2132011-08-03 13:31:57 +020027:ref:`VARBLOCK <bigfiles>` encryption:
Sybren A. Stüvelc1c455d2011-08-01 23:04:30 +020028 Python-RSA only, not compatible with any other known application.
Sybren A. Stüvela3fd61a2011-07-31 00:22:31 +020029
Sybren A. Stüvel58fe9462011-08-03 13:56:32 +020030.. _openssl:
Sybren A. Stüvela3fd61a2011-07-31 00:22:31 +020031
Sybren A. Stüvel58fe9462011-08-03 13:56:32 +020032Interoperability with OpenSSL
Sybren A. Stüvel3934ab42016-02-05 16:01:20 +010033-----------------------------
Sybren A. Stüvela3fd61a2011-07-31 00:22:31 +020034
Sybren A. Stüvel58fe9462011-08-03 13:56:32 +020035You can create a 512-bit RSA key in OpenSSL as follows::
Sybren A. Stüvela3fd61a2011-07-31 00:22:31 +020036
Sybren A. Stüvel58fe9462011-08-03 13:56:32 +020037 openssl genrsa -out myprivatekey.pem 512
38
39To get a Python-RSA-compatible public key from OpenSSL, you need the
40private key first, then run it through the ``pyrsa-priv2pub``
41command::
42
43 pyrsa-priv2pub -i myprivatekey.pem -o mypublickey.pem
44
45Encryption and decryption is also compatible::
46
47 $ echo hello there > testfile.txt
48 $ pyrsa-encrypt -i testfile.txt -o testfile.rsa publickey.pem
49 $ openssl rsautl -in testfile.rsa -inkey privatekey.pem -decrypt
50 hello there
Sybren A. Stüveld92b6672011-07-31 17:44:44 +020051
Sybren A. Stüvel7cf95f42014-02-22 11:21:45 +010052Interoperability with PKCS#8
Sybren A. Stüvel3934ab42016-02-05 16:01:20 +010053----------------------------
Sybren A. Stüvel7cf95f42014-02-22 11:21:45 +010054
55The standard PKCS#8 is widely used, and more complex than the PKCS#1
56v1.5 supported by Python-RSA. In order to extract a key from the
57PKCS#8 format you need an external tool such as OpenSSL::
58
59 openssl rsa -in privatekey-pkcs8.pem -out privatekey.pem
60
61You can then extract the corresponding public key as described above.
62