diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2013-10-17 12:14:43 -0700 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2013-10-17 12:14:43 -0700 |
commit | b8f6a3669d6895d39652d582c190eea20a7c826b (patch) | |
tree | f2fe1e341989321148bf6577323725e018f365c2 /cryptography | |
parent | 169dee88faa7c46b5551b89cf97a1b30c0a1c6ea (diff) | |
parent | 89b3dd38c32b19853d24caa0f091a0dd78e54084 (diff) | |
download | cryptography-b8f6a3669d6895d39652d582c190eea20a7c826b.tar.gz cryptography-b8f6a3669d6895d39652d582c190eea20a7c826b.tar.bz2 cryptography-b8f6a3669d6895d39652d582c190eea20a7c826b.zip |
Merge pull request #104 from reaperhulk/ctr-support
AES Counter support
Diffstat (limited to 'cryptography')
-rw-r--r-- | cryptography/bindings/openssl/api.py | 2 | ||||
-rw-r--r-- | cryptography/primitives/block/modes.py | 9 | ||||
-rw-r--r-- | cryptography/primitives/interfaces.py | 4 |
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 |