aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cryptography/hazmat/backends/openssl/backend.py8
-rw-r--r--cryptography/hazmat/primitives/ciphers/algorithms.py14
-rw-r--r--docs/hazmat/primitives/symmetric-encryption.rst12
3 files changed, 33 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
diff --git a/docs/hazmat/primitives/symmetric-encryption.rst b/docs/hazmat/primitives/symmetric-encryption.rst
index 2ee5085b..daa4b36f 100644
--- a/docs/hazmat/primitives/symmetric-encryption.rst
+++ b/docs/hazmat/primitives/symmetric-encryption.rst
@@ -165,6 +165,16 @@ Weak Ciphers
>>> decryptor.update(ct)
'a secret message'
+.. class:: IDEA(key)
+
+ IDEA (`International Data Encryption Algorithm`_) is a block cipher created
+ in 1991. It is an optional component of the `OpenPGP`_ standard. This cipher
+ is susceptible to attacks when using weak keys. It is recommended that you
+ do not use this cipher for new applications.
+
+ :param bytes key: The secret key, 128 bits in length. This must be kept
+ secret.
+
.. _symmetric-encryption-modes:
@@ -468,3 +478,5 @@ Interfaces
.. _`encrypt`: https://ssd.eff.org/tech/encryption
.. _`CRYPTREC`: http://www.cryptrec.go.jp/english/
.. _`significant patterns in the output`: http://en.wikipedia.org/wiki/Cipher_block_chaining#Electronic_codebook_.28ECB.29
+.. _`International Data Encryption Algorithm`: https://en.wikipedia.org/wiki/International_Data_Encryption_Algorithm
+.. _`OpenPGP`: http://www.openpgp.org