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
56
Issues
56
List
Boards
Labels
Service Desk
Milestones
Merge Requests
8
Merge Requests
8
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gajim
gajim-plugins
Commits
bf8a88d5
Commit
bf8a88d5
authored
Nov 21, 2020
by
Philipp Hörist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[openpgp] Generate keys without protection
parent
d8bf566d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
17 deletions
+13
-17
openpgp/backend/pygpg.py
openpgp/backend/pygpg.py
+13
-17
No files found.
openpgp/backend/pygpg.py
View file @
bf8a88d5
...
...
@@ -33,14 +33,13 @@ KeyringItem = namedtuple('KeyringItem', 'jid keyid fingerprint')
class
PythonGnuPG
(
gnupg
.
GPG
):
def
__init__
(
self
,
jid
,
gnupghome
):
gnupg
.
GPG
.
__init__
(
self
,
gpgbinary
=
'gpg'
,
gnupghome
=
str
(
gnupghome
))
gnupg
.
GPG
.
__init__
(
self
,
gpgbinary
=
'gpg'
,
gnupghome
=
str
(
gnupghome
))
self
.
_passphrase
=
'gajimopenpgppassphrase'
self
.
_jid
=
jid
.
getBare
()
self
.
_own_fingerprint
=
None
def
_get_key_params
(
self
,
jid
,
passphrase
):
@
staticmethod
def
_get_key_params
(
jid
):
'''
Generate --gen-key input
'''
...
...
@@ -49,17 +48,17 @@ class PythonGnuPG(gnupg.GPG):
'Key-Type'
:
'RSA'
,
'Key-Length'
:
2048
,
'Name-Real'
:
'xmpp:%s'
%
jid
,
'Passphrase'
:
passphrase
,
}
out
=
"Key-Type: %s
\n
"
%
params
.
pop
(
'Key-Type'
)
out
=
'Key-Type: %s
\n
'
%
params
.
pop
(
'Key-Type'
)
for
key
,
val
in
list
(
params
.
items
()):
out
+=
"%s: %s
\n
"
%
(
key
,
val
)
out
+=
"%commit
\n
"
out
+=
'%s: %s
\n
'
%
(
key
,
val
)
out
+=
'%no-protection
\n
'
out
+=
'%commit
\n
'
return
out
def
generate_key
(
self
):
super
().
gen_key
(
self
.
_get_key_params
(
self
.
_jid
,
self
.
_passphrase
))
super
().
gen_key
(
self
.
_get_key_params
(
self
.
_jid
))
def
encrypt
(
self
,
payload
,
keys
):
recipients
=
[
key
.
fingerprint
for
key
in
keys
]
...
...
@@ -71,8 +70,7 @@ class PythonGnuPG(gnupg.GPG):
recipients
,
armor
=
False
,
sign
=
self
.
_own_fingerprint
,
always_trust
=
True
,
passphrase
=
self
.
_passphrase
)
always_trust
=
True
)
if
result
.
ok
:
error
=
''
...
...
@@ -82,9 +80,7 @@ class PythonGnuPG(gnupg.GPG):
return
result
.
data
,
error
def
decrypt
(
self
,
payload
):
result
=
super
().
decrypt
(
payload
,
always_trust
=
True
,
passphrase
=
self
.
_passphrase
)
result
=
super
().
decrypt
(
payload
,
always_trust
=
True
)
if
not
result
.
ok
:
raise
DecryptionFailed
(
result
.
status
)
...
...
@@ -134,6 +130,7 @@ class PythonGnuPG(gnupg.GPG):
result
=
self
.
scan_keys
(
temppath
)
if
result
:
key_found
=
False
for
uid
in
result
.
uids
:
if
uid
.
startswith
(
'xmpp:'
):
if
uid
[
5
:]
==
jid
:
...
...
@@ -174,10 +171,9 @@ class PythonGnuPG(gnupg.GPG):
def
export_key
(
self
,
fingerprint
):
key
=
super
().
export_keys
(
fingerprint
,
secret
=
False
,
armor
=
False
,
minimal
=
False
,
passphrase
=
self
.
_passphrase
)
fingerprint
,
secret
=
False
,
armor
=
False
,
minimal
=
True
)
return
key
def
delete_key
(
self
,
fingerprint
):
log
.
info
(
'Delete Key: %s'
,
fingerprint
)
super
().
delete_keys
(
fingerprint
,
passphrase
=
self
.
_passphrase
)
super
().
delete_keys
(
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