########################################################################
# GNUPG AGENT
########################################################################

if [ -z $GPG_AGENT_INFO ]
then
    GPG_TTY=$(tty)
    SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
    SSH_AUTH_SOCK_EXTRA=${SSH_AUTH_SOCK%%.ssh}.extra
    export GPG_TTY SSH_AUTH_SOCK SSH_AUTH_SOCK_EXTRA
    pgrep -qu sdk gpg-agent || gpg-connect-agent -q /bye
fi

DEFAULT_KEY=CBD3C46864B46517E8FBB90FB6BC2EC552BE43BA

gnupg-extend-default-key() {
    gpg --quick-set-expire $DEFAULT_KEY 1y '*'
}
gnupg-export-default-key() {
    gpg --export --armor --export-options export-minimal $DEFAULT_KEY > codevoid-gpg.key
}

gnupg-upload-default-key() {
    gpg --export $DEFAULT_KEY | curl -T - https://keys.openpgp.org
}
