Alex Stapleton | 940eee2 | 2014-02-05 20:25:30 +0000 | [diff] [blame] | 1 | .. hazmat:: |
| 2 | |
| 3 | RSA |
| 4 | === |
| 5 | |
| 6 | .. currentmodule:: cryptography.hazmat.primitives.asymmetric.rsa |
| 7 | |
| 8 | `RSA`_ is a `public-key`_ algorithm for encrypting and signing messages. |
| 9 | |
| 10 | .. class:: RSAPrivateKey(p, q, private_exponent, public_exponent, modulus) |
| 11 | |
| 12 | .. versionadded:: 0.2 |
| 13 | |
| 14 | An RSA private key is required for decryption and signing of messages. |
| 15 | |
| 16 | Normally you do not need to directly construct private keys because you'll |
| 17 | be loading them from a file or generating them automatically. |
| 18 | |
Alex Stapleton | be5da2d | 2014-02-07 08:15:39 +0000 | [diff] [blame] | 19 | .. warning:: |
| 20 | This method only checks a limited set of properties of its arguments. |
| 21 | Using an RSA that you do not trust or with incorrect parameters may |
| 22 | lead to insecure operation, crashes, and other undefined behavior. We |
| 23 | recommend that you only ever load private keys that were generated with |
| 24 | software you trust. |
| 25 | |
Alex Stapleton | 940eee2 | 2014-02-05 20:25:30 +0000 | [diff] [blame] | 26 | This class conforms to the |
| 27 | :class:`~cryptography.hazmat.primitives.interfaces.RSAPrivateKey` |
| 28 | interface. |
| 29 | |
| 30 | :raises TypeError: This is raised when the arguments are not all integers. |
| 31 | |
Alex Stapleton | 4eaab17 | 2014-02-06 21:06:18 +0000 | [diff] [blame] | 32 | :raises ValueError: This is raised when the values of `p`, `q`, |
| 33 | `private_exponent`, `public_exponent` or `modulus` do |
| 34 | not match the bounds specified in `RFC 3447`_. |
Alex Stapleton | 940eee2 | 2014-02-05 20:25:30 +0000 | [diff] [blame] | 35 | |
| 36 | .. class:: RSAPublicKey(public_exponent, modulus) |
| 37 | |
| 38 | .. versionadded:: 0.2 |
| 39 | |
| 40 | An RSA public key is required for encryption and verification of messages. |
| 41 | |
| 42 | Normally you do not need to directly construct public keys because you'll |
| 43 | be loading them from a file, generating them automatically or receiving |
| 44 | them from a 3rd party. |
| 45 | |
| 46 | This class conforms to the |
| 47 | :class:`~cryptography.hazmat.primitives.interfaces.RSAPublicKey` |
| 48 | interface. |
| 49 | |
| 50 | :raises TypeError: This is raised when the arguments are not all integers. |
| 51 | |
| 52 | :raises ValueError: This is raised when the values of `public_exponent` or |
| 53 | `modulus` do not match the bounds specified in |
Alex Stapleton | f44b6a9 | 2014-02-07 18:28:47 +0000 | [diff] [blame^] | 54 | `RFC 3447`_. |
Alex Stapleton | 940eee2 | 2014-02-05 20:25:30 +0000 | [diff] [blame] | 55 | |
| 56 | .. _`RSA`: https://en.wikipedia.org/wiki/RSA_(cryptosystem) |
| 57 | .. _`public-key`: https://en.wikipedia.org/wiki/Public-key_cryptography |
| 58 | .. _`RFC 3447`: https://tools.ietf.org/html/rfc3447 |