blob: 851b31a93ac52402fa6365bd3e4ad209fe8d2950 [file] [log] [blame]
David Reid2a746ce2013-11-15 15:32:14 -08001.. hazmat::
2
3Backend Interfaces
4==================
5
6.. currentmodule:: cryptography.hazmat.bindings.interfaces
7
8
9.. class:: CipherBackend
10
David Reid5973f4c2013-11-18 11:29:44 -080011 A backend which provides methods for using ciphers for encryption
12 and decryption.
13
David Reid2a746ce2013-11-15 15:32:14 -080014 .. method:: cipher_supported(cipher, mode)
15
David Reid5973f4c2013-11-18 11:29:44 -080016 Check if a ``cipher`` and ``mode`` combination is supported by
17 this backend.
18
19 :param cipher: An instance of a
20 :class:`~cryptography.hazmat.primitives.interfaces.CipherAlgorithm`
21 provider.
22 :param mode: An instance of a
23 :class:`~cryptography.hazmat.primitives.interfaces.Mode` provider.
24
25 :returns: ``True`` if the specified ``cipher`` and ``mode`` combination
26 is supported by this backend, otherwise ``False``
David Reid2a746ce2013-11-15 15:32:14 -080027
28 .. method:: register_cipher_adapter(cipher_cls, mode_cls, adapter)
29
David Reid5973f4c2013-11-18 11:29:44 -080030 Register an adapter which can be used to create a backend specific
31 object from instances of the
32 :class:`~cryptography.hazmat.primitives.interfaces.CipherAlgorithm` and
33 the :class:`~cryptography.hazmat.primitives.interfaces.Mode` primitives.
34
35 :param cipher_cls: A class whose instances provide
36 :class:`~cryptography.hazmat.primitives.interfaces.CipherAlgorithm`
37 :param mode_cls: A class whose instances provide:
38 :class:`~cryptography.hazmat.primitives.interfaces.Mode`
39 :param adapter: A ``function`` that takes 3 arguments, ``backend`` (a
40 :class:`CipherBackend` provider), ``cipher`` (a
41 :class:`~cryptography.hazmat.primitives.interfaces.CipherAlgorithm`
42 provider ), and ``mode`` (a
43 :class:`~cryptography.hazmat.primitives.interfaces.Mode` provider).
44 It returns a backend specific object which may be used to construct
45 a :class:`~cryptogrpahy.hazmat.primitives.interfaces.CipherContext`.
46
David Reid2a746ce2013-11-15 15:32:14 -080047
48 .. method:: create_symmetric_encryption_ctx(cipher, mode)
49
David Reid5973f4c2013-11-18 11:29:44 -080050 Create a
51 :class:`~cryptogrpahy.hazmat.primitives.interfaces.CipherContext` that
52 can be used for encrypting data with the symmetric ``cipher`` using
53 the given ``mode``.
54
55 :param cipher: An instance of a
56 :class:`~cryptography.hazmat.primitives.interfaces.CipherAlgorithm`
57 provider.
58 :param mode: An instance of a
59 :class:`~cryptography.hazmat.primitives.interfaces.Mode` provider.
60
61 :returns:
62 :class:`~cryptography.hazmat.primitives.interfaces.CipherContext`
63
David Reid2a746ce2013-11-15 15:32:14 -080064
65 .. method:: create_symmetric_decryption_ctx(cipher, mode)
66
David Reid5973f4c2013-11-18 11:29:44 -080067 Create a
68 :class:`~cryptogrpahy.hazmat.primitives.interfaces.CipherContext` that
69 can be used for decrypting data with the symmetric ``cipher`` using
70 the given ``mode``.
71
72 :param cipher: An instance of a
73 :class:`~cryptography.hazmat.primitives.interfaces.CipherAlgorithm`
74 provider.
75 :param mode: An instance of a
76 :class:`~cryptography.hazmat.primitives.interfaces.Mode` provider.
77
78 :returns:
79 :class:`~cryptography.hazmat.primitives.interfaces.CipherContext`
David Reid2a746ce2013-11-15 15:32:14 -080080
81
82.. class:: HashBackend
83
David Reid5973f4c2013-11-18 11:29:44 -080084 A backend with methods for using cryptographic hash functions.
85
David Reid2a746ce2013-11-15 15:32:14 -080086 .. method:: hash_supported(algorithm)
87
David Reid5973f4c2013-11-18 11:29:44 -080088 :param algorithm: An instance of a
89 :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm`
90 provider.
91
92 :returns: ``True`` if the specified ``algorithm`` is supported by this
93 backend, otherwise ``False``.
94
David Reid2a746ce2013-11-15 15:32:14 -080095
96 .. method:: create_hash_ctx(algorithm)
97
David Reid5973f4c2013-11-18 11:29:44 -080098 :param algorithm: An instance of a
99 :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm`
100 provider.
101
102 :returns:
103 :class:`~cryptography.hazmat.primitives.interfaces.HashContext`
David Reid2a746ce2013-11-15 15:32:14 -0800104
105
106.. class:: HMACBackend
107
David Reid5973f4c2013-11-18 11:29:44 -0800108 A backend with methods for using cryptographic hash functions as message
109 authentication codes.
110
David Reid2a746ce2013-11-15 15:32:14 -0800111 .. method:: create_hmac_ctx(algorithm)
112
David Reid5973f4c2013-11-18 11:29:44 -0800113 :param algorithm: An instance of a
114 :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm`
115 provider.
116
117 :returns:
118 :class:`~cryptography.hazmat.primitives.interfaces.HashContext`