コード例 #1
0
	def checkAllContactsKeys():
		for c in DbClient.getMessageableContacts():
			torId = c.get("torid", None) if c else None
			if torId:
				keyId = c.get("keyid", None)
				if not keyId:
					print("No keyid found for torid", torId)
				elif not CryptoClient.getPublicKey(keyId):
					print("CryptoClient hasn't got a public key for torid", torId)
				if not keyId or not CryptoClient.getPublicKey(keyId):
					# We haven't got their key in our keyring!
					DbClient.updateContact(torId, {"status":"requested"})
コード例 #2
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")
コード例 #3
0
 def setUp(self):
     Config.load()
     CryptoClient.useTestKeyring()
     self.FRIEND_TORID = "zo7quhgn1nq1uppt"
     FRIEND_KEYID = "3B898548F994C536"
     TestUtils.setupOwnProfile("46944E14D24D711B")  # id of key1
     DbI.updateProfile(
         self.FRIEND_TORID, {
             "status": "trusted",
             "keyid": FRIEND_KEYID,
             "name": "Norbert Jones",
             "displayName": "Uncle Norbert"
         })
     TestUtils.setupKeyring(["key1_private", "key2_public"])
コード例 #4
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")
コード例 #5
0
ファイル: contactmgr.py プロジェクト: bellyfat/Murmeli
 def processPendingContacts(torId):
     print("Process pending contact accept responses from:", torId)
     foundReq = False
     for resp in DbI.getPendingContactMessages(torId):
         name = resp.get("fromName", None)
         if not name:
             profile = DbI.getProfile(torId)
             name = profile["displayName"]
         print("Found pending contact accept request from: ", name)
         # Check signature using keyring
         _, signatureKey = CryptoClient.decryptAndCheckSignature(
             resp.get("encryptedMsg", None))
         if signatureKey:
             foundReq = True
             # Insert new message into inbox with message contents
             rowToStore = {
                 "messageType": "contactresponse",
                 "fromId": resp.get("fromId", None),
                 "fromName": name,
                 "accepted": True,
                 "messageBody": resp.get("messageBody", ""),
                 "timestamp": resp.get("timestamp", None),
                 "messageRead": True,
                 "messageReplied": True,
                 "recipients": DbI.getOwnTorid()
             }
             DbI.addToInbox(rowToStore)
     if foundReq:
         DbI.updateProfile(torId, {"status": "untrusted"})
         # Delete all pending contact responses from this torId
         DbI.deletePendingContactMessages(torId)
コード例 #6
0
ファイル: message.py プロジェクト: activityworkshop/Murmeli
	def getPublicKey(self, torid):
		'''Use the keyid stored in mongo, and get the corresponding public key from the Crypto module'''
		profile = DbClient.getProfile(torid)
		if profile is not None:
			keyid = profile.get('keyid', None)
			if keyid is not None:
				return CryptoClient.getPublicKey(keyid)
コード例 #7
0
ファイル: fingerprinttest.py プロジェクト: bellyfat/Murmeli
 def testFingerprints12(self):
     '''Test the fingerprints of our loaded keys 1 and 2 together'''
     ourFingerprint = CryptoClient.getFingerprint(self.KEYID_1)
     self.assertIsNotNone(ourFingerprint,
                          "Our fingerprint shouldn't be blank")
     theirFingerprint = CryptoClient.getFingerprint(self.KEYID_2)
     self.assertIsNotNone(theirFingerprint,
                          "Their fingerprint shouldn't be blank")
     self.assertNotEqual(ourFingerprint, theirFingerprint,
                         "Fingerprints shouldn't be equal")
     print(ourFingerprint, theirFingerprint)
     # Generate our set of words
     checker = FingerprintChecker(ourFingerprint, theirFingerprint)
     self.assertEqual(checker.getCorrectAnswer(), 0,
                      "Correct answer should be 0")
     myWords = checker.getCodeWords(True, 0, "en")
     self.assertEqual(myWords, "connection microscope secrecy power dragon")
     myWordsGerman = checker.getCodeWords(True, 0, "de")
     self.assertEqual(myWordsGerman,
                      "Nachbarn Navigation Fußball Tintenfisch abwaschen")
     theirWords0 = checker.getCodeWords(False, 0, "en")
     theirWords1 = checker.getCodeWords(False, 1, "en")
     theirWords2 = checker.getCodeWords(False, 2, "en")
     self.assertNotEqual(theirWords0, theirWords1,
                         "Generated words 0 shouldn't equal 1")
     self.assertNotEqual(theirWords0, theirWords2,
                         "Generated words 0 shouldn't equal 2")
     self.assertNotEqual(theirWords1, theirWords2,
                         "Generated words 1 shouldn't equal 2")
     # Now again but from their side
     checker = FingerprintChecker(theirFingerprint, ourFingerprint)
     self.assertEqual(checker.getCorrectAnswer(), 0,
                      "Correct answer should be 0")
     theirCorrectWords = checker.getCodeWords(True, 0, "en")
     self.assertEqual(theirWords0, theirCorrectWords,
                      "Their words should match what we calculate")
     myWords0 = checker.getCodeWords(False, 0, "en")
     myWords1 = checker.getCodeWords(False, 1, "en")
     myWords2 = checker.getCodeWords(False, 2, "en")
     self.assertNotEqual(myWords0, myWords1,
                         "Generated words 0 shouldn't equal 1")
     self.assertNotEqual(myWords0, myWords2,
                         "Generated words 0 shouldn't equal 2")
     self.assertNotEqual(myWords1, myWords2,
                         "Generated words 1 shouldn't equal 2")
     self.assertEqual(myWords0, myWords,
                      "My words should match what they calculate")
