aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2015-02-14 10:27:14 -0600
committerPaul Kehrer <paul.l.kehrer@gmail.com>2015-02-14 10:36:24 -0600
commit7c5c9fedd513f4ef66b62fcf5fdcde8dc30fe532 (patch)
tree1600ea1cdc548421f021bdc79a1251db8a7a0ebf /src
parent2129d5035849c69f990a646ac76891d1a886be55 (diff)
downloadcryptography-7c5c9fedd513f4ef66b62fcf5fdcde8dc30fe532.tar.gz
cryptography-7c5c9fedd513f4ef66b62fcf5fdcde8dc30fe532.tar.bz2
cryptography-7c5c9fedd513f4ef66b62fcf5fdcde8dc30fe532.zip
export interfaces from base in ciphers, update docs
Diffstat (limited to 'src')
-rw-r--r--src/cryptography/hazmat/backends/commoncrypto/ciphers.py12
-rw-r--r--src/cryptography/hazmat/backends/openssl/ciphers.py13
-rw-r--r--src/cryptography/hazmat/primitives/ciphers/__init__.py10
-rw-r--r--src/cryptography/hazmat/primitives/ciphers/algorithms.py2
-rw-r--r--src/cryptography/hazmat/primitives/cmac.py5
-rw-r--r--src/cryptography/hazmat/primitives/interfaces/__init__.py24
6 files changed, 37 insertions, 29 deletions
diff --git a/src/cryptography/hazmat/backends/commoncrypto/ciphers.py b/src/cryptography/hazmat/backends/commoncrypto/ciphers.py
index 54715d85..1ce8aec5 100644
--- a/src/cryptography/hazmat/backends/commoncrypto/ciphers.py
+++ b/src/cryptography/hazmat/backends/commoncrypto/ciphers.py
@@ -8,14 +8,14 @@ from cryptography import utils
from cryptography.exceptions import (
InvalidTag, UnsupportedAlgorithm, _Reasons
)
-from cryptography.hazmat.primitives import constant_time
-from cryptography.hazmat.primitives.ciphers import base, modes
+from cryptography.hazmat.primitives import ciphers, constant_time
+from cryptography.hazmat.primitives.ciphers import modes
from cryptography.hazmat.primitives.ciphers.modes import (
CFB, CFB8, CTR, OFB
)
-@utils.register_interface(base.CipherContext)
+@utils.register_interface(ciphers.CipherContext)
class _CipherContext(object):
def __init__(self, backend, cipher, mode, operation):
self._backend = backend
@@ -32,7 +32,7 @@ class _CipherContext(object):
# treat RC4 and other stream cipher block sizes).
# This bug has been filed as rdar://15589470
self._bytes_processed = 0
- if (isinstance(cipher, base.BlockCipherAlgorithm) and not
+ if (isinstance(cipher, ciphers.BlockCipherAlgorithm) and not
isinstance(mode, (OFB, CFB, CFB8, CTR))):
self._byte_block_size = cipher.block_size // 8
else:
@@ -102,8 +102,8 @@ class _CipherContext(object):
return self._backend._ffi.buffer(buf)[:outlen[0]]
-@utils.register_interface(base.AEADCipherContext)
-@utils.register_interface(base.AEADEncryptionContext)
+@utils.register_interface(ciphers.AEADCipherContext)
+@utils.register_interface(ciphers.AEADEncryptionContext)
class _GCMCipherContext(object):
def __init__(self, backend, cipher, mode, operation):
self._backend = backend
diff --git a/src/cryptography/hazmat/backends/openssl/ciphers.py b/src/cryptography/hazmat/backends/openssl/ciphers.py
index e836175d..64097c7b 100644
--- a/src/cryptography/hazmat/backends/openssl/ciphers.py
+++ b/src/cryptography/hazmat/backends/openssl/ciphers.py
@@ -6,12 +6,13 @@ from __future__ import absolute_import, division, print_function
from cryptography import utils
from cryptography.exceptions import InvalidTag, UnsupportedAlgorithm, _Reasons
-from cryptography.hazmat.primitives.ciphers import base, modes
+from cryptography.hazmat.primitives import ciphers
+from cryptography.hazmat.primitives.ciphers import modes
-@utils.register_interface(base.CipherContext)
-@utils.register_interface(base.AEADCipherContext)
-@utils.register_interface(base.AEADEncryptionContext)
+@utils.register_interface(ciphers.CipherContext)
+@utils.register_interface(ciphers.AEADCipherContext)
+@utils.register_interface(ciphers.AEADEncryptionContext)
class _CipherContext(object):
_ENCRYPT = 1
_DECRYPT = 0
@@ -23,7 +24,7 @@ class _CipherContext(object):
self._operation = operation
self._tag = None
- if isinstance(self._cipher, base.BlockCipherAlgorithm):
+ if isinstance(self._cipher, ciphers.BlockCipherAlgorithm):
self._block_size = self._cipher.block_size
else:
self._block_size = 1
@@ -180,7 +181,7 @@ class _CipherContext(object):
tag = utils.read_only_property("_tag")
-@utils.register_interface(base.CipherContext)
+@utils.register_interface(ciphers.CipherContext)
class _AESCTRCipherContext(object):
"""
This is needed to provide support for AES CTR mode in OpenSSL 0.9.8. It can
diff --git a/src/cryptography/hazmat/primitives/ciphers/__init__.py b/src/cryptography/hazmat/primitives/ciphers/__init__.py
index d779531d..b5dd0ed7 100644
--- a/src/cryptography/hazmat/primitives/ciphers/__init__.py
+++ b/src/cryptography/hazmat/primitives/ciphers/__init__.py
@@ -4,9 +4,17 @@
from __future__ import absolute_import, division, print_function
-from cryptography.hazmat.primitives.ciphers.base import Cipher
+from cryptography.hazmat.primitives.ciphers.base import (
+ AEADCipherContext, AEADEncryptionContext, BlockCipherAlgorithm, Cipher,
+ CipherAlgorithm, CipherContext
+)
__all__ = [
"Cipher",
+ "CipherAlgorithm",
+ "BlockCipherAlgorithm",
+ "CipherContext",
+ "AEADCipherContext",
+ "AEADEncryptionContext",
]
diff --git a/src/cryptography/hazmat/primitives/ciphers/algorithms.py b/src/cryptography/hazmat/primitives/ciphers/algorithms.py
index 0e219bec..b71dddbb 100644
--- a/src/cryptography/hazmat/primitives/ciphers/algorithms.py
+++ b/src/cryptography/hazmat/primitives/ciphers/algorithms.py
@@ -5,7 +5,7 @@
from __future__ import absolute_import, division, print_function
from cryptography import utils
-from cryptography.hazmat.primitives.ciphers.base import (
+from cryptography.hazmat.primitives.ciphers import (
BlockCipherAlgorithm, CipherAlgorithm
)
diff --git a/src/cryptography/hazmat/primitives/cmac.py b/src/cryptography/hazmat/primitives/cmac.py
index d746147a..c2038a30 100644
--- a/src/cryptography/hazmat/primitives/cmac.py
+++ b/src/cryptography/hazmat/primitives/cmac.py
@@ -9,8 +9,7 @@ from cryptography.exceptions import (
AlreadyFinalized, UnsupportedAlgorithm, _Reasons
)
from cryptography.hazmat.backends.interfaces import CMACBackend
-from cryptography.hazmat.primitives import interfaces
-from cryptography.hazmat.primitives.ciphers import base
+from cryptography.hazmat.primitives import ciphers, interfaces
@utils.register_interface(interfaces.MACContext)
@@ -22,7 +21,7 @@ class CMAC(object):
_Reasons.BACKEND_MISSING_INTERFACE
)
- if not isinstance(algorithm, base.BlockCipherAlgorithm):
+ if not isinstance(algorithm, ciphers.BlockCipherAlgorithm):
raise TypeError(
"Expected instance of BlockCipherAlgorithm."
)
diff --git a/src/cryptography/hazmat/primitives/interfaces/__init__.py b/src/cryptography/hazmat/primitives/interfaces/__init__.py
index 52433e16..5de7fb8c 100644
--- a/src/cryptography/hazmat/primitives/interfaces/__init__.py
+++ b/src/cryptography/hazmat/primitives/interfaces/__init__.py
@@ -9,28 +9,28 @@ import abc
import six
from cryptography import utils
-from cryptography.hazmat.primitives import hashes, padding
+from cryptography.hazmat.primitives import ciphers, hashes, padding
from cryptography.hazmat.primitives.asymmetric import dsa, ec, rsa
-from cryptography.hazmat.primitives.ciphers import base, modes
+from cryptography.hazmat.primitives.ciphers import modes
BlockCipherAlgorithm = utils.deprecated(
- base.BlockCipherAlgorithm,
+ ciphers.BlockCipherAlgorithm,
__name__,
(
"The BlockCipherAlgorithm interface has moved to the "
- "cryptography.hazmat.primitives.ciphers.base module"
+ "cryptography.hazmat.primitives.ciphers module"
),
utils.DeprecatedIn08
)
CipherAlgorithm = utils.deprecated(
- base.CipherAlgorithm,
+ ciphers.CipherAlgorithm,
__name__,
(
"The CipherAlgorithm interface has moved to the "
- "cryptography.hazmat.primitives.ciphers.base module"
+ "cryptography.hazmat.primitives.ciphers module"
),
utils.DeprecatedIn08
)
@@ -81,33 +81,33 @@ ModeWithNonce = utils.deprecated(
CipherContext = utils.deprecated(
- base.CipherContext,
+ ciphers.CipherContext,
__name__,
(
"The CipherContext interface has moved to the "
- "cryptography.hazmat.primitives.ciphers.base module"
+ "cryptography.hazmat.primitives.ciphers module"
),
utils.DeprecatedIn08
)
AEADCipherContext = utils.deprecated(
- base.AEADCipherContext,
+ ciphers.AEADCipherContext,
__name__,
(
"The AEADCipherContext interface has moved to the "
- "cryptography.hazmat.primitives.ciphers.base module"
+ "cryptography.hazmat.primitives.ciphers module"
),
utils.DeprecatedIn08
)
AEADEncryptionContext = utils.deprecated(
- base.AEADEncryptionContext,
+ ciphers.AEADEncryptionContext,
__name__,
(
"The AEADEncryptionContext interface has moved to the "
- "cryptography.hazmat.primitives.ciphers.base module"
+ "cryptography.hazmat.primitives.ciphers module"
),
utils.DeprecatedIn08
)