diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-07-12 13:36:18 -0500 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-07-12 13:36:18 -0500 |
commit | 9acea68c91720143ee55818d37e5a0ec585fc816 (patch) | |
tree | 6bf1184173d63848ff74d3ea0c7a774d3d7cfc7b | |
parent | f11d17b5c787409a7689279aec8f5435c64fdce8 (diff) | |
parent | 45fd0572bbc295bb771ba0500c70d6fd1b046847 (diff) | |
download | cryptography-9acea68c91720143ee55818d37e5a0ec585fc816.tar.gz cryptography-9acea68c91720143ee55818d37e5a0ec585fc816.tar.bz2 cryptography-9acea68c91720143ee55818d37e5a0ec585fc816.zip |
Merge pull request #1262 from alex/write-all-the-words
Try to make the examples of verifying an HMAC/CMAC clearer -- refs #1259
-rw-r--r-- | docs/hazmat/primitives/mac/cmac.rst | 4 | ||||
-rw-r--r-- | docs/hazmat/primitives/mac/hmac.rst | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/docs/hazmat/primitives/mac/cmac.rst b/docs/hazmat/primitives/mac/cmac.rst index 104ba8b8..1ba1b3fa 100644 --- a/docs/hazmat/primitives/mac/cmac.rst +++ b/docs/hazmat/primitives/mac/cmac.rst @@ -31,7 +31,7 @@ A subset of CMAC with the AES-128 algorithm is described in :rfc:`4493`. >>> from cryptography.hazmat.primitives.ciphers import algorithms >>> c = cmac.CMAC(algorithms.AES(key), backend=default_backend()) >>> c.update(b"message to authenticate") - >>> c.copy().finalize() + >>> c.finalize() 'CT\x1d\xc8\x0e\x15\xbe4e\xdb\xb6\x84\xca\xd9Xk' If the backend doesn't support the requested ``algorithm`` an @@ -47,6 +47,8 @@ A subset of CMAC with the AES-128 algorithm is described in :rfc:`4493`. .. doctest:: + >>> c = cmac.CMAC(algorithms.AES(key), backend=default_backend()) + >>> c.update(b"message to authenticate") >>> c.verify(b"an incorrect signature") Traceback (most recent call last): ... diff --git a/docs/hazmat/primitives/mac/hmac.rst b/docs/hazmat/primitives/mac/hmac.rst index da75fa9d..9ce49c8d 100644 --- a/docs/hazmat/primitives/mac/hmac.rst +++ b/docs/hazmat/primitives/mac/hmac.rst @@ -31,7 +31,7 @@ of a message. >>> from cryptography.hazmat.primitives import hashes, hmac >>> h = hmac.HMAC(key, hashes.SHA256(), backend=default_backend()) >>> h.update(b"message to hash") - >>> h.copy().finalize() + >>> h.finalize() '#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 @@ -47,6 +47,8 @@ of a message. .. doctest:: + >>> h = hmac.HMAC(key, hashes.SHA256(), backend=default_backend()) + >>> h.update(b"message to hash") >>> h.verify(b"an incorrect signature") Traceback (most recent call last): ... |