Sybren A. Stüvel | d92b667 | 2011-07-31 17:44:44 +0200 | [diff] [blame] | 1 | Reference |
Sybren A. Stüvel | 3934ab4 | 2016-02-05 16:01:20 +0100 | [diff] [blame] | 2 | ========= |
Sybren A. Stüvel | d92b667 | 2011-07-31 17:44:44 +0200 | [diff] [blame] | 3 | |
Sybren A. Stüvel | dbea213 | 2011-08-03 13:31:57 +0200 | [diff] [blame] | 4 | This is the class and function reference. For more usage information |
| 5 | see the :ref:`usage` page. |
| 6 | |
Sybren A. Stüvel | d92b667 | 2011-07-31 17:44:44 +0200 | [diff] [blame] | 7 | Functions |
Sybren A. Stüvel | 3934ab4 | 2016-02-05 16:01:20 +0100 | [diff] [blame] | 8 | --------- |
Sybren A. Stüvel | d92b667 | 2011-07-31 17:44:44 +0200 | [diff] [blame] | 9 | |
| 10 | .. autofunction:: rsa.encrypt |
| 11 | |
| 12 | .. autofunction:: rsa.decrypt |
| 13 | |
| 14 | .. autofunction:: rsa.sign |
| 15 | |
| 16 | .. autofunction:: rsa.verify |
| 17 | |
| 18 | .. autofunction:: rsa.newkeys(keysize) |
| 19 | |
Sybren A. Stüvel | c1c455d | 2011-08-01 23:04:30 +0200 | [diff] [blame] | 20 | |
Sybren A. Stüvel | d92b667 | 2011-07-31 17:44:44 +0200 | [diff] [blame] | 21 | Classes |
Sybren A. Stüvel | 3934ab4 | 2016-02-05 16:01:20 +0100 | [diff] [blame] | 22 | ------- |
Sybren A. Stüvel | d92b667 | 2011-07-31 17:44:44 +0200 | [diff] [blame] | 23 | |
Sybren A. Stüvel | 4bc9733 | 2016-01-22 15:41:40 +0100 | [diff] [blame] | 24 | .. note:: |
| 25 | |
| 26 | Storing public and private keys via the `pickle` module is possible. |
| 27 | However, it is insecure to load a key from an untrusted source. |
| 28 | The pickle module is not secure against erroneous or maliciously |
| 29 | constructed data. Never unpickle data received from an untrusted |
| 30 | or unauthenticated source. |
| 31 | |
Sybren A. Stüvel | d92b667 | 2011-07-31 17:44:44 +0200 | [diff] [blame] | 32 | .. autoclass:: rsa.PublicKey |
| 33 | :members: |
| 34 | :inherited-members: |
| 35 | |
| 36 | .. autoclass:: rsa.PrivateKey |
| 37 | :members: |
| 38 | :inherited-members: |
| 39 | |
Sybren A. Stüvel | 1f011e1 | 2011-07-31 19:20:46 +0200 | [diff] [blame] | 40 | Exceptions |
Sybren A. Stüvel | 3934ab4 | 2016-02-05 16:01:20 +0100 | [diff] [blame] | 41 | ---------- |
Sybren A. Stüvel | 1f011e1 | 2011-07-31 19:20:46 +0200 | [diff] [blame] | 42 | |
| 43 | .. autoclass:: rsa.pkcs1.CryptoError(Exception) |
| 44 | |
| 45 | .. autoclass:: rsa.pkcs1.DecryptionError(CryptoError) |
| 46 | |
| 47 | .. autoclass:: rsa.pkcs1.VerificationError(CryptoError) |
| 48 | |
Sybren A. Stüvel | d92b667 | 2011-07-31 17:44:44 +0200 | [diff] [blame] | 49 | |
Sybren A. Stüvel | c1c455d | 2011-08-01 23:04:30 +0200 | [diff] [blame] | 50 | .. index:: VARBLOCK (file format) |
| 51 | |
Sybren A. Stüvel | dbea213 | 2011-08-03 13:31:57 +0200 | [diff] [blame] | 52 | The VARBLOCK file format |
Sybren A. Stüvel | 3934ab4 | 2016-02-05 16:01:20 +0100 | [diff] [blame] | 53 | ++++++++++++++++++++++++ |
Sybren A. Stüvel | dbea213 | 2011-08-03 13:31:57 +0200 | [diff] [blame] | 54 | |
Sybren A. Stüvel | 1681a0b | 2016-01-22 13:54:52 +0100 | [diff] [blame] | 55 | .. warning:: |
| 56 | |
| 57 | The VARBLOCK format is NOT recommended for general use, has been deprecated since |
Sybren A. Stüvel | 1d14c4e | 2017-04-10 11:31:09 +0200 | [diff] [blame] | 58 | Python-RSA 3.4, and was removed in version 4.0. It's vulnerable to a |
Sybren A. Stüvel | 1681a0b | 2016-01-22 13:54:52 +0100 | [diff] [blame] | 59 | number of attacks. See :ref:`bigfiles` for more information. |
| 60 | |
Sybren A. Stüvel | c1c455d | 2011-08-01 23:04:30 +0200 | [diff] [blame] | 61 | The VARBLOCK file format allows us to encrypt files that are larger |
| 62 | than the RSA key. The format is as follows; || denotes byte string |
| 63 | concatenation:: |
| 64 | |
| 65 | VARBLOCK := VERSION || BLOCK || BLOCK || ... |
| 66 | |
| 67 | VERSION := 1 |
| 68 | |
| 69 | BLOCK := LENGTH || DATA |
| 70 | |
Sybren A. Stüvel | dbea213 | 2011-08-03 13:31:57 +0200 | [diff] [blame] | 71 | LENGTH := varint-encoded length of the following data, in bytes |
Sybren A. Stüvel | c1c455d | 2011-08-01 23:04:30 +0200 | [diff] [blame] | 72 | |
| 73 | DATA := the data to store in the block |
| 74 | |
| 75 | The varint-format was taken from Google's Protobuf_, and allows us to |
| 76 | efficiently encode an arbitrarily long integer. |
| 77 | |
| 78 | .. _Protobuf: |
Sybren A. Stüvel | 3934ab4 | 2016-02-05 16:01:20 +0100 | [diff] [blame] | 79 | https://code.google.com/apis/protocolbuffers/docs/encoding.html#varints |
Sybren A. Stüvel | d92b667 | 2011-07-31 17:44:44 +0200 | [diff] [blame] | 80 | |
Sybren A. Stüvel | dbea213 | 2011-08-03 13:31:57 +0200 | [diff] [blame] | 81 | |
| 82 | Module: rsa.core |
Sybren A. Stüvel | 3934ab4 | 2016-02-05 16:01:20 +0100 | [diff] [blame] | 83 | ---------------- |
Sybren A. Stüvel | dbea213 | 2011-08-03 13:31:57 +0200 | [diff] [blame] | 84 | |
| 85 | At the core of the RSA encryption method lie these functions. They |
| 86 | both operate on (arbitrarily long) integers only. They probably aren't |
| 87 | of much use to you, but I wanted to document them anyway as they are |
| 88 | the core of the entire library. |
| 89 | |
| 90 | .. autofunction:: rsa.core.encrypt_int |
| 91 | |
| 92 | .. autofunction:: rsa.core.decrypt_int |