Пример #1
0
    def write(keydict, savedir):
        if not os.path.exists(savedir):
            raise Exception('"' + savedir + '" does not exist!')

        kf = os.path.join(savedir, PidginProperties.keyfile)
        # Pidgin requires the XMPP resource in the account name field of the
        # OTR private keys file, so fetch it from the existing account info
        if os.path.exists(os.path.join(savedir, PidginProperties.accountsfile)):
            accountsdir = savedir
        elif os.path.exists(os.path.join(PidginProperties.path,
                                         PidginProperties.accountsfile)):
            accountsdir = PidginProperties.path
        else:
            raise Exception('Cannot find "' + PidginProperties.accountsfile
                            + '" in "' + savedir + '"')
        resources = PidginProperties._get_resources(accountsdir)
        OtrPrivateKeys.write(keydict, kf, resources=resources)

        accounts = []
        # look for all private keys and use them for the accounts list
        for name, key in keydict.items():
            if 'x' in key:
                accounts.append(name)
        fpf = os.path.join(savedir, PidginProperties.fingerprintfile)
        OtrFingerprints.write(keydict, fpf, accounts, resources=resources)
Пример #2
0
    def write(keydict, savedir):
        if not os.path.exists(savedir):
            raise Exception('"' + savedir + '" does not exist!')

        kf = os.path.join(savedir, PidginProperties.keyfile)
        # Pidgin requires the XMPP resource in the account name field of the
        # OTR private keys file, so fetch it from the existing account info
        if os.path.exists(os.path.join(savedir,
                                       PidginProperties.accountsfile)):
            accountsdir = savedir
        elif os.path.exists(
                os.path.join(PidginProperties.path,
                             PidginProperties.accountsfile)):
            accountsdir = PidginProperties.path
        else:
            raise Exception('Cannot find "' + PidginProperties.accountsfile +
                            '" in "' + savedir + '"')
        resources = PidginProperties._get_resources(accountsdir)
        OtrPrivateKeys.write(keydict, kf, resources=resources)

        accounts = []
        # look for all private keys and use them for the accounts list
        for name, key in keydict.items():
            if 'x' in key:
                accounts.append(name)
        fpf = os.path.join(savedir, PidginProperties.fingerprintfile)
        OtrFingerprints.write(keydict, fpf, accounts, resources=resources)
Пример #3
0
    def write(keydict, savedir):
        if not os.path.exists(savedir):
            raise Exception('"' + savedir + '" does not exist!')

        kf = os.path.join(savedir, IrssiProperties.keyfile)
        OtrPrivateKeys.write(keydict, kf)

        accounts = []
        # look for all private keys and use them for the accounts list
        for name, key in keydict.items():
            if "x" in key:
                accounts.append(name)
        fpf = os.path.join(savedir, IrssiProperties.fingerprintfile)
        OtrFingerprints.write(keydict, fpf, accounts)
Пример #4
0
    def write(keydict, savedir):
        if not os.path.exists(savedir):
            raise Exception('"' + savedir + '" does not exist!')

        kf = os.path.join(savedir, XchatProperties.keyfile)
        OtrPrivateKeys.write(keydict, kf)

        accounts = []
        # look for all private keys and use them for the accounts list
        for name, key in keydict.items():
            if 'x' in key:
                accounts.append(name)
        fpf = os.path.join(savedir, XchatProperties.fingerprintfile)
        OtrFingerprints.write(keydict, fpf, accounts)
Пример #5
0
    def parse(settingsdir=None):
        if settingsdir == None:
            settingsdir = KopeteProperties.path

        kf = os.path.join(settingsdir, KopeteProperties.keyfile)
        if os.path.exists(kf):
            keydict = OtrPrivateKeys.parse(kf)
            for key in keydict:
                for value in keydict[key]:
                    if value == 'protocol':
                        keydict[key][
                            value] = KopeteProperties._convert_protocol_name(
                                keydict[key][value])
        else:
            keydict = dict()

        fpf = os.path.join(settingsdir, KopeteProperties.fingerprintfile)
        if os.path.exists(fpf):
            tmpdict = OtrFingerprints.parse(fpf)
            for key in tmpdict:
                for value in tmpdict[key]:
                    if value == 'protocol':
                        tmpdict[key][
                            value] = KopeteProperties._convert_protocol_name(
                                tmpdict[key][value])

            otrapps.util.merge_keydicts(keydict, tmpdict)

        return keydict
Пример #6
0
    def parse(settingsdir=None):
        if settingsdir == None:
            settingsdir = KopeteProperties.path

        kf = os.path.join(settingsdir, KopeteProperties.keyfile)
        if os.path.exists(kf):
            keydict = OtrPrivateKeys.parse(kf)
            for key in keydict:
                for value in keydict[key]:
                    if value == 'protocol':
                        keydict[key][value] = KopeteProperties._convert_protocol_name(keydict[key][value])
        else:
            keydict = dict()

        fpf = os.path.join(settingsdir, KopeteProperties.fingerprintfile)
        if os.path.exists(fpf):
            tmpdict = OtrFingerprints.parse(fpf)
            for key in tmpdict:
                for value in tmpdict[key]:
                    if value == 'protocol':
                        tmpdict[key][value] = KopeteProperties._convert_protocol_name(tmpdict[key][value])

            otrapps.util.merge_keydicts(keydict, tmpdict)

        return keydict
