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

Support additionnal hash algorithms for artifact signing #181

Closed

Conversation

alexiscampan
Copy link

No description provided.

Copy link
Contributor

@haydentherapper haydentherapper left a comment

Choose a reason for hiding this comment

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

Hey, thanks for the PR. The issue for log key types wasn’t about more hash algorithms for the log, it was to support different key algorithms. sha256 is fairly standard for log deployment at this point, and I’d prefer to not add support for other digests if it’s not easily possible to deploy such a log.

As for the second part of this change to add more hash algorithms for artifact signing, this looks good at a glance. Can you add tests for this too?

Signed-off-by: alexiscampan <alexis.campan@ut-capitole.fr>
@alexiscampan alexiscampan changed the title feat(keys): Support additionnal log key types Support additionnal hash algorithms for artifact signing May 18, 2024
@alexiscampan
Copy link
Author

Hey @haydentherapper, thanks for the review. I've just added some tests for the artifact signing part and refined the scope of this PR. I'll do the support of new algorithms for the verify part in another PR.

@@ -117,6 +118,8 @@ func main() {
trustedRootPath = &os.Args[i+1]
case "--staging":
staging = true
case "--signing-algorithm":
Copy link
Member

Choose a reason for hiding this comment

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

We want the conformance command line options to match https://github.com/sigstore/sigstore-conformance/blob/main/docs/cli_protocol.md. If we decide to continue with this change, we could add this as an option to examples/signing/main.go (for signing) or cmd/sigstore-go/main.go (for verifying).

Hint []byte
// TODO: support additional key algorithms
Hint []byte
HashAlgorithm protocommon.HashAlgorithm
Copy link
Member

Choose a reason for hiding this comment

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

So this was actually proposed before, and we decided not to allow hash algorithm options for ECDSA P256, because even if you specify a hash with more bits it will get truncated to match the key size.

I guess to take a step back, what problem are we trying to solve here? What use-case are we trying to enable?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd like to see cryptographic agility. Agreed that specifying the hash here doesn't make sense.

Instead of HashAlgorithm, should we be taking in PublicKeyDetails - https://github.com/sigstore/protobuf-specs/blob/main/protos/sigstore_common.proto#L62, and initializing both a signing algorithm and hash algorithm based on that.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, yeah, we can support some additional keys in https://github.com/sigstore/protobuf-specs/blob/main/protos/sigstore_common.proto#L62, especially for key types and hashes we expect to be very common.

But I don't think that pkg/sign/keys.go should implement every possible combination. The point of the Keypair interface is so that sigstore-go doesn't have to implement every key type - you can provide your own implementation to that interface.

That's why I was curious what @alexiscampan's use-case is. If they were anticipating lots of clients needing to sign with a specific key type and hash, or if it would make more sense for them to implement their own Keypair when they use sigstore-go.

Copy link
Contributor

Choose a reason for hiding this comment

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

That makes sense for KMS keys or other key interfaces that pull in dependencies or experimental algorithms, e.g. PQC. Or for signing where keys are managed, e.g on disk or HSMs.

For algorithms that are natively supported in Go and where keys are used in ephemeral signing, why not support them here too? The default of ECDSA-P256 is reasonable, but in the spirit of cryptographic agility (#74), I would like to add in a way to configure RSA, ed25519, and other elliptic curves. I recognize this is a case of YAGNI, but it's straightforward to add this support and removes a barrier for potential integrators while still directing them to the default, preferred Sigstore signing workflow.

Copy link
Author

Choose a reason for hiding this comment

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

Ah, yeah, we can support some additional keys in https://github.com/sigstore/protobuf-specs/blob/main/protos/sigstore_common.proto#L62, especially for key types and hashes we expect to be very common.

But I don't think that pkg/sign/keys.go should implement every possible combination. The point of the Keypair interface is so that sigstore-go doesn't have to implement every key type - you can provide your own implementation to that interface.

That's why I was curious what @alexiscampan's use-case is. If they were anticipating lots of clients needing to sign with a specific key type and hash, or if it would make more sense for them to implement their own Keypair when they use sigstore-go.

Hey @steiza, I have no particular use case for this specific feature. With my company we are going to need the signing part, we could use other librairies like the one in python to sign our images but all our applications are written in Go so we wanted to stay consistant. I also think that the default ECDSA-P256 is sufficient for our use case. I just wanted to do a first contribution before contributing on the signing part. I will close this PR for now as the priority of this feature is not high and we don't really know if it will be useful. I will try to give some support on the signing part which is the main feature of this library. Thanks for your fast review.

Hint []byte
// TODO: support additional key algorithms
Hint []byte
HashAlgorithm protocommon.HashAlgorithm
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd like to see cryptographic agility. Agreed that specifying the hash here doesn't make sense.

Instead of HashAlgorithm, should we be taking in PublicKeyDetails - https://github.com/sigstore/protobuf-specs/blob/main/protos/sigstore_common.proto#L62, and initializing both a signing algorithm and hash algorithm based on that.

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.

3 participants