blob: d60fe186a188b32c768f85122cd490d6f940376d [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.. class:: MACContext
55
56 .. versionadded:: 0.7
57
58 .. method:: update(data)
59
Alex Gaynore85e3562014-11-22 23:26:30 -080060 :param bytes data: The data you want to authenticate.
Terry Chiacc5e4452014-10-12 15:35:21 +080061
62 .. method:: finalize()
63
64 :return: The message authentication code.
65
66 .. method:: copy()
67
Alex Gaynor7d156882014-10-20 10:40:34 -070068 :return: A
69 :class:`~cryptography.hazmat.primitives.interfaces.MACContext` that
70 is a copy of the current context.
Terry Chiacc5e4452014-10-12 15:35:21 +080071
Alex Gaynor7d156882014-10-20 10:40:34 -070072 .. method:: verify(signature)
Terry Chiacc5e4452014-10-12 15:35:21 +080073
Alex Gaynore85e3562014-11-22 23:26:30 -080074 :param bytes signature: The signature to verify.
Terry Chiacc5e4452014-10-12 15:35:21 +080075
76 :raises cryptography.exceptions.InvalidSignature: This is raised when
77 the provided signature does not match the expected signature.
Ayrxc8121702014-04-15 19:02:05 +080078
Paul Kehrer05c122b2014-11-24 08:41:05 -100079
Ayrx83cd3f82014-04-15 21:56:32 +080080.. _`CMAC`: https://en.wikipedia.org/wiki/CMAC