Search code examples
linuxsecuritygnupgpgp

Hot to verify a public key's extensions before importing it to GnuPG?


How do I verify a user's extended public key file's integrity (when downloading through a connection that lacks confidentiality and authentication) when I have their previous (now expired) public key in my keyring? Is their expired key sufficient information to verify the extended key? Consider the below scenario:

  1. I have Bob's trusted public key in my keyring.
  2. Bob's key expired yesterday, so he extended his keypair and uploaded a new ascii-armoured public key to his website.
  3. I downloaded Bob's new public key file over http, and I want to verify it.

Is the new public key file signed with his old key in a verifiable way? How would I verify the integrity of the new key file utilizing his existing (expired) key in my keyring?


Solution

  • For a general scenario with a new key pair: If either the key itself is signed by his old key (this is the usual way to do such key changes) and/or the key file you downloaded is signed by his old key, you can verify and validate the signature anyway: all that happens is GnuPG indicating that the key already expired.

    But you wrote

    Bob's key expired yesterday, so he extended his keypair and uploaded a new ascii-armoured public key to his website

    Extending the key's validity does not produce a different key. They key is identified by the tuple of public key and creation timestamp, which is hashed together to the fingerprint of the key. Short and long key IDs are derived from that. If all he did is indeed extend the validity of the key, simply import the key. The signature and trust you issued on that key are still valid.

    If you wish you can compare at least the long key ID before importing, run

    gpg --keyid-format 0xlong [key-file]
    

    and compare with the key already in your key chain.


    Anyway: don't simply trust keys in your key chain, but use signatures and trust instead. Lots of mail clients automatically fetch keys to verify signatures, you might have fetched some (unvalidated) keys for reading signatures issued on other keys, ...