aboutsummaryrefslogtreecommitdiffstats
path: root/cryptography
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2014-03-11 14:25:26 -0700
committerAlex Gaynor <alex.gaynor@gmail.com>2014-03-11 14:25:26 -0700
commit80b8cfa2f31fb3a19308e7aebce58fb8d1bc0f4a (patch)
tree44c656d4ccb1f9fb8544e58e2fb94032e8eecdb9 /cryptography
parentcc23b5b3ea1a3f72a8739c5ea0140211b635a961 (diff)
parent7ba0c011880d7b346615aad246e0e72e4c9b4691 (diff)
downloadcryptography-80b8cfa2f31fb3a19308e7aebce58fb8d1bc0f4a.tar.gz
cryptography-80b8cfa2f31fb3a19308e7aebce58fb8d1bc0f4a.tar.bz2
cryptography-80b8cfa2f31fb3a19308e7aebce58fb8d1bc0f4a.zip
Merge pull request #782 from reaperhulk/enable-idea-cipher
Enable IDEA cipher
Diffstat (limited to 'cryptography')
-rw-r--r--cryptography/hazmat/backends/openssl/backend.py11
-rw-r--r--cryptography/hazmat/primitives/ciphers/algorithms.py14
2 files changed, 21 insertions, 4 deletions
diff --git a/cryptography/hazmat/backends/openssl/backend.py b/cryptography/hazmat/backends/openssl/backend.py
index b4625aae..bdbbffd6 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,
@@ -159,11 +159,14 @@ class Backend(object):
mode_cls,
GetCipherByName("bf-{mode.name}")
)
- for mode_cls in [CBC, CFB, OFB, ECB]:
+ for cipher_cls, mode_cls in itertools.product(
+ [CAST5, IDEA],
+ [CBC, OFB, CFB, ECB],
+ ):
self.register_cipher_adapter(
- CAST5,
+ cipher_cls,
mode_cls,
- GetCipherByName("cast5-{mode.name}")
+ GetCipherByName("{cipher.name}-{mode.name}")
)
self.register_cipher_adapter(
ARC4,
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