Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michel Le Bihan
gajim
Commits
eb0257bf
Commit
eb0257bf
authored
1 year ago
by
mjk
Browse files
Options
Downloads
Patches
Plain Diff
feat: JID sharing: Include verified OMEMO fingerprints
parent
fa79e9be
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
gajim/common/modules/omemo.py
+23
-0
23 additions, 0 deletions
gajim/common/modules/omemo.py
gajim/gtk/chat_banner.py
+2
-2
2 additions, 2 deletions
gajim/gtk/chat_banner.py
gajim/gtk/omemo_trust_manager.py
+6
-21
6 additions, 21 deletions
gajim/gtk/omemo_trust_manager.py
with
31 additions
and
23 deletions
gajim/common/modules/omemo.py
+
23
−
0
View file @
eb0257bf
...
...
@@ -50,6 +50,7 @@ from omemo_dr.exceptions import DuplicateMessage
from
omemo_dr.exceptions
import
KeyExchangeMessage
from
omemo_dr.exceptions
import
MessageNotForDevice
from
omemo_dr.exceptions
import
SelfMessage
from
omemo_dr.identitykey
import
IdentityKey
from
omemo_dr.session_manager
import
OMEMOSessionManager
from
omemo_dr.structs
import
OMEMOBundle
from
omemo_dr.structs
import
OMEMOConfig
...
...
@@ -61,6 +62,7 @@ from gajim.common import types
from
gajim.common.const
import
EncryptionData
from
gajim.common.const
import
EncryptionInfoMsg
from
gajim.common.const
import
Trust
as
GajimTrust
from
gajim.common.const
import
XmppUriQuery
from
gajim.common.events
import
EncryptionInfo
from
gajim.common.events
import
MucAdded
from
gajim.common.events
import
MucDiscoUpdate
...
...
@@ -92,6 +94,8 @@ ALLOWED_TAGS = [
(
'
origin-id
'
,
Namespace
.
SID
),
]
DeviceIdT
=
int
IdentityT
=
tuple
[
DeviceIdT
,
IdentityKey
]
class
OMEMO
(
BaseModule
):
...
...
@@ -646,6 +650,25 @@ class OMEMO(BaseModule):
stanzastr
=
stanzastr
[
0
:
-
1
]
self
.
_log
.
debug
(
stanzastr
)
def
compose_trust_uri
(
self
,
jid
:
JID
)
->
str
:
verified_identities
=
[
(
info
.
device_id
,
info
.
public_key
)
for
info
in
self
.
_backend
.
get_identity_infos
(
jid
.
bare
,
only_active
=
True
,
trust
=
OMEMOTrust
.
VERIFIED
)
]
if
self
.
_client
.
is_own_jid
(
jid
):
verified_identities
.
insert
(
0
,
self
.
_backend
.
get_our_identity
())
return
compose_trust_uri
(
jid
,
verified_identities
)
def
cleanup
(
self
)
->
None
:
self
.
_backend
.
destroy
()
del
self
.
_backend
def
compose_trust_uri
(
jid
:
JID
,
devices
:
list
[
IdentityT
])
->
str
:
query
=
(
XmppUriQuery
.
MESSAGE
.
value
,
[(
f
'
omemo-sid-
{
sid
}
'
,
ik
.
get_fingerprint
())
for
sid
,
ik
in
devices
]
)
if
devices
else
None
uri
=
jid
.
new_as_bare
().
to_iri
(
query
)
return
uri
This diff is collapsed.
Click to expand it.
gajim/gtk/chat_banner.py
+
2
−
2
View file @
eb0257bf
...
...
@@ -334,13 +334,13 @@ class ChatBanner(Gtk.Box, EventHelper):
self
.
_ui
.
jid_label
.
set_text
(
str
(
self
.
_contact
.
jid
))
def
_get_share_uri
(
self
)
->
str
:
assert
self
.
_client
is
not
None
assert
self
.
_contact
is
not
None
jid
=
self
.
_contact
.
get_address
()
if
self
.
_contact
.
is_groupchat
:
return
jid
.
to_iri
(
XmppUriQuery
.
JOIN
.
value
)
else
:
# TODO: add verified OMEMO FPs
return
jid
.
to_iri
()
return
self
.
_client
.
get_module
(
'
OMEMO
'
).
compose_trust_uri
(
jid
)
def
_on_share_clicked
(
self
,
_button
:
Gtk
.
Button
)
->
None
:
# Generate QR code on demand (i.e. not when switching chats)
...
...
This diff is collapsed.
Click to expand it.
gajim/gtk/omemo_trust_manager.py
+
6
−
21
View file @
eb0257bf
...
...
@@ -25,22 +25,20 @@ import locale
import
logging
import
time
from
gi.repository
import
GdkPixbuf
from
gi.repository
import
Gtk
from
nbxmpp.protocol
import
JID
from
omemo_dr.const
import
OMEMOTrust
from
omemo_dr.structs
import
IdentityInfo
from
gajim.common
import
app
from
gajim.common
import
ged
from
gajim.common
import
types
from
gajim.common.const
import
XmppUriQuery
from
gajim.common.events
import
AccountConnected
from
gajim.common.events
import
AccountDisconnected
from
gajim.common.ged
import
EventHelper
from
gajim.common.helpers
import
generate_qr_code
from
gajim.common.i18n
import
_
from
gajim.common.modules.contacts
import
BareContact
from
gajim.common.modules.omemo
import
compose_trust_uri
from
.builder
import
get_builder
from
.dialogs
import
ConfirmationDialog
...
...
@@ -196,25 +194,12 @@ class OMEMOTrustManager(Gtk.Box, EventHelper):
str
(
contact
.
jid
)):
self
.
_ui
.
list
.
add
(
KeyRow
(
contact
,
identity_info
))
@staticmethod
def
_get_qrcode
(
jid
:
JID
,
sid
:
int
,
fingerprint
:
str
)
->
GdkPixbuf
.
Pixbuf
|
None
:
qry
=
(
XmppUriQuery
.
MESSAGE
.
value
,
[(
f
'
omemo-sid-
{
sid
}
'
,
fingerprint
)])
ver_string
=
jid
.
new_as_bare
().
to_iri
(
qry
)
log
.
debug
(
'
Verification String: %s
'
,
ver_string
)
return
generate_qr_code
(
ver_string
)
def
_load_qrcode
(
self
)
->
None
:
client
=
app
.
get_client
(
self
.
_account
)
our_device_id
,
our_identity_key
=
\
self
.
_omemo
.
backend
.
get_our_identity
()
pixbuf
=
self
.
_get_qrcode
(
client
.
get_own_jid
(),
our_device_id
,
our_identity_key
.
get_fingerprint
())
self
.
_ui
.
qr_code_image
.
set_from_pixbuf
(
pixbuf
)
uri
=
compose_trust_uri
(
app
.
get_client
(
self
.
_account
).
get_own_jid
(),
[
self
.
_omemo
.
backend
.
get_our_identity
()])
log
.
debug
(
'
Trust URI: %s
'
,
uri
)
self
.
_ui
.
qr_code_image
.
set_from_pixbuf
(
generate_qr_code
(
uri
))
def
_on_show_inactive
(
self
,
switch
:
Gtk
.
Switch
,
_param
:
Any
)
->
None
:
self
.
_ui
.
list
.
invalidate_filter
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment