Do not continue with subkey when changing password fails for primary
Open, NormalPublic

Assigned To
None
Authored By
• ebo
Sep 15 2026, 9:29 AM

Description

How to reproduce: Start to change a keys password via gpg --edit-keyand then passwd, and then enter only wrong passwords.
Expected: Failure of action after 3 tries.
Actual behavior: After the 3 tries pinentry then asks 3 times for the password of the (first) subkey.

If one should need to change a password of a subkey, I'd expect that I could select that key (with key 1) and then change only the password of that subkey.
But actually this does exactly the same as if one had not selected a key, i.e. it does the same as above.

The behavior also shows in Kleopatra, where it confuses inexperienced users and could cause a user to unintentionally change only the password for a subkey instead of the whole key.

Details

Version
Gpg4win-5.0.1 + VSD 3.3.7

Event Timeline

• ebo created this object with edit policy "Contributor (Project)".
• werner triaged this task as Normal priority.Sep 17 2026, 3:48 PM

IIUC, for the behavior change, this change is needed:

diff --git a/g10/keyedit.c b/g10/keyedit.c
index affe6c655..a4f4b9c5d 100644
--- a/g10/keyedit.c
+++ b/g10/keyedit.c
@@ -1292,7 +1292,9 @@ change_passphrase (ctrl_t ctrl, kbnode_t keyblock)
                      _("key %s: error changing passphrase: %s\n"),
                        keystr_with_sub (keyid, subid),
                        gpg_strerror (err));
-          if (gpg_err_code (err) == GPG_ERR_FULLY_CANCELED)
+          if (gpg_err_code (err) == GPG_ERR_FULLY_CANCELED
+              || gpg_err_code (err) == GPG_ERR_BAD_PASSPHRASE
+              || gpg_err_code (err) == GPG_ERR_BAD_PIN)
             break;
         }
     }

BTW, the passwd command doesn't have any support for sub key selection (now).