Skip to content

Instantly share code, notes, and snippets.

View Commod0re's full-sized avatar

Michael Greene Commod0re

  • System1
  • Seattle, WA
View GitHub Profile
@Commod0re
Commod0re / assemble_rsa_pubkey.py
Created November 8, 2017 18:28
build a key from existing values
#!/usr/bin/env python
from datetime import datetime
from pgpy import PGPKey, PGPUID, PGPSignature
from pgpy.constants import PubKeyAlgorithm
from pgpy.packet import PubKeyV4
from pgpy.packet.types import MPI
def assemble_rsa_pubkey(n, e, created):
# WARNING: HERE BE DRAGONS
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
@Commod0re
Commod0re / list_packets.py
Last active November 16, 2017 21:07
inspect PGP packets in PGPy 0.4.x
#!/usr/bin/env python
# this is a hackish way to inspect the packets in a PGP object with PGPy 0.4.x
# in the future listing packets directly and determining what fields are useful should be part of the API
# this example prints a few packet types in close to the same format as gpg --list-packets
import sys
from pgpy.types import Armorable
from pgpy.packet import Packet
from pgpy.constants import PacketTag

Keybase proof

I hereby claim:

  • I am commod0re on github.
  • I am commod0re (https://keybase.io/commod0re) on keybase.
  • I have a public key ASCNyzJcY8GwI6DIxQ4d5jfokZUIvLnJ9Jqrm8EfcIWyXQo

To claim this, I am signing this object: