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

Async signing of repository objects. #163

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Async signing of repository objects. #163

wants to merge 3 commits into from

Conversation

partim
Copy link
Member

@partim partim commented Oct 13, 2021

This PR is a proposal for a way to allow both blocking and async signers.

It twists the traits around: Instead of having a signer trait, it provides two traits SignWithKey and Sign (the names are temporary, I suppose the first one should really be PrepareForSign or something) that are implemented by types that want to be signed. There are two traits since signing happens in two stages: first, the public key is given to the object via SignWithKey so it can use it to create the actual content to be signed if that includes information about the public key (e.g., in RPKI, the Subject of certificate is based on the hash of the public key). It then returns an intermediary object that has the data to be signed. It provides access to that data via Sign::signed_data so a signer can grab an octets slice to do the signing on. Once it is finished, it gives the signature to the object which transforms itself into the final output object.

The OpenSslSigner implements the signer interface for this via the two methods sign_with_key and sign_with_one_off_key (names temporary to not collide with the existing signer trait methods). They both take something that implements SignWithKey and do the dance described above.

To see if this works in practice, the new reverse signer traits have been implement for certificates and signed objects. There is a lot of extra types necessary, particularly for signed objects, but if we adopt this approach, the current builders can be cleaned up to better work with these types. Currently, this is just a quick and dirty implementation.

The user side is a lot less tedious. You can see it in action in the reverse_signer_test modules of both repository::cert and repository::sigobj. In the latter case, you need to explicitly sign in two stages – first with the one-off key for signing the attributes and then with the issuer key to create the certificate. But I think that’s okay.

For a blocking signer, we can adjust the existing Signer trait to actually use the new facilities and re-implement the existing methods on the various signed types so that there will be no actual user-visible changes.

@partim partim requested review from timbru and ximon18 October 13, 2021 11:05
@partim partim marked this pull request as draft October 13, 2021 11:06
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