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]
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
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
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]
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)
def getSessionCipher(self, identity): """Construct SessionCipher for given identity""" return SessionCipher(self.store, self.store, self.store, self.store, identity, self.DEFAULT_DEVICE_ID)