-
-
Save Commod0re/46026d6c01bfb4a202303e727f8a1438 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): | |
if revoker.is_primary and revoker.fingerprint == target.fingerprint: | |
return True | |
self_sigs = target.self_signatures if target.is_primary else target.parent.self_signatures | |
for self_sig in self_sigs: | |
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 _can_revoke(self, target): | |
sig_type = SignatureType.KeyRevocation if target.is_primary else sig_type = Signature.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