aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2014-01-08 18:36:57 -0800
committerAlex Gaynor <alex.gaynor@gmail.com>2014-01-08 18:36:57 -0800
commit5bbcf7660b07f5a77ce9ff5666bede3c3377dfc7 (patch)
treef96e36d4e1438e379998d26761f311d8c7158245 /docs
parentc958f0cf3388029558b38b02cd7debdbcc2bd825 (diff)
downloadcryptography-5bbcf7660b07f5a77ce9ff5666bede3c3377dfc7.tar.gz
cryptography-5bbcf7660b07f5a77ce9ff5666bede3c3377dfc7.tar.bz2
cryptography-5bbcf7660b07f5a77ce9ff5666bede3c3377dfc7.zip
Make verify on HMAC more prominent
Diffstat (limited to 'docs')
-rw-r--r--docs/hazmat/primitives/hmac.rst33
1 files changed, 22 insertions, 11 deletions
diff --git a/docs/hazmat/primitives/hmac.rst b/docs/hazmat/primitives/hmac.rst
index dc5c54f8..f4f5daa1 100644
--- a/docs/hazmat/primitives/hmac.rst
+++ b/docs/hazmat/primitives/hmac.rst
@@ -37,6 +37,17 @@ message.
If the backend doesn't support the requested ``algorithm`` an
:class:`~cryptography.exceptions.UnsupportedAlgorithm` will be raised.
+ If you've been given a signature and need to check that it's correct, this
+ can be done with the :meth:`verify` method, you'll get an exception if the
+ signature is wrong:
+
+ .. code-block:: pycon
+
+ >>> h.verify(b"an incorrect signature")
+ Traceback (most recent call last):
+ ...
+ cryptography.exceptions.InvalidSignature: Signature did not match digest.
+
:param key: Secret key as ``bytes``.
:param algorithm: A
:class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm`
@@ -61,17 +72,6 @@ message.
and finalized independently of the original instance.
:raises cryptography.exceptions.AlreadyFinalized: See :meth:`finalize`
- .. method:: finalize()
-
- Finalize the current context and return the message digest as bytes.
-
- Once ``finalize`` is called this object can no longer be used and
- :meth:`update`, :meth:`copy`, and :meth:`finalize` will raise
- :class:`~cryptography.exceptions.AlreadyFinalized`.
-
- :return bytes: The message digest as bytes.
- :raises cryptography.exceptions.AlreadyFinalized:
-
.. method:: verify(signature)
Finalize the current context and securely compare digest to
@@ -82,3 +82,14 @@ message.
:raises cryptography.exceptions.AlreadyFinalized: See :meth:`finalize`
:raises cryptography.exceptions.InvalidSignature: If signature does not
match digest
+
+ .. method:: finalize()
+
+ Finalize the current context and return the message digest as bytes.
+
+ Once ``finalize`` is called this object can no longer be used and
+ :meth:`update`, :meth:`copy`, and :meth:`finalize` will raise
+ :class:`~cryptography.exceptions.AlreadyFinalized`.
+
+ :return bytes: The message digest as bytes.
+ :raises cryptography.exceptions.AlreadyFinalized: