GnuPG: replace "pinentry" with custom GUI

GnuPG interacts with pinentry using a text-based protocol "Assuan IPC". The overall format is exactly the same as that used by gpg-agent, scdaemon, and other GnuPG components.

To implement it, your program needs to be able to receive commands through stdin and receive responses through stdout. The Assuan IPC protocol is entirely text-based with one command per line, and with percent-encoded values (like in URLs, except spaces are not converted to +).

The commands used by pinentry are documented in the info "(pinentry)Protocol" info page. Your program needs to accept commands such as OPTION, SETPROMPT, SETTITLE, SETDESC, etc. and return OK/ERR responses.

    */usr/bin/pinentry is started*
Pinentry:   OK Carlos' React-based Pinentry Ready!
GnuPG:      OPTION display=:0
Pinentry:   OK
GnuPG:      SETDESC Please%20unlock%20the%20card
Pinentry:   OK
GnuPG:      GETPIN
    *the GUI window shows up*
    *user enters "secret password"*
Pinentry:   D secret%20password
Pinentry:   OK

Once you receive the GETPIN or CONFIRM command, you can show the appropriate window, and once you have the input you have to return it through stdout as a "data" response ('D' before the 'OK').

Finally, configure ~/.gnupg/gpg-agent.conf to use your custom 'pinentry-program' instead of the standard one.