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

COSE envelope implementation updates #26

Closed
wants to merge 37 commits into from
Closed

COSE envelope implementation updates #26

wants to merge 37 commits into from

Conversation

shizhMSFT
Copy link
Contributor

Tracking the merger of the cose branch into main.

@shizhMSFT shizhMSFT added the enhancement New feature or request label Aug 8, 2022
@shizhMSFT shizhMSFT added this to the RC-1 milestone Aug 8, 2022
@shizhMSFT shizhMSFT requested review from a team August 8, 2022 08:03
@codecov-commenter
Copy link

codecov-commenter commented Aug 8, 2022

Codecov Report

Merging #26 (c515e7a) into main (f0a5409) will decrease coverage by 6.55%.
The diff coverage is 50.25%.

@@            Coverage Diff             @@
##             main      #26      +/-   ##
==========================================
- Coverage   70.33%   63.77%   -6.56%     
==========================================
  Files          23       27       +4     
  Lines        1591     2363     +772     
==========================================
+ Hits         1119     1507     +388     
- Misses        355      647     +292     
- Partials      117      209      +92     
Impacted Files Coverage Δ
signature/jws/signer.go 38.23% <38.23%> (ø)
signature/jws/jws.go 50.00% <50.00%> (ø)
signature/jws/utils.go 51.13% <51.13%> (ø)
signature/cose/cose.go 51.38% <51.38%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

signature/signer.go Outdated Show resolved Hide resolved
shizhMSFT and others added 5 commits August 10, 2022 16:26
Refactor Verify so that it just returns the payload and signerInfo from the internal envelope.

Signed-off-by: Binbin Li <[email protected]>

Signed-off-by: Binbin Li <[email protected]>
Co-authored-by: Binbin Li <[email protected]>
Signed-off-by: Junjie Gao <[email protected]>

Signed-off-by: Junjie Gao <[email protected]>
Co-authored-by: Junjie Gao <[email protected]>
Signed-off-by: Binbin Li <[email protected]>

Signed-off-by: Binbin Li <[email protected]>
Co-authored-by: Binbin Li <[email protected]>
* feat: implemented COSE envelope sign

Signed-off-by: Patrick Zheng <[email protected]>

* implemented cose envelope

Signed-off-by: Patrick Zheng <[email protected]>

* update per code review

Signed-off-by: Patrick Zheng <[email protected]>

* resolve conflicts

Signed-off-by: Patrick Zheng <[email protected]>

* added extendedAttributes related logic

Signed-off-by: Patrick Zheng <[email protected]>

* updated to most current cose branch

Signed-off-by: Patrick Zheng <[email protected]>

* per code review

Signed-off-by: Patrick Zheng <[email protected]>

* updated per code review

Signed-off-by: Patrick Zheng <[email protected]>

* updates

Signed-off-by: Patrick Zheng <[email protected]>

* updates

Signed-off-by: Patrick Zheng <[email protected]>

Signed-off-by: Patrick Zheng <[email protected]>
@JeyJeyGao
Copy link
Contributor

I will work on this task.

binbin-li and others added 3 commits August 15, 2022 17:06
* refactor: add common logic to base envelope

Signed-off-by: Binbin Li <[email protected]>

* feat: add payload and signerInfo verification in Verify

Signed-off-by: Binbin Li <[email protected]>

Signed-off-by: Binbin Li <[email protected]>
Co-authored-by: Binbin Li <[email protected]>
* updated COSE envelope implementation per code reivew

Signed-off-by: Patrick Zheng <[email protected]>

* renamed to envelope under cose package

Signed-off-by: Patrick Zheng <[email protected]>

* update per code review

Signed-off-by: Patrick Zheng <[email protected]>

* updated per code review

Signed-off-by: Patrick Zheng <[email protected]>

* clean up

Signed-off-by: Patrick Zheng <[email protected]>

* more clean up

Signed-off-by: Patrick Zheng <[email protected]>

* updated errors according to errors.go

Signed-off-by: Patrick Zheng <[email protected]>

* clean up

Signed-off-by: Patrick Zheng <[email protected]>

Signed-off-by: Patrick Zheng <[email protected]>
* feat: add error

Signed-off-by: Binbin Li <[email protected]>

* feat: validate key and cert while creating local signer

Signed-off-by: Binbin Li <[email protected]>

* refactor: refactor isKeyPair

Signed-off-by: Binbin Li <[email protected]>

Signed-off-by: Binbin Li <[email protected]>
Co-authored-by: Binbin Li <[email protected]>
@SteveLasker
Copy link
Contributor

SteveLasker commented Aug 16, 2022

@binbin-li, @shizhMSFT, we have a set of DCO errors. Can we get these fixed up?

@shizhMSFT
Copy link
Contributor Author

@binbin-li, @shizhMSFT, we have a set of DCO errors. Can we get these fixed up?

@SteveLasker This PR is just show the working progress of COSE, and will be split to multiple PRs to be reviewed and merged. Once those PRs are merged, this PR will be closed.

JeyJeyGao and others added 3 commits August 17, 2022 09:48
1. JWT sign replace custom sign
2. add SigningScheme, crit

Signed-off-by: Junjie Gao <[email protected]>

Signed-off-by: Junjie Gao <[email protected]>
Co-authored-by: Junjie Gao <[email protected]>
* updated COSE envelope implementation per code reivew

Signed-off-by: Patrick Zheng <[email protected]>

* renamed to envelope under cose package

Signed-off-by: Patrick Zheng <[email protected]>

* update per code review

Signed-off-by: Patrick Zheng <[email protected]>

* updated per code review

Signed-off-by: Patrick Zheng <[email protected]>

* clean up

Signed-off-by: Patrick Zheng <[email protected]>

* more clean up

Signed-off-by: Patrick Zheng <[email protected]>

* updated errors according to errors.go

Signed-off-by: Patrick Zheng <[email protected]>

* clean up

Signed-off-by: Patrick Zheng <[email protected]>

* update unit tests

Signed-off-by: Patrick Zheng <[email protected]>

* update unit tests

Signed-off-by: Patrick Zheng <[email protected]>

* update cose unprotected header

Signed-off-by: Patrick Zheng <[email protected]>

Signed-off-by: Patrick Zheng <[email protected]>
* updated COSE envelope implementation per code reivew

Signed-off-by: Patrick Zheng <[email protected]>

* renamed to envelope under cose package

Signed-off-by: Patrick Zheng <[email protected]>

* update per code review

Signed-off-by: Patrick Zheng <[email protected]>

* updated per code review

Signed-off-by: Patrick Zheng <[email protected]>

* clean up

Signed-off-by: Patrick Zheng <[email protected]>

* more clean up

Signed-off-by: Patrick Zheng <[email protected]>

* updated errors according to errors.go

Signed-off-by: Patrick Zheng <[email protected]>

* clean up

Signed-off-by: Patrick Zheng <[email protected]>

* update unit tests

Signed-off-by: Patrick Zheng <[email protected]>

* update unit tests

Signed-off-by: Patrick Zheng <[email protected]>

* update cose unprotected header

Signed-off-by: Patrick Zheng <[email protected]>

* updated COSE expiry header check

Signed-off-by: Patrick Zheng <[email protected]>

* updated COSE expiry header check

Signed-off-by: Patrick Zheng <[email protected]>

Signed-off-by: Patrick Zheng <[email protected]>

// Error returns the formatted error message
func (e *EnvelopeKeyRepeatedError) Error() string {
return fmt.Sprintf("repeated key: `%s` exists in the envelope.", e.Key)
Copy link

Choose a reason for hiding this comment

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

The %q verb automagically quotes the string. Use it instead of `%s`.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@binbin-li Could you address this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, I'll do it.

JeyJeyGao and others added 23 commits August 18, 2022 14:06
Payload() returns the raw payload context instead of base64 encoded data

Signed-off-by: Junjie Gao <[email protected]>

Signed-off-by: Junjie Gao <[email protected]>
* doc: add signature documents

Signed-off-by: Binbin Li <[email protected]>

* doc: refactor comments

Signed-off-by: Binbin Li <[email protected]>

Signed-off-by: Binbin Li <[email protected]>
Co-authored-by: Binbin Li <[email protected]>
* test: add signature unit tests

Signed-off-by: Binbin Li <[email protected]>

* test: add tests for base envelope

Signed-off-by: Binbin Li <[email protected]>

* test: add more valid cases

Signed-off-by: Binbin Li <[email protected]>

Signed-off-by: Binbin Li <[email protected]>
Co-authored-by: Binbin Li <[email protected]>
* updated COSE envelope implementation per code reivew

Signed-off-by: Patrick Zheng <[email protected]>

* renamed to envelope under cose package

Signed-off-by: Patrick Zheng <[email protected]>

* update per code review

Signed-off-by: Patrick Zheng <[email protected]>

* updated per code review

Signed-off-by: Patrick Zheng <[email protected]>

* clean up

Signed-off-by: Patrick Zheng <[email protected]>

* more clean up

Signed-off-by: Patrick Zheng <[email protected]>

* updated errors according to errors.go

Signed-off-by: Patrick Zheng <[email protected]>

* clean up

Signed-off-by: Patrick Zheng <[email protected]>

* update unit tests

Signed-off-by: Patrick Zheng <[email protected]>

* update unit tests

Signed-off-by: Patrick Zheng <[email protected]>

* update cose unprotected header

Signed-off-by: Patrick Zheng <[email protected]>

* updated COSE expiry header check

Signed-off-by: Patrick Zheng <[email protected]>

* updated COSE expiry header check

Signed-off-by: Patrick Zheng <[email protected]>

* updated COSE envelope unit tests

Signed-off-by: Patrick Zheng <[email protected]>

* updated COSE envelope unit tests

Signed-off-by: Patrick Zheng <[email protected]>

* updated COSE unit tests

Signed-off-by: Patrick Zheng <[email protected]>

* updated per code review

Signed-off-by: Patrick Zheng <[email protected]>

Signed-off-by: Patrick Zheng <[email protected]>
* added extended attribute getter for notation-go

Signed-off-by: Patrick Zheng <[email protected]>

* update

Signed-off-by: Patrick Zheng <[email protected]>

Signed-off-by: Patrick Zheng <[email protected]>
* added extended attribute getter for notation-go

Signed-off-by: Patrick Zheng <[email protected]>

* update

Signed-off-by: Patrick Zheng <[email protected]>

* updated COSE envelope unit tests

Signed-off-by: Patrick Zheng <[email protected]>

Signed-off-by: Patrick Zheng <[email protected]>
… well (#48)

Signed-off-by: Binbin Li <[email protected]>

Signed-off-by: Binbin Li <[email protected]>
Co-authored-by: Binbin Li <[email protected]>
Signed-off-by: Binbin Li <[email protected]>

Signed-off-by: Binbin Li <[email protected]>
Co-authored-by: Binbin Li <[email protected]>
Signed-off-by: Binbin Li <[email protected]>

Signed-off-by: Binbin Li <[email protected]>
Co-authored-by: Binbin Li <[email protected]>
* added extended attribute getter for notation-go

Signed-off-by: Patrick Zheng <[email protected]>

* update

Signed-off-by: Patrick Zheng <[email protected]>

* updated COSE envelope unit tests

Signed-off-by: Patrick Zheng <[email protected]>

* updating certificate chain

Signed-off-by: Patrick Zheng <[email protected]>

* updated COSE envelope for the certificate chain changes

Signed-off-by: Patrick Zheng <[email protected]>

* updated COSE envelope for certificate chain changes

Signed-off-by: Patrick Zheng <[email protected]>

Signed-off-by: Patrick Zheng <[email protected]>
* added extended attribute getter for notation-go

Signed-off-by: Patrick Zheng <[email protected]>

* update

Signed-off-by: Patrick Zheng <[email protected]>

* updated COSE envelope unit tests

Signed-off-by: Patrick Zheng <[email protected]>

* updating certificate chain

Signed-off-by: Patrick Zheng <[email protected]>

* updated COSE envelope for the certificate chain changes

Signed-off-by: Patrick Zheng <[email protected]>

* updated COSE envelope for certificate chain changes

Signed-off-by: Patrick Zheng <[email protected]>

* updated to latest go-cose

Signed-off-by: Patrick Zheng <[email protected]>

Signed-off-by: Patrick Zheng <[email protected]>
* add jws test

Signed-off-by: Junjie Gao <[email protected]>

* update PR

Signed-off-by: Junjie Gao <[email protected]>

Signed-off-by: Junjie Gao <[email protected]>
Co-authored-by: Junjie Gao <[email protected]>
* added extended attribute getter for notation-go

Signed-off-by: Patrick Zheng <[email protected]>

* update

Signed-off-by: Patrick Zheng <[email protected]>

* updated COSE envelope unit tests

Signed-off-by: Patrick Zheng <[email protected]>

* updating certificate chain

Signed-off-by: Patrick Zheng <[email protected]>

* updated COSE envelope for the certificate chain changes

Signed-off-by: Patrick Zheng <[email protected]>

* updated COSE envelope for certificate chain changes

Signed-off-by: Patrick Zheng <[email protected]>

* updated to latest go-cose

Signed-off-by: Patrick Zheng <[email protected]>

* added COSE conformance tests

Signed-off-by: Patrick Zheng <[email protected]>

* update

Signed-off-by: Patrick Zheng <[email protected]>

* updated comments

Signed-off-by: Patrick Zheng <[email protected]>

* updated per code review

Signed-off-by: Patrick Zheng <[email protected]>

Signed-off-by: Patrick Zheng <[email protected]>
Signed-off-by: Junjie Gao <[email protected]>

Signed-off-by: Junjie Gao <[email protected]>
Co-authored-by: Junjie Gao <[email protected]>
Signed-off-by: Junjie Gao <[email protected]>

Signed-off-by: Junjie Gao <[email protected]>
Co-authored-by: Junjie Gao <[email protected]>
* added extended attribute getter for notation-go

Signed-off-by: Patrick Zheng <[email protected]>

* update

Signed-off-by: Patrick Zheng <[email protected]>

* updated COSE envelope unit tests

Signed-off-by: Patrick Zheng <[email protected]>

* updating certificate chain

Signed-off-by: Patrick Zheng <[email protected]>

* updated COSE envelope for the certificate chain changes

Signed-off-by: Patrick Zheng <[email protected]>

* updated COSE envelope for certificate chain changes

Signed-off-by: Patrick Zheng <[email protected]>

* updated to latest go-cose

Signed-off-by: Patrick Zheng <[email protected]>

* added COSE conformance tests

Signed-off-by: Patrick Zheng <[email protected]>

* update

Signed-off-by: Patrick Zheng <[email protected]>

* updated comments

Signed-off-by: Patrick Zheng <[email protected]>

* updated per code review

Signed-off-by: Patrick Zheng <[email protected]>

* added verification plugin critical headers check

Signed-off-by: Patrick Zheng <[email protected]>

* updated errors related code

Signed-off-by: Patrick Zheng <[email protected]>

Signed-off-by: Patrick Zheng <[email protected]>
* added extended attribute getter for notation-go

Signed-off-by: Patrick Zheng <[email protected]>

* update

Signed-off-by: Patrick Zheng <[email protected]>

* updated COSE envelope unit tests

Signed-off-by: Patrick Zheng <[email protected]>

* updating certificate chain

Signed-off-by: Patrick Zheng <[email protected]>

* updated COSE envelope for the certificate chain changes

Signed-off-by: Patrick Zheng <[email protected]>

* updated COSE envelope for certificate chain changes

Signed-off-by: Patrick Zheng <[email protected]>

* updated to latest go-cose

Signed-off-by: Patrick Zheng <[email protected]>

* added COSE conformance tests

Signed-off-by: Patrick Zheng <[email protected]>

* update

Signed-off-by: Patrick Zheng <[email protected]>

* updated comments

Signed-off-by: Patrick Zheng <[email protected]>

* updated per code review

Signed-off-by: Patrick Zheng <[email protected]>

* added verification plugin critical headers check

Signed-off-by: Patrick Zheng <[email protected]>

* updated errors related code

Signed-off-by: Patrick Zheng <[email protected]>

* quick fix

Signed-off-by: Patrick Zheng <[email protected]>

Signed-off-by: Patrick Zheng <[email protected]>
* fix: update jwt.Claims

Signed-off-by: Junjie Gao <[email protected]>

* update PR

Signed-off-by: Junjie Gao <[email protected]>

Signed-off-by: Junjie Gao <[email protected]>
Co-authored-by: Junjie Gao <[email protected]>
…ror (#63)

* added extended attribute getter for notation-go

Signed-off-by: Patrick Zheng <[email protected]>

* update

Signed-off-by: Patrick Zheng <[email protected]>

* updated COSE envelope unit tests

Signed-off-by: Patrick Zheng <[email protected]>

* updating certificate chain

Signed-off-by: Patrick Zheng <[email protected]>

* updated COSE envelope for the certificate chain changes

Signed-off-by: Patrick Zheng <[email protected]>

* updated COSE envelope for certificate chain changes

Signed-off-by: Patrick Zheng <[email protected]>

* updated to latest go-cose

Signed-off-by: Patrick Zheng <[email protected]>

* added COSE conformance tests

Signed-off-by: Patrick Zheng <[email protected]>

* update

Signed-off-by: Patrick Zheng <[email protected]>

* updated comments

Signed-off-by: Patrick Zheng <[email protected]>

* updated per code review

Signed-off-by: Patrick Zheng <[email protected]>

* added verification plugin critical headers check

Signed-off-by: Patrick Zheng <[email protected]>

* updated errors related code

Signed-off-by: Patrick Zheng <[email protected]>

* quick fix

Signed-off-by: Patrick Zheng <[email protected]>

* renamed TestSignatureNotFoundError to TestSignatureEnvelopeNotFoundError

Signed-off-by: Patrick Zheng <[email protected]>

Signed-off-by: Patrick Zheng <[email protected]>
* added extended attribute getter for notation-go

Signed-off-by: Patrick Zheng <[email protected]>

* update

Signed-off-by: Patrick Zheng <[email protected]>

* updated COSE envelope unit tests

Signed-off-by: Patrick Zheng <[email protected]>

* updating certificate chain

Signed-off-by: Patrick Zheng <[email protected]>

* updated COSE envelope for the certificate chain changes

Signed-off-by: Patrick Zheng <[email protected]>

* updated COSE envelope for certificate chain changes

Signed-off-by: Patrick Zheng <[email protected]>

* updated to latest go-cose

Signed-off-by: Patrick Zheng <[email protected]>

* added COSE conformance tests

Signed-off-by: Patrick Zheng <[email protected]>

* update

Signed-off-by: Patrick Zheng <[email protected]>

* updated comments

Signed-off-by: Patrick Zheng <[email protected]>

* updated per code review

Signed-off-by: Patrick Zheng <[email protected]>

* added verification plugin critical headers check

Signed-off-by: Patrick Zheng <[email protected]>

* updated errors related code

Signed-off-by: Patrick Zheng <[email protected]>

* quick fix

Signed-off-by: Patrick Zheng <[email protected]>

* renamed TestSignatureNotFoundError to TestSignatureEnvelopeNotFoundError

Signed-off-by: Patrick Zheng <[email protected]>

* quick update regarding verification plugin

Signed-off-by: Patrick Zheng <[email protected]>

Signed-off-by: Patrick Zheng <[email protected]>
* Bump github.com/golang-jwt/jwt/v4 from 4.4.1 to 4.4.2 (#14)

Bumps [github.com/golang-jwt/jwt/v4](https://github.com/golang-jwt/jwt) from 4.4.1 to 4.4.2.
- [Release notes](https://github.com/golang-jwt/jwt/releases)
- [Changelog](https://github.com/golang-jwt/jwt/blob/main/VERSION_HISTORY.md)
- [Commits](golang-jwt/jwt@v4.4.1...v4.4.2)

---
updated-dependencies:
- dependency-name: github.com/golang-jwt/jwt/v4
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* added extended attribute getter for notation-go

Signed-off-by: Patrick Zheng <[email protected]>

* update

Signed-off-by: Patrick Zheng <[email protected]>

* updated COSE envelope unit tests

Signed-off-by: Patrick Zheng <[email protected]>

* updating certificate chain

Signed-off-by: Patrick Zheng <[email protected]>

* updated COSE envelope for the certificate chain changes

Signed-off-by: Patrick Zheng <[email protected]>

* updated COSE envelope for certificate chain changes

Signed-off-by: Patrick Zheng <[email protected]>

* updated to latest go-cose

Signed-off-by: Patrick Zheng <[email protected]>

* added COSE conformance tests

Signed-off-by: Patrick Zheng <[email protected]>

* update

Signed-off-by: Patrick Zheng <[email protected]>

* updated comments

Signed-off-by: Patrick Zheng <[email protected]>

* updated per code review

Signed-off-by: Patrick Zheng <[email protected]>

* added verification plugin critical headers check

Signed-off-by: Patrick Zheng <[email protected]>

* updated errors related code

Signed-off-by: Patrick Zheng <[email protected]>

* quick fix

Signed-off-by: Patrick Zheng <[email protected]>

* renamed TestSignatureNotFoundError to TestSignatureEnvelopeNotFoundError

Signed-off-by: Patrick Zheng <[email protected]>

* quick update regarding verification plugin

Signed-off-by: Patrick Zheng <[email protected]>

* refactor: refactor envelope and signer to support cose (#53)

Signed-off-by: Binbin Li <[email protected]>

* resolve conflicts

Signed-off-by: Patrick Zheng <[email protected]>

* update

Signed-off-by: Patrick Zheng <[email protected]>

* fixed broken unit tests

Signed-off-by: Patrick Zheng <[email protected]>

* added maps for Notation CLI cert

Signed-off-by: Patrick Zheng <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Signed-off-by: Patrick Zheng <[email protected]>
Signed-off-by: Binbin Li <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Binbin Li <[email protected]>
Signed-off-by: Junjie Gao <[email protected]>

Signed-off-by: Junjie Gao <[email protected]>
Co-authored-by: Junjie Gao <[email protected]>
@shizhMSFT
Copy link
Contributor Author

This PR is succeeded by #72 and #75

@shizhMSFT shizhMSFT closed this Sep 21, 2022
@shizhMSFT shizhMSFT removed this from the RC-1 milestone Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants