aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2015-01-01 17:31:13 -0600
committerPaul Kehrer <paul.l.kehrer@gmail.com>2015-01-01 17:31:13 -0600
commitb522c9920049be0f130e8f3c77702b46a0601a71 (patch)
treef453505ac3dd128aea183496bd7e01e5c95a2f08
parent8fbba2e30c25041c3be2a845805732224922ab97 (diff)
parentcdf3d6700526ce0611b21ee3940a9e62c9159ad6 (diff)
downloadcryptography-b522c9920049be0f130e8f3c77702b46a0601a71.tar.gz
cryptography-b522c9920049be0f130e8f3c77702b46a0601a71.tar.bz2
cryptography-b522c9920049be0f130e8f3c77702b46a0601a71.zip
Merge pull request #1595 from greghaynes/feature/split-out-primitives-interfaces-ciphers
Start splitting out interfaces with ciphers
-rw-r--r--src/cryptography/hazmat/primitives/interfaces/__init__.py (renamed from src/cryptography/hazmat/primitives/interfaces.py)79
-rw-r--r--src/cryptography/hazmat/primitives/interfaces/ciphers.py76
2 files changed, 89 insertions, 66 deletions
diff --git a/src/cryptography/hazmat/primitives/interfaces.py b/src/cryptography/hazmat/primitives/interfaces/__init__.py
index 76616e1f..fd1b25f3 100644
--- a/src/cryptography/hazmat/primitives/interfaces.py
+++ b/src/cryptography/hazmat/primitives/interfaces/__init__.py
@@ -8,72 +8,19 @@ import abc
import six
-
-@six.add_metaclass(abc.ABCMeta)
-class CipherAlgorithm(object):
- @abc.abstractproperty
- def name(self):
- """
- A string naming this mode (e.g. "AES", "Camellia").
- """
-
- @abc.abstractproperty
- def key_size(self):
- """
- The size of the key being used as an integer in bits (e.g. 128, 256).
- """
-
-
-@six.add_metaclass(abc.ABCMeta)
-class BlockCipherAlgorithm(object):
- @abc.abstractproperty
- def block_size(self):
- """
- The size of a block as an integer in bits (e.g. 64, 128).
- """
-
-
-@six.add_metaclass(abc.ABCMeta)
-class Mode(object):
- @abc.abstractproperty
- def name(self):
- """
- A string naming this mode (e.g. "ECB", "CBC").
- """
-
- @abc.abstractmethod
- def validate_for_algorithm(self, algorithm):
- """
- Checks that all the necessary invariants of this (mode, algorithm)
- combination are met.
- """
-
-
-@six.add_metaclass(abc.ABCMeta)
-class ModeWithInitializationVector(object):
- @abc.abstractproperty
- def initialization_vector(self):
- """
- The value of the initialization vector for this mode as bytes.
- """
-
-
-@six.add_metaclass(abc.ABCMeta)
-class ModeWithNonce(object):
- @abc.abstractproperty
- def nonce(self):
- """
- The value of the nonce for this mode as bytes.
- """
-
-
-@six.add_metaclass(abc.ABCMeta)
-class ModeWithAuthenticationTag(object):
- @abc.abstractproperty
- def tag(self):
- """
- The value of the tag supplied to the constructor of this mode.
- """
+from cryptography.hazmat.primitives.interfaces.ciphers import (
+ BlockCipherAlgorithm, CipherAlgorithm, Mode,
+ ModeWithAuthenticationTag, ModeWithInitializationVector, ModeWithNonce
+)
+
+__all__ = [
+ "BlockCipherAlgorithm",
+ "CipherAlgorithm",
+ "Mode",
+ "ModeWithAuthenticationTag",
+ "ModeWithInitializationVector",
+ "ModeWithNonce"
+]
@six.add_metaclass(abc.ABCMeta)
diff --git a/src/cryptography/hazmat/primitives/interfaces/ciphers.py b/src/cryptography/hazmat/primitives/interfaces/ciphers.py
new file mode 100644
index 00000000..075a9c25
--- /dev/null
+++ b/src/cryptography/hazmat/primitives/interfaces/ciphers.py
@@ -0,0 +1,76 @@
+# This file is dual licensed under the terms of the Apache License, Version
+# 2.0, and the BSD License. See the LICENSE file in the root of this repository
+# for complete details.
+
+from __future__ import absolute_import, division, print_function
+
+import abc
+
+import six
+
+
+@six.add_metaclass(abc.ABCMeta)
+class CipherAlgorithm(object):
+ @abc.abstractproperty
+ def name(self):
+ """
+ A string naming this mode (e.g. "AES", "Camellia").
+ """
+
+ @abc.abstractproperty
+ def key_size(self):
+ """
+ The size of the key being used as an integer in bits (e.g. 128, 256).
+ """
+
+
+@six.add_metaclass(abc.ABCMeta)
+class BlockCipherAlgorithm(object):
+ @abc.abstractproperty
+ def block_size(self):
+ """
+ The size of a block as an integer in bits (e.g. 64, 128).
+ """
+
+
+@six.add_metaclass(abc.ABCMeta)
+class Mode(object):
+ @abc.abstractproperty
+ def name(self):
+ """
+ A string naming this mode (e.g. "ECB", "CBC").
+ """
+
+ @abc.abstractmethod
+ def validate_for_algorithm(self, algorithm):
+ """
+ Checks that all the necessary invariants of this (mode, algorithm)
+ combination are met.
+ """
+
+
+@six.add_metaclass(abc.ABCMeta)
+class ModeWithInitializationVector(object):
+ @abc.abstractproperty
+ def initialization_vector(self):
+ """
+ The value of the initialization vector for this mode as bytes.
+ """
+
+
+@six.add_metaclass(abc.ABCMeta)
+class ModeWithNonce(object):
+ @abc.abstractproperty
+ def nonce(self):
+ """
+ The value of the nonce for this mode as bytes.
+ """
+
+
+@six.add_metaclass(abc.ABCMeta)
+class ModeWithAuthenticationTag(object):
+ @abc.abstractproperty
+ def tag(self):
+ """
+ The value of the tag supplied to the constructor of this mode.
+ """