Skip to content

Verifier: Use correct Timestamp hash algorithm #1385

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ All versions prior to 0.9.0 are untracked.
* TSA: Changed the Timestamp Authority requests to explicitly use sha256 for message digests.
[#1373](https://github.com/sigstore/sigstore-python/pull/1373)

* TSA: Correctly verify timestamps with hashes other than SHA-256. Currently supported
algorithms are SHA-256, SHA-384, SHA-512.
[#1373](https://github.com/sigstore/sigstore-python/pull/1373)

* Fixed the certificate calidity period check for Timestamp Authorities (TSA).
Certificates need not have and end date, while still requiring a start date.
[#1368](https://github.com/sigstore/sigstore-python/pull/1368)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dependencies = [
"requests",
"rich >= 13,< 15",
"rfc8785 ~= 0.1.2",
"rfc3161-client >= 0.1.2,< 1.1.0",
"rfc3161-client >= 1.0.2,< 1.1.0",
# NOTE(ww): Both under active development, so strictly pinned.
"sigstore-protobuf-specs == 0.4.2",
"sigstore-rekor-types == 0.0.18",
Expand Down
14 changes: 5 additions & 9 deletions sigstore/verify/verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def _from_trust_config(cls, trust_config: ClientTrustConfig) -> Verifier:
)

def _verify_signed_timestamp(
self, timestamp_response: TimeStampResponse, signature: bytes
self, timestamp_response: TimeStampResponse, message: bytes
) -> TimestampVerificationResult | None:
"""
Verify a Signed Timestamp using the TSA provided by the Trusted Root.
Expand All @@ -140,7 +140,8 @@ def _verify_signed_timestamp(

verifier = builder.build()
try:
verifier.verify(timestamp_response, signature)
# TODO: remove ignore after rfc3161-client upgrade
verifier.verify_message(timestamp_response, message) # type: ignore[attr-defined]
except Rfc3161VerificationError as e:
_logger.debug("Unable to verify Timestamp with CA.")
_logger.exception(e)
Expand Down Expand Up @@ -183,15 +184,10 @@ def _verify_timestamp_authority(
msg = "duplicate timestamp found"
raise VerificationError(msg)

# The Signer sends a hash of the signature as the messageImprint in a TimeStampReq
# to the Timestamping Service
signature_hash = sha256_digest(bundle.signature).digest
verified_timestamps = [
verified_timestamp
result
for tsr in timestamp_responses
if (
verified_timestamp := self._verify_signed_timestamp(tsr, signature_hash)
)
if (result := self._verify_signed_timestamp(tsr, bundle.signature))
]

return verified_timestamps
Expand Down