A wrong passphrase gives an error that says so (closes #157)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
A passphrase that did not decrypt the passphrase unlocker failed with age's "no identity matched any of the recipients" and advice to give the vault a new unlocker from its mnemonic, which would replace an unlocker that works. GetIdentity now turns that age error into "wrong passphrase for unlocker <id>", wrapping the new secret.ErrWrongPassphrase, and withMnemonicAdvice leaves it alone, as it does when no passphrase was read. A passphrase from SB_UNLOCK_PASSPHRASE and a typed one both reach this code. A priv.age that is not an age file keeps the advice. Judgement call: age cannot tell a wrong passphrase from a damaged key inside a priv.age whose header reads, so that case now reads as a wrong passphrase. Model: opus-5-5
This commit is contained in:
@@ -291,10 +291,13 @@ func (v *Vault) unlockLongTermKey(
|
||||
// without a mnemonic records none, and without its metadata the key cannot
|
||||
// be derived. It is not added when the passphrase could not be read: the
|
||||
// unlocker was not tried, and adding one would need a passphrase read the
|
||||
// same way. Nor is it added when the current unlocker does not exist and the
|
||||
// vault has others: the error already says to select one of them.
|
||||
// same way. Nor is it added when the passphrase is wrong: the unlocker still
|
||||
// opens the vault with the right one. Nor is it added when the current
|
||||
// unlocker does not exist and the vault has others: the error already says
|
||||
// to select one of them.
|
||||
func (v *Vault) withMnemonicAdvice(err error) error {
|
||||
if errors.Is(err, secret.ErrPassphraseNotRead) ||
|
||||
errors.Is(err, secret.ErrWrongPassphrase) ||
|
||||
errors.Is(err, ErrUnlockerNotFound) {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user