blob: f58d324df5f241a54dfd97e7c4be29ce7c143afd [file] [log] [blame]
David Reid30722b92013-11-07 13:03:39 -08001.. hazmat::
2
Paul Kehrer45efdbc2015-02-12 10:58:22 -06003.. module:: cryptography.hazmat.primitives.interfaces
4
David Reid30722b92013-11-07 13:03:39 -08005Interfaces
6==========
7
8
9``cryptography`` uses `Abstract Base Classes`_ as interfaces to describe the
David Reidbd18bcd2013-11-07 13:13:30 -080010properties and methods of most primitive constructs. Backends may also use
11this information to influence their operation. Interfaces should also be used
David Reid30722b92013-11-07 13:03:39 -080012to document argument and return types.
13
Alex Gaynore9df2942014-12-12 10:56:26 -080014.. _`Abstract Base Classes`: https://docs.python.org/3/library/abc.html
David Reid30722b92013-11-07 13:03:39 -080015
16
Alex Stapletonc5fffd32014-03-18 15:29:00 +000017Asymmetric interfaces
Alex Gaynor645315b2014-06-23 11:55:55 -070018---------------------
19
Paul Kehrer0d6203f2015-02-16 13:17:14 -060020In 0.8 the asymmetric signature and verification interfaces were moved to the
21:mod:`cryptography.hazmat.primitives.asymmetric` module.
Alex Gaynor645315b2014-06-23 11:55:55 -070022
Paul Kehrer64ddb7a2015-02-14 19:20:28 -060023In 0.8 the asymmetric padding interface was moved to the
24:mod:`cryptography.hazmat.primitives.asymmetric.padding` module.
Alex Gaynor645315b2014-06-23 11:55:55 -070025
Paul Kehrerd2fa7d22015-02-12 00:15:02 -060026DSA
27~~~
28
29In 0.8 the DSA key interfaces were moved to the
30:mod:`cryptography.hazmat.primitives.asymmetric.dsa` module.
31
Alex Gaynor645315b2014-06-23 11:55:55 -070032
33RSA
34~~~
Paul Kehrerac423232014-01-25 14:13:09 -060035
Alex Stapletonf79c2312014-12-30 12:50:14 +000036In 0.8 the RSA key interfaces were moved to the
37:mod:`cryptography.hazmat.primitives.asymmetric.rsa` module.
Paul Kehrerf0a48c62014-06-07 17:04:13 -050038
Alex Stapleton085f3782014-04-01 16:18:17 +010039
Alex Gaynor645315b2014-06-23 11:55:55 -070040Elliptic Curve
41~~~~~~~~~~~~~~
42
Paul Kehrer3bc87ab2015-02-12 00:01:53 -060043In 0.8 the EC key interfaces were moved to the
44:mod:`cryptography.hazmat.primitives.asymmetric.ec` module.
Paul Kehrere025be22014-09-24 11:26:48 -050045
46
Alex Stapletonc5fffd32014-03-18 15:29:00 +000047Key derivation functions
Alex Gaynor645315b2014-06-23 11:55:55 -070048------------------------
Alex Gaynorb2774f52014-01-27 11:05:29 -080049
Paul Kehrer48402ff2015-02-16 15:31:52 -060050In 0.8 the key derivation function interface was moved to the
51:mod:`cryptography.hazmat.primitives.kdf` module.
Alex Gaynorb2774f52014-01-27 11:05:29 -080052
Ayrxc8121702014-04-15 19:02:05 +080053
Terry Chiacc5e4452014-10-12 15:35:21 +080054`Message Authentication Code`_
55------------------------------
Ayrxc8121702014-04-15 19:02:05 +080056
57.. class:: CMACContext
58
Alex Gaynor7d156882014-10-20 10:40:34 -070059 :class:`CMACContext` has been deprecated in favor of :class:`MACContext`.
Terry Chiac7c82f32014-10-20 12:15:22 +080060
Ayrxc8121702014-04-15 19:02:05 +080061 .. versionadded:: 0.4
62
63 .. method:: update(data)
64
Alex Gaynore85e3562014-11-22 23:26:30 -080065 :param bytes data: The data you want to authenticate.
Ayrxc8121702014-04-15 19:02:05 +080066
67 .. method:: finalize()
68
Ayrx7964c172014-04-15 21:50:58 +080069 :return: The message authentication code.
Ayrxc8121702014-04-15 19:02:05 +080070
71 .. method:: copy()
72
73 :return: A :class:`~cryptography.hazmat.primitives.interfaces.CMACContext`
74 that is a copy of the current context.
75
Terry Chiacc5e4452014-10-12 15:35:21 +080076.. class:: MACContext
77
78 .. versionadded:: 0.7
79
80 .. method:: update(data)
81
Alex Gaynore85e3562014-11-22 23:26:30 -080082 :param bytes data: The data you want to authenticate.
Terry Chiacc5e4452014-10-12 15:35:21 +080083
84 .. method:: finalize()
85
86 :return: The message authentication code.
87
88 .. method:: copy()
89
Alex Gaynor7d156882014-10-20 10:40:34 -070090 :return: A
91 :class:`~cryptography.hazmat.primitives.interfaces.MACContext` that
92 is a copy of the current context.
Terry Chiacc5e4452014-10-12 15:35:21 +080093
Alex Gaynor7d156882014-10-20 10:40:34 -070094 .. method:: verify(signature)
Terry Chiacc5e4452014-10-12 15:35:21 +080095
Alex Gaynore85e3562014-11-22 23:26:30 -080096 :param bytes signature: The signature to verify.
Terry Chiacc5e4452014-10-12 15:35:21 +080097
98 :raises cryptography.exceptions.InvalidSignature: This is raised when
99 the provided signature does not match the expected signature.
Ayrxc8121702014-04-15 19:02:05 +0800100
Paul Kehrer05c122b2014-11-24 08:41:05 -1000101
Ayrx83cd3f82014-04-15 21:56:32 +0800102.. _`CMAC`: https://en.wikipedia.org/wiki/CMAC