def test_basic_for_stream_ciphers(self): for buffersize in (3, 7, 56, 128, 1231): data = self.generate_random_buffer(buffersize) for name in ('rc4', 'seal', 'chacha', 'salsa'): unit = resolve(name) for size in unit.key_sizes: S = unit(key=self.generate_random_buffer(size)) self.assertEqual(S(S(data)), data)
def test_basic_for_block_ciphers(self): for buffersize in (3, 7, 56, 128, 1231): data = self.generate_random_buffer(buffersize) for name in ('aes', 'blowfish', 'cast', 'des', 'des3', 'rc2'): unit = resolve(name) for size in unit.key_sizes: K = self.generate_random_buffer(size) V = self.generate_random_buffer(unit.blocksize) D = unit(key=K, iv=V, mode='CBC') for P in ['PKCS7', 'ISO7816', 'X923']: E = unit(key=K, iv=V, padding=P, mode='CBC') self.assertEqual(D.process(E.reverse(data)), data)
def test_reversible(self): neg = resolve('neg') b64 = resolve('b64') self.assertEqual(neg.is_reversible, False) self.assertEqual(b64.is_reversible, True)