8000 Add note signers by cmurphy · Pull Request #87 · sigstore/rekor-tiles · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add note signers #87

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

Merged
merged 1 commit into from
Mar 11, 2025
Merged

Add note signers #87

merged 1 commit into from
Mar 11, 2025

Conversation

cmurphy
Copy link
Contributor
@cmurphy cmurphy commented Mar 7, 2025

This change copies most of the sigstore/rekor/pkg/signer package to enable signing checkpoints with an on-disk key file or a KMS provider, and adds a note helper package to convert the Rekor signers to the sumdb/note signing format.

Fixes #9
Relates to sigstore/rekor#2062

Summary

Release Note

Documentation

@cmurphy cmurphy requested review from a team as code owners March 7, 2025 22:48
@cmurphy
Copy link
Contributor Author
cmurphy commented Mar 7, 2025

I've not tested this with tink or other KMSs yet.

Copy link
codecov bot commented Mar 7, 2025

Codecov Report

Attention: Patch coverage is 36.48649% with 94 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@bc41dcd). Learn more about missing BASE report.

Files with missing lines Patch % Lines
pkg/signer/tink.go 23.25% 31 Missing and 2 partials ⚠️
pkg/signer/signer.go 0.00% 31 Missing ⚠️
pkg/note/note.go 57.81% 20 Missing and 7 partials ⚠️
pkg/signer/file.go 70.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main      #87   +/-   ##
=======================================
  Coverage        ?   14.53%           
=======================================
  Files           ?       21           
  Lines           ?     1390           
  Branches        ?        0           
=======================================
  Hits            ?      202           
  Misses          ?     1172           
  Partials        ?       16           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

pkg/note/note.go Outdated
const (
algEd25519 = 1
algUndef = 255
rsaID = "RSA-PKCS#1v1.5"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can follow up later, but we should document this custom ID in a readme on log entry verification.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#93

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@haydentherapper what's the reasoning behind your suggestion to use PKCS#1 as the identifier, vs PKCS#8 or PKIX? It has implications on whether I use https://pkg.go.dev/crypto/x509#MarshalPKCS1PublicKey or https://pkg.go.dev/crypto/x509#MarshalPKIXPublicKey to convert the key object to bytes, I just noticed I'm using the wrong one for this identifier.

Copy link
Contributor

Choose a reason for hiding this comment

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

To differentiate between the two modern RSA schemes, PSS and PKCS#1v1.5. You're right that there are two ways to encode public keys, so can we include both the scheme and public key encoding in the ID name?

Copy link
Contributor

Choose a reason for hiding this comment

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

Including encoding also matches up well with how we’ve named the supported keys - https://github.com/sigstore/protobuf-specs/blob/e3f5847bde2c42348d1b99add0737ab3193f45d0/protos/sigstore_common.proto#L69

)

// New returns a Signer for the given KMS provider, Tink, or a private key file on disk.
func New(ctx context.Context, signer, pass, tinkKEKURI, tinkKeysetPath string) (signature.Signer, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this was copied in, but I (who wrote this) never loved passing a bunch of strings, prone to mixing them up. Do you want to change this to a config struct (or file a follow up issue)?

func(s string) bool {
return strings.HasPrefix(signer, s)
}):
return kms.Get(ctx, signer, crypto.SHA256)
Copy link
Contributor

Choose a reason for hiding this comment

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

(Also can be a follow up) Related to the crypto agility work we're doing now, we found in Fulcio that hardcoding this hash caused ECDSA P384 and P521 keys to not work correctly since those are typically associated with SHA-384 and SHA-512, especially for KMS providers.

Can we add an option to pass in the hash algorithm?

return nil, fmt.Errorf("file: provide a valid signer, %s is not valid: %w", keyPath, err)
}

signer, err := signature.LoadSignerVerifier(opaqueKey, crypto.SHA256)
Copy link
Contributor

Choose a reason for hiding this comment

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

(Also can do in a follow up) Can we change from a hardcoded hash to the typical signature-hash pairing in https://github.com/sigstore/sigstore/pull/2014/files#diff-90f2b413b0fbeae56caac0481e57d7dff1bde02810bce967bd3f8c7d98670010R242?

Any RSA key size uses SHA-256, ECDSA P256/P384/P521 uses SHA-256/384/512 respectively, and Ed25519 uses SHA-512 but that's harcoded into the implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can change this to signature.LoadDefaultSignerVerifier which was added ... today.

Copy link
Contributor

Choose a reason for hiding this comment

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

SG, I'll cut a sigstore/sigstore release now

Copy link
Contributor

Choose a reason for hiding this comment

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

"path/filepath"
"strings"

tinkUtils "github.com/sigstore/rekor/pkg/signer/tink"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we pull in the Tink utilities to remove the dependency on rekor?

Copy link
Member
@jku jku Mar 11, 2025

Choose a reason for hiding this comment

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

8000

it's a bit strange since it looks like we already do -- isn't that pkg/signer/tink/ in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, just forgot to update the import.

pkg/signer/tink/tink.go now exists in fulcio, rekor and rekor-tiles, maybe we should just put it in sigstore/sigstore?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, that sounds good.

// See the License for the specific language governing permissions and
// limitations under the License.

// Copied from https://github.com/sigstore/rekor/blob/c820fcaf3afdc91f0acf6824d55c1ac7df249df1/pkg/signer/tink_test.go
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Copied from https://github.com/sigstore/rekor/blob/c820fcaf3afdc91f0acf6824d55c1ac7df249df1/pkg/signer/tink_test.go
// Copied from https://github.com/sigstore/rekor/blob/c820fcaf3afdc91f0acf6824d55c1ac7df249df1/pkg/signer/tink/tink.go

although it's not a direct copy, there are at least some lint changes

This change copies most of the sigstore/rekor/pkg/signer package to
enable signing checkpoints with an on-disk key file or a KMS provider,
and adds a note helper package to convert the Rekor signers to the
sumdb/note signing format.

Signed-off-by: Colleen Murphy <colleenmurphy@google.com>
@cmurphy cmurphy merged commit f7ace05 into sigstore:main Mar 11, 2025
13 checks passed
@cmurphy cmurphy deleted the note-signers branch March 28, 2025 17:54
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.

Add checkpoint note signers
4 participants
0