diff options
| author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-02-20 16:19:32 -0600 |
|---|---|---|
| committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-03-11 10:49:59 -0400 |
| commit | e5dc122b74b9335454cb4e9321b21a20e756dc96 (patch) | |
| tree | f7366e0798fd48f4c473d6601def331d15c2653c /cryptography | |
| parent | c99c2148fa8f27678acab4d9d02297cf097c77cf (diff) | |
| download | cryptography-e5dc122b74b9335454cb4e9321b21a20e756dc96.tar.gz cryptography-e5dc122b74b9335454cb4e9321b21a20e756dc96.tar.bz2 cryptography-e5dc122b74b9335454cb4e9321b21a20e756dc96.zip | |
basic IDEA ECB support for OpenSSL backend
Diffstat (limited to 'cryptography')
| -rw-r--r-- | cryptography/hazmat/backends/openssl/backend.py | 8 | ||||
| -rw-r--r-- | cryptography/hazmat/primitives/ciphers/algorithms.py | 14 |
2 files changed, 21 insertions, 1 deletions
diff --git a/cryptography/hazmat/backends/openssl/backend.py b/cryptography/hazmat/backends/openssl/backend.py index b4625aae..5d739135 100644 --- a/cryptography/hazmat/backends/openssl/backend.py +++ b/cryptography/hazmat/backends/openssl/backend.py @@ -28,7 +28,7 @@ from cryptography.hazmat.bindings.openssl.binding import Binding from cryptography.hazmat.primitives import interfaces, hashes from cryptography.hazmat.primitives.asymmetric import rsa from cryptography.hazmat.primitives.ciphers.algorithms import ( - AES, Blowfish, Camellia, TripleDES, ARC4, CAST5 + AES, Blowfish, Camellia, CAST5, TripleDES, ARC4, IDEA ) from cryptography.hazmat.primitives.ciphers.modes import ( CBC, CTR, ECB, OFB, CFB, GCM, @@ -175,6 +175,12 @@ class Backend(object): GCM, GetCipherByName("{cipher.name}-{cipher.key_size}-{mode.name}") ) + for mode_cls in [ECB]: + self.register_cipher_adapter( + IDEA, + mode_cls, + GetCipherByName("idea-{mode.name}") + ) def create_symmetric_encryption_ctx(self, cipher, mode): return _CipherContext(self, cipher, mode, _CipherContext._ENCRYPT) diff --git a/cryptography/hazmat/primitives/ciphers/algorithms.py b/cryptography/hazmat/primitives/ciphers/algorithms.py index a5cfce92..2d37e0cf 100644 --- a/cryptography/hazmat/primitives/ciphers/algorithms.py +++ b/cryptography/hazmat/primitives/ciphers/algorithms.py @@ -116,3 +116,17 @@ class ARC4(object): @property def key_size(self): return len(self.key) * 8 + + +@utils.register_interface(interfaces.CipherAlgorithm) +class IDEA(object): + name = "IDEA" + block_size = 64 + key_sizes = frozenset([128]) + + def __init__(self, key): + self.key = _verify_key_size(self, key) + + @property + def key_size(self): + return len(self.key) * 8 |
