Skip to content

Commit 0f23402

Browse files
authored
rekor: Fix checkpoint signature lookup (#1514)
Checkpoint can have multiple signatures from multiple keys. We just want one of them to be the log key. Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
1 parent 664b064 commit 0f23402

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

sigstore/_internal/rekor/checkpoint.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -165,24 +165,26 @@ def from_text(cls, text: str) -> SignedNote:
165165

166166
def verify(self, rekor_keyring: RekorKeyring, key_id: KeyID) -> None:
167167
"""
168-
Verify the `SignedNote` using the given RekorKeyring by verifying
169-
each contained signature.
168+
Verify the `SignedNote` using the given RekorKeyring and KeyID.
170169
"""
171170

172171
note = str.encode(self.note)
173172

174173
for sig in self.signatures:
175-
if sig.sig_hash != key_id[:4]:
176-
raise VerificationError(
177-
"checkpoint: sig_hash hint does not match expected key_id"
178-
)
174+
if sig.sig_hash == key_id[:4]:
175+
try:
176+
rekor_keyring.verify(
177+
key_id=key_id,
178+
signature=base64.b64decode(sig.signature),
179+
data=note,
180+
)
181+
return
182+
except VerificationError as sig_err:
183+
raise VerificationError(f"checkpoint: invalid signature: {sig_err}")
179184

180-
try:
181-
rekor_keyring.verify(
182-
key_id=key_id, signature=base64.b64decode(sig.signature), data=note
183-
)
184-
except VerificationError as sig_err:
185-
raise VerificationError(f"checkpoint: invalid signature: {sig_err}")
185+
raise VerificationError(
186+
f"checkpoint: Signature not found for log ID {key_id.hex()}"
187+
)
186188

187189

188190
@dataclass(frozen=True)

0 commit comments

Comments
 (0)