@@ -1,19 +1,27 @@ |
| 1 | 1 | # gpgkey testdata |
| 2 | 2 | |
| 3 | | -This directory exists for future committed fixtures (real-world |
| 4 | | -`gpg`-produced ASCII-armored blocks that might be useful as |
| 5 | | -regression-test inputs). It is **empty by default**. |
| 3 | +Two committed fixtures — real `gpg`-produced ASCII-armored blocks |
| 4 | +serving as a regression baseline. The bulk of `parse_test.go` still |
| 5 | +synthesizes fixtures in-memory via `github.com/ProtonMail/go-crypto/openpgp` |
| 6 | +(no `gpg` dependency in CI, deterministic, no time-bomb expiry races), |
| 7 | +but these two files exercise the **codec compatibility** with real-world |
| 8 | +output from `gpg (GnuPG)`: |
| 6 | 9 | |
| 7 | | -The current `parse_test.go` synthesizes its fixtures in-memory via |
| 8 | | -`github.com/ProtonMail/go-crypto/openpgp` so: |
| 10 | +- `ed25519.asc` — `gpg --quick-gen-key 'shithub-test-ed25519 <ed25519@shithub.test>' default default 0` then `--armor --export`. ed25519 primary + curve25519 encryption subkey, no expiry. |
| 11 | +- `rsa4096.asc` — `gpg --quick-gen-key 'shithub-test-rsa <rsa@shithub.test>' rsa4096 default 0` then `--armor --export`. RSA-4096 primary + RSA-4096 encryption subkey. |
| 9 | 12 | |
| 10 | | -- Tests run without `gpg` installed (CI portability). |
| 11 | | -- Fixtures are deterministic (no time-bomb expiry races). |
| 12 | | -- The `private` and `signature` armor-block fixtures don't have to |
| 13 | | - be committed as files (they're constructed on demand from synthesized |
| 14 | | - entities). |
| 13 | +Both are throwaway keys; no real-user material is ever committed here. |
| 15 | 14 | |
| 16 | 15 | If a future bug surfaces from a specific real-world key shape, drop the |
| 17 | 16 | producing key here as `<shape>.asc` and reference it from |
| 18 | | -`parse_test.go` via `os.ReadFile`. Keep keys throwaway; never commit |
| 19 | | -material from a real user. |
| 17 | +`parse_test.go` via `os.ReadFile`. Generation recipe (uses an isolated |
| 18 | +GNUPGHOME so it doesn't pollute the host keyring): |
| 19 | + |
| 20 | +```bash |
| 21 | +TMPHOME=$(mktemp -d) && chmod 700 "$TMPHOME" |
| 22 | +export GNUPGHOME=$TMPHOME |
| 23 | +gpg --batch --pinentry-mode loopback --passphrase '' \ |
| 24 | + --quick-gen-key '<your-test-id> <email@shithub.test>' <algo> <usage> 0 |
| 25 | +gpg --armor --export <email@shithub.test> > <shape>.asc |
| 26 | +rm -rf "$TMPHOME" |
| 27 | +``` |