def testCbcEncryptDecryptSuccessfully(self):
     logging.debug('Running testCbcEncryptDecryptSuccessfully method.')
     # test success for 16, 16, 24, and 32 byte length keys.
     for key in (_KEY1, _KEY2, _KEY1 + '12345678', _KEY1 + _KEY2):
         self.cipher = ccrypto.AesCbc(key)
         ciphertext = self.cipher.Encrypt(_PLAINTEXT1)
         self.assertEqual(_PLAINTEXT1, self.cipher.Decrypt(ciphertext))
     # test success with different plaintexts
     self.cipher = ccrypto.AesCbc(_KEY1)
     for plaintext in ('22', _PLAINTEXT1, _PLAINTEXT2,
                       _PLAINTEXT1 + _PLAINTEXT2):
         ciphertext = self.cipher.Encrypt(plaintext)
         self.assertEqual(plaintext, self.cipher.Decrypt(ciphertext))
 def __init__(self, key):
     """Cipher is initialized with a key of valid Aes key lengths."""
     super(ProbabilisticCipher, self).__init__()
     self._cipher = ccrypto.AesCbc(key)
 def setUp(self):
     """Run once for each test in the class."""
     self.cipher = ccrypto.AesCbc(_KEY1)