aboutsummaryrefslogtreecommitdiffstats
path: root/docs/hazmat/primitives
diff options
context:
space:
mode:
authorDavid Reid <dreid@dreid.org>2013-11-06 11:12:45 -0800
committerDavid Reid <dreid@dreid.org>2013-11-20 09:50:18 -0800
commitef0fcf26c920c011948f078481739f4e2c31535f (patch)
tree24fa4b4603d77f24b6052fac5ce3b9337a685871 /docs/hazmat/primitives
parent077e76e697ebf25aa9fd757f0ef1fd1251b7d408 (diff)
downloadcryptography-ef0fcf26c920c011948f078481739f4e2c31535f.tar.gz
cryptography-ef0fcf26c920c011948f078481739f4e2c31535f.tar.bz2
cryptography-ef0fcf26c920c011948f078481739f4e2c31535f.zip
Add a default_backend and start updating docs.
Diffstat (limited to 'docs/hazmat/primitives')
-rw-r--r--docs/hazmat/primitives/cryptographic-hashes.rst6
-rw-r--r--docs/hazmat/primitives/hmac.rst5
-rw-r--r--docs/hazmat/primitives/symmetric-encryption.rst9
3 files changed, 12 insertions, 8 deletions
diff --git a/docs/hazmat/primitives/cryptographic-hashes.rst b/docs/hazmat/primitives/cryptographic-hashes.rst
index 52e87702..b3db9f19 100644
--- a/docs/hazmat/primitives/cryptographic-hashes.rst
+++ b/docs/hazmat/primitives/cryptographic-hashes.rst
@@ -5,7 +5,7 @@ Message Digests
.. currentmodule:: cryptography.hazmat.primitives.hashes
-.. class:: Hash(algorithm)
+.. class:: Hash(algorithm, backend)
A cryptographic hash function takes an arbitrary block of data and
calculates a fixed-size bit string (a digest), such that different data
@@ -19,9 +19,9 @@ Message Digests
various message digests.
.. doctest::
-
+ >>> from cryptography.hazmat.bindings import default_backend
>>> from cryptography.hazmat.primitives import hashes
- >>> digest = hashes.Hash(hashes.SHA256())
+ >>> digest = hashes.Hash(hashes.SHA256(), default_backend())
>>> digest.update(b"abc")
>>> digest.update(b"123")
>>> digest.finalize()
diff --git a/docs/hazmat/primitives/hmac.rst b/docs/hazmat/primitives/hmac.rst
index cff2dbf1..7d87ca7e 100644
--- a/docs/hazmat/primitives/hmac.rst
+++ b/docs/hazmat/primitives/hmac.rst
@@ -15,7 +15,7 @@ message authentication codes using a cryptographic hash function coupled with a
secret key. You can use an HMAC to verify integrity as well as authenticate a
message.
-.. class:: HMAC(key, algorithm)
+.. class:: HMAC(key, algorithm, backend)
HMAC objects take a ``key`` and a provider of
:class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm`.
@@ -27,8 +27,9 @@ message.
.. doctest::
+ >>> from cryptography.hazmat.bindings import default_backend
>>> from cryptography.hazmat.primitives import hashes, hmac
- >>> h = hmac.HMAC(key, hashes.SHA256())
+ >>> h = hmac.HMAC(key, hashes.SHA256(), 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'
diff --git a/docs/hazmat/primitives/symmetric-encryption.rst b/docs/hazmat/primitives/symmetric-encryption.rst
index eef359d6..42d2090c 100644
--- a/docs/hazmat/primitives/symmetric-encryption.rst
+++ b/docs/hazmat/primitives/symmetric-encryption.rst
@@ -12,6 +12,9 @@ Symmetric Encryption
key = binascii.unhexlify(b"0" * 32)
iv = binascii.unhexlify(b"0" * 32)
+ from cryptography.hazmat.bindings import default_backend
+ backend = default_backend()
+
Symmetric encryption is a way to encrypt (hide the plaintext value) material
where the sender and receiver both use the same key. Note that symmetric
@@ -22,7 +25,7 @@ For this reason it is *strongly* recommended to combine encryption with a
message authentication code, such as :doc:`HMAC </hazmat/primitives/hmac>`, in
an "encrypt-then-MAC" formulation as `described by Colin Percival`_.
-.. class:: Cipher(algorithm, mode)
+.. class:: Cipher(algorithm, mode, backend)
Cipher objects combine an algorithm (such as
:class:`~cryptography.hazmat.primitives.ciphers.algorithms.AES`) with a
@@ -33,8 +36,8 @@ an "encrypt-then-MAC" formulation as `described by Colin Percival`_.
.. doctest::
- >>> from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
- >>> cipher = Cipher(algorithms.AES(key), modes.CBC(iv))
+ >>> from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, mode
+ >>> cipher = Cipher(algorithms.AES(key), modes.CBC(iv), backend)
>>> encryptor = cipher.encryptor()
>>> ct = encryptor.update(b"a secret message") + encryptor.finalize()
>>> decryptor = cipher.decryptor()