Sybren A. Stüvel | d92b667 | 2011-07-31 17:44:44 +0200 | [diff] [blame] | 1 | Reference |
| 2 | ================================================== |
| 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 |
| 8 | -------------------------------------------------- |
| 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 |
| 22 | -------------------------------------------------- |
| 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 |
| 41 | -------------------------------------------------- |
| 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 | Module: rsa.bigfile |
Sybren A. Stüvel | c1c455d | 2011-08-01 23:04:30 +0200 | [diff] [blame] | 53 | -------------------------------------------------- |
| 54 | |
Sybren A. Stüvel | 1681a0b | 2016-01-22 13:54:52 +0100 | [diff] [blame] | 55 | .. warning:: |
| 56 | |
| 57 | The :py:mod:`rsa.bigfile` module is NOT recommended for general use, has been |
| 58 | deprecated since Python-RSA 3.4, and will be removed in a future release. It's |
| 59 | vulnerable to a number of attacks. See :ref:`bigfiles` for more information. |
| 60 | |
Sybren A. Stüvel | dbea213 | 2011-08-03 13:31:57 +0200 | [diff] [blame] | 61 | The :py:mod:`rsa.bigfile` module contains functions for encrypting and |
| 62 | decrypting files that are larger than the RSA key. See |
| 63 | :ref:`bigfiles` for more information. |
| 64 | |
| 65 | .. autofunction:: rsa.bigfile.encrypt_bigfile |
| 66 | |
| 67 | .. autofunction:: rsa.bigfile.decrypt_bigfile |
| 68 | |
| 69 | .. _VARBLOCK: |
| 70 | |
| 71 | The VARBLOCK file format |
| 72 | ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 73 | |
Sybren A. Stüvel | 1681a0b | 2016-01-22 13:54:52 +0100 | [diff] [blame] | 74 | .. warning:: |
| 75 | |
| 76 | The VARBLOCK format is NOT recommended for general use, has been deprecated since |
| 77 | Python-RSA 3.4, and will be removed in a future release. It's vulnerable to a |
| 78 | number of attacks. See :ref:`bigfiles` for more information. |
| 79 | |
Sybren A. Stüvel | c1c455d | 2011-08-01 23:04:30 +0200 | [diff] [blame] | 80 | The VARBLOCK file format allows us to encrypt files that are larger |
| 81 | than the RSA key. The format is as follows; || denotes byte string |
| 82 | concatenation:: |
| 83 | |
| 84 | VARBLOCK := VERSION || BLOCK || BLOCK || ... |
| 85 | |
| 86 | VERSION := 1 |
| 87 | |
| 88 | BLOCK := LENGTH || DATA |
| 89 | |
Sybren A. Stüvel | dbea213 | 2011-08-03 13:31:57 +0200 | [diff] [blame] | 90 | LENGTH := varint-encoded length of the following data, in bytes |
Sybren A. Stüvel | c1c455d | 2011-08-01 23:04:30 +0200 | [diff] [blame] | 91 | |
| 92 | DATA := the data to store in the block |
| 93 | |
| 94 | The varint-format was taken from Google's Protobuf_, and allows us to |
| 95 | efficiently encode an arbitrarily long integer. |
| 96 | |
| 97 | .. _Protobuf: |
| 98 | http://code.google.com/apis/protocolbuffers/docs/encoding.html#varints |
Sybren A. Stüvel | d92b667 | 2011-07-31 17:44:44 +0200 | [diff] [blame] | 99 | |
Sybren A. Stüvel | dbea213 | 2011-08-03 13:31:57 +0200 | [diff] [blame] | 100 | |
| 101 | Module: rsa.core |
| 102 | -------------------------------------------------- |
| 103 | |
| 104 | At the core of the RSA encryption method lie these functions. They |
| 105 | both operate on (arbitrarily long) integers only. They probably aren't |
| 106 | of much use to you, but I wanted to document them anyway as they are |
| 107 | the core of the entire library. |
| 108 | |
| 109 | .. autofunction:: rsa.core.encrypt_int |
| 110 | |
| 111 | .. autofunction:: rsa.core.decrypt_int |
| 112 | |