Skip to content

Handle "new-style" COSE envelop and validate transparent receipts#38

Draft
micromaomao wants to merge 12 commits into
mainfrom
transparant-fragments
Draft

Handle "new-style" COSE envelop and validate transparent receipts#38
micromaomao wants to merge 12 commits into
mainfrom
transparant-fragments

Conversation

@micromaomao
Copy link
Copy Markdown
Member

@micromaomao micromaomao commented May 11, 2026

Prepare for validating transparant fragments.

> sign1util print -in ~/cplat-0.2.14-dev.202603261649/package/LinuxBootFiles/transparent_reference_info.cose
checkCoseSign1 passed
CCF receipt 0 from esrp-cts-db.confidential-ledger.azure.com validation passed
iss: did:x509:0:sha256:I__iuL25oXEVFdTP_aBLx_eT1RPHbCQ_ECBQfYZpt9s::eku:1.3.6.1.4.1.311.76.59.1.2
feed: ContainerPlat-AMD-UVM
cty: application/json
pubkey: MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAxTSM4xP4oW53VIo0Q0rnOk99dFCjkrEoDr0Euwb9KHvMHGk30wkA62B5ey0MHtL6zwNCiLdJxatExQrm0xC8bv3q5fbBjGZ0yZGIMlTKrbI7zHz/ZF2pm0ojqSWlV2fcaEgM4UuyK4waxZPXm/Z37oGVdHSOJH0wNn1VqLIcfO6mhxq+rqUaKwNNjLIkmMyClTQKmRIAeB9bSd/TJlsHfaOCbodXKIjyiqqSZsBf5GFQDMKS+j3CzEPFIMg6eK0nADEEtygnq2wU0tT/yOL6F/nCRAExYulJ97rq/X2J1IERKQSTIuGQ7eCIL0j0rVLDoi9rq+Lf4vYUCayeKDnHmjJ6DmwPeXdQmoZftSvWLkFXdzkhT3ue8O5IIM8z0VkoVH2mgWeqsHuhdyJCuyELk4A33+Yo+OD+JLTNMeGLas7g8mKAbK6HnPf47v90ofh7BVytqpuugKvjei+UU46tgmj2jvbZuyj5j83V/Jha9yfyJquv0mA0G3LhDB4W8hrZAgMBAAE=
pubcert: MIIGazCCBFOgAwIBAgITMwAAAE+CVvVEUdIgyAAAAAAATzANBgkqhkiG9w0BAQwFADBVMQswCQYDV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: "application/json"
  15: {1: "did:x509:0:sha256:I__iuL25oXEVFdTP_aBLx_eT1RPHbCQ_ECBQfYZpt9s::eku:1.3.6.1.4.1.311.76.59.1.2", 2: "ContainerPlat-AMD-UVM", 6: 2026-03-26 17:01:36 +0000 UTC, "svn": 104}
  33: ...
  34: ...
all unprotected headers:
  394: ...
payload:
{
  "x-ms-sevsnpvm-launchmeasurement": "dc3f5a934489232a9b1818f12a0a88d2324ced00f8ab370f40451a76b7880bc3e211849a0739642d3d6c3b2b4bfb9866"
}

receipt 0:
  protected headers:
    ccf.v1: {"txid": "685.17237"}
    1: ES384
    4: "da7694f16def5a056ca96afb21e89a9450e4cc875e2de351da76d99544a3e849"
    395: 2
    15: {6: 1774544498, 1: "esrp-cts-db.confidential-ledger.azure.com", 2: "scitt.ccf.signature.v1"}
  unprotected headers:
    396:
      -1: inclusion proof
  payload: ""

Todo:

  • Needs to actually check that receipt matches the data
  • Mayve we should keep the existing output of sign1util print, and only prints the headers and receipts if --print-headers / --print-receipts flags are provided?

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the COSE_Sign1 unpack/validation path to understand “new-style” envelopes using CWT claim maps and to parse/validate COSE receipts (CCF profile), and updates sign1util to display headers/receipts and validate receipts by fetching issuer JWKS.

Changes:

  • Add COSE/CWT/receipt-related constants and extend UnpackAndValidateCOSE1CertChain to expose protected/unprotected headers and parse attached receipts.
  • Implement receipt validation (structure checks + Merkle root recomputation for CCF inclusion proofs + COSE_Sign1 signature verification).
  • Update sign1util to fetch JWKS, validate receipts, print headers/receipts, and add a global --log-level flag.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.

File Description
pkg/cosesign1/constants.go Introduces numeric constants for COSE header labels, receipt profile identifiers, and CWT claim keys.
pkg/cosesign1/check.go Adds receipt parsing/validation and “new-style” CWT claim extraction, and exposes headers/receipts on the unpacked object.
cmd/sign1util/main.go Adds JWKS fetching + receipt validation and expands verbose printing (headers + receipts) plus global log-level configuration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/cosesign1/check.go
Comment thread pkg/cosesign1/check.go Outdated
Comment thread pkg/cosesign1/check.go
Comment on lines +298 to +310
// Validate validates the COSE Receipt's structure and signature. See
// https://www.ietf.org/archive/id/draft-ietf-cose-merkle-tree-proofs-18.html
// for details about COSE Receipts.
//
// It checks that:
// - the protected header carries a vds (label 395),
// - the payload is detached,
// - the unprotected `vdp` header (label 396) contains at least one
// inclusion proof (key -1) encoded as a byte string,
// - the Merkle root recomputed from each inclusion proof verifies the
// receipt's COSE_Sign1 signature, using the public key in `keys` indexed by
// r.Kid.
func (r ParsedCOSEReceipt) Validate(keys map[string]crypto.PublicKey) error {
Comment thread cmd/sign1util/main.go Outdated
Comment thread cmd/sign1util/main.go Outdated
Comment thread cmd/sign1util/main.go Outdated
Comment thread cmd/sign1util/main.go Outdated
Comment thread cmd/sign1util/main.go Outdated
KenGordon
KenGordon previously approved these changes May 11, 2026
Copy link
Copy Markdown
Contributor

@KenGordon KenGordon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe break the key fetch out of main.

Comment thread cmd/sign1util/ccf_keyfetch.go Dismissed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

Comment thread pkg/cosesign1/check.go
Comment thread cmd/sign1util/ccf_keyfetch.go
Comment on lines +99 to +106
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("reading %s: %w", url, err)
}
var set jwkSet
if err := json.Unmarshal(body, &set); err != nil {
return nil, fmt.Errorf("parsing %s: %w", url, err)
}
Comment thread cmd/sign1util/main.go Outdated
@micromaomao micromaomao marked this pull request as draft May 12, 2026 23:50
@micromaomao
Copy link
Copy Markdown
Member Author

need to check that receipt actually matches the data

@micromaomao micromaomao force-pushed the transparant-fragments branch from 1e2b04c to e5006b1 Compare May 13, 2026 00:11
@micromaomao micromaomao force-pushed the transparant-fragments branch from e5006b1 to 4fa4ccf Compare May 13, 2026 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants