-
Notifications
You must be signed in to change notification settings - Fork 281
Description
Purpose
It would be good to make it easier to manage repository metadata with TUF's repository_tool
module while using specialized hardware signing mechanisms that do not pass private keys around in memory. Currently, repository_tool
expects to be provided private keys that it can use to produce signatures.
Current workaround
The workaround currently involves producing metadata normally (with unchanged TUF code) through repository_tool
using dummy keys, and then using external code to, without TUF, replace signatures in the produced JSON metadata, for any signatures to be made with private key data that cannot be provided to TUF. These can just be swapped into the JSON metadata that repository_tool
produces. This should be easy. (Caveat: If Snapshot, specifically, has to be signed with an external key, then in addition to replacing that signature, one must also re-calculate Timestamp's hash of snapshot metadata and re-sign Timestamp. One could make TUF calls to do the Timestamp adjustment after externally re-signing Snapshot in that case.)
Options for the Future
Option 1: External Signing Support
A PR has been put forward to suggest an API defining key signers via an extension of the metadata combined with additional handler mappings for all key types, where the mapped-to value is a class that supports a signature-related functions. I think this is unfortunately a little over-engineered for the codebase of the reference implementation, requiring additional classes and metadata changes, and impairing readability. 😔
I have to do some thinking about what a good API will look like if we go the direction of adding general external signing support. I'd prefer something much thinner and less intrusive. Off the top of my head, while I don't love it, here's an example:
- a (dummy if necessary) key is provided that lists a
scheme
value identifying the (internally) unsupported signing scheme (or some 'custom' value) - loading the key into TUF is permitted despite the unknown signing scheme (or, permitted if the scheme is 'custom', say)
- when signing with the "key", TUF notes the scheme is unsupported (or perhaps an expected value like 'custom' or 'external') and calls out to an external handler module with a fixed name, providing the bytes to be signed and the (potentially dummy) "key", taking the result as the signature.
- the external module can be provided by a separate dependency and need only support a one-function interface producing a signature through whatever mechanism is appropriate for the key as determined externally based on
scheme
.
I'm very much open to alternative suggestions. (@lukpueh?)
Option 2: TUF support for CCID / PIV
There also may be additional (to OLL) interest in this. @trishankatdatadog?
It seems to me like it would be reasonable to add some optional dependencies (similar to the PyNaCl
and cryptography
libraries) that could handle this and would require some non-Python dependencies. It's likely that the API for this would look like dummy private keys, similar to what I suggested above. I'm curious, though, about how in-toto handles this. (Indirectly via gpg...?) @lukpueh @SantiagoTorres
I also have some reading to do about functionality for CCID/PIV support in Notary.