aboutsummaryrefslogtreecommitdiffstats
path: root/docs/hazmat/primitives/mac/hmac.rst
diff options
context:
space:
mode:
Diffstat (limited to 'docs/hazmat/primitives/mac/hmac.rst')
-rw-r--r--docs/hazmat/primitives/mac/hmac.rst20
1 files changed, 11 insertions, 9 deletions
diff --git a/docs/hazmat/primitives/mac/hmac.rst b/docs/hazmat/primitives/mac/hmac.rst
index 2515ac91..9d11694b 100644
--- a/docs/hazmat/primitives/mac/hmac.rst
+++ b/docs/hazmat/primitives/mac/hmac.rst
@@ -1,7 +1,7 @@
.. hazmat::
-Hash-based message authentication codes
-=======================================
+Hash-based message authentication codes (HMAC)
+==============================================
.. currentmodule:: cryptography.hazmat.primitives.hmac
@@ -18,7 +18,7 @@ of a message.
.. class:: HMAC(key, algorithm, backend)
HMAC objects take a ``key`` and a
- :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` provider.
+ :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` instance.
The ``key`` should be :doc:`randomly generated bytes </random-numbers>` and
is recommended to be equal in length to the ``digest_size`` of the hash
function chosen. You must keep the ``key`` secret.
@@ -32,14 +32,14 @@ of a message.
>>> h = hmac.HMAC(key, hashes.SHA256(), backend=default_backend())
>>> h.update(b"message to hash")
>>> h.finalize()
- '#F\xdaI\x8b"e\xc4\xf1\xbb\x9a\x8fc\xff\xf5\xdex.\xbc\xcd/+\x8a\x86\x1d\x84\'\xc3\xa6\x1d\xd8J'
+ b'#F\xdaI\x8b"e\xc4\xf1\xbb\x9a\x8fc\xff\xf5\xdex.\xbc\xcd/+\x8a\x86\x1d\x84\'\xc3\xa6\x1d\xd8J'
If the backend doesn't support the requested ``algorithm`` an
:class:`~cryptography.exceptions.UnsupportedAlgorithm` exception will be
raised.
If ``algorithm`` isn't a
- :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` provider
+ :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` instance
then ``TypeError`` will be raised.
To check that a given signature is correct use the :meth:`verify` method.
@@ -54,14 +54,15 @@ of a message.
...
cryptography.exceptions.InvalidSignature: Signature did not match digest.
- :param bytes key: Secret key as ``bytes``.
+ :param key: Secret key as ``bytes``.
+ :type key: :term:`bytes-like`
:param algorithm: An
:class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm`
- provider such as those described in
+ instance such as those described in
:ref:`Cryptographic Hashes <cryptographic-hash-algorithms>`.
:param backend: An
:class:`~cryptography.hazmat.backends.interfaces.HMACBackend`
- provider.
+ instance.
:raises cryptography.exceptions.UnsupportedAlgorithm: This is raised if the
provided ``backend`` does not implement
@@ -69,7 +70,8 @@ of a message.
.. method:: update(msg)
- :param bytes msg: The bytes to hash and authenticate.
+ :param msg: The bytes to hash and authenticate.
+ :type msg: :term:`bytes-like`
:raises cryptography.exceptions.AlreadyFinalized: See :meth:`finalize`
:raises TypeError: This exception is raised if ``msg`` is not ``bytes``.