forked from sigstore/model-transparency
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add signing and verification methods based on in-toto statements (sig…
…store#193) * signing and verification Signed-off-by: Martin Sablotny <msablotny@nvidia.com> * changed behavior to raise an exception on failure license gitignore newline add dependencies Signed-off-by: Martin Sablotny <msablotny@nvidia.com> deps * gitignore;requirements Signed-off-by: Martin Sablotny <msablotny@nvidia.com> * dependencies Signed-off-by: Martin Sablotny <msablotny@nvidia.com> * Bump frozen dependencies Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * import paths Signed-off-by: Martin Sablotny <msablotny@nvidia.com> --------- Signed-off-by: Martin Sablotny <msablotny@nvidia.com> Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Signed-off-by: Martin Sablotny <susperius@gmail.com> Co-authored-by: susperius <1203928+susperius@users.noreply.github.com>
- Loading branch information
Showing
19 changed files
with
783 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1 +1,4 @@ | ||
__pycache__/ | ||
.venv/ | ||
.pytest_cache/ | ||
test_material/ |
This file contains 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 |
---|---|---|
@@ -1,2 +1,9 @@ | ||
absl-py | ||
betterproto | ||
cryptography | ||
in-toto-attestation | ||
pyOpenSSL | ||
protobuf | ||
psutil | ||
sigstore | ||
sigstore-protobuf-specs |
This file contains 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 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 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 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 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 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,13 @@ | ||
# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. | ||
# | ||
# 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. |
This file contains 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,38 @@ | ||
# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. | ||
# | ||
# 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. | ||
from google.protobuf import json_format | ||
from in_toto_attestation.v1 import statement_pb2 as statement_pb | ||
|
||
PAYLOAD_TYPE = "application/vnd.in-toto+json" | ||
|
||
|
||
def pae(statement: statement_pb.Statement) -> bytes: | ||
"""Generates the PAE encoding of the statement. | ||
See https://github.com/secure-systems-lab/dsse/blob/v1.0.0/protocol.md | ||
for details. | ||
Args: | ||
statement (statement_pb.Statement): the statement to be encoded. | ||
Returns: | ||
bytes: the encoded statement as bytes. | ||
""" | ||
enc_payload = json_format.MessageToJson(statement).encode() | ||
payload_len = len(enc_payload) | ||
pae = ('DSSEV1' | ||
f' {len(PAYLOAD_TYPE)} {PAYLOAD_TYPE}' | ||
f' {payload_len} {enc_payload}') | ||
pae = pae.encode() | ||
return pae |
Oops, something went wrong.