Beispiel #1
0
	def test_decrypt_succeeds(self):

		Ek, Ak = mkpasswd(test_pass)

		encrypted_data = encrypt(test_data, Ek, Ak).getvalue()

		Ek, Ak = mkpasswd(test_pass)

		decrypted_data = decrypt(encrypted_data, Ek, Ak).getvalue()

		self.assertEqual(decrypted_data, test_data)
Beispiel #2
0
	def test_auth_fail_bad_mac(self):
		"""cuts off the real MAC and puts in some bogus HMAC-SHA256 signature 
		that will cause decrypt() to raise an Exception."""

		Ek, Ak = mkpasswd(test_data)

		encrypted_data = encrypt(test_data, Ek, Ak).getvalue()

		bad_mac = get_signature("bogus data", Ak)
		encrypted_data = encrypted_data[:-MAC_SIZE] + bad_mac

		with self.assertRaises(AuthenticationError):
			decrypt(encrypted_data, Ek, Ak)