You have a file. It came from a website, a release page, a mirror, or an email. Before you run it, you can check one thing: whether the file matches what the publisher signed. That check is called OpenPGP signature verification, and GnuPG (GPG) is the tool most people use to do it.
This is not a story about trust in software. It is a procedure. It has four moving parts: your GPG installation, the publisher’s public key, the file you downloaded, and a small detached signature file. The procedure produces one of a few outputs. Your job is to read the output correctly and decide what it means.
What a signature actually proves
A digital signature certifies and timestamps a document. If the document is modified afterward, verification fails. That is the whole integrity guarantee: the file you have is the file that was signed, byte for byte. The GNU Privacy Handbook states this directly: “A digital signature certifies and timestamps a document. If the document is subsequently modified in any way, a verification of the signature will fail.”
The signature also ties the file to a key. In OpenPGP, a signature is created with the signer’s private key and verified with the corresponding public key. RFC 9580 describes the receiving side: the implementation generates a new hash digest for the received message and verifies it using the message’s signature. If verification succeeds, the message is accepted as authentic.
What the signature does not prove is just as important. It does not prove the software is safe, well-written, or free of vulnerabilities. It does not prove the publisher is trustworthy in any broader sense. It proves that the file matches what the holder of a particular private key signed. Everything else is a separate question.
What you need before you start
Four things:
- GnuPG installed. OpenPGP software is available for Windows, macOS, GNU/Linux, Android, and iOS, according to openpgp.org. On most Linux distributions, GPG is already present. On Windows and macOS, you install a package such as Gpg4win or GPG Suite. The command-line tool is called
gpg.
- The publisher’s public key. This is usually a
.asc or .gpg file on the publisher’s website, or a key you fetch from a keyserver. The publisher’s release page should tell you where to get it.
- The file you downloaded. For example,
software-1.2.3.tar.gz or installer.exe.
- The detached signature file. This is a separate small file, usually ending in
.sig or .asc, that contains only the signature. It is not the file itself.
If the publisher does not provide a detached signature, you cannot do this procedure. That is a fact about the publisher, not about you.
Step 1: Import the publisher’s public key
A public key can be added to your public keyring with the --import option. The GNU Privacy Handbook documents this:
gpg --import publisher-key.asc
GPG will print something like:
gpg: key 1234567890ABCDEF: public key "Publisher Name <release@example.org>" imported
gpg: Total number processed: 1
gpg: imported: 1
That output tells you a key was added. It does not tell you the key belongs to the publisher. That is the next step, and it is the one people skip.
Step 2: Check the fingerprint through a second channel
A key’s fingerprint can be viewed with the --fingerprint command-line option. The GNU Privacy Handbook documents this:
gpg --fingerprint release@example.org
You will see something like:
pub rsa4096 2024-01-15 [SC]
1A2B 3C4D 5E6F 7A8B 9C0D 1E2F 3A4B 5C6D 7E8F 9A0B
uid [ unknown] Publisher Name <release@example.org>
sub rsa4096 2024-01-15 [E]
The long string of hex characters is the fingerprint. It is the identity of the key. A Key ID is shorter and is not guaranteed to be unique; RFC 9580 says implementations should not assume Key IDs are unique. Use the full fingerprint, not the short Key ID, when you compare.
Now compare that fingerprint to one you obtained through a different channel than the one you used to download the key. The GNU Privacy Handbook is explicit about this: a key’s fingerprint is verified with the key’s owner, in person or over the phone or through any other means as long as you can guarantee you are communicating with the key’s true owner.
In practice, for a software publisher, that second channel might be:
- A fingerprint printed on a different page of the publisher’s website than the download page.
- A fingerprint in a signed release announcement that you received through a mailing list you already trust.
- A fingerprint in the publisher’s source repository, in a file that is itself part of a signed release.
- A fingerprint you confirm with a colleague who has verified it before.
What does not count as a second channel: the same page where you downloaded the key. If an attacker can replace the key on that page, they can replace the fingerprint next to it.
This is the human step. GPG cannot do it for you. If you skip it, you have verified that a file matches a key, but not that the key belongs to the publisher.
Step 3: Run the verification
With the key imported and the fingerprint checked, run:
gpg --verify software-1.2.3.tar.gz.sig software-1.2.3.tar.gz
The first argument is the signature file. The second is the file you downloaded. GPG will read both and print a result.
A successful verification looks like this:
gpg: Signature made Mon 15 Jan 2024 10:23:45 AM UTC
gpg: using RSA key 1A2B3C4D5E6F7A8B9C0D1E2F3A4B5C6D7E8F9A0B
gpg: Good signature from "Publisher Name <release@example.org>" [unknown]
The phrase to look for is Good signature. The [unknown] in brackets is a trust value. It means GPG has not been told that you personally trust this key. That is normal for a key you just imported. It does not mean the signature is bad. It means the trust decision is yours, which is why Step 2 exists.
Step 4: Read the output correctly
There are several possible outcomes. They do not all mean the same thing.
Good signature
The file matches the signature, and the signature was made by the key you imported. If you completed Step 2, you have a reasonable basis to believe the file came from the publisher. If you skipped Step 2, you have verified that the file matches a key, but not whose key.
BAD signature
The file does not match the signature. Either the file was modified after signing, or the signature file does not belong to this file, or the download was corrupted. Do not install the file. Re-download both the file and the signature from the publisher’s site and try again. If it still fails, treat the download as untrusted.
Can’t check signature: No public key
GPG does not have the key that made the signature. This is not a failure of the file; it is a missing key. Import the publisher’s key and try again. If you cannot find the key, you cannot verify the download.
Expired or revoked key
GPG may report that the key has expired or has been revoked. A revoked key means the publisher has declared that key should no longer be used. A signature made before revocation may still verify, but you should treat the key as compromised or retired and look for the publisher’s current key. The GNU Privacy Handbook notes that a revoked public key can still be used to verify signatures made in the past, but it cannot be used to encrypt future messages.
Where keys come from, and why it matters
You can get a public key from the publisher’s website, from a keyserver, or from a file someone sent you. These are not equivalent.
keys.openpgp.org is a public keyserver that treats identity information differently from technical information. According to its own documentation, non-identity information is stored and freely redistributed if it passes a cryptographic integrity check. Identity information — names and email addresses — is only distributed with consent. Once the owner verifies their email address, the key can be found by searching for that address.
This has a practical consequence for verification. If you search a keyserver by email address and find nothing, that is not evidence the key is fake. It may mean the owner has not opted in to identity distribution on that server. You can still verify a signature with a key you obtained directly from the publisher, as long as you complete the fingerprint check.
The keyserver is a distribution mechanism, not a trust authority. It does not tell you whether a key belongs to the person named in it.
A reusable checklist
For any download where the publisher provides a detached signature:
- Download the file and the signature file from the publisher’s site.
- Download the publisher’s public key.
- Import the key:
gpg --import publisher-key.asc.
- View the fingerprint:
gpg --fingerprint release@example.org.
- Compare the full fingerprint to one from a second, independent channel.
- Verify:
gpg --verify file.sig file.
- Look for “Good signature.”
- If the result is anything else, stop and investigate before installing.
This procedure does not cover encrypted files, clearsigned messages, or signatures embedded in package managers. It covers detached signatures on downloaded files, which is the common case for software releases.
What this does not do
Verifying a signature does not make the software safe. It does not scan for malware. It does not tell you whether the publisher’s build system was compromised. It does not tell you whether the key was stored securely. It answers one narrow question: does this file match what the holder of this key signed?
That narrow question is worth answering. A patch window, a procurement deadline, or a statutory response clock does not care whether you feel confident. It cares whether you checked. This is a check you can run today, with tools you probably already have, against a procedure documented in the GnuPG manual and the OpenPGP standard.
FAQ
Do I need to sign the publisher’s key after checking the fingerprint?
No. Signing a key is a way to record your own verification so that GPG can use it in its web-of-trust calculations. It is optional for a one-time verification. The GNU Privacy Handbook describes signing as part of validating a key, but the verification itself works without it.
What if the publisher only provides a checksum, not a signature?
A checksum verifies integrity against a value published on the same page. If an attacker can replace the file, they can usually replace the checksum too. A signature is stronger because it requires the attacker to also have the private key. If only a checksum is available, you have less to work with.
Can I verify a signature without importing the key first?
No. GPG needs the public key to check the signature. The --import step is how the key gets into your keyring.
What does the trust value in brackets mean?
GPG displays a trust value for each key, such as [unknown] or [full]. This reflects your own trust settings, not the validity of the signature. A good signature from an untrusted key is still a good signature. The trust value tells you whether GPG has been told to rely on that key for other keys.
Is a longer key always better?
Key size affects resistance to brute-force attacks, but it is not the main variable in this procedure. The main variable is whether you checked the fingerprint. A large key you have not verified is less useful than a smaller key you have.
Where can I read the primary sources?
The GNU Privacy Handbook is at gnupg.org/gph/en/manual.html. The GnuPG manual is at gnupg.org/documentation/manuals/gnupg/. RFC 9580, the current OpenPGP specification, is at rfc-editor.org/rfc/rfc9580.html. The keys.openpgp.org documentation is at keys.openpgp.org/about.