Use pysequoia for decryption

This commit is contained in:
Wiktor Kwapisiewicz 2023-06-01 23:03:03 +02:00
parent 9d47de4979
commit eef301c863
1 changed files with 5 additions and 2 deletions

View File

@ -197,8 +197,11 @@ class GPGDecryptor:
def decrypt(self):
"""Decrypt the message."""
p = subprocess.Popen(self._command(), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
decdata = p.communicate(input=self._message)[0]
return (decdata, p.returncode)
try:
decrypted = pysequoia.decrypt(bytes = self._message)
return (decrypted.bytes.decode("utf8"), 0)
except:
return ("", 1)
def _command(self):
return _build_command(self._keyhome, "--trust-model", "always", "--batch", "--yes", "--no-secmem-warning", "-a", "-d")