@@ -259,16 +259,17 @@ def from_bundle(
259
259
)
260
260
tlog_entry = tlog_entries [0 ]
261
261
262
- # NOTE: We only load the inclusion proof from the bundle if we know that
263
- # we're performing an offline verification, since that's the only case
264
- # in which we'll use it.
262
+ # NOTE: Bundles are not required to include inclusion proofs,
263
+ # since offline (or non-gossiped) verification of an inclusion proof is
264
+ # only as strong as verification of the inclusion promise, which
265
+ # is always provided.
265
266
inclusion_proof = tlog_entry .inclusion_proof
266
267
parsed_inclusion_proof : LogInclusionProof | None = None
267
- if inclusion_proof and offline :
268
+ if inclusion_proof :
268
269
checkpoint = inclusion_proof .checkpoint
269
270
270
- # If the bundle to be verified offline includes an inclusion proof,
271
- # we verify it, which requires a checkpoint.
271
+ # If the inclusion proof is provided, it must include its
272
+ # checkpoint.
272
273
if not checkpoint .envelope :
273
274
raise InvalidMaterials ("expected checkpoint in inclusion proof" )
274
275
@@ -316,8 +317,23 @@ def rekor_entry(self, client: RekorClient) -> LogEntry:
316
317
"""
317
318
Returns a `RekorEntry` for the current signing materials.
318
319
"""
320
+
321
+ # The Rekor entry we use depends on a few different states:
322
+ # 1. If the user has requested offline verification and we've
323
+ # been given an offline Rekor entry to use, we use it.
324
+ # 2. If the user has not requested offline verification,
325
+ # we *opportunistically* use the offline Rekor entry,
326
+ # so long as it contains an inclusion proof. If it doesn't
327
+ # contain an inclusion proof, then we do an online entry lookup.
328
+
329
+ offline = self ._offline
330
+ has_rekor_entry = self .has_rekor_entry
331
+ has_inclusion_proof = (
332
+ self .has_rekor_entry and self ._rekor_entry .inclusion_proof is not None
333
+ )
334
+
319
335
entry : LogEntry | None
320
- if self . _offline and self . has_rekor_entry :
336
+ if ( offline and has_rekor_entry ) or ( not offline and has_inclusion_proof ) :
321
337
logger .debug ("using offline rekor entry" )
322
338
entry = self ._rekor_entry
323
339
else :
@@ -328,6 +344,7 @@ def rekor_entry(self, client: RekorClient) -> LogEntry:
328
344
self .certificate ,
329
345
)
330
346
347
+ # No matter what we do above, we must end up with a Rekor entry.
331
348
if entry is None :
332
349
raise RekorEntryMissing
333
350
0 commit comments