Пример #7
0
    def parse(settingsdir=None):
        if settingsdir == None:
            settingsdir = AdiumProperties.path

        kf = os.path.join(settingsdir, AdiumProperties.keyfile)
        if os.path.exists(kf):
            keydict = OtrPrivateKeys.parse(kf)
        else:
            keydict = dict()

        accounts = AdiumProperties._get_accounts_from_plist(settingsdir)
        newkeydict = dict()
        for adiumIndex, key in keydict.items():
            for account in accounts:
                if account['ObjectID'] == key['name']:
                    name = account['UID']
                    key['name'] = name
                    newkeydict[name] = key
        keydict = newkeydict

        fpf = os.path.join(settingsdir, AdiumProperties.fingerprintfile)
        if os.path.exists(fpf):
            otrapps.util.merge_keydicts(keydict, OtrFingerprints.parse(fpf))

        return keydict
Пример #8
0
 def parse(settingsdir=None):
     if settingsdir == None:
         settingsdir = GajimProperties.path
     keydict = dict()
     for fpf in glob.glob(os.path.join(settingsdir, "*.fpr")):
         print("Reading in " + fpf)
         otrapps.util.merge_keydicts(keydict, OtrFingerprints.parse(fpf))
     return keydict
Пример #9
0
    def write(keydict, savedir):
        if not os.path.exists(savedir):
            raise Exception('"' + savedir + '" does not exist!')

        for key in keydict:
            for value in keydict[key]:
                if value == 'protocol':
                    keydict[key][value] = KopeteProperties._convert_protocol_name(keydict[key][value])

        kf = os.path.join(savedir, KopeteProperties.keyfile)
        OtrPrivateKeys.write(keydict, kf)

        accounts = []
        # look for all private keys and use them for the accounts list
        for name, key in keydict.items():
            if 'x' in key:
                accounts.append(name)
        fpf = os.path.join(savedir, KopeteProperties.fingerprintfile)
        OtrFingerprints.write(keydict, fpf, accounts)
Пример #10
0
    def write(keydict, savedir):
        if not os.path.exists(savedir):
            raise Exception('"' + savedir + '" does not exist!')

        for key in keydict:
            for value in keydict[key]:
                if value == 'protocol':
                    keydict[key][
                        value] = KopeteProperties._convert_protocol_name(
                            keydict[key][value])

        kf = os.path.join(savedir, KopeteProperties.keyfile)
        OtrPrivateKeys.write(keydict, kf)

        accounts = []
        # look for all private keys and use them for the accounts list
        for name, key in keydict.items():
            if 'x' in key:
                accounts.append(name)
        fpf = os.path.join(savedir, KopeteProperties.fingerprintfile)
        OtrFingerprints.write(keydict, fpf, accounts)
Пример #11
0
    def write(keydict, savedir='./'):
        if not os.path.exists(savedir):
            raise Exception('"' + savedir + '" does not exist!')

        # need when converting account names back to Adium's account index number
        accountsplist = AdiumProperties._get_accounts_from_plist(savedir)

        kf = os.path.join(savedir, AdiumProperties.keyfile)
        adiumkeydict = dict()
        for name, key in keydict.items():
            name = key['name']
            for account in accountsplist:
                if account['UID'] == name:
                    key['name'] = account['ObjectID']
                    adiumkeydict[name] = key
        OtrPrivateKeys.write(keydict, kf)

        accounts = []
        for account in accountsplist:
            accounts.append(account['ObjectID'])
        fpf = os.path.join(savedir, AdiumProperties.fingerprintfile)
        OtrFingerprints.write(keydict, fpf, accounts)
Пример #12
0
    def parse(settingsdir=None):
        if settingsdir == None:
            settingsdir = IrssiProperties.path

        kf = os.path.join(settingsdir, IrssiProperties.keyfile)
        if os.path.exists(kf):
            keydict = OtrPrivateKeys.parse(kf)
        else:
            keydict = dict()

        fpf = os.path.join(settingsdir, IrssiProperties.fingerprintfile)
        if os.path.exists(fpf):
            otrapps.util.merge_keydicts(keydict, OtrFingerprints.parse(fpf))

        return keydict
Пример #13
0
    def parse(settingsdir=None):
        if settingsdir == None:
            settingsdir = XchatProperties.path

        kf = os.path.join(settingsdir, XchatProperties.keyfile)
        if os.path.exists(kf):
            keydict = OtrPrivateKeys.parse(kf)
        else:
            keydict = dict()

        fpf = os.path.join(settingsdir, XchatProperties.fingerprintfile)
        if os.path.exists(fpf):
            otrapps.util.merge_keydicts(keydict, OtrFingerprints.parse(fpf))

        return keydict
