Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions sigstore/_internal/rekor/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,24 +165,26 @@ def from_text(cls, text: str) -> SignedNote:

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

note = str.encode(self.note)

for sig in self.signatures:
if sig.sig_hash != key_id[:4]:
raise VerificationError(
"checkpoint: sig_hash hint does not match expected key_id"
)
if sig.sig_hash == key_id[:4]:
try:
rekor_keyring.verify(
key_id=key_id,
signature=base64.b64decode(sig.signature),
data=note,
)
return
except VerificationError as sig_err:
raise VerificationError(f"checkpoint: invalid signature: {sig_err}")

try:
rekor_keyring.verify(
key_id=key_id, signature=base64.b64decode(sig.signature), data=note
)
except VerificationError as sig_err:
raise VerificationError(f"checkpoint: invalid signature: {sig_err}")
raise VerificationError(
f"checkpoint: Signature not found for log ID {key_id.hex()}"
)


@dataclass(frozen=True)
Expand Down
Loading