Skip to content

Commit 52f38a3

Browse files
committed
Verifier: Use correct algorithm for Timestamp hash
Don't assume sha256. Use verify_message() instead: it looks up the correct hash from the the timestamp response. TODO: this requires unreleased rfc3161-client. Signed-off-by: Jussi Kukkonen <[email protected]>
1 parent 71da8a7 commit 52f38a3

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

CHANGELOG.md

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

21+
* TSA: Correctly verify timestamps with hashes other than SHA-256. Currently supported
22+
algorithms are SHA-256, SHA-384, SHA-512.
23+
[#1373](https://github.com/sigstore/sigstore-python/pull/1373)
24+
2125
* Fixed the certificate calidity period check for Timestamp Authorities (TSA).
2226
Certificates need not have and end date, while still requiring a start date.
2327
[#1368](https://github.com/sigstore/sigstore-python/pull/1368)

sigstore/verify/verifier.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def _from_trust_config(cls, trust_config: ClientTrustConfig) -> Verifier:
125125
)
126126

127127
def _verify_signed_timestamp(
128-
self, timestamp_response: TimeStampResponse, signature: bytes
128+
self, timestamp_response: TimeStampResponse, message: bytes
129129
) -> TimestampVerificationResult | None:
130130
"""
131131
Verify a Signed Timestamp using the TSA provided by the Trusted Root.
@@ -140,7 +140,7 @@ def _verify_signed_timestamp(
140140

141141
verifier = builder.build()
142142
try:
143-
verifier.verify(timestamp_response, signature)
143+
verifier.verify_message(timestamp_response, message)
144144
except Rfc3161VerificationError as e:
145145
_logger.debug("Unable to verify Timestamp with CA.")
146146
_logger.exception(e)
@@ -183,14 +183,11 @@ def _verify_timestamp_authority(
183183
msg = "duplicate timestamp found"
184184
raise VerificationError(msg)
185185

186-
# The Signer sends a hash of the signature as the messageImprint in a TimeStampReq
187-
# to the Timestamping Service
188-
signature_hash = sha256_digest(bundle.signature).digest
189186
verified_timestamps = [
190187
verified_timestamp
191188
for tsr in timestamp_responses
192189
if (
193-
verified_timestamp := self._verify_signed_timestamp(tsr, signature_hash)
190+
verified_timestamp := self._verify_signed_timestamp(tsr, bundle.signature)
194191
)
195192
]
196193

0 commit comments

Comments
 (0)