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

document ImportKeyPair and LoadPrivateKey functions in pkg/cosign #3776

Merged
merged 2 commits into from
Jul 11, 2024

Conversation

dmitris
Copy link
Contributor

@dmitris dmitris commented Jul 10, 2024

Summary

Document the IMportKeyPair and LoadPrivateKey functions in the pkg/cosign to explicitly indicate the supported PKCS #8 format.

Fix #3775.

Release Note

NONE

Documentation

A godoc function comments added for ImportKeyPair and LoadPrivateKey.

@dmitris dmitris changed the title Import keys expand ImportKeyPair to add PKCS #1 (RSA) and SEC (EC) formats support Jul 10, 2024
Copy link

codecov bot commented Jul 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 37.09%. Comparing base (2ef6022) to head (858c9c6).
Report is 154 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3776      +/-   ##
==========================================
- Coverage   40.10%   37.09%   -3.02%     
==========================================
  Files         155      200      +45     
  Lines       10044    12280    +2236     
==========================================
+ Hits         4028     4555     +527     
- Misses       5530     7178    +1648     
- Partials      486      547      +61     

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

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.

I don't think we need to update LoadPrivateKey to support keys that are not encoded as PKCS8. Its purpose is to load the password-encrypted key which is expected to be generated with GenerateKeyPair or ImportKeyPair, both of which output encrypted PKCS8 encoded keys. Did you have another use case in mind?

Let's update the documentation. As for the TODOs, I agree this should be in an internal package, this isn't meant to be general purpose.

@dmitris dmitris changed the title expand ImportKeyPair to add PKCS #1 (RSA) and SEC (EC) formats support document ImportKeyPair and LoadPrivateKey functions in pkg/cosign Jul 11, 2024

// given already decrypted blob with x509 encoded private key, try different x509.Parse<*>PrivateKey
// functions to load it.
func parsePrivateKey(key []byte) (crypto.PrivateKey, error) {
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 revert this change, since it should only be for PKCS8 encoded keys?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

rolled back in 858c9c6 (except comments) - kept the additional test to make clear which key formats are supported. Additionally created #3779 for the task of moving functions to an internal package.

Currently ImportKeyPair() in pkg/cosign supports
only private keys in PKCS sigstore#8 form. This change
extends it to also support PKCS #1 for RSA keys
("RSA PUBLIC KEY") and SEC 1 for EC keys
("EC PRIVATE KEY").

Fix sigstore#3775.

Signed-off-by: Dmitry S <[email protected]>
@haydentherapper haydentherapper merged commit f7a5725 into sigstore:main Jul 11, 2024
22 checks passed
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.

expand LoadPrivateKey in pkg/cosign to support Sigstore Encrypted EC keys ("EC PRIVATE KEY" format)
2 participants