Skip to content

Design key import/generation for the signer API #466

Closed
@jku

Description

@jku

With #456 the signer API comes a lot closer to being a "fully featured API". The missing part is key generation and import (and maybe storing private keys)

Related issues: #446, #408, #280, #451 (and probably more)

Current status (after #456):

  • Using signers and keys is possible without knowing the signer or key implementation, and without using the "old" API
  • except to create keys this sort of code is typically used:
    key = keys.generate_ed25519_key() # key is a dictionary. keys is a module we would like to start hiding from users
    pubkey = SSlibKey.from_securesystemslib_key(key) # pubkey is an implementation of Key
    signer = Signer.from_priv_key_uri("file:path/to/file?encrypted=false", pubkey) # signer is an implementation of Signer
    
    
  • the key dictionary is only used as an intermediate step

Proposal

  • Signer implementations should provide implementation specific methods to create new keys or import them from other systems
  • these methods may have whatever arguments they need
  • Signer should expose the public key so callers can access it
  • typical usage:
    # call implementation specific API (in this case SSlibsigner to generate a ed25519 key)
    signer = SSlibSigner.new_ed25519(...) 
    pubkey = signer.public_key
    
  • this hides the keys module from users, and makes SSlibKey.from_securesystemslib_key unneeded
  • AFAICT this should work for KMS, HSM, GPG, ...
  • The implementation specific method could live elsewhere as well, but it seemed like it would make most sense in signer.

The part I have not 100% figured out is private key storage: how and when do you store the private key content in a way that you can then use the from_priv_key_uri() to load it again. This is somewhat different depending on the key type and in many cases does not even make sense (you can't really store environment variables)... possibly it should happen during the constructor, so SSlibSigner.new_ed25519() could actually take a priv_key_uri argument and and the generated key would immediately get stored ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions