blob: d1b0b6d300808db5e1f4341fcd3387a00a00a872 [file] [log] [blame]
Sybren A. Stüveld92b6672011-07-31 17:44:44 +02001Reference
Sybren A. Stüvel3934ab42016-02-05 16:01:20 +01002=========
Sybren A. Stüveld92b6672011-07-31 17:44:44 +02003
Sybren A. Stüveldbea2132011-08-03 13:31:57 +02004This is the class and function reference. For more usage information
5see the :ref:`usage` page.
6
Sybren A. Stüveld92b6672011-07-31 17:44:44 +02007Functions
Sybren A. Stüvel3934ab42016-02-05 16:01:20 +01008---------
Sybren A. Stüveld92b6672011-07-31 17:44:44 +02009
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üvelc1c455d2011-08-01 23:04:30 +020020
Sybren A. Stüveld92b6672011-07-31 17:44:44 +020021Classes
Sybren A. Stüvel3934ab42016-02-05 16:01:20 +010022-------
Sybren A. Stüveld92b6672011-07-31 17:44:44 +020023
Sybren A. Stüvel4bc97332016-01-22 15:41:40 +010024.. 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üveld92b6672011-07-31 17:44:44 +020032.. autoclass:: rsa.PublicKey
33 :members:
34 :inherited-members:
35
36.. autoclass:: rsa.PrivateKey
37 :members:
38 :inherited-members:
39
Sybren A. Stüvel1f011e12011-07-31 19:20:46 +020040Exceptions
Sybren A. Stüvel3934ab42016-02-05 16:01:20 +010041----------
Sybren A. Stüvel1f011e12011-07-31 19:20:46 +020042
43.. autoclass:: rsa.pkcs1.CryptoError(Exception)
44
45.. autoclass:: rsa.pkcs1.DecryptionError(CryptoError)
46
47.. autoclass:: rsa.pkcs1.VerificationError(CryptoError)
48
Sybren A. Stüveld92b6672011-07-31 17:44:44 +020049
Sybren A. Stüvelc1c455d2011-08-01 23:04:30 +020050.. index:: VARBLOCK (file format)
51
Sybren A. Stüveldbea2132011-08-03 13:31:57 +020052Module: rsa.bigfile
Sybren A. Stüvel3934ab42016-02-05 16:01:20 +010053-------------------
Sybren A. Stüvelc1c455d2011-08-01 23:04:30 +020054
Sybren A. Stüvel1681a0b2016-01-22 13:54:52 +010055.. 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üveldbea2132011-08-03 13:31:57 +020061The :py:mod:`rsa.bigfile` module contains functions for encrypting and
62decrypting 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
71The VARBLOCK file format
Sybren A. Stüvel3934ab42016-02-05 16:01:20 +010072++++++++++++++++++++++++
Sybren A. Stüveldbea2132011-08-03 13:31:57 +020073
Sybren A. Stüvel1681a0b2016-01-22 13:54:52 +010074.. 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üvelc1c455d2011-08-01 23:04:30 +020080The VARBLOCK file format allows us to encrypt files that are larger
81than the RSA key. The format is as follows; || denotes byte string
82concatenation::
83
84 VARBLOCK := VERSION || BLOCK || BLOCK || ...
85
86 VERSION := 1
87
88 BLOCK := LENGTH || DATA
89
Sybren A. Stüveldbea2132011-08-03 13:31:57 +020090 LENGTH := varint-encoded length of the following data, in bytes
Sybren A. Stüvelc1c455d2011-08-01 23:04:30 +020091
92 DATA := the data to store in the block
93
94The varint-format was taken from Google's Protobuf_, and allows us to
95efficiently encode an arbitrarily long integer.
96
97.. _Protobuf:
Sybren A. Stüvel3934ab42016-02-05 16:01:20 +010098 https://code.google.com/apis/protocolbuffers/docs/encoding.html#varints
Sybren A. Stüveld92b6672011-07-31 17:44:44 +020099
Sybren A. Stüveldbea2132011-08-03 13:31:57 +0200100
101Module: rsa.core
Sybren A. Stüvel3934ab42016-02-05 16:01:20 +0100102----------------
Sybren A. Stüveldbea2132011-08-03 13:31:57 +0200103
104At the core of the RSA encryption method lie these functions. They
105both operate on (arbitrarily long) integers only. They probably aren't
106of much use to you, but I wanted to document them anyway as they are
107the core of the entire library.
108
109.. autofunction:: rsa.core.encrypt_int
110
111.. autofunction:: rsa.core.decrypt_int
112