David Reid | 30722b9 | 2013-11-07 13:03:39 -0800 | [diff] [blame] | 1 | .. hazmat:: |
| 2 | |
| 3 | Interfaces |
| 4 | ========== |
| 5 | |
| 6 | |
| 7 | ``cryptography`` uses `Abstract Base Classes`_ as interfaces to describe the |
David Reid | bd18bcd | 2013-11-07 13:13:30 -0800 | [diff] [blame] | 8 | properties and methods of most primitive constructs. Backends may also use |
| 9 | this information to influence their operation. Interfaces should also be used |
David Reid | 30722b9 | 2013-11-07 13:03:39 -0800 | [diff] [blame] | 10 | to document argument and return types. |
| 11 | |
David Reid | 9ed25e4 | 2013-11-07 13:15:27 -0800 | [diff] [blame] | 12 | .. _`Abstract Base Classes`: http://docs.python.org/3.2/library/abc.html |
David Reid | 30722b9 | 2013-11-07 13:03:39 -0800 | [diff] [blame] | 13 | |
| 14 | |
David Reid | 0a394df | 2013-11-15 16:19:50 -0800 | [diff] [blame] | 15 | Symmetric Ciphers |
| 16 | ~~~~~~~~~~~~~~~~~ |
David Reid | 30722b9 | 2013-11-07 13:03:39 -0800 | [diff] [blame] | 17 | |
| 18 | .. currentmodule:: cryptography.hazmat.primitives.interfaces |
| 19 | |
David Reid | 0a394df | 2013-11-15 16:19:50 -0800 | [diff] [blame] | 20 | |
| 21 | .. class:: CipherAlgorithm |
| 22 | |
| 23 | A named symmetric encryption algorithm. |
| 24 | |
| 25 | .. attribute:: name |
| 26 | |
| 27 | :type: str |
| 28 | |
| 29 | The standard name for the mode, for example, "AES", "Camellia", or |
| 30 | "Blowfish". |
| 31 | |
| 32 | .. attribute:: key_size |
| 33 | |
| 34 | :type: int |
| 35 | |
| 36 | The number of bits in the key being used. |
| 37 | |
| 38 | |
David Reid | 668d480 | 2013-12-17 11:53:43 -0800 | [diff] [blame] | 39 | .. class:: BlockCipherAlgorithm |
| 40 | |
| 41 | A block cipher algorithm. |
| 42 | |
| 43 | .. attribute:: block_size |
| 44 | |
| 45 | :type: int |
| 46 | |
| 47 | The number of bits in a block. |
| 48 | |
| 49 | |
David Reid | 0a394df | 2013-11-15 16:19:50 -0800 | [diff] [blame] | 50 | Cipher Modes |
| 51 | ------------ |
| 52 | |
David Reid | 30722b9 | 2013-11-07 13:03:39 -0800 | [diff] [blame] | 53 | Interfaces used by the symmetric cipher modes described in |
| 54 | :ref:`Symmetric Encryption Modes <symmetric-encryption-modes>`. |
| 55 | |
| 56 | .. class:: Mode |
| 57 | |
| 58 | A named cipher mode. |
| 59 | |
| 60 | .. attribute:: name |
| 61 | |
| 62 | :type: str |
| 63 | |
| 64 | This should be the standard shorthand name for the mode, for example |
| 65 | Cipher-Block Chaining mode is "CBC". |
| 66 | |
| 67 | The name may be used by a backend to influence the operation of a |
| 68 | cipher in conjunction with the algorithm's name. |
| 69 | |
| 70 | |
| 71 | .. class:: ModeWithInitializationVector |
| 72 | |
| 73 | A cipher mode with an initialization vector. |
| 74 | |
| 75 | .. attribute:: initialization_vector |
| 76 | |
| 77 | :type: bytes |
| 78 | |
| 79 | Exact requirements of the initialization are described by the |
| 80 | documentation of individual modes. |
| 81 | |
| 82 | |
| 83 | .. class:: ModeWithNonce |
| 84 | |
| 85 | A cipher mode with a nonce. |
| 86 | |
| 87 | .. attribute:: nonce |
| 88 | |
| 89 | :type: bytes |
| 90 | |
| 91 | Exact requirements of the nonce are described by the documentation of |
| 92 | individual modes. |