From 95b8620e738b36a1e6e4bd015149bcb0851b3da9 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Thu, 8 Aug 2013 19:36:44 -0700 Subject: Started stubbing stuff out, including a simple test, now is the part where we write some actual cryptographic software. So yeah. --- docs/primitives/symmetric-encryption.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'docs') diff --git a/docs/primitives/symmetric-encryption.rst b/docs/primitives/symmetric-encryption.rst index fe074f3e..29eb2823 100644 --- a/docs/primitives/symmetric-encryption.rst +++ b/docs/primitives/symmetric-encryption.rst @@ -12,7 +12,7 @@ where the encrypter and decrypter both use the same key. .. code-block:: pycon - >>> from cryptography.primitives.block import BlockCipher, cipher, mode, padding + >>> from cryptography.primitives.block import BlockCipher, ciphers, modes, padding >>> cipher = BlockCipher(cipher.AES(key), mode.CBC(iv, padding.PKCS7())) >>> cipher.encrypt("my secret message") + cipher.finalize() # The ciphertext @@ -36,7 +36,7 @@ where the encrypter and decrypter both use the same key. Ciphers ~~~~~~~ -.. class:: cryptography.primitives.block.cipher.AES(key) +.. class:: cryptography.primitives.block.ciphers.AES(key) AES (Advanced Encryption Standard) is a block cipher standardized by NIST. AES is both fast, and cryptographically strong. It is a good default @@ -49,7 +49,7 @@ Ciphers Modes ~~~~~ -.. class:: cryptography.primitives.block.mode.CBC(initialization_vector, padding) +.. class:: cryptography.primitives.block.modes.CBC(initialization_vector, padding) CBC (Cipher block chaining) is a mode of operation for block ciphers. It is considered cryptographically strong. -- cgit v1.2.3 From 93b1df6049c5b80c336153a7be0e3485fa2611bc Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sat, 10 Aug 2013 15:38:14 -0400 Subject: Remove padding from the docs. --- docs/primitives/symmetric-encryption.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'docs') diff --git a/docs/primitives/symmetric-encryption.rst b/docs/primitives/symmetric-encryption.rst index 090e8e29..05aea0fa 100644 --- a/docs/primitives/symmetric-encryption.rst +++ b/docs/primitives/symmetric-encryption.rst @@ -12,8 +12,8 @@ where the encrypter and decrypter both use the same key. .. code-block:: pycon - >>> from cryptography.primitives.block import BlockCipher, ciphers, modes, padding - >>> cipher = BlockCipher(cipher.AES(key), mode.CBC(iv, padding.PKCS7())) + >>> from cryptography.primitives.block import BlockCipher, ciphers, modes + >>> cipher = BlockCipher(cipher.AES(key), mode.CBC(iv)) >>> cipher.encrypt("my secret message") + cipher.finalize() # The ciphertext [...] @@ -49,7 +49,7 @@ Ciphers Modes ~~~~~ -.. class:: cryptography.primitives.block.modes.CBC(initialization_vector, padding) +.. class:: cryptography.primitives.block.modes.CBC(initialization_vector) CBC (Cipher block chaining) is a mode of operation for block ciphers. It is considered cryptographically strong. -- cgit v1.2.3 From 173de98d630b77583d4541e399b164cc2eb014a7 Mon Sep 17 00:00:00 2001 From: Donald Stufft Date: Mon, 12 Aug 2013 07:34:39 -0400 Subject: Test the symmetric encryption doc snippets using doctest --- docs/primitives/symmetric-encryption.rst | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'docs') diff --git a/docs/primitives/symmetric-encryption.rst b/docs/primitives/symmetric-encryption.rst index 9986d89d..1b8d1d73 100644 --- a/docs/primitives/symmetric-encryption.rst +++ b/docs/primitives/symmetric-encryption.rst @@ -1,6 +1,13 @@ Symmetric Encryption ==================== +.. testsetup:: + + import binascii + key = binascii.unhexlify(b"0" * 32) + iv = binascii.unhexlify(b"0" * 32) + + Symmetric encryption is a way to encrypt (hide the plaintext value) material where the encrypter and decrypter both use the same key. @@ -10,13 +17,12 @@ where the encrypter and decrypter both use the same key. They combine an underlying algorithm (such as AES), with a mode (such as CBC, CTR, or GCM). A simple example of encrypting content with AES is: - .. code-block:: pycon + .. doctest:: >>> from cryptography.primitives.block import BlockCipher, ciphers, modes >>> cipher = BlockCipher(ciphers.AES(key), modes.CBC(iv)) >>> cipher.encrypt(b"a secret message") + cipher.finalize() - # The ciphertext - [...] + '...' :param cipher: One of the ciphers described below. :param mode: One of the modes described below. -- cgit v1.2.3