diff options
-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 bbcfa327..c454a4f3 100644 --- a/cryptography/hazmat/backends/openssl/backend.py +++ b/cryptography/hazmat/backends/openssl/backend.py @@ -35,7 +35,7 @@ from cryptography.hazmat.primitives.asymmetric.padding import ( MGF1, PKCS1v15, PSS ) from cryptography.hazmat.primitives.ciphers.algorithms import ( - AES, ARC4, Blowfish, CAST5, Camellia, IDEA, TripleDES + AES, ARC4, Blowfish, CAST5, Camellia, IDEA, TripleDES, SEED ) from cryptography.hazmat.primitives.ciphers.modes import ( CBC, CFB, CTR, ECB, GCM, OFB @@ -167,6 +167,12 @@ class Backend(object): mode_cls, GetCipherByName("bf-{mode.name}") ) + for mode_cls in [CBC, CFB, OFB, ECB]: + self.register_cipher_adapter( + SEED, + mode_cls, + GetCipherByName("seed-{mode.name}") + ) for cipher_cls, mode_cls in itertools.product( [CAST5, IDEA], [CBC, OFB, CFB, ECB], diff --git a/cryptography/hazmat/primitives/ciphers/algorithms.py b/cryptography/hazmat/primitives/ciphers/algorithms.py index 2d37e0cf..0305c36b 100644 --- a/cryptography/hazmat/primitives/ciphers/algorithms.py +++ b/cryptography/hazmat/primitives/ciphers/algorithms.py @@ -130,3 +130,17 @@ class IDEA(object): @property def key_size(self): return len(self.key) * 8 + +@utils.register_interface(interfaces.BlockCipherAlgorithm) +@utils.register_interface(interfaces.CipherAlgorithm) +class SEED(object): + name = "SEED" + block_size = 128 + 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 |