Skip to content

Instantly share code, notes, and snippets.

@the-eater
Last active August 16, 2018 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save the-eater/34d3d61c1d132d8336450cf0f434e94d to your computer and use it in GitHub Desktop.
Save the-eater/34d3d61c1d132d8336450cf0f434e94d to your computer and use it in GitHub Desktop.
Create a visual graph of your gpg trust network!

The following script creates a dot graph from your trust network (who signed who).

Run the following to generate

gpg --list-sigs --with-colons | awk -Egpg2dot.awk > gpg.dot

Then you can render the graph to png or svg

dot -Tsvg gpg.dot > gpg.svg
function print_part(id, label, paths, expired, unknown) {
if (id != "") {
gsub(/\"/, "\\\"", label)
attr = ""
if (unknown) {
label = "[UNKNOWN]\\n" label
attr = "color=yellow,"
}
if (expired) {
label = "[EXPIRED]\\n" label
attr = "color=red,"
}
print " item_" id " [" attr "label=\"" label "\"];";
print paths;
}
};
BEGIN {
FS=":"
print "digraph gpg {"
print " graph [splines=true overlap=false];\n"
};
$1 == "pub" {
print_part(current_uid, current_label, current_paths, expired);
current_uid = $5;
current_paths="";
next_is_id=0;
current_label=current_uid;
known_id[current_uid] = 1
expired=($2 == "e");
delete unknown_id[current_uid]
};
$1 == "sig" {
if ($5 == current_uid) {
next;
}
if (!($5 in known_paths)) {
current_paths=current_paths " item_" $5 " -> item_" current_uid ";\n";
known_paths[$5] = 1;
if (!($5 in known_id)) {
unknown_id[$5] = $5;
}
}
};
$1 == "uid" && $10 ~ /^\[(jpeg|unknown)/ {
next;
}
$1 == "uid" {
current_label=current_label "\\n" $10;
};
END {
print_part(current_uid, current_label, current_paths, expired);
for (uid in unknown_id) {
print_part(uid, uid, "", 0, 1);
}
print "}";
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment