Skip to content

Commit

Permalink
Check VDS value on receipts (#6769)
Browse files Browse the repository at this point in the history
  • Loading branch information
achamayou authored Jan 20, 2025
1 parent 516b158 commit d69da4c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions python/src/ccf/cose.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
# should move to a pycose.header value after RFC publication

COSE_PHDR_VDP_LABEL = 396
COSE_PHDR_VDS_LABEL = 395
COSE_PHDR_VDS_CCF_LEDGER_SHA256 = 2
COSE_RECEIPT_INCLUSION_PROOF_LABEL = -1

# See https://datatracker.ietf.org/doc/draft-birkholz-cose-receipts-ccf-profile/
Expand Down Expand Up @@ -222,6 +224,13 @@ def verify_receipt(
assert receipt.phdr[pycose.headers.KID] == expected_kid
receipt.key = cose_key

assert (
COSE_PHDR_VDS_LABEL in receipt.phdr
), "Verifiable data structure type is required"
assert (
receipt.phdr[COSE_PHDR_VDS_LABEL] == COSE_PHDR_VDS_CCF_LEDGER_SHA256
), "vds(395) protected header must be CCF_LEDGER_SHA256(2)"

assert COSE_PHDR_VDP_LABEL in receipt.uhdr, "Verifiable data proof is required"
proof = receipt.uhdr[COSE_PHDR_VDP_LABEL]
assert COSE_RECEIPT_INCLUSION_PROOF_LABEL in proof, "Inclusion proof is required"
Expand Down

0 comments on commit d69da4c

Please sign in to comment.