diff options
author | Legrandin <gooksankoo@hoiptorrow.mailexpire.com> | 2012-06-20 23:35:07 +0200 |
---|---|---|
committer | Legrandin <gooksankoo@hoiptorrow.mailexpire.com> | 2012-06-20 23:35:07 +0200 |
commit | bf24d2907edb2e0dd2eede63b8679b8bdfdc96b7 (patch) | |
tree | d6d8b29c81d3b868bfccada1a51d8d96e9875af5 /lib/Crypto/SelfTest | |
parent | 63a45be86bc9d9a94116f359e6bd22103009bb5b (diff) | |
download | pycrypto-bf24d2907edb2e0dd2eede63b8679b8bdfdc96b7.tar.gz |
Added ARC4-drop[n] cipher
Diffstat (limited to 'lib/Crypto/SelfTest')
-rw-r--r-- | lib/Crypto/SelfTest/Cipher/test_ARC4.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/Crypto/SelfTest/Cipher/test_ARC4.py b/lib/Crypto/SelfTest/Cipher/test_ARC4.py index 1c5ed90..801d2cb 100644 --- a/lib/Crypto/SelfTest/Cipher/test_ARC4.py +++ b/lib/Crypto/SelfTest/Cipher/test_ARC4.py @@ -423,10 +423,30 @@ class RFC6229_Tests(unittest.TestCase): count += 1 self.assertEqual(count, len(tv[1])) +class Drop_Tests(unittest.TestCase): + key = b('\xAA')*16 + data = b('\x00')*5000 + + def setUp(self): + self.cipher = ARC4.new(self.key) + + def test_drop256_encrypt(self): + cipher_drop = ARC4.new(self.key, 256) + ct_drop = cipher_drop.encrypt(self.data[:16]) + ct = self.cipher.encrypt(self.data)[256:256+16] + self.assertEquals(ct_drop, ct) + + def test_drop256_decrypt(self): + cipher_drop = ARC4.new(self.key, 256) + pt_drop = cipher_drop.decrypt(self.data[:16]) + pt = self.cipher.decrypt(self.data)[256:256+16] + self.assertEquals(pt_drop, pt) + def get_tests(config={}): from common import make_stream_tests tests = make_stream_tests(ARC4, "ARC4", test_data) tests += list_test_cases(RFC6229_Tests) + tests += list_test_cases(Drop_Tests) return tests if __name__ == '__main__': |