Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a new openpgp.cert.d based keystore #3341

Closed
pmatilai opened this issue Sep 30, 2024 · 22 comments · Fixed by #3437
Closed

Implement a new openpgp.cert.d based keystore #3341

pmatilai opened this issue Sep 30, 2024 · 22 comments · Fixed by #3437
Assignees
Labels
crypto Signatures, keys, hashes and their verification RFE
Milestone

Comments

@pmatilai
Copy link
Member

We already have the "fs" keystore as an alternative to gpg-pubkey's in rpmdb, but it's primitive at best. This isn't our core business anyhow, so we'd rather outsource that to something else. A hot tip from @nwalfield in #3313 reveals there's a standard-in-progress that suits our needs: https://datatracker.ietf.org/doc/draft-nwjw-openpgp-cert-d/ - no point looking further.

Sequoia-sq and some other tools/libraries already supports this so we don't need to implement the standard by ourselves (with the possible exception of reading keys from it), we can just call 'sq' to do the actual job. For those worried about dependencies: sequoia-sq is a self-contained thing, it adds no other dependencies that rpm wouldn't already drag in (assuming sane build configuration). It does have build-dependencies of course, but AIUI those would be mostly covered by rpm-sequoia already.

FWIW, a gnupg based keystore would of course be possible, but the implementation is private to gnupg and gnupg itself depends on non-FIPS compliant crypto libraries and does not offer choice on that matter.

@pmatilai pmatilai added RFE crypto Signatures, keys, hashes and their verification labels Sep 30, 2024
@pmatilai pmatilai added this to the 6.0.0 alpha milestone Sep 30, 2024
@pmatilai pmatilai added this to RPM Sep 30, 2024
@github-project-automation github-project-automation bot moved this to Backlog in RPM Sep 30, 2024
@nwalfield
Copy link
Contributor

we can just call 'sq' to do the actual job

I'm not so excited about programs shelling out to sq. Although we plan to have a stable API in a few months, we still don't have machine-readable output. (We plan to implement that in 2025.) I'd rather we specify an API, and then I implement it in rpm-sequoia (or some another library?).

For those worried about dependencies: sequoia-sq is a self-contained thing, it adds no other dependencies that rpm wouldn't already drag in (assuming sane build configuration). It does have build-dependencies of course, but AIUI those would be mostly covered by rpm-sequoia already.

This is half true. sq pulls in a few more dependencies than rpm-sequoia. I've attached some slides that hopefully make this clearer.

What I'm proposing here is only adding a dependency on sequoia-cert-store or the lower-level pgp-cert-d library, and not the key store, or the network services, etc.

slide1

slide2

slide3

@Conan-Kudo
Copy link
Member

Honestly, we need our own directories anyway, because we need keys stored in /usr preloaded by vendors and keys stored in /etc that the user adds.

@pmatilai
Copy link
Member Author

pmatilai commented Sep 30, 2024

I'm not so excited about programs shelling out to sq. Although we plan to have a stable API in a few months, we still don't have machine-readable output. (We plan to implement that in 2025.) I'd rather we specify an API, and then I implement it in rpm-sequoia (or some another library?).

API in rpm-sequoia would be by far preferred by me too, and something I thought would eventually happen anyhow, this was more based on "what tools do we have right now". The shell-out part I envisioned would be basically for import and delete, where the only thing we care is exit code from the call, not looking at any of the output. Just reading the bits off disk shouldn't be too complicated for rpm to implement by itself. The overall picture wasn't probably too clear in the initial description, sorry about that.

This is half true. sq pulls in a few more dependencies than rpm-sequoia. I've attached some slides that hopefully make this clearer.

Nod. I'm thinking more in the terms of distros there: eg Fedora and RHEL already have sequoia-sq, so even the build-dependencies are something that already are there. And in any case, it's a handful of dependencies, not 120 new.

What I'm proposing here is only adding a dependency on sequoia-cert-store or the lower-level pgp-cert-d library, and not the key store, or the network services, etc.

Yup, for an API directly in rpm-sequoia, that sounds good.

@Conan-Kudo
Copy link
Member

I'm not so excited about programs shelling out to sq. Although we plan to have a stable API in a few months, we still don't have machine-readable output. (We plan to implement that in 2025.) I'd rather we specify an API, and then I implement it in rpm-sequoia (or some another library?).

API in rpm-sequoia would be by far preferred by me too, and something I thought would eventually happen anyhow, this was more based on "what tools do we have right now". The shell-out part I envisioned would be basically for import and delete, where the only thing we care is exit code from the call, not looking at any of the output. Just reading the bits off disk shouldn't be too complicated for rpm to implement by itself. The overall picture wasn't probably too clear in the initial description, sorry about that.

I would rather avoid this, because we will wind up in a situation where things parse the output as API. This happened in DNF with rpmkeys and it happens all the time in Zypper too.

@pmatilai
Copy link
Member Author

Well, I specifically said "not looking at any of the output" in there 😅

@Conan-Kudo
Copy link
Member

Unfortunately, while we can do reasonable things, I can't expect our consumers to. 😓

@pmatilai
Copy link
Member Author

pmatilai commented Oct 1, 2024

I don't know what you mean by that. We would not be forwarding any output from those programs either, except stderr I guess but that's no different to getting error messages from a library beneath you.

@nwalfield
Copy link
Contributor

Honestly, we need our own directories anyway, because we need keys stored in /usr preloaded by vendors and keys stored in /etc that the user adds.

@Conan-Kudo, what do you mean by "we need our own directories"? Are you agreeing that we should use the Shared OpenPGP Certificate Directory for these directories, or are you saying that rpm should use its own format? If the latter, how do you imagine this format would look, and how would it be managed?

@Conan-Kudo
Copy link
Member

I don't care what the format looks like, but we should not use the same shared PGP certs directory used by plain Sequoia, GnuPG, etc.

Essentially, we need to maintain the equivalent of our own keyring with our own import semantics.

@nwalfield
Copy link
Contributor

I don't care what the format looks like, but we should not use the same shared PGP certs directory used by plain Sequoia, GnuPG, etc.

Thanks for clarifying. I was quite confused by your "anyway." I agree that rpm should use its own certificate store.

Essentially, we need to maintain the equivalent of our own keyring with our own import semantics.

What semantics are you thinking of here? Why should rpm's import semantics differ from, say, vanilla sq.

@pmatilai
Copy link
Member Author

pmatilai commented Oct 2, 2024

I think @Conan-Kudo just means that we shouldn't be using any users certs directory, but something specific rpm.
Ie what we do now, and I don't see it changing, I don't see anything here even suggesting it would change.

@Conan-Kudo
Copy link
Member

Yes, more or less. The only other thing I'd like us to do is add the ability to have GPG keys shipped in RPM packages (like fedora-gpg-keys does) go into a location in /usr rather than /etc (e.g. /usr/lib/sysimage/rpmpgpkeys.d or similar).

@nwalfield
Copy link
Contributor

Thanks for the clarifications.

@pmatilai
Copy link
Member Author

pmatilai commented Oct 4, 2024

Currently importing a key into rpm(db) implies trusting that key. That's not something we'd want to do for keys dropped into a directory by random packages.

Differentiating between known keys and trusted keys, basically for the purposes of determining whether a package can be installed or not, is something we've needed to do for a long time, but that's a topic for a ticket of its own.

Edit: filed #3358 for that purpose, it's good to have an item open for it. I'm quite positive we've had such a ticket on some tracker but we've tracker-hopped enough that a lot of history has gotten lost.

@ffesti ffesti self-assigned this Oct 30, 2024
@ffesti ffesti moved this from Backlog to In Progress in RPM Oct 30, 2024
ffesti added a commit to ffesti/rpm that referenced this issue Nov 7, 2024
Refactor code from the fs backend into shared helper functions

This does implement the write lock for the openpgp.cert.d according to
https://www.ietf.org/archive/id/draft-nwjw-openpgp-cert-d-00.htm but not
the implement the Trust root, Petname mapping or Trusted introducers.

Resolves:  rpm-software-management#3341
ffesti added a commit to ffesti/rpm that referenced this issue Nov 7, 2024
Refactor code from the fs backend into shared helper functions

This does implement the write lock for the openpgp.cert.d according to
https://www.ietf.org/archive/id/draft-nwjw-openpgp-cert-d-00.htm but not
the implement the Trust root, Petname mapping or Trusted introducers.

Resolves:  rpm-software-management#3341
ffesti added a commit to ffesti/rpm that referenced this issue Nov 8, 2024
Refactor code from the fs backend into shared helper functions

This does implement the write lock for the openpgp.cert.d according to
https://www.ietf.org/archive/id/draft-nwjw-openpgp-cert-d-00.html but not
the implement the Trust root, Petname mapping or Trusted introducers.

Resolves:  rpm-software-management#3341
ffesti added a commit to ffesti/rpm that referenced this issue Nov 8, 2024
Refactor code from the fs backend into shared helper functions

This does implement the layout on the file system and the write lock of
the openpgp.cert.d proposal according to
https://www.ietf.org/archive/id/draft-nwjw-openpgp-cert-d-00.html
but not the Trust root, Petname mapping or Trusted introducers.

This still is a mess of C and C++ style strings that we want to clean
up later by adding C++ string based path handling and may be using the
filesystem C++ library.

