gopass
gopass copied to clipboard
Importing ECC key pair from another machine. Cannot re-encrypt passwords
Summary
I'm moving from using RSA keys to ECC keys. I've imported a ECC key pair from another machine.
I've created and added the new ECC key as a recipient.
I've ran gopass fsck
and was told to run the same command with --decrypt
to re-encrypt. This does not work.
Steps To Reproduce
Import a public and private ECC key from another machine.
Add that key as a recipient:
gopass recipients add you-key-id
Run gopass fsck
to make sure everything is okay.
Get prompted to pass --decrypt
to re-encrypt keys automatically.
Get the following output on at least 1 key in your store:
[] ❌ Missing recipients on Forums/Some-Fourm-Site: [the ECC key's id]
Run fsck with the --decrypt flag to re-encrypt it automatically, or edit this secret yourself.
gpg: public key decryption failed: No secret key
gpg: decryption failed: No secret key
[] ❌ Decryption failed: exit status 2
❌ fsck failed on root store: failed to check "Forums/Some-Forum-Site": failed to decode secret Forums/Some-Forum-Site failed to decrypt
Error: fsck found errors: 1 error occurred:
* failed to check "Forums/Some-Forum-Site": failed to decode secret Forums/Some-Forum-Site: failed to decrypt
Expected behavior
Automatic re-encryption to work with newly imported ECC key pair.
Environment
- OS: MacOS
- OS version: Monterey 12.4
- gopass Version: gopass 1.14.3 go1.18.2 darwin amd64
- Installation method: brew
Additional context
Some of my passwords were encrypted with RSA keys that no longer exist and/or are/were not on this machine.
This could totally be my misunderstanding of how GPG recipients work.
(If the keys exist on the other machine I can luckily remove and add them back in, or just reset the passwords. So it's not a huge deal but things didn't work as I expected.)
Maybe I don't understand you correctly, but if you don't have the RSA keys to decrypt some of your secrets you won't be able to decrypt them?!
You can always try to run gopass with GOPASS_DEBUG_LOG=/tmp/some.log gopass ...
.
But especially in this case this might contain a lot of sensitive information (e.g. recipients) so you don't want to share that verbatim.
Maybe I don't understand you correctly, but if you don't have the RSA keys to decrypt some of your secrets you won't be able to decrypt them?!
Well, yes. But some of them who previous used some RSA key pass fine. When running gopass fsck --decrypt
:
[] Checking storage backend
] 1 / 194 [Gs ] 0.52%
[] Compacting storage if possible
[] Checking all secrets in store
] 106 / 194 [Gooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooopass ] 54.64%
[] Re-encrypting A-Site/Me to fix recipients and storage format.
] 108 / 194 [Gooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooopass ] 55.67%
[] Re-encrypting Another-Site/Also-Me to fix recipients and storage format.
And those go down alphabetically and when the program reaches, as in my example, the F's it fails to re-encrypt. The first few passwords being re-encrypted used an RSA key on a different machine, yet they could be re-encrypt with the newly imported ECC key? Am I misunderstanding how this all works?
(Basically, if I didn't make this super clear, I want to re-encrypt all my passwords with the ECC key.)
For reference, I followed this guide here.
Assuming you are on a Unix device, could you please do the following:
cd $(gopass config path)
pgpdump Forums/Some-Forum-Site.gpg
pgpdump should give you an output like this:
pgpdump Forums/Some-Forum-Site.gpg master
Old: Public-Key Encrypted Session Key Packet(tag 1)(524 bytes)
New version(3)
Key ID - 0xAB80D5F3811A2E22
Pub alg - RSA Encrypt or Sign(pub 1)
RSA m^e mod n(4096 bits) - ...
-> m = sym alg(1 byte) + checksum(2 bytes) + PKCS-1 block type 02
Old: Public-Key Encrypted Session Key Packet(tag 1)(396 bytes)
New version(3)
Key ID - 0x3FFBFB489521447C
Pub alg - RSA Encrypt or Sign(pub 1)
RSA m^e mod n(3071 bits) - ...
-> m = sym alg(1 byte) + checksum(2 bytes) + PKCS-1 block type 02
New: Symmetrically Encrypted and MDC Packet(tag 18)(70 bytes)
Ver 1
Encrypted data [sym alg is specified in pub-key encrypted session key]
(plain text + MDC SHA1(20 bytes))
Notice the Key ID
field?
You need to double check that this entry Forums/Some-Forum-Site
is encrypted using a Key ID that is in your secret keyring when listed using --keyid-format 0xlong
:
gpg -K --keyid-format 0xlong
If not, please double check to which key ID it corresponds and if it's in your public key ring:
gpg -k --keyid-format 0xlong
This should help us understand what's going on.
@AnomalRoil I'm experiencing the same issue. When I run pgpdump Forums/Some-Forum-Site.gpg
after I added a new recipient it prints 0x0000000000
for the KeyId.
Apologies, I meant to give some input on this. I somewhat recall importing just the public key with gpg --import
and then having no issues. I no long have any issues with any keys or anything like that. Although @marijanp seems to be having some more advanced issues as to what I was having, so I don't know if this should be closed.
@marijanp issue seems to be the same as here: https://github.com/gopasspw/gopass/issues/1083
The problem is that you probably used PGP with the "hidden recipient" option enabled, or the "throw-keyid" config. Please check you don't have something like this in your ~/.gnupg/gpg.conf
:
throw-keyids
Notice that in theory gopass should still work fine on entries that were encrypted using this option, since we delegate decryption to gpg
which will try all local private keys to decrypt such entries.
Let us know if you need more help @marijanp, in the meantime I'm going to close this one.