コード例 #1
0
	def testEncryption(self):
		self._setupKeyring(["key1_private", "key1_public"])
		MESSAGE = "This is the unencrypted source text we're going to use".encode("utf-8")
		RECPTKEYID = self.KEYID_1
		# encrypt for ourselves
		ans = CryptoClient.encryptAndSign(MESSAGE, RECPTKEYID, RECPTKEYID)
		self.assertIsNotNone(ans, "Encrypted result shouldn't be none")
		self.assertNotEqual(len(ans), 0, "Encrypted result shouldn't have zero length")
		self.assertNotEqual(ans, MESSAGE, "Encrypted result shouldn't be the same as the input")
コード例 #2
0
	def testEncryptFromKey2(self):
		self._setupKeyring(["key1_public", "key2_private"])
		MESSAGE = "The little dog laughed to see such fun, and the dish ran away with the spoon.".encode("utf-8")
		# encrypt for public key 1 using private key 2
		ans = CryptoClient.encryptAndSign(MESSAGE, self.KEYID_1, self.KEYID_2)
		self.assertIsNotNone(ans, "Encrypted result shouldn't be none")
		self.assertNotEqual(len(ans), 0, "Encrypted result shouldn't have zero length")
		self.assertNotEqual(ans, MESSAGE, "Encrypted result shouldn't be the same as the input")
		print("Encrypted from 2:", ans)
コード例 #3
0
	def testEncDecryption(self):
		self._setupKeyring(["key1_private", "key1_public"])
		MESSAGE = "This is the unencrypted source text we're going to use".encode("utf-8")
		RECPTKEYID = self.KEYID_1
		# encrypt for ourselves
		ans = CryptoClient.encryptAndSign(MESSAGE, RECPTKEYID, RECPTKEYID)
		self.assertIsNotNone(ans, "Encrypted result shouldn't be none")
		backAgain, sigok = CryptoClient.decryptAndCheckSignature(ans)
		self.assertIsNotNone(backAgain, "Decrypted result shouldn't be none")
		self.assertTrue(sigok, "Signature check should be ok")
		self.assertNotEqual(len(backAgain), 0, "Decrypted result shouldn't have zero length")
		self.assertNotEqual(ans, MESSAGE, "Encrypted result shouldn't be the same as the input")
		self.assertEqual(backAgain, MESSAGE, "Decrypted result should be the same as the input")
コード例 #4
0
ファイル: message.py プロジェクト: activityworkshop/Murmeli
	def _createPayload(self, recipientKeyId):
		'''Create the encrypted output for the given recipient'''
		total = self._createUnencryptedPayload()
		# Encrypt and sign the result
		ownKeyId = DbClient.getOwnKeyId()
		return CryptoClient.encryptAndSign(total, recipientKeyId, ownKeyId)
コード例 #5
0
ファイル: message.py プロジェクト: bellyfat/Murmeli
 def _createPayload(self, recipientKeyId):
     '''Create the encrypted output for the given recipient'''
     total = self._createUnencryptedPayload()
     # Encrypt and sign the result
     ownKeyId = DbI.getOwnKeyid()
     return CryptoClient.encryptAndSign(total, recipientKeyId, ownKeyId)