diff options
author | David Reid <dreid@dreid.org> | 2013-11-09 15:53:33 -0800 |
---|---|---|
committer | David Reid <dreid@dreid.org> | 2013-11-09 15:53:33 -0800 |
commit | 1aefe584a2c5c4f6bbf2839184868b16bdb9dc0b (patch) | |
tree | 2dd352daf4326db4856819b85487ca751b811632 /cryptography/hazmat/primitives/ciphers/algorithms.py | |
parent | df52fa9d388c2fc7d721c0fba5ca21ec88a01a15 (diff) | |
parent | 0994c5628a3d960a45f8aac33f0d5d985eb48cf7 (diff) | |
download | cryptography-1aefe584a2c5c4f6bbf2839184868b16bdb9dc0b.tar.gz cryptography-1aefe584a2c5c4f6bbf2839184868b16bdb9dc0b.tar.bz2 cryptography-1aefe584a2c5c4f6bbf2839184868b16bdb9dc0b.zip |
Merge pull request #214 from reaperhulk/arc4-support
ARC4 Support
Diffstat (limited to 'cryptography/hazmat/primitives/ciphers/algorithms.py')
-rw-r--r-- | cryptography/hazmat/primitives/ciphers/algorithms.py | 19 |
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 |