-
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.
- Loading branch information
Showing
6 changed files
with
241 additions
and
24 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
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 |
---|---|---|
@@ -1,12 +1,35 @@ | ||
class TimeStampRequest: ... | ||
class TimeStampRequest: | ||
@property | ||
def nonce(self) -> int: ... | ||
|
||
@property | ||
def version(self) -> int: ... | ||
|
||
@property | ||
def policy(self) -> ObjectIdentifier: ... | ||
|
||
def create_timestamp_request( | ||
data: bytes, | ||
) -> TimeStampRequest: ... | ||
|
||
|
||
class TimeStampResponse: ... | ||
class TimeStampResponse: | ||
@property | ||
def status(self) -> int: ... | ||
|
||
@property | ||
def tst_info_version(self) -> int: ... | ||
|
||
@property | ||
def tst_info_nonce(self) -> int: ... | ||
|
||
@property | ||
def tst_info_policy(self) -> ObjectIdentifier: ... | ||
|
||
def parse_timestamp_response( | ||
data: bytes, | ||
) -> TimeStampResponse: ... | ||
|
||
class ObjectIdentifier: | ||
@property | ||
def dotted_string(self) -> str:... |
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,42 @@ | ||
"""Verification module.""" | ||
|
||
from sigstore_tsp.base import PKIStatus, TimestampRequest, TimestampResponse | ||
|
||
|
||
def verify_signed_timestamp( | ||
signed_timestamp: TimestampResponse, timestamp_request: TimestampRequest | ||
) -> bool: | ||
"""Verify a Timestamp Response. | ||
Inspired by: | ||
https://github.com/sigstore/timestamp-authority/blob/main/pkg/verification/verify.go#L209 | ||
""" | ||
# Note: digitorus/timestamp does not validate if the result is GRANTED_WITH_MOD | ||
# https://github.com/digitorus/timestamp/blob/master/timestamp.go#L268 | ||
if signed_timestamp.status == PKIStatus.GRANTED: | ||
return False | ||
|
||
# TODO(dm): verifyTSRWithChain | ||
|
||
# Verify Nonce | ||
if timestamp_request.nonce is not None: | ||
return False | ||
|
||
if ( | ||
timestamp_request.policy_oid is not None | ||
and timestamp_request.policy_oid != signed_timestamp.tst_info.policy | ||
): | ||
return False | ||
|
||
# TODO(dm) | ||
# if err = verifyLeafCert(*ts, opts); err != nil { | ||
# return nil, err | ||
# } | ||
|
||
# // verify the hash in the timestamp response matches the artifact hash | ||
# if err = verifyHashedMessages(ts.HashAlgorithm.New(), ts.HashedMessage, artifact); err != nil { | ||
# return nil, err | ||
# } | ||
|
||
return True |