aboutsummaryrefslogtreecommitdiffstats
path: root/docs/hazmat
diff options
context:
space:
mode:
Diffstat (limited to 'docs/hazmat')
-rw-r--r--docs/hazmat/primitives/hmac.rst32
-rw-r--r--docs/hazmat/primitives/symmetric-encryption.rst16
2 files changed, 35 insertions, 13 deletions
diff --git a/docs/hazmat/primitives/hmac.rst b/docs/hazmat/primitives/hmac.rst
index dc5c54f8..a21799be 100644
--- a/docs/hazmat/primitives/hmac.rst
+++ b/docs/hazmat/primitives/hmac.rst
@@ -37,6 +37,16 @@ message.
If the backend doesn't support the requested ``algorithm`` an
:class:`~cryptography.exceptions.UnsupportedAlgorithm` will be raised.
+ To check that a given signature is correct use the :meth:`verify` method.
+ You will receive 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 +71,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 +81,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:
diff --git a/docs/hazmat/primitives/symmetric-encryption.rst b/docs/hazmat/primitives/symmetric-encryption.rst
index 2233d525..83165690 100644
--- a/docs/hazmat/primitives/symmetric-encryption.rst
+++ b/docs/hazmat/primitives/symmetric-encryption.rst
@@ -169,6 +169,8 @@ Modes
CBC (Cipher block chaining) is a mode of operation for block ciphers. It is
considered cryptographically strong.
+ **Padding is required when using this mode.**
+
:param bytes initialization_vector: Must be random bytes. They do not need
to be kept secret (they can be included
in a transmitted message). Must be the
@@ -211,6 +213,8 @@ Modes
cryptographically strong. It transforms a block cipher into a stream
cipher.
+ **This mode does not require padding.**
+
:param bytes nonce: Should be random bytes. It is critical to never reuse a
``nonce`` with a given key. Any reuse of a nonce
with the same key compromises the security of every
@@ -224,6 +228,8 @@ Modes
OFB (Output Feedback) is a mode of operation for block ciphers. It
transforms a block cipher into a stream cipher.
+ **This mode does not require padding.**
+
:param bytes initialization_vector: Must be random bytes. They do not need
to be kept secret (they can be included
in a transmitted message). Must be the
@@ -237,6 +243,8 @@ Modes
CFB (Cipher Feedback) is a mode of operation for block ciphers. It
transforms a block cipher into a stream cipher.
+ **This mode does not require padding.**
+
:param bytes initialization_vector: Must be random bytes. They do not need
to be kept secret (they can be included
in a transmitted message). Must be the
@@ -261,6 +269,8 @@ Modes
Additional means of verifying integrity (like
:doc:`HMAC </hazmat/primitives/hmac>`) are not necessary.
+ **This mode does not require padding.**
+
:param bytes initialization_vector: Must be random bytes. They do not need
to be kept secret (they can be included
in a transmitted message). NIST
@@ -365,6 +375,8 @@ Insecure Modes
identical plaintext blocks will always result in identical ciphertext
blocks, and thus result in information leakage
+ **Padding is required when using this mode.**
+
Interfaces
----------
@@ -377,8 +389,8 @@ Interfaces
finish the operation and obtain the remainder of the data.
Block ciphers require that plaintext or ciphertext always be a multiple of
- their block size, because of that **padding** is often required to make a
- message the correct size. ``CipherContext`` will not automatically apply
+ their block size, because of that **padding** is sometimes required to make
+ a message the correct size. ``CipherContext`` will not automatically apply
any padding; you'll need to add your own. For block ciphers the recommended
padding is :class:`cryptography.hazmat.primitives.padding.PKCS7`. If you
are using a stream cipher mode (such as