Resolves:  rpm-software-management#3341
ffesti added a commit to ffesti/rpm that referenced this issue Nov 8, 2024
Refactor code from the fs backend into shared helper functions

This does implement the layout on the file system and the write lock of
the openpgp.cert.d proposal according to
https://www.ietf.org/archive/id/draft-nwjw-openpgp-cert-d-00.html
but not the Trust root, Petname mapping or Trusted introducers.

This still is a mess of C and C++ style strings that we want to clean
up later by adding C++ string based path handling and may be using the
filesystem C++ library.

Resolves:  rpm-software-management#3341
@pmatilai
Copy link
Member Author

We should think about the name of this keystore a bit: the keystore in #3437 is intentionally a simple one that just implements the fs layout, with no support for the root trust stuff. Going forward we'd like a proper implementation from Sequoia that does, and so we should preserve the primary name of opengpgp.cert.d for that "full version". And name the built-in simplified version in somehow self-documenting fashion. Something in the spirit of "openpgp_notrust" or so (not to say I like that name). Thoughts?

@Conan-Kudo
Copy link
Member

Conan-Kudo commented Nov 11, 2024

Actually, I'd flip it on its head: trust should be per-system instance and can be in /etc/pki/rpm-pgp/trusted-keys.d and a regular /etc/pki/rpm-pgp/keys.d and /usr/share/pki/rpm-pgp-keys.d (or /usr/lib/sysimage/rpm-pgp-keys.d) for keys that need TOFU (as the current workflow does now with packaged keys) should be used as the point for new keys.

I feel like that describes enough of how this works.

ffesti added a commit to ffesti/rpm that referenced this issue Nov 11, 2024
This will be useful for the next commit.

This still is a mess of C and C++ style strings that we want to clean
up later by adding C++ string based path handling and may be using the
filesystem C++ library.

Related: rpm-software-management#3341
ffesti added a commit to ffesti/rpm that referenced this issue Nov 11, 2024
This does implement the layout on the file system and the write lock of
the openpgp.cert.d proposal according to
https://www.ietf.org/archive/id/draft-nwjw-openpgp-cert-d-00.html
but not the Trust root, Petname mapping or Trusted introducers.

Resolves:  rpm-software-management#3341
@pmatilai
Copy link
Member Author

Trust based on just somebody dropping files in a directory isn't sufficient, really. You can trust a packager enough to install content on your system, but not enough to trust anybody they choose to trust. In social media terms, you have friends you trust, but you don't trust their friends.

@Conan-Kudo
Copy link
Member

So then, all keys are TOFU? Then what? Where are trusted keys?

ffesti added a commit to ffesti/rpm that referenced this issue Nov 11, 2024
This does implement the layout on the file system and the write lock of
the openpgp.cert.d proposal according to
https://www.ietf.org/archive/id/draft-nwjw-openpgp-cert-d-00.html
but not the Trust root, Petname mapping or Trusted introducers.

Resolves:  rpm-software-management#3341
@pmatilai
Copy link
Member Author

See https://www.ietf.org/archive/id/draft-nwjw-openpgp-cert-d-00.html#name-rooting-trust - that's the standard draft we're talking about implementing in this ticket.

@Conan-Kudo
Copy link
Member

SHOULD NOT have any subkeys.

Does this mean subkeys aren't supportable? We have distributions using subkeys (e.g. AlmaLinux).

@ffesti
Copy link
Contributor

ffesti commented Nov 11, 2024

This is for the Trust Root certificate only. The keys in the directory ofc can have sub keys.

@Conan-Kudo
Copy link
Member

Okay, and we don't have those for RPM PGP, so I am confused how we're going to have trust established in the first place. Nobody wants to be a PGP CA, and that's what this spec calls for.

ffesti added a commit to ffesti/rpm that referenced this issue Nov 11, 2024
This does implement the layout on the file system and the write lock of
the openpgp.cert.d proposal according to
https://www.ietf.org/archive/id/draft-nwjw-openpgp-cert-d-00.html
but not the Trust root, Petname mapping or Trusted introducers.

Resolves:  rpm-software-management#3341
dmnks pushed a commit that referenced this issue Nov 12, 2024
This will be useful for the next commit.

This still is a mess of C and C++ style strings that we want to clean
up later by adding C++ string based path handling and may be using the
filesystem C++ library.

Related: #3341
@dmnks dmnks closed this as completed in 6e19c16 Nov 12, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in RPM Nov 12, 2024
ffesti added a commit to ffesti/rpm that referenced this issue Nov 12, 2024
ffesti added a commit to ffesti/rpm that referenced this issue Nov 12, 2024
dmnks pushed a commit that referenced this issue Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crypto Signatures, keys, hashes and their verification RFE
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants