Exemplo n.º 1
0
    def _process_pre_key_message(self, jid, device, key):
        self._log.info('Process pre key message from %s', jid)
        pre_key_message = PreKeyWhisperMessage(serialized=key)
        if not pre_key_message.getPreKeyId():
            raise Exception('Received Pre Key Message '
                            'without PreKey => %s' % jid)

        session_cipher = self._get_session_cipher(jid, device)
        key = session_cipher.decryptPkmsg(pre_key_message)

        identity_key = pre_key_message.getIdentityKey()
        trust = self._get_trust_from_identity_key(jid, identity_key)
        fingerprint = get_fingerprint(identity_key)

        self._storage.setIdentityLastSeen(jid, identity_key)

        self.xmpp_con.set_bundle()
        self.add_device(jid, device)
        return key, fingerprint, trust
Exemplo n.º 2
0
 def _get_identity_key_from_pk_message(key):
     pre_key_message = PreKeyWhisperMessage(serialized=key)
     return pre_key_message.getIdentityKey()