Last active
August 4, 2017 21:35
-
-
Save J08nY/dc91e71801179ee0bf2bb32706fcfa23 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _can_revoke(revoker, target_primary): | |
for self_sig in target_primary.self_signatures: | |
for rk in self_sig.revocation_key: | |
if rk.algorithm == revoker.key_algorithm and rk.fingerprint == revoker.fingerprint: | |
return True | |
return False | |
hash_algo = prefs.pop('hash', None) | |
sig_type = None | |
if isinstance(target, PGPUID): | |
sig_type = SignatureType.CertRevocation | |
elif isinstance(target, PGPKey): | |
# Check that we are revoking a key we can revoke. | |
if target.is_primary: | |
if target.fingerprint == self.fingerprint or _can_revoke(self, target): | |
sig_type = SignatureType.KeyRevocation | |
else: | |
if target in self or _can_revoke(self, target.parent): | |
sig_type = SignatureType.SubkeyRevocation | |
else: # pragma: no cover | |
raise TypeError | |
if sig_type is None: | |
raise PGPError("Can't revoke the given key with this key.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment