Commit fa9e8f7f authored by Philipp Hörist's avatar Philipp Hörist

[openpgp] Fix some bugs

- Dont use armor when encrypting
- Convert timestamp to int
- Fix getting the default trust
parent 7776ae0a
......@@ -70,6 +70,7 @@ class PGPContext(gnupg.GPG):
result = super().encrypt(str(payload).encode('utf8'),
recipients,
armor=False,
sign=self._own_fingerprint,
always_trust=True,
passphrase=self._passphrase)
......@@ -79,7 +80,7 @@ class PGPContext(gnupg.GPG):
else:
error = result.status
return str(result), error
return result.data, error
def decrypt(self, payload):
result = super().decrypt(payload,
......
......@@ -116,7 +116,7 @@ class ContactData:
@property
def default_trust(self):
for key in self._key_store:
for key in self._key_store.values():
if key.trust in (Trust.NOT_TRUSTED, Trust.BLIND):
return Trust.UNKNOWN
return Trust.BLIND
......
......@@ -97,7 +97,7 @@ class PGPKeylist(AbstractPEPModule):
if timestamp is None:
raise StanzaMalformed('Invalid date timestamp: %s', date)
keylist.append(Key(attrs['v4-fingerprint'], timestamp))
keylist.append(Key(attrs['v4-fingerprint'], int(timestamp)))
return keylist
def _notification_received(self, jid, keylist):
......
......@@ -177,8 +177,7 @@ def get_rpad():
def create_openpgp_message(obj, encrypted_payload):
b64encoded_payload = b64encode(
encrypted_payload.encode('utf-8')).decode('utf8')
b64encoded_payload = b64encode(encrypted_payload).decode('utf8')
openpgp_node = nbxmpp.Node('openpgp', attrs={'xmlns': NS_OPENPGP})
openpgp_node.addData(b64encoded_payload)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment