aboutsummaryrefslogtreecommitdiffstats
path: root/cryptography/hazmat/primitives/ciphers/algorithms.py
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2013-11-07 07:50:17 +0800
committerPaul Kehrer <paul.l.kehrer@gmail.com>2013-11-07 08:02:08 +0800
commit4da28c35d93e14a5e6b0a252751e7cfbaf0fe372 (patch)
tree854c50830dcd7083c31e8e91b16ba4f1813d6ca1 /cryptography/hazmat/primitives/ciphers/algorithms.py
parent60d4c68845aff3d44902cb978231fa01a5e74359 (diff)
downloadcryptography-4da28c35d93e14a5e6b0a252751e7cfbaf0fe372.tar.gz
cryptography-4da28c35d93e14a5e6b0a252751e7cfbaf0fe372.tar.bz2
cryptography-4da28c35d93e14a5e6b0a252751e7cfbaf0fe372.zip
ARC4 support
Diffstat (limited to 'cryptography/hazmat/primitives/ciphers/algorithms.py')
-rw-r--r--cryptography/hazmat/primitives/ciphers/algorithms.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/cryptography/hazmat/primitives/ciphers/algorithms.py b/cryptography/hazmat/primitives/ciphers/algorithms.py
index 8046bd26..cbfaceb8 100644
--- a/cryptography/hazmat/primitives/ciphers/algorithms.py
+++ b/cryptography/hazmat/primitives/ciphers/algorithms.py
@@ -116,3 +116,22 @@ class CAST5(object):
@property
def key_size(self):
return len(self.key) * 8
+
+
+class ARC4(object):
+ name = "RC4"
+ key_sizes = frozenset([40, 56, 64, 80, 128, 192, 256])
+
+ def __init__(self, key):
+ super(ARC4, 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