Skip to content

Implement default signing algorithms based on the key type#2014

Merged
Hayden-IO merged 4 commits intosigstore:mainfrom
trail-of-forks:default-sv-from-privkey
Mar 10, 2025
Merged

Implement default signing algorithms based on the key type#2014
Hayden-IO merged 4 commits intosigstore:mainfrom
trail-of-forks:default-sv-from-privkey

Conversation

@ret2libc
Copy link
Copy Markdown
Contributor

@ret2libc ret2libc commented Mar 4, 2025

Summary

As we make the Sigstore ecosystem more crypto agile, we realized that right now it is using some uncommon algorithms, like ECDSA-P384 with the SHA256 hash algorithm. However, we want the crypto-agility to be controlled and limited to a set of algorithms (see AlgorithmRegistry). Moreover, we want the agility to be mainly about supporting multiple key types, rather than multiple algorithms for the same key type. Thus, this PR introduces a single point where the defaults are defined.

This is going to simplify other changes across the Sigstore ecosystem, given that often enough the only information you have is the public key. Being able to derive the signing algorithm to use (or used to sign a blob) means we don't need to store or pass around any extra information (e.g. the hash function), because that can be derived automatically from the key.

See sigstore/sig-clients#16 .

Release Note

  • Introduce default AlgorithmDetails for public keys based on their types.

Signed-off-by: Riccardo Schirone <riccardo.schirone@trailofbits.com>
@ret2libc ret2libc requested a review from a team as a code owner March 4, 2025 16:07
ret2libc added 2 commits March 5, 2025 10:21
Signed-off-by: Riccardo Schirone <riccardo.schirone@trailofbits.com>
Signed-off-by: Riccardo Schirone <riccardo.schirone@trailofbits.com>
@ret2libc
Copy link
Copy Markdown
Contributor Author

ret2libc commented Mar 5, 2025

I'm considering adding a Default prefix (e.g. LoadDefaultSignerVerifier) to the various methods to make them more easily distinguishable from LoadSignerVerifierWithOpts. The only real difference is that in these new methods we want to ignore the hash option as we follow what's the default hash for the given public key type.

Hayden-IO
Hayden-IO previously approved these changes Mar 6, 2025
Copy link
Copy Markdown
Contributor

@Hayden-IO Hayden-IO left a comment

Choose a reason for hiding this comment

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

I like the suggestion to add Default to the method names. Otherwise this looks great.

@Hayden-IO
Copy link
Copy Markdown
Contributor

Would you like me to merge as-is, or update the func names now with Default?

@ret2libc
Copy link
Copy Markdown
Contributor Author

Would you like me to merge as-is, or update the func names now with Default?

I was planning on doing a bunch of changes tomorrow to the various PRs, but I can do this now!

@Hayden-IO
Copy link
Copy Markdown
Contributor

No rush, just wanted to check!

Signed-off-by: Riccardo Schirone <riccardo.schirone@trailofbits.com>
@Hayden-IO Hayden-IO merged commit f577ba0 into sigstore:main Mar 10, 2025
16 checks passed
Copy link
Copy Markdown

@eiffel-fl eiffel-fl left a comment

Choose a reason for hiding this comment

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

Hi,

We use sigstore in our project and I always take a look at the release notes while bumping the package version.
This time, I have some comments, but nothing critical.

Best regards,

case elliptic.P384():
return v1.PublicKeyDetails_PKIX_ECDSA_P384_SHA_384, nil
case elliptic.P521():
return v1.PublicKeyDetails_PKIX_ECDSA_P521_SHA_512, nil
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There is a typo in the name of this const:
PublicKeyDetails_PKIX_ECDSA_P521_SHA_512 -> PublicKeyDetails_PKIX_ECDSA_P512_SHA_512

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +119 to +128
filteredOpts := []LoadOption{options.WithHash(algorithmDetails.hashType)}
for _, opt := range opts {
var useED25519ph bool
var rsaPSSOptions *rsa.PSSOptions
opt.ApplyED25519ph(&useED25519ph)
opt.ApplyRSAPSS(&rsaPSSOptions)
if useED25519ph || rsaPSSOptions != nil {
filteredOpts = append(filteredOpts, opt)
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You repeat this code in verifier.go, it would be easier for maintenance to factorize it in a function and then call this function from these two places.
The function could just return a filteredOpts.

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