aboutsummaryrefslogtreecommitdiffstats
path: root/docs/hazmat/primitives
diff options
context:
space:
mode:
authorDavid Reid <dreid@dreid.org>2014-01-08 19:29:44 -0800
committerDavid Reid <dreid@dreid.org>2014-01-08 19:29:44 -0800
commit6a050316afc0e67f00c0068d0ba7e61c4b53a8e6 (patch)
tree1673d297e64527888ca873bdbe50f0ccdd5fd7c0 /docs/hazmat/primitives
parentec276478043d3c9f5355f3352cb80788113a9005 (diff)
parent5bbcf7660b07f5a77ce9ff5666bede3c3377dfc7 (diff)
downloadcryptography-6a050316afc0e67f00c0068d0ba7e61c4b53a8e6.tar.gz
cryptography-6a050316afc0e67f00c0068d0ba7e61c4b53a8e6.tar.bz2
cryptography-6a050316afc0e67f00c0068d0ba7e61c4b53a8e6.zip
Merge pull request #438 from alex/more-prominent-verify
Make verify on HMAC more prominent
Diffstat (limited to 'docs/hazmat/primitives')
-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: