aboutsummaryrefslogtreecommitdiffstats
path: root/cryptography
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2013-10-16 08:46:50 -0500
committerPaul Kehrer <paul.l.kehrer@gmail.com>2013-10-17 11:38:32 -0500
commitd0ec60e7d671bb1f927cd711949d95441d947933 (patch)
tree98cd623e89a7569d9eaf552d903766502e98c850 /cryptography
parent169dee88faa7c46b5551b89cf97a1b30c0a1c6ea (diff)
downloadcryptography-d0ec60e7d671bb1f927cd711949d95441d947933.tar.gz
cryptography-d0ec60e7d671bb1f927cd711949d95441d947933.tar.bz2
cryptography-d0ec60e7d671bb1f927cd711949d95441d947933.zip
AES Counter support
* vectors from RFC 3686 * Documentation for the mode
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 f1a2c087..79ec5eea 100644
--- a/cryptography/bindings/openssl/api.py
+++ b/cryptography/bindings/openssl/api.py
@@ -103,6 +103,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