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

Add alternative TUF metadata repo implementation (WIP) #512

Draft
wants to merge 7 commits into
base: feature/tuf-repositoty
Choose a base branch
from

Conversation

lukpueh
Copy link

@lukpueh lukpueh commented Aug 23, 2024

Implements basic primitives, defined by the python-tuf Repository abstraction, to read and edit metadata on disk, handling version and expiry bumps, and signature creation, and facilitating snapshot and timestamp creation.

And adds exemplary API methods that use these primitives while preserving consistent repo states:

  • create
  • add_target_files
  • add_keys

Can be tested with:

PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 pytest --noconftest taf/tests/tuf/

More details about the design, and recommendations for how to move on from here can be found in this Google doc.

Copy link
Collaborator

@renatav renatav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a close look and this all makes sense to me. I should be able to start porting our repository_tool.

@renatav renatav changed the base branch from master to feature/tuf-repositoty August 23, 2024 23:06
Remove unused pyopenssl

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
Implements basic primitives, defined by the python-tuf Repository
abstraction, to read and edit metadata on disk, handling version and
expiry bumps, and signature creation, and facilitating snapshot and
timestamp creation.

And adds exemplary API methods that use these primitives while
preserving consistent repo states:
- create
- add_target_files
- add_keys

Can be tested with:
```
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 pytest --noconftest taf/tests/tuf/
```

More detailed usage docs + migration path TBD...

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
The original design aimed at separating the concepts of delegation
(adding public keys) and signing (using private keys).

Since the MetadataRepository assumes that metadata can be signed
rightaway after edit (e.g. after having added a delegation), which in
turn requires private keys to be available, we might as well conflate
these two concepts.

The advantage is that the signer cache does not have to be managed
independently and is more likely to stay in sync with the delegations.

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
This should really happen upstream (see linked issue)

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
YkSigner provides a minimal compatibility layer over `taf.yubikey`
module functions for use with MetadataRepository.

Even though a yubikey signer implementation (HSMSigner) based on
pykcs11 is available in securesystemslib, YkSigner was added for the
following reasons:

- TAF requires rsa support for yubikeys, but HSMSigner only supports
  ecdsa. Adding rsa support to HSMSigner, or providing a custom
  pykcs11-based RSAHSMSigner is feasible, and seems desirable, but
  requires more effort than this YkSigner did.

- TAF provides a few additional features, like setting up a Yubikey,
  changing pins, etc., which will not be added to securesystemslib.
  This means the current Yubikey infrastructure based on yubikey-manager
  needs to be preserved for the time being. Thus it made sense to
  re-use the existing implementation for YkSigner.

- YkSigner show-cases the new Signer API and might be used as blue print
  for future Signer implementations in TAF.

This commit adds basic tests with fake and real Yubikey:

```
REAL_YK=1 PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 \
    pytest --noconftest  taf/tests/tuf/ taf/tests/tuf/test_yk.py -s
```

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
This allows running previously added YkSigner tests, but breaks
other things, which need change anyway in the course of upgrading to
latest tuf/securesystemslib.

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
@lukpueh
Copy link
Author

lukpueh commented Aug 28, 2024

I just pushed YkSigner, which provides a minimal compatibility layer over taf.yubikey module functions for use with MetadataRepository.

See 42fbfac commit message for details.

Notes about tests:

  • I had to comment out a few legacy imports to test YkSigner so that it can import taf.yubikey (see most recent commit)
  • If you run YkSigner tests with REAL_YK=1, it will look for a real yubikey and use it, which includes prompting for the pin.

@renatav renatav deleted the branch openlawlibrary:feature/tuf-repositoty October 7, 2024 21:12
@renatav renatav closed this Oct 7, 2024
@renatav renatav reopened this Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants