Part of something I'm doing involved flashing a Debian live image to a USB thumb drive, which is a pretty straightforward process. However this time I realised that I always ignore the little checksum and signature files that sit alongside them and that if I wanted to use them to verify the integrity/security of the image I had no idea how. So here's a quick HOWTO describing the process I followed.
I needed to use a Debian non-free live image since the Thinkpad X250 has an intel wifi device which requires a closed source firmware blob:
$ wget -c http://cdimage.debian.org/cdimage/unofficial/non-free/cd-including-firmware/8.3.0-live+nonfree/amd64/iso-hybrid/debian-live-8.3.0-amd64-xfce-desktop+nonfree.iso $ wget http://cdimage.debian.org/cdimage/unofficial/non-free/cd-including-firmware/8.3.0-live+nonfree/amd64/iso-hybrid/SHA512SUMS.sign $ wget http://cdimage.debian.org/cdimage/unofficial/non-free/cd-including-firmware/8.3.0-live+nonfree/amd64/iso-hybrid/SHA512SUMS
Firslty we need to check that the signature of the sha512sum file was created by someone we trust
$ gpg2 --verify SHA512SUMS.sign SHA512SUMS gpg: Signature made Thu 28 Jan 2016 02:07:24 CET gpg: using RSA key 0xDA87E80D6294BE9B gpg: Can't check signature: No public key
In this case gpg2 doesn't have any knowledge of the key used to sign this image - 0xDA87E80D6294BE9B. We'll need to retrieve it from the official Debian key server:
$ gpg2 --keyserver keyring.debian.org --recv-keys 0xDA87E80D6294BE9B gpg: requesting key 0xDA87E80D6294BE9B from hkp server keyring.debian.org gpg: key 0xDA87E80D6294BE9B: public key "Debian CD signing key " imported gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u gpg: Total number processed: 1 gpg: imported: 1 (RSA: 1)
Now we have the key we can check the signature, checksums match the key:
$ gpg2 --verify SHA512SUMS.sign SHA512SUMS gpg: Signature made Thu 28 Jan 2016 02:07:24 CET gpg: using RSA key 0xDA87E80D6294BE9B gpg: Good signature from "Debian CD signing key " [unknown] gpg: WARNING: This key is not certified with a trusted signature! gpg: There is no indication that the signature belongs to the owner. Primary key fingerprint: DF9B 9C49 EAA9 2984 3258 9D76 DA87 E80D 6294 BE9B
So the signature is fine, but since we haven't explicitly trusted this key yet we're getting a warning. I'm about 99% sure this is sufficiently secure. Now that is out of the way we can check the ISO using sha512sum:
$ sha512sum -c <(grep "debian-live-8.3.0-amd64-xfce-desktop+nonfree.iso$" SHA512SUMS) debian-live-8.3.0-amd64-xfce-desktop+nonfree.iso: OK
So everything semes to check out and we can be confident the NSA haven't sneakily compromised the image somehow. Just to quickly summarise - here's what we've done:
- downloaded a Debian 8.3 live image, checksums and signature
- verified the signature was produced by the Debian organisation, and the signature represents the sha512sum
- verified the ISO matches the sha512sum.