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

Make new api compatible with the Signing interface #1272

Merged
merged 1 commit into from
Mar 10, 2021

Conversation

MVrachev
Copy link
Collaborator

@MVrachev MVrachev commented Feb 3, 2021

Related to: #1263

Description of the changes being introduced by the pull request:

This pr makes TUF compatible with changes introduced in secure-systems-lab/securesystemslib#319.

Please wait for the securesystemlib pr to be merged first!

Signed-off-by: Martin Vrachev mvrachev@vmware.com

@MVrachev MVrachev marked this pull request as draft February 3, 2021 16:50
Copy link
Member

@lukpueh lukpueh left a comment

Choose a reason for hiding this comment

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

Cool stuff, @MVrachev! I only noticed one thing (see inline comment), but we can revisit once secure-systems-lab/securesystemslib#319 has landed.

On a general note, I appreciate slightly more informative commit messages.

tuf/api/metadata.py Outdated Show resolved Hide resolved
@MVrachev
Copy link
Collaborator Author

Cool stuff, @MVrachev! I only noticed one thing (see inline comment), but we can revisit once secure-systems-lab/securesystemslib#319 has landed.

On a general note, I appreciate slightly more informative commit messages.

Sorry for the lack of a good commit message, you are right.

I will update this pr when the securesystemslib signer interface is merged and I will add a better commit message before mark it
as a non-draft pr.

@MVrachev MVrachev force-pushed the signer-interface branch 2 times, most recently from 3062307 to 19e08d0 Compare February 24, 2021 12:27
@MVrachev
Copy link
Collaborator Author

MVrachev commented Feb 24, 2021

I updated the pr addressing Lukas comment #1272 (comment), adding a new commit fixing one comment in the code, and making the commit message more descriptive.

@MVrachev MVrachev marked this pull request as ready for review February 24, 2021 13:01
@MVrachev MVrachev force-pushed the signer-interface branch 2 times, most recently from a5e64e1 to ce655ac Compare February 26, 2021 22:42
@MVrachev
Copy link
Collaborator Author

Updated the pr after we have bumped securesystemslib version to 0.20.0 which supports the new Signer interface.

@joshuagl
Copy link
Member

joshuagl commented Mar 3, 2021

Thanks for this PR Martin, I'm hoping to give it a thorough review ASAP.

One quick observation: we should bump the minimum version of securesystemslib in the install_requires entry of setup.py to the version with the Signer abstraction.

Copy link
Member

@joshuagl joshuagl left a comment

Choose a reason for hiding this comment

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

The small diffstat of this PR feels like a nice validation of the Signer interface.

This LGTM, thank you @MVrachev. Could you please add a patch to the PR to update the securesystemslib version in setup.py's install_requires? Also, your first patch will no longer be required once we merge #1293.

tuf/api/metadata.py Outdated Show resolved Hide resolved
@MVrachev MVrachev force-pushed the signer-interface branch 4 times, most recently from 1856040 to 977f0d4 Compare March 5, 2021 15:04
@MVrachev
Copy link
Collaborator Author

MVrachev commented Mar 5, 2021

I addressed your comments @joshuagl and fixed the conflicts.

Copy link
Member

@lukpueh lukpueh left a comment

Choose a reason for hiding this comment

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

Except for two minor nits this is good to go.

tuf/api/metadata.py Outdated Show resolved Hide resolved
tuf/api/metadata.py Outdated Show resolved Hide resolved
@MVrachev
Copy link
Collaborator Author

MVrachev commented Mar 9, 2021

I updated according to the last @lukpueh remarks.

In the securesystemslib pr secure-systems-lab/securesystemslib#319
I added a new Signer interface with the purpose of supporting multiple
signing implementations.
Additionally, I added the SSlibSigner implementation of that interface
which implements the signing operation for rsa, ed25519 and ecdsa
schemes.
With this commit, I integrate the SSlibSigner into the new API in tuf.

Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
Copy link
Member

@lukpueh lukpueh left a comment

Choose a reason for hiding this comment

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

Hey @MVrachev, I took the liberty to rebase your PR on top of #1279, fixing conflicts and making minimal changes. See comments inline...

To get a full diff between your old diff and my new rebased diff you can do:

git range-diff develop 3050fb6 49aa0fc

I think we can merge. But maybe should consult with a 3rd-party, now that we are both authors? (ping @joshuagl, @jku, @sechkova)

from securesystemslib.util import persist_temp_file
from securesystemslib.signer import Signer, Signature
Copy link
Member

Choose a reason for hiding this comment

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

Re-ordered imports alphabetically.

# metadata['signatures'], call Signature.from_dict for each item, and
# pass a list of Signature objects to the Metadata constructor instead.
signatures = []
for signature in metadata.pop('signatures'):
Copy link
Member

Choose a reason for hiding this comment

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

Now popping the signatures list for consistently destructing the passed dictionary as described in the newly added "Side Effect" docstring section.

signed_serializer: Optional[SignedSerializer] = None
) -> Dict[str, Any]:
"""Creates signature over 'signed' and assigns it to 'signatures'.

Arguments:
key: A securesystemslib-style private key object used for signing.
signer: An object implementing the securesystemslib.signer.Signer
Copy link
Member

Choose a reason for hiding this comment

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

Did s/singer/signer to fix a typo I had missed in my review.

@MVrachev
Copy link
Collaborator Author

I agree with your changes @lukpueh.
Let us wait and see what the others will say.

Copy link
Member

@joshuagl joshuagl left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the changes @MVrachev and the rebase/fixes @lukpueh

@lukpueh lukpueh merged commit 65005cf into theupdateframework:develop Mar 10, 2021
@lukpueh
Copy link
Member

lukpueh commented Mar 10, 2021

Ping @woodruffw! Metadata.sign now accepts a custom Signer. :)

@trishankatdatadog
Copy link
Member

Very cool, thanks for all the great work, guys!

Will, you should be able to reuse a lot of the Vault-specific code I wrote as part of this PR...

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.

4 participants