예제 #1
0
파일: message.py 프로젝트: bellyfat/Murmeli
 def construct(payload, isEncrypted):
     '''Construct a message from its payload'''
     originalPayload, signKey = CryptoClient.verifySignedData(
         payload) if isEncrypted else (payload, None)
     if originalPayload:
         # The payload could be verified and extracted, but we still don't know
         # if the contents are for me or for somebody else (probably for somebody else!)
         messageForMe = Message.MessageFromReceivedData(
             originalPayload, isEncrypted)
         if messageForMe:
             return messageForMe
         else:
             msg = RelayingMessage(rcvdBytes=originalPayload)
             msg.senderId = DbI.findUserIdFromKeyId(signKey)
             return msg
예제 #2
0
	def testJustSignature(self):
		'''Test the verification of data which has been signed but not encrypted'''
		self._setupKeyring(["key1_private"])
		junk = bytearray()
		junk.append(3)
		junk.append(0)
		junk.append(9)
		MESSAGE = "This is the unencrypted source text we're going to use".encode("utf-8") + bytes(junk)
		OWNKEYID = self.KEYID_1
		self.assertFalse("BEGIN PGP SIGNED MESSAGE".encode("utf-8") in MESSAGE, "Input data shouldn't include PGP prefix")
		signed = CryptoClient.signData(MESSAGE, OWNKEYID)
		self.assertTrue(signed, "Signed data shouldn't be blank")
		self.assertTrue("BEGIN PGP SIGNED MESSAGE".encode("utf-8") in signed, "Signed data should include PGP prefix")
		retrieved, keyid = CryptoClient.verifySignedData(signed)
		self.assertEqual(MESSAGE, retrieved, "Retrieved data should be the same as the input")
		self.assertIsNotNone(keyid, "keyid which signed should not be blank")