示例#1
0
文件: layer.py 项目: yurilq/yowsup
 def getSessionCipher(self, recipientId):
     if recipientId in self.sessionCiphers:
         return self.sessionCiphers[recipientId]
     else:
         self.sessionCiphers[recipientId] = SessionCipher(
             self.store, self.store, self.store, self.store, recipientId, 1)
         return self.sessionCiphers[recipientId]
示例#2
0
 def _get_session_cipher(self, recipientid):
     logger.debug("get_session_cipher(recipientid=%s)" % recipientid)
     if recipientid in self._session_ciphers:
         session_cipher = self._session_ciphers[recipientid]
     else:
         session_cipher= SessionCipher(self._store, self._store, self._store, self._store, recipientid, 1)
         self._session_ciphers[recipientid] = session_cipher
     return session_cipher
示例#3
0
 def _get_session_cipher(self, jid, device_id):
     try:
         return self._session_ciphers[jid][device_id]
     except KeyError:
         cipher = SessionCipher(self._storage, self._storage, self._storage,
                                self._storage, jid, device_id)
         self._session_ciphers[jid][device_id] = cipher
         return cipher
示例#4
0
    def get_session_cipher(self, jid, device_id):
        if jid not in self.session_ciphers:
            self.session_ciphers[jid] = {}

        if device_id not in self.session_ciphers[jid]:
            cipher = SessionCipher(self.store, self.store, self.store,
                                   self.store, jid, device_id)
            self.session_ciphers[jid][device_id] = cipher

        return self.session_ciphers[jid][device_id]
示例#5
0
def handle_data_msg(store, who, body):
    messageBytes = binascii.unhexlify(body)
    print("UNWRAPPED >>> [%r]" % binascii.hexlify(messageBytes))

    try:
        sc = SessionCipher(store, store, store, store, who, 1)
        print("SessionCipher >>>", sc)

        wm = WhisperMessage(serialized=messageBytes)
        print("WhisperMessage >>>", wm)

        data = sc.decryptMsg(wm)
        print("DECRYPTED >>> ", data)

    except Exception as e:
        print("EXCEPTION >>>", e)

        exc_type, exc_value, exc_traceback = sys.exc_info()
        print("*** print_tb:")
        traceback.print_tb(exc_traceback, limit=1, file=sys.stdout)
示例#6
0
文件: core.py 项目: xmikos/pyxolotl
 def getSessionCipher(self, identity):
     """Construct SessionCipher for given identity"""
     return SessionCipher(self.store, self.store, self.store, self.store,
                          identity, self.DEFAULT_DEVICE_ID)