コード例 #8
0
	def _importKeyFromFile(self, filename):
		'''Load the specified file and import the contents to the current keyring.
		   This works for text files containing either a public key or a private key.'''
		key = ""
		with open(os.path.join("inputdata", filename + ".txt"), "r") as f:
			for l in f:
				key += l
		return CryptoClient.importPublicKey(key)
コード例 #9
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)
コード例 #10
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")
コード例 #11
0
ファイル: contactmgr.py プロジェクト: bellyfat/Murmeli
 def checkAllContactsKeys():
     '''Return a list of names for which the key can't be found'''
     nameList = []
     for c in DbI.getMessageableProfiles():
         torId = c['torid'] if c else None
         if torId:
             keyId = c['keyid']
             if not keyId:
                 print("No keyid found for torid", torId)
                 nameList.append(c['displayName'])
             elif not CryptoClient.getPublicKey(keyId):
                 print("CryptoClient hasn't got a public key for torid",
                       torId)
                 nameList.append(c['displayName'])
             if not keyId or not CryptoClient.getPublicKey(keyId):
                 # We haven't got their key in our keyring!
                 DbI.updateProfile(torId, {"status": "requested"})
     return nameList
コード例 #12
0
ファイル: message.py プロジェクト: bellyfat/Murmeli
    def construct(payload, isEncrypted=True):
        '''Factory constructor using a given payload and extracting the fields'''
        if not payload:
            return None
        signatureKey = None
        if isEncrypted:
            # Decrypt the payload with our key
            decrypted, signatureKey = CryptoClient.decryptAndCheckSignature(
                payload)
        else:
            decrypted = payload
        if decrypted:
            print("Asymmetric message, length of decrypted is", len(decrypted))
        else:
            print("Asymmetric message has no decrypted")
        # Separate fields of message into common ones and the type-specific payload
        msgType, subpayload, tstmp = AsymmetricMessage._stripFields(decrypted)
        print("Recovered timestamp='", tstmp, "' (", len(tstmp), ")")

        # Find a suitable subclass to call using the messageType
        msg = None
        if msgType == Message.TYPE_CONTACT_RESPONSE:
            msg = ContactResponseMessage.constructFrom(subpayload)
        elif msgType == Message.TYPE_STATUS_NOTIFY:
            msg = StatusNotifyMessage.constructFrom(subpayload)
        elif msgType == Message.TYPE_ASYM_MESSAGE:
            msg = RegularMessage.constructFrom(subpayload)
        elif msgType == Message.TYPE_INFO_REQUEST:
            msg = InfoRequestMessage.constructFrom(subpayload)
        elif msgType == Message.TYPE_INFO_RESPONSE:
            msg = InfoResponseMessage.constructFrom(subpayload)
        elif msgType == Message.TYPE_FRIEND_REFERRAL:
            msg = ContactReferralMessage.constructFrom(subpayload)
        elif msgType == Message.TYPE_FRIENDREFER_REQUEST:
            msg = ContactReferRequestMessage.constructFrom(subpayload)
        # Ask the message if it's ok to have no signature
        if isEncrypted and msg:
            if msg.acceptUnrecognisedSignature():
                # Save the encrypted contents so we can verify it later
                msg.encryptedContents = payload
            elif not signatureKey:
                msg = None
        if msg:
            try:
                msgTimestamp = tstmp.decode('utf-8')
            except:
                msgTimestamp = msg.makeCurrentTimestamp()
            msg.timestamp = Message.convertTimestampFromString(msgTimestamp)
            msg.signatureKeyId = signatureKey
            if signatureKey:
                print(
                    "Asymm setting senderId because I've got a signatureKey: '%s'"
                    % signatureKey)
                signatureId = DbI.findUserIdFromKeyId(signatureKey)
                if signatureId:
                    msg.senderId = signatureId
        return msg