Пример #14
0
    def parse(settingsdir=None):
        if settingsdir is None:
            settingsdir = GajimProperties.path
            accounts_config = GajimProperties.accounts_path
        else:
            accounts_config = settingsdir

        keydict = dict()
        for fpf in glob.glob(os.path.join(settingsdir, '*.fpr')):
            print('Reading in ' + fpf)
            keys = OtrFingerprints.parse(fpf)

            # replace gajim's 'xmpp' protocol with 'prpl-jabber' that we use in keysync
            for key, value in keys.items():
                value['protocol'] = 'prpl-jabber'
                keys[key] = value

            otrapps.util.merge_keydicts(keydict, keys)

        accounts = GajimProperties._parse_account_config(accounts_config)

        for key_file in glob.glob(os.path.join(settingsdir, '*.key3')):
            account_name = os.path.splitext(os.path.basename(key_file))[0]
            if not account_name in accounts.keys():
                print("ERROR found %s not in the account list", key_file)
                continue
            with open(key_file, 'rb') as key_file:
                name = '%s@%s' % (accounts[account_name]['name'],
                                  accounts[account_name]['hostname'])
                if name in keydict:
                    key = keydict[name]
                else:
                    key = dict()
                    key['name'] = name
                key['protocol'] = 'prpl-jabber'
                key['resource'] = accounts[account_name]['resource']

                pk = potr.crypt.PK.parsePrivateKey(key_file.read())[0]
                keydata = ['y', 'g', 'p', 'q', 'x']
                for data in keydata:
                    key[data] = getattr(pk.priv, data)

                key['fingerprint'] = otrapps.util.fingerprint((key['y'], key['g'],
                                                               key['p'], key['q']))

                keydict[key['name']] = key

        return keydict
Пример #15
0
    def parse(settingsdir):
        if settingsdir is None:
            settingsdir = GajimProperties.path
            accounts_config = GajimProperties.accounts_path
        else:
            accounts_config = settingsdir

        keydict = dict()
        for fpf in glob.glob(os.path.join(settingsdir, '*.fpr')):
            print('Reading in ' + fpf)
            keys = OtrFingerprints.parse(fpf)

            # replace gajim's 'xmpp' protocol with 'prpl-jabber' that we use in keysync
            for key, value in keys.items():
                value['protocol'] = 'prpl-jabber'
                keys[key] = value

            otrapps.util.merge_keydicts(keydict, keys)

        accounts = GajimProperties._parse_account_config(accounts_config)

        for key_file in glob.glob(os.path.join(settingsdir, '*.key3')):
            account_name = os.path.splitext(os.path.basename(key_file))[0]
            if not account_name in accounts.keys():
                print("ERROR found %s not in the account list", key_file)
                continue
            with open(key_file, 'rb') as key_file:
                name = '%s@%s' % (accounts[account_name]['name'],
                                  accounts[account_name]['hostname'])
                if name in keydict:
                    key = keydict[name]
                else:
                    key = dict()
                    key['name'] = name
                key['protocol'] = 'prpl-jabber'
                key['resource'] = accounts[account_name]['resource']

                pk = potr.crypt.PK.parsePrivateKey(key_file.read())[0]
                keydata = ['y', 'g', 'p', 'q', 'x']
                for data in keydata:
                    key[data] = getattr(pk.priv, data)

                key['fingerprint'] = otrapps.util.fingerprint(
                    (key['y'], key['g'], key['p'], key['q']))

                keydict[key['name']] = key

        return keydict
Пример #16
0
    def parse(settingsdir=None):
        if settingsdir == None:
            settingsdir = PidginProperties.path

        kf = os.path.join(settingsdir, PidginProperties.keyfile)
        if os.path.exists(kf):
            keydict = OtrPrivateKeys.parse(kf)
        else:
            keydict = dict()

        fpf = os.path.join(settingsdir, PidginProperties.fingerprintfile)
        if os.path.exists(fpf):
            otrapps.util.merge_keydicts(keydict, OtrFingerprints.parse(fpf))

        resources = PidginProperties._get_resources(settingsdir)
        for name, key in keydict.items():
            if key['protocol'] == 'prpl-jabber' \
                    and 'x' in key.keys() \
                    and name in resources.keys():
                key['resource'] = resources[name]

        return keydict
Пример #17
0
    def parse(settingsdir=None):
        if settingsdir == None:
            settingsdir = PidginProperties.path

        kf = os.path.join(settingsdir, PidginProperties.keyfile)
        if os.path.exists(kf):
            keydict = OtrPrivateKeys.parse(kf)
        else:
            keydict = dict()

        fpf = os.path.join(settingsdir, PidginProperties.fingerprintfile)
        if os.path.exists(fpf):
            otrapps.util.merge_keydicts(keydict, OtrFingerprints.parse(fpf))

        resources = PidginProperties._get_resources(settingsdir)
        for name, key in keydict.items():
            if key['protocol'] == 'prpl-jabber' \
                    and 'x' in key.keys() \
                    and name in resources.keys():
                key['resource'] = resources[name]

        return keydict