Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Malte L
gajim-plugins
Commits
2f0aafba
Commit
2f0aafba
authored
Feb 19, 2019
by
Philipp Hörist
Browse files
[omemo] Dont fail on invalid session
parent
49ad0b1f
Changes
2
Hide whitespace changes
Inline
Side-by-side
omemo/backend/liteaxolotlstore.py
View file @
2f0aafba
...
...
@@ -491,13 +491,17 @@ class LiteAxolotlStore(AxolotlStore):
def
isTrusted
(
self
,
recipient_id
,
device_id
):
record
=
self
.
loadSession
(
recipient_id
,
device_id
)
identity_key
=
record
.
getSessionState
().
getRemoteIdentityKey
()
try
:
identity_key
=
record
.
getSessionState
().
getRemoteIdentityKey
()
except
Exception
:
log
.
exception
(
'Unable to determine trust for %s %s'
,
recipient_id
,
device_id
)
return
False
return
self
.
getTrustForIdentity
(
recipient_id
,
identity_key
)
==
Trust
.
TRUSTED
def
isUntrusted
(
self
,
recipient_id
,
device_id
):
record
=
self
.
loadSession
(
recipient_id
,
device_id
)
identity_key
=
record
.
getSessionState
().
getRemoteIdentityKey
()
def
isUntrustedIdentity
(
self
,
recipient_id
,
identity_key
):
return
self
.
getTrustForIdentity
(
recipient_id
,
identity_key
)
not
in
(
Trust
.
TRUSTED
,
Trust
.
UNDECIDED
)
...
...
omemo/backend/state.py
View file @
2f0aafba
...
...
@@ -224,7 +224,8 @@ class OmemoState(DeviceManager):
raise
Exception
(
'Received Pre Key Message '
'without PreKey => %s'
%
jid
)
if
self
.
_storage
.
isUntrusted
(
jid
,
device
):
identity_key
=
pre_key_message
.
getIdentityKey
()
if
self
.
_storage
.
isUntrustedIdentity
(
jid
,
identity_key
):
raise
SenderNotTrusted
session_cipher
=
self
.
_get_session_cipher
(
jid
,
device
)
...
...
@@ -232,7 +233,7 @@ class OmemoState(DeviceManager):
log
.
info
(
'%s => Process pre key message from %s'
,
self
.
_account
,
jid
)
key
=
session_cipher
.
decryptPkmsg
(
pre_key_message
)
fingerprint
=
get_fingerprint
(
pre_key_message
.
getI
dentity
Key
()
)
fingerprint
=
get_fingerprint
(
i
dentity
_key
)
self
.
xmpp_con
.
set_bundle
()
self
.
add_device
(
jid
,
device
)
...
...
@@ -242,16 +243,16 @@ class OmemoState(DeviceManager):
message
=
WhisperMessage
(
serialized
=
key
)
log
.
info
(
'%s => Process message from %s'
,
self
.
_account
,
jid
)
session_record
=
self
.
_storage
.
loadSession
(
jid
,
device
)
identity_key
=
session_record
.
getSessionState
().
getRemoteIdentityKey
()
fingerprint
=
get_fingerprint
(
identity_key
)
session_cipher
=
self
.
_get_session_cipher
(
jid
,
device
)
key
=
session_cipher
.
decryptMsg
(
message
,
textMsg
=
False
)
if
self
.
_storage
.
isUntrusted
(
jid
,
device
):
session_record
=
self
.
_storage
.
loadSession
(
jid
,
device
)
identity_key
=
session_record
.
getSessionState
().
getRemoteIdentityKey
()
if
self
.
_storage
.
isUntrustedIdentity
(
jid
,
identity_key
):
raise
SenderNotTrusted
fingerprint
=
get_fingerprint
(
identity_key
)
self
.
add_device
(
jid
,
device
)
return
key
,
fingerprint
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment