David Reid | 30722b9 | 2013-11-07 13:03:39 -0800 | [diff] [blame] | 1 | .. hazmat:: |
| 2 | |
Paul Kehrer | 45efdbc | 2015-02-12 10:58:22 -0600 | [diff] [blame] | 3 | .. module:: cryptography.hazmat.primitives.interfaces |
| 4 | |
David Reid | 30722b9 | 2013-11-07 13:03:39 -0800 | [diff] [blame] | 5 | Interfaces |
| 6 | ========== |
| 7 | |
| 8 | |
| 9 | ``cryptography`` uses `Abstract Base Classes`_ as interfaces to describe the |
David Reid | bd18bcd | 2013-11-07 13:13:30 -0800 | [diff] [blame] | 10 | properties and methods of most primitive constructs. Backends may also use |
| 11 | this information to influence their operation. Interfaces should also be used |
David Reid | 30722b9 | 2013-11-07 13:03:39 -0800 | [diff] [blame] | 12 | to document argument and return types. |
| 13 | |
Alex Gaynor | e9df294 | 2014-12-12 10:56:26 -0800 | [diff] [blame] | 14 | .. _`Abstract Base Classes`: https://docs.python.org/3/library/abc.html |
David Reid | 30722b9 | 2013-11-07 13:03:39 -0800 | [diff] [blame] | 15 | |
| 16 | |
Alex Stapleton | c5fffd3 | 2014-03-18 15:29:00 +0000 | [diff] [blame] | 17 | Asymmetric interfaces |
Alex Gaynor | 645315b | 2014-06-23 11:55:55 -0700 | [diff] [blame] | 18 | --------------------- |
| 19 | |
Paul Kehrer | 0d6203f | 2015-02-16 13:17:14 -0600 | [diff] [blame] | 20 | In 0.8 the asymmetric signature and verification interfaces were moved to the |
| 21 | :mod:`cryptography.hazmat.primitives.asymmetric` module. |
Alex Gaynor | 645315b | 2014-06-23 11:55:55 -0700 | [diff] [blame] | 22 | |
Paul Kehrer | 64ddb7a | 2015-02-14 19:20:28 -0600 | [diff] [blame] | 23 | In 0.8 the asymmetric padding interface was moved to the |
| 24 | :mod:`cryptography.hazmat.primitives.asymmetric.padding` module. |
Alex Gaynor | 645315b | 2014-06-23 11:55:55 -0700 | [diff] [blame] | 25 | |
Paul Kehrer | d2fa7d2 | 2015-02-12 00:15:02 -0600 | [diff] [blame] | 26 | DSA |
| 27 | ~~~ |
| 28 | |
| 29 | In 0.8 the DSA key interfaces were moved to the |
| 30 | :mod:`cryptography.hazmat.primitives.asymmetric.dsa` module. |
| 31 | |
Alex Gaynor | 645315b | 2014-06-23 11:55:55 -0700 | [diff] [blame] | 32 | |
| 33 | RSA |
| 34 | ~~~ |
Paul Kehrer | ac42323 | 2014-01-25 14:13:09 -0600 | [diff] [blame] | 35 | |
Alex Stapleton | f79c231 | 2014-12-30 12:50:14 +0000 | [diff] [blame] | 36 | In 0.8 the RSA key interfaces were moved to the |
| 37 | :mod:`cryptography.hazmat.primitives.asymmetric.rsa` module. |
Paul Kehrer | f0a48c6 | 2014-06-07 17:04:13 -0500 | [diff] [blame] | 38 | |
Alex Stapleton | 085f378 | 2014-04-01 16:18:17 +0100 | [diff] [blame] | 39 | |
Alex Gaynor | 645315b | 2014-06-23 11:55:55 -0700 | [diff] [blame] | 40 | Elliptic Curve |
| 41 | ~~~~~~~~~~~~~~ |
| 42 | |
Paul Kehrer | 3bc87ab | 2015-02-12 00:01:53 -0600 | [diff] [blame] | 43 | In 0.8 the EC key interfaces were moved to the |
| 44 | :mod:`cryptography.hazmat.primitives.asymmetric.ec` module. |
Paul Kehrer | e025be2 | 2014-09-24 11:26:48 -0500 | [diff] [blame] | 45 | |
| 46 | |
Alex Stapleton | c5fffd3 | 2014-03-18 15:29:00 +0000 | [diff] [blame] | 47 | Key derivation functions |
Alex Gaynor | 645315b | 2014-06-23 11:55:55 -0700 | [diff] [blame] | 48 | ------------------------ |
Alex Gaynor | b2774f5 | 2014-01-27 11:05:29 -0800 | [diff] [blame] | 49 | |
Paul Kehrer | 48402ff | 2015-02-16 15:31:52 -0600 | [diff] [blame] | 50 | In 0.8 the key derivation function interface was moved to the |
| 51 | :mod:`cryptography.hazmat.primitives.kdf` module. |
Alex Gaynor | b2774f5 | 2014-01-27 11:05:29 -0800 | [diff] [blame] | 52 | |
Ayrx | c812170 | 2014-04-15 19:02:05 +0800 | [diff] [blame] | 53 | |
Terry Chia | cc5e445 | 2014-10-12 15:35:21 +0800 | [diff] [blame] | 54 | .. class:: MACContext |
| 55 | |
| 56 | .. versionadded:: 0.7 |
| 57 | |
| 58 | .. method:: update(data) |
| 59 | |
Alex Gaynor | e85e356 | 2014-11-22 23:26:30 -0800 | [diff] [blame] | 60 | :param bytes data: The data you want to authenticate. |
Terry Chia | cc5e445 | 2014-10-12 15:35:21 +0800 | [diff] [blame] | 61 | |
| 62 | .. method:: finalize() |
| 63 | |
| 64 | :return: The message authentication code. |
| 65 | |
| 66 | .. method:: copy() |
| 67 | |
Alex Gaynor | 7d15688 | 2014-10-20 10:40:34 -0700 | [diff] [blame] | 68 | :return: A |
| 69 | :class:`~cryptography.hazmat.primitives.interfaces.MACContext` that |
| 70 | is a copy of the current context. |
Terry Chia | cc5e445 | 2014-10-12 15:35:21 +0800 | [diff] [blame] | 71 | |
Alex Gaynor | 7d15688 | 2014-10-20 10:40:34 -0700 | [diff] [blame] | 72 | .. method:: verify(signature) |
Terry Chia | cc5e445 | 2014-10-12 15:35:21 +0800 | [diff] [blame] | 73 | |
Alex Gaynor | e85e356 | 2014-11-22 23:26:30 -0800 | [diff] [blame] | 74 | :param bytes signature: The signature to verify. |
Terry Chia | cc5e445 | 2014-10-12 15:35:21 +0800 | [diff] [blame] | 75 | |
| 76 | :raises cryptography.exceptions.InvalidSignature: This is raised when |
| 77 | the provided signature does not match the expected signature. |
Ayrx | c812170 | 2014-04-15 19:02:05 +0800 | [diff] [blame] | 78 | |
Paul Kehrer | 05c122b | 2014-11-24 08:41:05 -1000 | [diff] [blame] | 79 | |
Ayrx | 83cd3f8 | 2014-04-15 21:56:32 +0800 | [diff] [blame] | 80 | .. _`CMAC`: https://en.wikipedia.org/wiki/CMAC |