building-envelope-data / database

Reference implementation of a product data server as part of the product data network buildingenvelopedata.org
MIT License
0 stars 0 forks source link

Sign data for approvals #2

Open simon-wacker opened 3 years ago

simon-wacker commented 3 years ago

Documents can be signed detached and signatures verified with GnuPG, see "Making and verifying signatures", section "Detached signatures" (for an introduction to GnuPG read The GNU Privacy Handbook and PGP and You which also talks about use cases like signing git commits and tags and e-mails). To turn JSON data into a document to sign or to verify a signature, sort all keys alphabetically, remove all unnecessary whitespace, and save the data in UTF-8.

There sadly is no stable not the one GnuPG wrapper in C#. The most stable and maintained one I could find is PgpCore which is based on Bouncy Castle. What comes closest is gpgme-sharp but it's experimental and seems unmaintained, or Bouncy Castle which is rather low-level but maintained, or starksoft-aspen which seems better and kind of maintained, or PgpCore which is based on Bouncy Castle and maintained. We could also run shell commands directly as explained in GnuGP decryption in C#. Doing that requires spawning a new process for each run, which is expensive, turning input into strings, parsing the command-line output, and turning command-line errors into C# exceptions.

It may also be of interest to us to host an OpenPGP keyserver (see also GnuPG Manual Keyserver and Roll Your Own PGP Keyserver) or use an existing one. Existing frameworks are Sequoia written in Rust by former GnuPG developers deployed on keys.openpgp.org, and SKS written on Ocaml deployed on pgp.mit.edu (note that SKS has major problems as explained on Hagrid: A new verifying keyserver based on Sequoia and should not be used). The guides by Matt Rude on how to set-up a keyserver may be helpful. For security reasons (because keyservers cannot be trusted), there is a pool of keyservers and one is chosen randomly by tools. Also of interest may by Web Key Directories and Web Key Services (see also Roll Your Own WKS) --- those are said to be more secure than keyservers who before Sequoia suffered from the unverified e-mail address problem. On how to host web key directories see https://keyserver.mattrude.com/guides/web-key-directory/ and https://wiki.gnupg.org/WKDHosting

Side notes: