blob: d81f742d41fa3b2f842a5dda1facff270c01f269 [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 +020052The VARBLOCK file format
Sybren A. Stüvel3934ab42016-02-05 16:01:20 +010053++++++++++++++++++++++++
Sybren A. Stüveldbea2132011-08-03 13:31:57 +020054
Sybren A. Stüvel1681a0b2016-01-22 13:54:52 +010055.. warning::
56
57 The VARBLOCK format is NOT recommended for general use, has been deprecated since
Sybren A. Stüvel1d14c4e2017-04-10 11:31:09 +020058 Python-RSA 3.4, and was removed in version 4.0. It's vulnerable to a
Sybren A. Stüvel1681a0b2016-01-22 13:54:52 +010059 number of attacks. See :ref:`bigfiles` for more information.
60
Sybren A. Stüvelc1c455d2011-08-01 23:04:30 +020061The VARBLOCK file format allows us to encrypt files that are larger
62than the RSA key. The format is as follows; || denotes byte string
63concatenation::
64
65 VARBLOCK := VERSION || BLOCK || BLOCK || ...
66
67 VERSION := 1
68
69 BLOCK := LENGTH || DATA
70
Sybren A. Stüveldbea2132011-08-03 13:31:57 +020071 LENGTH := varint-encoded length of the following data, in bytes
Sybren A. Stüvelc1c455d2011-08-01 23:04:30 +020072
73 DATA := the data to store in the block
74
75The varint-format was taken from Google's Protobuf_, and allows us to
76efficiently encode an arbitrarily long integer.
77
78.. _Protobuf:
Sybren A. Stüvel3934ab42016-02-05 16:01:20 +010079 https://code.google.com/apis/protocolbuffers/docs/encoding.html#varints
Sybren A. Stüveld92b6672011-07-31 17:44:44 +020080
Sybren A. Stüveldbea2132011-08-03 13:31:57 +020081
82Module: rsa.core
Sybren A. Stüvel3934ab42016-02-05 16:01:20 +010083----------------
Sybren A. Stüveldbea2132011-08-03 13:31:57 +020084
85At the core of the RSA encryption method lie these functions. They
86both operate on (arbitrarily long) integers only. They probably aren't
87of much use to you, but I wanted to document them anyway as they are
88the core of the entire library.
89
90.. autofunction:: rsa.core.encrypt_int
91
92.. autofunction:: rsa.core.decrypt_int