When editing the Expiration Time of a key that has both a Direct Key Signature packet and a User ID Binding Signature, GnuPG doesn't work as I'd expect.
For such keys, gpg --edit-key -> expire only changes the Expiration Time value on the User ID Binding Signature, but leaves the Expiration Time on the Direct Key Signature unchanged.
This leaves the key in an internally inconsistent state, which seems bad to me.
It's additionally confusing that when displaying the key, GnuPG prints the (unchanged) Expiration Time (from the Direct Key Signature packet). This makes the key-edit operation appear like a no-op.
I've attached a sample key to reproduce the problem:
To reproduce:
$ gpg --import alice.priv gpg: key 6045BF99496B42A9: public key "<alice@example.org>" imported gpg: key 6045BF99496B42A9: secret key imported gpg: Total number processed: 1 gpg: imported: 1 gpg: secret keys read: 1 gpg: secret keys imported: 1 $ gpg --edit-key alice gpg (GnuPG) 2.3.7; Copyright (C) 2021 Free Software Foundation, Inc. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Secret key is available. sec ed25519/6045BF99496B42A9 created: 2022-10-10 expires: 2025-10-10 usage: C trust: unknown validity: unknown ssb ed25519/9B6A3622908344C8 created: 2022-10-10 expires: 2025-10-10 usage: A ssb ed25519/A4118C71E2E75989 created: 2022-10-10 expires: 2025-10-10 usage: S ssb cv25519/A76F88DDE7CCAC00 created: 2022-10-10 expires: 2025-10-10 usage: E [ unknown] (1). <alice@example.org> gpg> expire Changing expiration time for the primary key. Please specify how long the key should be valid. 0 = key does not expire <n> = key expires in n days <n>w = key expires in n weeks <n>m = key expires in n months <n>y = key expires in n years Key is valid for? (0) 10y Key expires at Thu 07 Oct 2032 06:04:34 PM CEST Is this correct? (y/N) y sec ed25519/6045BF99496B42A9 created: 2022-10-10 expires: 2025-10-10 usage: C trust: unknown validity: unknown ssb ed25519/9B6A3622908344C8 created: 2022-10-10 expires: 2025-10-10 usage: A ssb ed25519/A4118C71E2E75989 created: 2022-10-10 expires: 2025-10-10 usage: S ssb cv25519/A76F88DDE7CCAC00 created: 2022-10-10 expires: 2025-10-10 usage: E [ unknown] (1). <alice@example.org>
Note that the "expires" value at the end of the edit process appears unchanged.
Thanks,
Heiko