def group_decrypt(self, groupid, participantid, data): logger.debug("group_decrypt(groupid=%s, participantid=%s, data=[omitted])" % (groupid, participantid)) group_cipher = self._get_group_cipher(groupid, participantid) try: plaintext = group_cipher.decrypt(data) plaintext = self._unpad(plaintext) return plaintext except NoSessionException: raise exceptions.NoSessionException() except DuplicateMessageException: raise exceptions.DuplicateMessageException()
def decrypt_pkmsg(self, senderid, data, unpad): logger.debug("decrypt_pkmsg(senderid=%s, data=(omitted), unpad=%s)" % (senderid, unpad)) pkmsg = PreKeyWhisperMessage(serialized=data) try: plaintext = self._get_session_cipher(senderid).decryptPkmsg(pkmsg) return self._unpad(plaintext) if unpad else plaintext except NoSessionException: raise exceptions.NoSessionException() except InvalidKeyIdException: raise exceptions.InvalidKeyIdException() except InvalidMessageException: raise exceptions.InvalidMessageException() except DuplicateMessageException: raise exceptions.DuplicateMessageException()