[openpgp] Fix some bugs
- Dont use armor when encrypting - Convert timestamp to int - Fix getting the default trust
This commit is contained in:
@@ -70,6 +70,7 @@ class PGPContext(gnupg.GPG):
|
|||||||
|
|
||||||
result = super().encrypt(str(payload).encode('utf8'),
|
result = super().encrypt(str(payload).encode('utf8'),
|
||||||
recipients,
|
recipients,
|
||||||
|
armor=False,
|
||||||
sign=self._own_fingerprint,
|
sign=self._own_fingerprint,
|
||||||
always_trust=True,
|
always_trust=True,
|
||||||
passphrase=self._passphrase)
|
passphrase=self._passphrase)
|
||||||
@@ -79,7 +80,7 @@ class PGPContext(gnupg.GPG):
|
|||||||
else:
|
else:
|
||||||
error = result.status
|
error = result.status
|
||||||
|
|
||||||
return str(result), error
|
return result.data, error
|
||||||
|
|
||||||
def decrypt(self, payload):
|
def decrypt(self, payload):
|
||||||
result = super().decrypt(payload,
|
result = super().decrypt(payload,
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ class ContactData:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def default_trust(self):
|
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):
|
if key.trust in (Trust.NOT_TRUSTED, Trust.BLIND):
|
||||||
return Trust.UNKNOWN
|
return Trust.UNKNOWN
|
||||||
return Trust.BLIND
|
return Trust.BLIND
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ class PGPKeylist(AbstractPEPModule):
|
|||||||
if timestamp is None:
|
if timestamp is None:
|
||||||
raise StanzaMalformed('Invalid date timestamp: %s', date)
|
raise StanzaMalformed('Invalid date timestamp: %s', date)
|
||||||
|
|
||||||
keylist.append(Key(attrs['v4-fingerprint'], timestamp))
|
keylist.append(Key(attrs['v4-fingerprint'], int(timestamp)))
|
||||||
return keylist
|
return keylist
|
||||||
|
|
||||||
def _notification_received(self, jid, keylist):
|
def _notification_received(self, jid, keylist):
|
||||||
|
|||||||
@@ -177,8 +177,7 @@ def get_rpad():
|
|||||||
|
|
||||||
|
|
||||||
def create_openpgp_message(obj, encrypted_payload):
|
def create_openpgp_message(obj, encrypted_payload):
|
||||||
b64encoded_payload = b64encode(
|
b64encoded_payload = b64encode(encrypted_payload).decode('utf8')
|
||||||
encrypted_payload.encode('utf-8')).decode('utf8')
|
|
||||||
|
|
||||||
openpgp_node = nbxmpp.Node('openpgp', attrs={'xmlns': NS_OPENPGP})
|
openpgp_node = nbxmpp.Node('openpgp', attrs={'xmlns': NS_OPENPGP})
|
||||||
openpgp_node.addData(b64encoded_payload)
|
openpgp_node.addData(b64encoded_payload)
|
||||||
|
|||||||
Reference in New Issue
Block a user