openpgp new

This commit is contained in:
Philipp Hörist
2019-03-31 19:55:53 +02:00
parent 33223f7a53
commit e53150c94e
3 changed files with 125 additions and 73 deletions

View File

@@ -44,6 +44,7 @@ from openpgp.modules.util import prepare_stanza
from openpgp.modules.key_store import PGPContacts
from openpgp.backend.sql import Storage
from openpgp.backend.pygpg import PGPContext
from openpgp.backend.aes import aes_encrypt
log = logging.getLogger('gajim.p.openpgp')
@@ -83,7 +84,7 @@ class OpenPGP(BaseModule):
own_bare_jid = self.own_jid.getBare()
path = Path(configpaths.get('MY_DATA')) / 'openpgp' / own_bare_jid
if not path.exists():
path.mkdir(parents=True)
path.mkdir(mode=0o700, parents=True)
self._pgp = PGPContext(self.own_jid, path)
self._storage = Storage(path)
@@ -108,6 +109,11 @@ class OpenPGP(BaseModule):
self._nbxmpp('OpenPGP').set_public_key(
key, self._fingerprint, self._date)
def set_secret_key(self, passphrase):
log.info('%s => Publish secret key', self._account)
secret_key = self._pgp.export_secret_key(passphrase)
self._nbxmpp('OpenPGP').set_secret_key(secret_key)
def request_public_key(self, jid, fingerprint):
log.info('%s => Request public key %s - %s',
self._account, fingerprint, jid)