-
Notifications
You must be signed in to change notification settings - Fork 64
API-level DSSE signing support #804
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
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
e2ce0eb
hackety hack
woodruffw 2c873ff
Merge branch 'main' into ww/dsse
woodruffw 476d527
hackety hack
woodruffw d3862c0
Merge branch 'main' into ww/dsse
woodruffw 0da7215
Merge branch 'main' into ww/dsse
woodruffw f6899be
sigstore: hackety hack
woodruffw 77526da
hackety hack
woodruffw 63f9b29
hackety hack
woodruffw 82a6fee
sigstore: don't double encode
woodruffw ff8d358
fixup DSSE signing, refactor RekorClientError
woodruffw 470232c
sigstore: docs
woodruffw b46eac9
sigstore: lintage
woodruffw 35a1e7f
make SigningResult generic over contents
woodruffw b3a6099
simplify condition
woodruffw 09499f3
sign: drop kw_only
woodruffw cb99b93
sigstore: cleanup
woodruffw ea548a7
Merge branch 'main' into ww/dsse
woodruffw b24c9b7
firmly pin in-toto-attestation, fix KindVersion
woodruffw ffd3400
Merge branch 'main' into ww/dsse
woodruffw ee92e32
bump sigstore-rekor-types
woodruffw 47ea07f
Merge branch 'main' into ww/dsse
woodruffw bdaef2d
pyproject: bump in-toto-attestation
woodruffw 4728b32
Merge remote-tracking branch 'origin/main' into ww/dsse
woodruffw bbe07ac
Merge branch 'main' into ww/dsse
woodruffw d087a39
remove testing script
woodruffw 0b23bc2
CHANGELOG: record changes
woodruffw ffcfa5b
Merge branch 'main' into ww/dsse
woodruffw 86daf93
Merge branch 'main' into ww/dsse
woodruffw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # Copyright 2022 The Sigstore Authors | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """ | ||
| Functionality for building and manipulating DSSE envelopes. | ||
| """ | ||
|
|
||
| from cryptography.hazmat.primitives import hashes | ||
| from cryptography.hazmat.primitives.asymmetric import ec | ||
| from google.protobuf.json_format import MessageToJson | ||
| from in_toto_attestation.v1.statement import Statement | ||
| from sigstore_protobuf_specs.io.intoto import Envelope, Signature | ||
|
|
||
|
|
||
| def sign_intoto(key: ec.EllipticCurvePrivateKey, payload: Statement) -> Envelope: | ||
| """ | ||
| Create a DSSE envelope containing a signature over an in-toto formatted | ||
| attestation. | ||
| """ | ||
|
|
||
| # See: | ||
| # https://github.com/secure-systems-lab/dsse/blob/v1.0.0/envelope.md | ||
| # https://github.com/in-toto/attestation/blob/v1.0/spec/v1.0/envelope.md | ||
|
|
||
| type_ = "application/vnd.in-toto+json" | ||
| payload_encoded = MessageToJson(payload.pb, sort_keys=True).encode() | ||
| # NOTE: `payload_encoded.decode()` to avoid printing `repr(bytes)`, which would | ||
| # add `b'...'` around the formatted payload. | ||
| pae = ( | ||
| f"DSSEv1 {len(type_)} {type_} {len(payload_encoded)} {payload_encoded.decode()}" | ||
| ) | ||
|
|
||
| signature = key.sign(pae.encode(), ec.ECDSA(hashes.SHA256())) | ||
| return Envelope( | ||
| payload=payload_encoded, | ||
| payload_type=type_, | ||
| signatures=[Signature(sig=signature, keyid=None)], | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.