question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support custom signing implementations in Metadata.sign method

See original GitHub issue

Description of issue or feature request: Allow TUF integrators to easily use custom metadata signing implementations instead of the currently supported securesystemslib one.

An urgent use case for this is the PEP458/Warehouse integration, where metadata must be signed with keys stored in a Hashicorp Vault and the implementation is already available.

NOTE: This feature request only concerns the tuf.api.Metadata.sign method and not the legacy signing facilities write and writeall in repository tool.

Current behavior: tuf.api.Metadata.sign(key, ...) calls securesystemslib.keys.create_signature with the passed sslib/json-formatted private key.

Expected behavior: tuf.api.Metadata.sign takes an abstract signer parameter, which implements signing. A default signer may resolve to the currently used securesystemslib.keys.create_signature.

Implementation considerations:

  • Different signers require completely different “keys”, e.g. the currently used generic implementation requires an sslib/json-formatted private key, whereas signing implementations that don’t have direct access to the key may only need a keyid (see GPG or HSM references below). As a consequence the key parameter in Metadata.sign should probably be encapsulated within the signer.

  • The abstract signer interface must strictly define the format of the returned signature for metadata interoperability.

  • The abstract signer interface design should also keep in mind other key-related tasks, such as signature verification, public key export to sslib metadata format, and keyid generation.

  • securesystemslib.keys.create_signature is already an abstract interface, where the json-formatted private key parameter format is generic enough to hold different key types and to choose one of many supported signing algorithms, identified by the key’s scheme field. (see public key metadata format reference below). However, it is not suited to extend to custom implementations. A new abstract signer interface should integrate well with the existing securesystemslib infrastructure and/or aim to replace it. It should not become yet another co-existing interface and/or layer of abstraction (see public API overview reference below).


Related work and references: (for the very ambitious reader)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:25 (16 by maintainers)

github_iconTop GitHub Comments

3reactions
lukpuehcommented, Jan 14, 2021

A very basic implementation could look something like this:

# in securesystemslib
class Signer:
    @abc.abstractmethod
    def sign(bytes: payload) -> Signature:
        raise NotImplementedError

class SSlibSigner(Signer):
    def __init__(self, sslib_private_key):
        self.key = sslib_private_key

    def sign(self, payload):
        return sslib_keys.create_signature(self.key, payload)

class GPGSigner(Signer):
    def __init__(self, gpg_keyid):
        self.keyid = gpg_keyid

    def sign(self, payload):
        return sslib_gpg.create_signature(payload, self.keyid)

# in TUF
class Metadata:
    def sign(sslib.Signer: signer):
        signer.sign(self.signed.to_canonical_bytes())

# in Warehouse
class VaultSigner(Signer):
    def sign(self, payload):
        # ... you get the idea

metadata = tuf.Metadata(...)
metadata.sign(VaultSigner(...))


2reactions
lukpuehcommented, Feb 8, 2021

@MVrachev, I thought you agreed with my arguments above for not implementing verification as method of the Signature class? (And even if we did, I wouldn’t store the public key on the Signature object but rather pass it to the verification method as argument.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

7. Metadata configuration - Spring
Metadata is not required to be signed by default. When present, signature is verified with PKIX algorithm and uses all public keys present...
Read more >
Implement custom encryption with Metadata signatures
This article explains how to implement custom encryption for Metadata ... Call sign method of Signature class instance and pass MetadataSignOptions to it....
Read more >
Use a SAML 2.0 Identity Provider (IdP) for Single Sign On
This document describes using a SAML 2.0 compliant Idp for single sign on.
Read more >
Using WebAuthn for Signing - Yubico Developers
In short, the registration and authenticaiton events consists of a cryptographic signing process with the public key returned, which is then used to...
Read more >
Single Sign-On Implementation Guide
The hashing algorithm for signed requests, either RSA-SHA1 or RSA-SHA256. Request Signature. Method. If the identity provider encrypts SAML ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found