コード例 #13
0
	def _setupKeyring(self, keyNames):
		'''Set up the keyring using the specified public and private key names'''
		keyringPath = CryptoClient._getKeyringPath()
		# Delete the entire keyring
		shutil.rmtree(keyringPath, ignore_errors=True)
		os.makedirs(keyringPath)
		if keyNames:
			for k in keyNames:
				keyId = self._importKeyFromFile(k)
				print("key id for", k, "=", keyId)
コード例 #14
0
ファイル: contactmgr.py プロジェクト: bellyfat/Murmeli
    def handleReceiveAccept(torId, name, keyStr):
        '''We have requested contact with another id, and this has now been accepted.
		So we can import their public key into our keyring and update their status
		from "requested" to "untrusted"'''
        # Use keyStr to update keyring and get the keyId
        keyId = CryptoClient.importPublicKey(keyStr)
        # Store the keyId and name in their existing row, and update status to "untrusted"
        DbI.updateProfile(torId, {
            "name": name,
            "status": "untrusted",
            "keyid": keyId
        })
コード例 #15
0
ファイル: message.py プロジェクト: activityworkshop/Murmeli
	def construct(payload, isEncrypted=True):
		'''Factory constructor using a given payload and extracting the fields'''
		if not payload:
			return None
		signatureKey = None
		if isEncrypted:
			# Decrypt the payload with our key
			decrypted, signatureKey = CryptoClient.decryptAndCheckSignature(payload)
		else:
			decrypted = payload
		if decrypted:
			print("Asymmetric message, length of decrypted is", len(decrypted))
		else:
			print("Asymmetric message has no decrypted")
		# Separate fields of message into common ones and the type-specific payload
		msgType, subpayload, tstmp = AsymmetricMessage._stripFields(decrypted)
		print("Recovered timestamp='", tstmp, "' (", len(tstmp), ")")

		# Find a suitable subclass to call using the messageType
		msg = None
		if msgType == Message.TYPE_CONTACT_RESPONSE:
			msg = ContactResponseMessage.constructFrom(subpayload)
		elif msgType == Message.TYPE_STATUS_NOTIFY:
			msg = StatusNotifyMessage.constructFrom(subpayload)
		elif msgType == Message.TYPE_ASYM_MESSAGE:
			msg = RegularMessage.constructFrom(subpayload)
		elif msgType == Message.TYPE_INFO_REQUEST:
			msg = InfoRequestMessage.constructFrom(subpayload)
		elif msgType == Message.TYPE_INFO_RESPONSE:
			msg = InfoResponseMessage.constructFrom(subpayload)
		elif msgType == Message.TYPE_FRIEND_REFERRAL:
			msg = ContactReferralMessage.constructFrom(subpayload)
		# Ask the message if it's ok to have no signature
		if isEncrypted and msg:
			if msg.acceptUnrecognisedSignature():
				# Save the encrypted contents so we can verify it later
				msg.encryptedContents = payload
			elif not signatureKey:
				msg = None
		if msg:
			try:
				msgTimestamp = tstmp.decode('utf-8')
			except:
				msgTimestamp = msg.makeCurrentTimestamp()
			msg.timestamp = Message.convertTimestampFromString(msgTimestamp)
			msg.signatureKeyId = signatureKey
			if signatureKey:
				print("Asymm setting senderId because I've got a signatureKey: '%s'" % signatureKey)
				signatureId = DbClient.findUserIdFromKeyId(signatureKey)
				if signatureId:
					msg.senderId = signatureId
		return msg
コード例 #16
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
コード例 #17
0
	def run(self):
		# Check each of the services in turn
		self.successFlags = {}
		# Mongo
		authSetup = AuthSetterUpper()
		self.successFlags['mongo'] = authSetup.setup()
		self.emit(QtCore.SIGNAL('updated()'))
		time.sleep(1)
		# Gnupg
		self.successFlags['gpg'] = CryptoClient.checkGpg()
		self.emit(QtCore.SIGNAL('updated()'))
		time.sleep(1)
		# Tor
		if TorClient.startTor():
			torid = TorClient.getOwnId()
			if torid:
				print("Started tor, our own id is: ", torid)
				self.successFlags['tor'] = True
			else: print("Failed to start tor")
		else: print("startTor returned false :(")
