Merge branch 'testing/drebs/bug/3097-fix-bugs' into develop
commit
967ae05c10
|
@ -597,7 +597,7 @@ class GPGBase(object):
|
||||||
"""Create a signature for a file.
|
"""Create a signature for a file.
|
||||||
|
|
||||||
:param file: The file stream (i.e. it's already been open()'d) to sign.
|
:param file: The file stream (i.e. it's already been open()'d) to sign.
|
||||||
:param str keyid: The key to sign with.
|
:param str default_key: The key to sign with.
|
||||||
:param str passphrase: The passphrase to pipe to stdin.
|
:param str passphrase: The passphrase to pipe to stdin.
|
||||||
:param bool clearsign: If True, create a cleartext signature.
|
:param bool clearsign: If True, create a cleartext signature.
|
||||||
:param bool detach: If True, create a detached signature.
|
:param bool detach: If True, create a detached signature.
|
||||||
|
|
|
@ -1348,5 +1348,8 @@ class ListPackets(object):
|
||||||
self.need_passphrase_sym = True
|
self.need_passphrase_sym = True
|
||||||
elif key == 'USERID_HINT':
|
elif key == 'USERID_HINT':
|
||||||
self.userid_hint = value.strip().split()
|
self.userid_hint = value.strip().split()
|
||||||
|
elif key in ('NO_SECKEY', 'BEGIN_DECRYPTION', 'DECRYPTION_FAILED',
|
||||||
|
'END_DECRYPTION'):
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
raise ValueError("Unknown status message: %r" % key)
|
raise ValueError("Unknown status message: %r" % key)
|
||||||
|
|
|
@ -166,7 +166,7 @@ class GPG(GPGBase):
|
||||||
|
|
||||||
:type data: str or file
|
:type data: str or file
|
||||||
:param data: A string or file stream to sign.
|
:param data: A string or file stream to sign.
|
||||||
:param str keyid: The key to sign with.
|
:param str default_key: The key to sign with.
|
||||||
:param str passphrase: The passphrase to pipe to stdin.
|
:param str passphrase: The passphrase to pipe to stdin.
|
||||||
:param bool clearsign: If True, create a cleartext signature.
|
:param bool clearsign: If True, create a cleartext signature.
|
||||||
:param bool detach: If True, create a detached signature.
|
:param bool detach: If True, create a detached signature.
|
||||||
|
@ -335,9 +335,9 @@ class GPG(GPGBase):
|
||||||
"""
|
"""
|
||||||
which='keys'
|
which='keys'
|
||||||
if secret:
|
if secret:
|
||||||
which='secret-key'
|
which='secret-keys'
|
||||||
if subkeys:
|
if subkeys:
|
||||||
which='secret-and-public-key'
|
which='secret-and-public-keys'
|
||||||
|
|
||||||
if _is_list_or_tuple(fingerprints):
|
if _is_list_or_tuple(fingerprints):
|
||||||
fingerprints = ' '.join(fingerprints)
|
fingerprints = ' '.join(fingerprints)
|
||||||
|
@ -959,7 +959,7 @@ class GPGUtilities(object):
|
||||||
def encrypted_to(self, raw_data):
|
def encrypted_to(self, raw_data):
|
||||||
"""Return the key to which raw_data is encrypted to."""
|
"""Return the key to which raw_data is encrypted to."""
|
||||||
# TODO: make this support multiple keys.
|
# TODO: make this support multiple keys.
|
||||||
result = self.list_packets(raw_data)
|
result = self._gpg.list_packets(raw_data)
|
||||||
if not result.key:
|
if not result.key:
|
||||||
raise LookupError(
|
raise LookupError(
|
||||||
"Content is not encrypted to a GnuPG key!")
|
"Content is not encrypted to a GnuPG key!")
|
||||||
|
@ -969,15 +969,15 @@ class GPGUtilities(object):
|
||||||
return self.find_key_by_subkey(result.key)
|
return self.find_key_by_subkey(result.key)
|
||||||
|
|
||||||
def is_encrypted_sym(self, raw_data):
|
def is_encrypted_sym(self, raw_data):
|
||||||
result = self.list_packets(raw_data)
|
result = self._gpg.list_packets(raw_data)
|
||||||
return bool(result.need_passphrase_sym)
|
return bool(result.need_passphrase_sym)
|
||||||
|
|
||||||
def is_encrypted_asym(self, raw_data):
|
def is_encrypted_asym(self, raw_data):
|
||||||
result = self.list_packets(raw_data)
|
result = self._gpg.list_packets(raw_data)
|
||||||
return bool(result.key)
|
return bool(result.key)
|
||||||
|
|
||||||
def is_encrypted(self, raw_data):
|
def is_encrypted(self, raw_data):
|
||||||
self.is_encrypted_asym() or self.is_encrypted_sym()
|
return self.is_encrypted_asym(raw_data) or self.is_encrypted_sym(raw_data)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
from .test import test_gnupg
|
from .test import test_gnupg
|
||||||
|
|
Loading…
Reference in New Issue