8000 Verifier: Use correct Timestamp hash algorithm (#1385) · SequeI/sigstore-python@0fcbdc7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0fcbdc7

Browse files
authored
Verifier: Use correct Timestamp hash algorithm (sigstore#1385)
* Verifier: Use correct algorithm for Timestamp hash Don't assume sha256. Use verify_message() from new rfc3161-client instead: it looks up the correct hash from the timestamp response. Signed-off-by: Jussi Kukkonen <jkukkonen@google.com> * verify: Add temporary mypy ignore Signed-off-by: Jussi Kukkonen <jkukkonen@google.com> --------- Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
1 parent 06e0ae2 commit 0fcbdc7

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ All versions prior to 0.9.0 are untracked.
2424
* TSA: Changed the Timestamp Authority requests to explicitly use sha256 for message digests.
2525
[#1373](https://github.com/sigstore/sigstore-python/pull/1373)
2626

27+
* TSA: Correctly verify timestamps with hashes other than SHA-256. Currently supported
28+
algorithms are SHA-256, SHA-384, SHA-512.
29+
[#1373](https://github.com/sigstore/sigstore-python/pull/1373)
30+
2731
* Fixed the certificate validity period check for Timestamp Authorities (TSA).
2832
Certificates need not have an end date, while still requiring a start date.
2933
[#1368](https://github.com/sigstore/sigstore-python/pull/1368)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ dependencies = [
3636
"requests",
3737
"rich >= 13,< 15",
3838
"rfc8785 ~= 0.1.2",
39-
"rfc3161-client >= 0.1.2,< 1.1.0",
39+
"rfc3161-client >= 1.0.2,< 1.1.0",
4040
# NOTE(ww): Both under active development, so strictly pinned.
4141
"sigstore-protobuf-specs == 0.4.2",
4242
"sigstore-rekor-types == 0.0.18",

sigstore/verify/verifier.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def staging(cls, *, offline: bool = False) -> Verifier:
116116
)
117117

118118
def _verify_signed_timestamp(
119-
self, timestamp_response: TimeStampResponse, signature: bytes
119+
self, timestamp_response: TimeStampResponse, message: bytes
120120
) -> TimestampVerificationResult | None:
121121
"""
122122
Verify a Signed Timestamp using the TSA provided by the Trusted Root.
@@ -131,7 +131,8 @@ def _verify_signed_timestamp(
131131

132132
verifier = builder.build()
133133
try:
134-
verifier.verify(timestamp_response, signature)
134+
# TODO: remove ignore after rfc3161-client upgrade
135+
verifier.verify_message(timestamp_response, message) # type: ignore[attr-defined]
135136
except Rfc3161VerificationError as e:
136137
_logger.debug("Unable to verify Timestamp with CA.")
137138
_logger.exception(e)
@@ -174,15 +175,10 @@ def _verify_timestamp_authority(
174175
msg = "duplicate timestamp found"
175176
raise VerificationError(msg)
176177

177-
# The Signer sends a hash of the signature as the messageImprint in a TimeStampReq
178-
# to the Timestamping Service
179-
signature_hash = sha256_digest(bundle.signature).digest
180178
verified_timestamps = [
181-
verified_timestamp
179+
result
182180
for tsr in timestamp_responses
183-
if (
184-
verified_timestamp := self._verify_signed_timestamp(tsr, signature_hash)
185-
)
181+
if (result := self._verify_signed_timestamp(tsr, bundle.signature))
186182
]
187183

188184
return verified_timestamps

0 commit comments

Comments
 (0)
0