Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gajim-plugins
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
muelli
gajim-plugins
Commits
7ad794da
Commit
7ad794da
authored
Sep 14, 2018
by
Philipp Hörist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[openpgp] Save encryption details
parent
9b3e23be
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
6 deletions
+33
-6
openpgp/backend/pygpg.py
openpgp/backend/pygpg.py
+1
-1
openpgp/modules/openpgp.py
openpgp/modules/openpgp.py
+24
-4
openpgp/modules/util.py
openpgp/modules/util.py
+6
-0
openpgp/pgpplugin.py
openpgp/pgpplugin.py
+2
-1
No files found.
openpgp/backend/pygpg.py
View file @
7ad794da
...
...
@@ -89,7 +89,7 @@ class PGPContext(gnupg.GPG):
if
not
result
.
ok
:
raise
DecryptionFailed
(
result
.
status
)
return
result
.
data
.
decode
(
'utf8'
)
return
result
.
data
.
decode
(
'utf8'
)
,
result
.
fingerprint
def
get_key
(
self
,
fingerprint
):
return
super
().
list_keys
(
keys
=
[
fingerprint
])
...
...
openpgp/modules/openpgp.py
View file @
7ad794da
...
...
@@ -28,6 +28,8 @@ from gajim.common import configpaths
from
gajim.common.connection_handlers_events
import
MessageNotSentEvent
from
openpgp.modules
import
util
from
openpgp.modules.util
import
ENCRYPTION_NAME
from
openpgp.modules.util
import
add_additional_data
from
openpgp.modules.util
import
NS_OPENPGP_PUBLIC_KEYS
from
openpgp.modules.util
import
NS_OPENPGP
from
openpgp.modules.util
import
Key
...
...
@@ -40,10 +42,8 @@ from openpgp.backend.pygpg import PGPContext
log
=
logging
.
getLogger
(
'gajim.plugin_system.openpgp'
)
ENCRYPTION_NAME
=
'OpenPGP'
# Module name
name
=
'OpenPGP'
name
=
ENCRYPTION_NAME
zeroconf
=
False
...
...
@@ -198,6 +198,9 @@ class ContactData:
return
[
k
for
k
in
keys
if
k
.
active
and
k
.
trust
in
(
Trust
.
VERIFIED
,
Trust
.
BLIND
)]
def
get_key
(
self
,
fingerprint
):
return
self
.
_key_store
.
get
(
fingerprint
,
None
)
def
set_trust
(
self
,
fingerprint
,
trust
):
self
.
_storage
.
set_trust
(
self
.
jid
,
fingerprint
,
trust
)
...
...
@@ -269,6 +272,16 @@ class PGPContacts:
except
KeyError
:
return
[]
def
get_trust
(
self
,
jid
,
fingerprint
):
contact_data
=
self
.
_contacts
.
get
(
jid
,
None
)
if
contact_data
is
None
:
return
Trust
.
UNKNOWN
key
=
contact_data
.
get_key
(
fingerprint
)
if
key
is
None
:
return
Trust
.
UNKNOWN
return
key
.
trust
class
OpenPGP
:
def
__init__
(
self
,
con
):
...
...
@@ -445,7 +458,8 @@ class OpenPGP:
encrypted_payload
=
b64decode
(
b64encode_payload
)
try
:
decrypted_payload
=
self
.
_pgp
.
decrypt
(
encrypted_payload
)
decrypted_payload
,
fingerprint
=
self
.
_pgp
.
decrypt
(
encrypted_payload
)
except
DecryptionFailed
as
error
:
log
.
warning
(
error
)
return
...
...
@@ -482,6 +496,9 @@ class OpenPGP:
if
body
:
obj
.
msgtxt
=
body
add_additional_data
(
obj
.
additional_data
,
fingerprint
)
obj
.
encrypted
=
ENCRYPTION_NAME
callback
(
obj
)
...
...
@@ -508,6 +525,9 @@ class OpenPGP:
util
.
create_openpgp_message
(
obj
,
encrypted_payload
)
add_additional_data
(
obj
.
additional_data
,
self
.
_fingerprint
)
obj
.
encrypted
=
ENCRYPTION_NAME
self
.
print_msg_to_log
(
obj
.
msg_iq
)
callback
(
obj
)
...
...
openpgp/modules/util.py
View file @
7ad794da
...
...
@@ -29,6 +29,7 @@ from nbxmpp import Node
from
gajim.common.modules.date_and_time
import
parse_datetime
ENCRYPTION_NAME
=
'OpenPGP'
NS_OPENPGP
=
'urn:xmpp:openpgp:0'
NS_OPENPGP_PUBLIC_KEYS
=
'urn:xmpp:openpgp:0:public-keys'
NS_NOTIFY
=
NS_OPENPGP_PUBLIC_KEYS
+
'+notify'
...
...
@@ -206,6 +207,11 @@ def get_info_message():
return
'[This message is *encrypted* with OpenPGP (See :XEP:`0373`]'
def
add_additional_data
(
data
,
fingerprint
,
trust
):
data
[
'encrypted'
]
=
{
'name'
:
ENCRYPTION_NAME
,
'fingerprint'
:
fingerprint
}
class
VerifyFailed
(
Exception
):
pass
...
...
openpgp/pgpplugin.py
View file @
7ad794da
...
...
@@ -32,6 +32,7 @@ from gajim.common.const import CSSPriority
from
gajim.gtk.dialogs
import
ErrorDialog
from
openpgp.modules.util
import
NS_NOTIFY
from
openpgp.modules.util
import
ENCRYPTION_NAME
from
openpgp.modules
import
pgp_keylist
try
:
from
openpgp.modules
import
openpgp
...
...
@@ -60,7 +61,7 @@ class OpenPGPPlugin(GajimPlugin):
self
.
modules
=
[
pgp_keylist
,
openpgp
]
self
.
encryption_name
=
'OpenPGP'
self
.
encryption_name
=
ENCRYPTION_NAME
self
.
config_dialog
=
None
self
.
gui_extension_points
=
{
'encrypt'
+
self
.
encryption_name
:
(
self
.
_encrypt_message
,
None
),
...
...
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