コード例 #18
0
	def testClearKeyring(self):
		'''Test removing keyring and adding keys to it'''
		keyringPath = CryptoClient._getKeyringPath()
		# Delete the entire keyring
		shutil.rmtree(keyringPath, ignore_errors=True)
		os.makedirs(keyringPath)
		self.assertEqual(len(CryptoClient.getPrivateKeys()), 0, "Keyring should be empty")
		# Add a public key from file
		self.assertIsNotNone(self._importKeyFromFile("key1_public"), "Import of public key should work")
		self.assertEqual(len(CryptoClient.getPrivateKeys()), 0, "Keyring shouldn't have private keys")
		self.assertEqual(len(CryptoClient.getPublicKeys()), 1, "Keyring should have one public key")
		# Now add the corresponding private key
		ownKeyId = self._importKeyFromFile("key1_private")
		self.assertIsNotNone(ownKeyId, "Import of private key should work")
		self.assertEqual(len(CryptoClient.getPrivateKeys()), 1, "Keyring should have one private key")
		self.assertEqual(len(CryptoClient.getPublicKeys()), 1, "Keyring should have one public key")
コード例 #19
0
ファイル: contactmgr.py プロジェクト: bellyfat/Murmeli
    def handleAccept(torId):
        '''We want to accept a contact request, so we need to find the request(s),
		and use it/them to update our keyring and our database entry'''

        # Get this person's current status from the db, if available
        profile = DbI.getProfile(torId)
        status = profile.get("status", None) if profile else None

        # Look for the contact request(s) in the inbox, and extract the name and publicKey
        senderName, senderKeystr, directRequest = ContactMaker.getContactRequestDetails(
            torId)
        keyValid = senderKeystr and len(senderKeystr) > 20

        if keyValid:
            if status in [None, "requested"]:
                # add key to keyring
                keyId = CryptoClient.importPublicKey(senderKeystr)
                # work out what name and status to stores
                storedSenderName = profile["name"] if profile else None
                nameToStore = storedSenderName if storedSenderName else senderName
                statusToStore = "untrusted" if directRequest else "pending"
                # add or update the profile
                DbI.updateProfile(
                    torId, {
                        "status": statusToStore,
                        "keyid": keyId,
                        "name": nameToStore,
                        "displayName": nameToStore
                    })
                ContactMaker.processPendingContacts(torId)
            elif status == "pending":
                print("Request already pending, nothing to do")
            elif status in ["untrusted", "trusted"]:
                # set status to untrusted?  Send response?
                print("Trying to handle an accept but status is already",
                      status)
            # Move all corresponding requests to be regular messages instead
            DbI.changeRequestMessagesToRegular(torId)
        else:
            print("Trying to handle an accept but key isn't valid")
コード例 #20
0
	def prepare(self):
		'''Called before showing the keypair page'''
		self.privateKeys = CryptoClient.getPrivateKeys()
		numKeys = len(self.privateKeys)
		self.labels["introemptykeyring"].setVisible(numKeys == 0)
		self.labels["introsinglekey"].setVisible(numKeys == 1)
		self.labels["introselectkey"].setVisible(numKeys > 1)
		self.generateProgressbar.setVisible(False)
		self.labels["mighttakeawhile"].setVisible(False)
		self.keypairListWidget.clear()
		for k in self.privateKeys:
			name = k['uids']
			if isinstance(name, list):
				name = str(name[0])
			self.keypairListWidget.addItem("%s - %s (%s)" % (k['keyid'], name, k['length']))
		self.keypairListWidget.setVisible(numKeys > 0)
		self.keypairListWidget.setCurrentRow(self.keypairListWidget.count() - 1)
		# Hide generation option if we've got a key already
		self.keygenbox.setVisible(numKeys == 0)
		self.generateButton.setVisible(numKeys == 0)
		# Rewrite button text in case language has changed
		self.generateButton.setText(I18nManager.getText("button.generate"))
コード例 #21
0
ファイル: startupwizard.py プロジェクト: bellyfat/Murmeli
 def run(self):
     # Check each of the services in turn
     self.successFlags = {}
     # Database
     time.sleep(0.5)
     DbI.setDb(MurmeliDb(Config.getSsDatabaseFile()))
     self.successFlags['database'] = True
     self.updatedSignal.emit()
     time.sleep(0.5)
     # Gnupg
     self.successFlags['gpg'] = CryptoClient.checkGpg()
     self.updatedSignal.emit()
     time.sleep(1)
     # Tor
     if TorClient.startTor():
         torid = TorClient.getOwnId()
         if torid:
             print("Started tor, our own id is: ", torid)
             self.successFlags['tor'] = True
         else:
             print("Failed to start tor")
     else:
         print("startTor returned false :(")
コード例 #22
0
ファイル: startupwizard.py プロジェクト: bellyfat/Murmeli
 def prepare(self):
     '''Called before showing the keypair page'''
     self.privateKeys = CryptoClient.getPrivateKeys()
     numKeys = len(self.privateKeys)
     self.labels["introemptykeyring"].setVisible(numKeys == 0)
     self.labels["introsinglekey"].setVisible(numKeys == 1)
     self.labels["introselectkey"].setVisible(numKeys > 1)
     self.generateProgressbar.setVisible(False)
     self.labels["mighttakeawhile"].setVisible(False)
     self.keypairListWidget.clear()
     for k in self.privateKeys:
         name = k['uids']
         if isinstance(name, list):
             name = str(name[0])
         self.keypairListWidget.addItem("%s - %s (%s)" %
                                        (k['keyid'], name, k['length']))
     self.keypairListWidget.setVisible(numKeys > 0)
     self.keypairListWidget.setCurrentRow(self.keypairListWidget.count() -
                                          1)
     # Hide generation option if we've got a key already
     self.keygenbox.setVisible(numKeys == 0)
     self.generateButton.setVisible(numKeys == 0)
     # Rewrite button text in case language has changed
     self.generateButton.setText(I18nManager.getText("button.generate"))
コード例 #23
0
ファイル: fingerprinttest.py プロジェクト: bellyfat/Murmeli
 def setUp(self):
     Config.load()
     CryptoClient.useTestKeyring()
     TestUtils.setupKeyring(["key1_private", "key1_public", "key2_public"])
     self.KEYID_1 = "46944E14D24D711B"
     self.KEYID_2 = "3B898548F994C536"
コード例 #24
0
 def setUp(self):
     Config.load()
     CryptoClient.useTestKeyring()
     TestUtils.setupKeyring(["key1_private", "key2_public"])
     TestUtils.setupOwnProfile("46944E14D24D711B")  # id of key1
コード例 #25
0
 def setUp(self):
     Config.load()
     CryptoClient.useTestKeyring()
     TestUtils.setupKeyring(["key1_private", "key2_public"])
コード例 #26
0
	def setUp(self):
		Config.load()
		CryptoClient.useTestKeyring()
		self.KEYID_1 = "46944E14D24D711B"
		self.KEYID_2 = "3B898548F994C536"
		self.MESSAGE_FROM_2_FOR_1 = b'\x85\x02\x0c\x03\xc1\xa6\x10l\x12d\r9\x01\x10\x00\x95|\xd4G\x9eD\xdc\x8a xr\xd8\xf5rN\x1e\x0el14 \xfd\x85\xd5<\x18\xb0\x7f\xc4\xed}ts\x16\x83]\xe1\xbf\xab[\xf3@Vt\x85\x95\x05e\x83\x8e>S%\x1e\xd4b\xe9\x05\xcc\x85X\x9e\xd5_\x01\x81\xba\x19\x89b\x80\x03\x00\xa7jH&\xb3\xf2\r8ew\'s\x15\xb1\x1e\xd5S\x87[%L\x96V\xf5\xd5\xe84\xd8\xff\x89\x04\x17K\x99\xea1dW\x83O\xb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7fo\r\xc0\xe6+\xc6\x8b\xa3*|\xf16\xca\xd0tG\x16\xc2\xccs\x97g\xb4C\xc0\xf6\xe6\xa26\xb4~f\xf4\'\x96\xae\xc80{<\xdf\x8c\xe1Y} \xe2\xc5v\x18v\xf1"S\xfeg\xd5\x0ebA\x08\t~; \xf9\x1c\x84!\x86\xc9\xe2\x19?E\xb6\x08\x92\xe2f\x88?t\x96\xe6\x98:\xf3\xb5\x16}zNp(\xbc`\xef.71\x85g\t3i2\xe7o\xc7\r\x19AW\xe6\xb9\xdf\xa9\x1f\xc2\xc28V\xf5\x1b\xc1n\xbf\x8a\x07ab\xdb\x16 r\xc3\xd2\x1f\xc1\xd0\x81p\xb7\xe2\xa7\x84/\x9f\xb7e\xffB\xd6^F\x96j\xff\x14eF\xdci\\dX\x9a\xd6\xf43]\xc3\xfbf\x11^\xd5\xbe^\xb3B~\xc7\x8c\x1bTF\xdey\x8b\x1dq6\xf0\xb0\xc4\x89i\xc4w\xc0\xcc\x13\xeal>\xa8"v\xf3\xe6\x01\x1b\x02z|\x9a\xa7\x03\x0c\xf8~\t\x02\xbe\x0c\xa4\x06\x109"\xa5\xef\xb9(\xbcT\xffe{\r\x9f\xb7e\xbfM\xfe@\xc8\x8f\xd8T\xf4\xc9\xd0\xabF7\x8d\xa2\x8fw\x87m\xd8\x11\xc4\x04/j\x89\xe9g\x7f&jB_\x82\xd9\x07!\x1f:I2\xd3UT.\xfek\x0b\x9f\xb2,\xf4\x845I'
