diff options
author | Taewook Kang <twkang@gmail.com> | 2014-04-08 20:19:09 +0900 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-04-09 11:12:25 -0500 |
commit | 65a890d0f66bc611cb1ff1be979345c4933160d8 (patch) | |
tree | acface20dc3524c4a514a7cc13d6674035a4ee6d | |
parent | fae681c86a71a478b78dd835353df13ece6fd4fc (diff) | |
download | cryptography-65a890d0f66bc611cb1ff1be979345c4933160d8.tar.gz cryptography-65a890d0f66bc611cb1ff1be979345c4933160d8.tar.bz2 cryptography-65a890d0f66bc611cb1ff1be979345c4933160d8.zip |
Adding SEED cipher algorithm to openssl backends
-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 |