diff options
author | Donald Stufft <donald@stufft.io> | 2013-11-22 17:24:23 -0800 |
---|---|---|
committer | Donald Stufft <donald@stufft.io> | 2013-11-22 17:24:23 -0800 |
commit | 8cf523ead464e758d1aa22a7a8abbc2eae2c9404 (patch) | |
tree | 10e3c439ad53412d1bb2b42c69f7050f25d2cfd7 /docs/hazmat/primitives/symmetric-encryption.rst | |
parent | 838ad7d2f5bb97242a9f75ac9055be5be75a7711 (diff) | |
parent | b7e8990aabb46ac6c0511530d7a67f69e08f1788 (diff) | |
download | cryptography-8cf523ead464e758d1aa22a7a8abbc2eae2c9404.tar.gz cryptography-8cf523ead464e758d1aa22a7a8abbc2eae2c9404.tar.bz2 cryptography-8cf523ead464e758d1aa22a7a8abbc2eae2c9404.zip |
Merge pull request #274 from alex/handle-bad-padding
Raise a correct error when content isn't padded correctly
Diffstat (limited to 'docs/hazmat/primitives/symmetric-encryption.rst')
-rw-r--r-- | docs/hazmat/primitives/symmetric-encryption.rst | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/docs/hazmat/primitives/symmetric-encryption.rst b/docs/hazmat/primitives/symmetric-encryption.rst index eef359d6..732af33c 100644 --- a/docs/hazmat/primitives/symmetric-encryption.rst +++ b/docs/hazmat/primitives/symmetric-encryption.rst @@ -75,6 +75,15 @@ an "encrypt-then-MAC" formulation as `described by Colin Percival`_. everything into the context. Once that is done call ``finalize()`` to 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 + any padding; you'll need to add your own. For block ciphers the reccomended + padding is :class:`cryptography.hazmat.primitives.padding.PKCS7`. If you + are using a stream cipher mode (such as + :class:`cryptography.hazmat.primitives.modes.CTR`) you don't have to worry + about this. + .. method:: update(data) :param bytes data: The data you wish to pass into the context. @@ -90,6 +99,9 @@ an "encrypt-then-MAC" formulation as `described by Colin Percival`_. .. method:: finalize() :return bytes: Returns the remainder of the data. + :raises ValueError: This is raised when the data provided isn't + correctly padded to be a multiple of the + algorithm's block size. Once ``finalize`` is called this object can no longer be used and :meth:`update` and :meth:`finalize` will raise |