kbpgp icon indicating copy to clipboard operation
kbpgp copied to clipboard

Box to multiple recipients

Open garry415 opened this issue 9 years ago • 11 comments

It doesn't seem possible to encrypt a message for multiple recipients with the current API. Is this something that will be implemented in the future?

garry415 avatar Oct 13 '15 22:10 garry415

Not documented, but it currently works. Pass an array of KeyManagers as the encrypt_for parameter.

On Tue, Oct 13, 2015 at 6:55 PM, garry415 [email protected] wrote:

It doesn't seem possible to encrypt a message for multiple recipients with the current API. Is this something that will be implemented in the future?

— Reply to this email directly or view it on GitHub https://github.com/keybase/kbpgp/issues/104.

maxtaco avatar Oct 13 '15 23:10 maxtaco

@maxtaco Cannot confirm that it works. I'm passing an array of KeyManagers, but when I later try to decrypt by the second user, I get an error: Can't find a key for bb4197923fd9dd27: key not found: ["bb4197923fd9dd27"] Note that for boxing I'm passing an array of KeyManagers with Public Keys loaded only. You don't seem to have a test for such a contingency, and unless I'm reading the test wrong, you seem to be encrypting with an array of KeyManagers that are loaded with private keys, not public keys (?!). This line: https://github.com/keybase/kbpgp/blob/master/test/files/multiples.iced#L25

niieani avatar Dec 10 '15 02:12 niieani

Run the message through gpg --list-packets to see who it's encrypted for.

maxtaco avatar Dec 10 '15 02:12 maxtaco

@maxtaco I see the problem now. When I box multiple recipients and sign, then for some reason only the person who signed is able to unbox messages with kbpgp. I removed the sign_with parameter from my box call and unboxing works for everybody now. Any ideas?

niieani avatar Dec 10 '15 02:12 niieani

That really doesn't conform to my understanding of how it works. What happens when you run the message through gpg --list-packets? I'm not convinced that box is producing the wrong behavior. From your description, it looks as if unbox is where you're having trouble.

maxtaco avatar Dec 10 '15 02:12 maxtaco

Likely what your problem is is that your keyfetch isn't returning the public key that corresponds to the signing key, so signature verification is failing. Try supplying strict : false to unbox and signing as usual. Does that also solve the problem?

maxtaco avatar Dec 10 '15 02:12 maxtaco

I'm using the default KeyRing instance, with one, freshly created KeyManager from a Private Key loaded and unlocked, so not sure why keyfetch wouldn't return the right key. But you are correct in that strict: false resolved the problem. What does it do? --list-packets output:

pubkey enc packet: version 3, algo 1, keyid BBFBBA3E41E2E496
    data: [2046 bits]
:pubkey enc packet: version 3, algo 1, keyid C34845812DC0C192
    data: [2047 bits]
:encrypted data packet:
    length: 373
    mdc_method: 2
gpg: encrypted with RSA key, ID 2DC0C192
gpg: encrypted with RSA key, ID 41E2E496

The key IDs look correct.

niieani avatar Dec 10 '15 02:12 niieani

Turning off strict mode means it's no longer necessary to verify the signature inside the encrypted message. You're failing to do so because your KeyRing doesn't contain the public key to verify the signature of the message. If you want to unbox a signed, encrypted message, you need two KeyManagers in your keyring. A private key to decrypt, and a public key to verify.

maxtaco avatar Dec 10 '15 02:12 maxtaco

Keep in mind, in PGP, the message only gives the 64-bit key ID of who signed the message. You must provide the full 2048-bit RSA key that corresponds to the given 64-bit Key ID. That's done via the KeyRing interface, and your KeyRing is failing to do so for the verification key.

maxtaco avatar Dec 10 '15 02:12 maxtaco

@maxtaco Ah, I get it now. Many thanks for the quick debugging session and explanation here. The error message (and the missing docs ;)) could be a bit more specific though. From the docs here: https://keybase.io/kbpgp/docs/decrypting it is not clear what types of keys are present in the KeyManagers you load to the KeyRing, since that part was skipped in the example. Thanks again, and have a good day/night.

niieani avatar Dec 10 '15 02:12 niieani

Glad I could help. Sorry the docs aren't better, if only there was time to get it all done!

maxtaco avatar Dec 10 '15 02:12 maxtaco