Skip to content

Commit 6a43f2c

Browse files
committed
rekor: Fix checkpoint signature lookup
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 f8387b5 commit 6a43f2c

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

sigstore/_internal/rekor/checkpoint.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -165,24 +165,22 @@ 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-
)
179-
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}")
174+
if sig.sig_hash == key_id[:4]:
175+
try:
176+
rekor_keyring.verify(
177+
key_id=key_id, signature=base64.b64decode(sig.signature), data=note
178+
)
179+
return
180+
except VerificationError as sig_err:
181+
raise VerificationError(f"checkpoint: invalid signature: {sig_err}")
182+
183+
raise VerificationError(f"checkpoint: Log signature not found for key {key_id}")
186184

187185

188186
@dataclass(frozen=True)

0 commit comments

Comments
 (0)