コード例 #27
0
 def setUp(self):
     Config.load()
     CryptoClient.useTestKeyring()
コード例 #28
0
	def testDecryptValid(self):
		self._setupKeyring(["key1_private", "key2_public"])
		ENCRYPTED_MESSAGE = self.MESSAGE_FROM_2_FOR_1
		backAgain, sigok = CryptoClient.decryptAndCheckSignature(ENCRYPTED_MESSAGE)
		self.assertIsNotNone(backAgain, "Decryption of valid data shouldn't give none")
		self.assertTrue(sigok, "Signature check should be ok")
コード例 #29
0
 def setUp(self):
     Config.load()
     DbClient.useTestTables()
     CryptoClient.useTestKeyring()
     TestUtils.setupKeyring(["key1_private", "key2_public"])
     TestUtils.setupOwnProfile("46944E14D24D711B")  # id of key1
コード例 #30
0
	def testDecryptNotForMe(self):
		self._setupKeyring(["key1_public", "key2_private"])
		ENCRYPTED_MESSAGE = self.MESSAGE_FROM_2_FOR_1
		backAgain, sigok = CryptoClient.decryptAndCheckSignature(ENCRYPTED_MESSAGE)
		self.assertIsNone(backAgain, "Failed decryption should give none")
		self.assertFalse(sigok, "Signature check should give false")
コード例 #31
0
	def testDecryptBlank(self):
		self._setupKeyring(["key1_private", "key1_public"])
		backAgain, sigok = CryptoClient.decryptAndCheckSignature("")
		self.assertIsNone(backAgain, "Decryption of empty string should give none")
		self.assertFalse(sigok, "Signature check should give false")
コード例 #32
0
	def testDecryptPlaintext(self):
		self._setupKeyring(["key1_private", "key1_public"])
		MESSAGE = "This is the unencrypted source text we're going to use".encode("utf-8")
		backAgain, sigok = CryptoClient.decryptAndCheckSignature(MESSAGE)
		self.assertIsNone(backAgain, "Decryption of plaintext should give none")
		self.assertFalse(sigok, "Signature check should give false")
コード例 #33
0
ファイル: startupwizard.py プロジェクト: bellyfat/Murmeli
 def run(self):
     self.keypair = CryptoClient.generateKeyPair(self.name, self.email,
                                                 self.comment)
コード例 #34
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)
コード例 #35
0
ファイル: message.py プロジェクト: bellyfat/Murmeli
 def _createPayload(self, recipientKeyId):
     '''Get the original message, and then sign it with our key'''
     if self.origParcel:
         ownKeyId = DbI.getOwnKeyid()
         return CryptoClient.signData(self.origParcel, ownKeyId)
コード例 #36
0
	def testDecryptUnrecognisedSig(self):
		self._setupKeyring(["key1_private"])
		ENCRYPTED_MESSAGE = self.MESSAGE_FROM_2_FOR_1
		backAgain, sigok = CryptoClient.decryptAndCheckSignature(ENCRYPTED_MESSAGE)
		self.assertIsNotNone(backAgain, "Decryption of encrypted text with unrecognised signature should still give a result")
		self.assertFalse(sigok, "Signature check should give false")
コード例 #37
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)
コード例 #38
0
	def run(self):
		self.keypair = CryptoClient.generateKeyPair(self.name, self.email, self.comment)