aboutsummaryrefslogtreecommitdiffstats
path: root/cryptography
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2013-10-17 12:16:01 -0700
committerAlex Gaynor <alex.gaynor@gmail.com>2013-10-17 12:16:01 -0700
commit8ffb64ccd166b00a89ddc27e82e3579e6bed8550 (patch)
tree2755cfcc1a30895e649d2ffa94230f2b0a2fd951 /cryptography
parenta4da1d2a6e568e2ec4c474c5d41bbc445f7c90e8 (diff)
parentb8f6a3669d6895d39652d582c190eea20a7c826b (diff)
downloadcryptography-8ffb64ccd166b00a89ddc27e82e3579e6bed8550.tar.gz
cryptography-8ffb64ccd166b00a89ddc27e82e3579e6bed8550.tar.bz2
cryptography-8ffb64ccd166b00a89ddc27e82e3579e6bed8550.zip
Merge branch 'master' into refactor-cipher-names
Diffstat (limited to 'cryptography')
-rw-r--r--cryptography/bindings/openssl/api.py2
-rw-r--r--cryptography/primitives/block/modes.py9
-rw-r--r--cryptography/primitives/interfaces.py4
3 files changed, 15 insertions, 0 deletions
diff --git a/cryptography/bindings/openssl/api.py b/cryptography/bindings/openssl/api.py
index d5a319c9..1d7ea13d 100644
--- a/cryptography/bindings/openssl/api.py
+++ b/cryptography/bindings/openssl/api.py
@@ -139,6 +139,8 @@ class API(object):
assert evp_cipher != self.ffi.NULL
if isinstance(mode, interfaces.ModeWithInitializationVector):
iv_nonce = mode.initialization_vector
+ elif isinstance(mode, interfaces.ModeWithNonce):
+ iv_nonce = mode.nonce
else:
iv_nonce = self.ffi.NULL
diff --git a/cryptography/primitives/block/modes.py b/cryptography/primitives/block/modes.py
index 9cfbca64..221e7393 100644
--- a/cryptography/primitives/block/modes.py
+++ b/cryptography/primitives/block/modes.py
@@ -44,6 +44,15 @@ class CFB(object):
self.initialization_vector = initialization_vector
+class CTR(object):
+ name = "CTR"
+
+ def __init__(self, nonce):
+ super(CTR, self).__init__()
+ self.nonce = nonce
+
+
interfaces.ModeWithInitializationVector.register(CBC)
interfaces.ModeWithInitializationVector.register(OFB)
interfaces.ModeWithInitializationVector.register(CFB)
+interfaces.ModeWithNonce.register(CTR)
diff --git a/cryptography/primitives/interfaces.py b/cryptography/primitives/interfaces.py
index 6f74ccf7..c1fc9910 100644
--- a/cryptography/primitives/interfaces.py
+++ b/cryptography/primitives/interfaces.py
@@ -20,3 +20,7 @@ import six
class ModeWithInitializationVector(six.with_metaclass(abc.ABCMeta)):
pass
+
+
+class ModeWithNonce(six.with_metaclass(abc.ABCMeta)):
+ pass