aboutsummaryrefslogtreecommitdiffstats
path: root/cryptography
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2013-09-27 13:43:06 -0500
committerPaul Kehrer <paul.l.kehrer@gmail.com>2013-10-06 17:31:31 -0500
commitdff22d4707a50b8164c5c6acd5521bcd91160cd1 (patch)
tree761787ecb9a65b941fcfd4907c16ee244f6bf9b4 /cryptography
parent867b979b81aba0578d7241d6a38201214a976ace (diff)
downloadcryptography-dff22d4707a50b8164c5c6acd5521bcd91160cd1.tar.gz
cryptography-dff22d4707a50b8164c5c6acd5521bcd91160cd1.tar.bz2
cryptography-dff22d4707a50b8164c5c6acd5521bcd91160cd1.zip
Camellia block cipher support
* Tests for CBC, OFB, CFB, and ECB * Tests will be automatically skipped if camellia support is not present in your OpenSSL library (e.g. OS X 10.8 with default OpenSSL) * Test for unsupported cipher in create_block_cipher_context * Docs for the cipher
Diffstat (limited to 'cryptography')
-rw-r--r--cryptography/primitives/block/ciphers.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/cryptography/primitives/block/ciphers.py b/cryptography/primitives/block/ciphers.py
index 01dbd027..1257fc33 100644
--- a/cryptography/primitives/block/ciphers.py
+++ b/cryptography/primitives/block/ciphers.py
@@ -32,3 +32,23 @@ class AES(object):
@property
def key_size(self):
return len(self.key) * 8
+
+
+class Camellia(object):
+ name = "camellia"
+ block_size = 128
+ key_sizes = set([128, 192, 256])
+
+ def __init__(self, key):
+ super(Camellia, self).__init__()
+ self.key = key
+
+ # Verify that the key size matches the expected key size
+ if self.key_size not in self.key_sizes:
+ raise ValueError("Invalid key size ({0}) for {1}".format(
+ self.key_size, self.name
+ ))
+
+ @property
+ def key_size(self):
+ return len(self.key) * 8