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