Signing and verifying a file

A signature leaves the file readable and attaches a proof that it came from a particular key and has not been altered. This set covers making a key, signing with gpg, and telling a good signature from a bad one when the file has changed.

4 questions 1 task Read the lesson

Questions

Each one is marked as you go, and the explanation arrives straight after, which is the part worth reading.

4 questions, marked as you go.

1 What does gpg --detach-sign produce?
2 gpg reports BAD signature when you verify a file against a signature. What has happened?
3 Which key makes a signature and which key checks it?
4 What does a good signature not, on its own, prove?

Tasks

These need your own device. Run the command in Termux, then paste what it printed. The marking looks at what the output means, so spacing, version numbers and ordering do not matter. If you have not installed anything yet, the lesson covers the setup.

Sign a file, then verify it before and after a change

This makes a demo key, signs a file, verifies it, then changes the file and verifies again. Watch the two verdicts at the end: one says Good and the other says BAD.

Run this in Termux On your own device. Nothing on this page executes it. The command runs in your terminal, and this box only reads what you paste back.

export GNUPGHOME="$HOME/.gnupg-demo"; mkdir -p "$GNUPGHOME"; chmod 700 "$GNUPGHOME"; gpg --batch --pinentry-mode loopback --passphrase '' --quick-gen-key "Learner Demo <learner@example.com>" ed25519 sign 0; printf 'release 1.0\n' > "$HOME/release.txt"; gpg --batch --yes --detach-sign --armor -o "$HOME/release.txt.asc" "$HOME/release.txt"; gpg --verify "$HOME/release.txt.asc" "$HOME/release.txt"; printf 'release 2.0\n' > "$HOME/release-changed.txt"; gpg --verify "$HOME/release.txt.asc" "$HOME/release-changed.txt"
Marking your own work Both halves of this are checked in your browser, with no server involved, so nothing stops you from pasting output you did not run. The tasks are written so that the easiest way to pass one is to actually do it and read the result, which is the whole intention.

All sets Read the lesson