sops icon indicating copy to clipboard operation
sops copied to clipboard

Support for gpg2?

Open jc00ke opened this issue 9 years ago • 38 comments

Hi!

I'm using gpg 2.1 and I'm unable to use sops because it can't find the new pubring.kbx that gpg2 uses. Looks like it's hardcoded to open pubring.gpg.

After digging a bit more, I'm not sure crypto/openpgp supports gpg > 2 :frowning:

I'm guessing I can't use sops unless I have secring.gpg and pubring.gpg and not pubring.kbx?

jc00ke avatar Jan 12 '17 23:01 jc00ke

We need to add an option to use command line gpg or gpg2 instead of using the crypto/openpgp library. I haven't looked at gpg2 yet. Do you know if the command line arguments are the same as with gpg ?

jvehent avatar Jan 13 '17 14:01 jvehent

I think we should do this distinctly from the openpgp Go package. Maybe even replace the current gpg handling to use the gpg binary like python sops did, and add openpgp as a new master key provider (like KMS). This way we'd end up with 3 providers, KMS, go-openpgp and gpg.

On Fri, Jan 13, 2017, 15:54 Julien Vehent [:ulfr] [email protected] wrote:

We need to add an option to use command line gpg or gpg2 instead of using the crypto/openpgp library. I haven't looked at gpg2 yet. Do you know if the command line arguments are the same as with gpg ?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mozilla/sops/issues/189#issuecomment-272461629, or mute the thread https://github.com/notifications/unsubscribe-auth/ACJ-V5w4VgRjdji4IpxVlNF4mrNX3Zo7ks5rR5AwgaJpZM4LiYBw .

autrilla avatar Jan 13 '17 14:01 autrilla

That doesn't make a lot of sense to me. It's the same protocol and key format, just a different way of accessing the data.

jvehent avatar Jan 13 '17 15:01 jvehent

sops 1 supported SOPS_GPG_EXEC. I think sops 2 should support it as well and, if defined, use the gpg binary specified in path to encrypt/decrypt the data key.

jvehent avatar Jan 13 '17 15:01 jvehent

It has the benefit of allowing to use sops without gpg installed. I don't know if that is important to anyone, though. Since we already have an implementation using crypto/openpgp, I think it might be good to keep it around and add a new one using the binary.

On Fri, Jan 13, 2017, 16:25 Julien Vehent [:ulfr] [email protected] wrote:

That doesn't make a lot of sense to me. It's the same protocol and key format, just a different way of accessing the data.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/mozilla/sops/issues/189#issuecomment-272469163, or mute the thread https://github.com/notifications/unsubscribe-auth/ACJ-V-d6eP5RuyyvfO1FWVEywJqijPfLks5rR5dXgaJpZM4LiYBw .

autrilla avatar Jan 13 '17 15:01 autrilla

I absolutely think crypto/openpgp should be the default method of performing PGP operations. My point is users should be able to override this and use the gpg1/2 binary by specifying the path to the binary in SOPS_GPG_EXEC.

jvehent avatar Jan 13 '17 15:01 jvehent

Are we sure the Go package doesn't already support the GnuPG 2.1 keyring location and format? The problem I saw from looking at the code was that sops has the paths of the keyrings hardcoded to the <= 2.0 versions of GnuPG, not necessarily a problem with the OpenPGP implementation itself.

jimmycuadra avatar Jan 13 '17 19:01 jimmycuadra

I don't see support for anything over v2.0 in the read tests.

jc00ke avatar Jan 13 '17 19:01 jc00ke

I'm 99.8% sure crypto/openpgp doesn't support gpg2 keyring format. That said, you can change the default location of the keyring using the GNUPGHOME env variable.

jvehent avatar Jan 13 '17 19:01 jvehent

My understanding is that secring.gpg is gone, as well. Both rings are stored inside pubring.kbx.

jimmycuadra avatar Jan 13 '17 19:01 jimmycuadra

@jimmycuadra is correct, see the changelog

Maybe we can access it through the agent?

With GnuPG 2.1 this changed and gpg now also delegates all private key operations to the gpg-agent.

jc00ke avatar Jan 13 '17 19:01 jc00ke

Hang on; doesn't SOPS talk to gpg-agent? (This is relevant to my interests, because I was unable to get SOPS to work with my Yubikey 4 token.)

lvh avatar Jan 18 '17 23:01 lvh

@lvh the Python version did, as it just calls the gpg binary it finds in your PATH. The Go version uses Go's crypto/openpgp package, which is fully independent from GPG and thus doesn't talk to the agent.

autrilla avatar Jan 18 '17 23:01 autrilla

Gotcha. See #191; I was confused by: https://github.com/mozilla/sops/blob/0483f8a07af035f2cb75e7a72b1901eccac82ed1/pgp/keysource.go#L15

also hi @autrilla long time no see

lvh avatar Jan 18 '17 23:01 lvh

Err, you're right, we do talk to gpg-agent. I didn't express myself correctly.

SOPS talks to gpg-agent to retrieve the passphrase for private keys. crypto/openpgp does not support smart card private keys. In any case, as I understand it, the way we communicate with gpg-agent would not work for smart cards at all, as even if we get the passphrase we'll never have access to the private key, which crypto/openpgp needs.

It's very likely I'm totally wrong about this, as my understanding of gpg is very limited.

autrilla avatar Jan 19 '17 00:01 autrilla

OK, that makes a lot of sense after more review of the code! You're right of course, the entire point of the token is that the key lives on the card and never, never leaves -- you send the message to the token to be encrypted, and it sends the encrypted thing back to you.

lvh avatar Jan 19 '17 00:01 lvh

I'm glad I learned the Go version doesn't support smart cards. I've been using sops with my Yubikey for a while and only now am realizing it's cause I still have the Python version. I'd better not upgrade. >_<

jimmycuadra avatar Jan 19 '17 01:01 jimmycuadra

Sops 1 is still maintained and installable via pip. You're safe to upgrade, we won't force you to v2.

On January 18, 2017 8:08:30 PM EST, Jimmy Cuadra [email protected] wrote:

I'm glad I learned the Go version doesn't support smart cards. I've been using sops with my Yubikey for a while and only now am realizing it's cause I still have the Python version. I'd better not upgrade. >_<

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/mozilla/sops/issues/189#issuecomment-273652292

-- Sent from my Android device with K-9 Mail. Please excuse my brevity.

jvehent-sops-ci avatar Jan 19 '17 01:01 jvehent-sops-ci

jvehent commented on Jan 13 I absolutely think crypto/openpgp should be the default method of performing PGP operations. My point is users should be able to override this and use the gpg1/2 binary by specifying the path to the binary in SOPS_GPG_EXEC.

Au contraire, given that crypto/openpgp isn't updated -- and tbh, even if it is -- it should only be a backup to CLI gpg when the latter isn't installed. What's the path forward on this issue?

yingzong avatar Jun 19 '17 15:06 yingzong

The path forward for now is implementing support for calling the gpg binary. What we should default to is a bit bikesheddy but I suppose it's up for discussion.

As I see it, the advantages for defaulting to crypto/openpgp:

  • Simpler to implement, therefore harder to mess up
  • No external dependencies

And the advantages for defaulting to the binary:

  • Support for more gpg features such as smart cards and the new gpg2 keyring format

Personally I agree with @jvehent that defaulting to crypto/openpgp is the way to go here, even if it has some issues. In any case, we could just add an option in .sops.yaml to override the default.

autrilla avatar Jun 19 '17 16:06 autrilla