Repository navigation
feat: add x5chain header helpers to Header and HeaderBuilder - #130
Merged
Merged
Conversation
daviddrysdale
approved these changes
Oct 3, 2026
daviddrysdale
left a comment
Contributor
There was a problem hiding this comment.
Thanks for this, looks good other than the very minor things mentioned.
I'm no longer at Google so I can't run workflows or merge. @landiwiese ?
landiwiese
reviewed
Oct 6, 2026
landiwiese
left a comment
Collaborator
There was a problem hiding this comment.
I was able to successfully run the approval workflow and I can approve once David's comments are addressed. Thank you!
dcondrey
force-pushed
the
x5chain-header-helpers
branch
from
October 6, 2026 17:21
50a8b5d to
ea6ab8b
Compare
Contributor
Author
|
Comment have been resolved. |
Collaborator
|
@daviddrysdale Let me know if the updates look good to you then I'll approve. |
Contributor
|
LGTM |
landiwiese
approved these changes
Oct 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
cosethas no first-class support for thex5chainheader parameter (RFC 9360, IANA label 33), which carries a signer-first chain of DER-encoded X.509 certificates. Consumers that need it (e.g.CoseSign1verifiers) currently have to read/write it manually viaHeader.rest/HeaderBuilder::value(33, ...).Fix
Adds a new
X5Chaintype (AsCborValue-based, matching RFC 9360'sCOSE_X509 = bstr / [ 2* bstr ]CDDL: a single certificate encodes as a barebstr, two or more as an array, signer-first) plusHeader::x5chain(&self) -> Result<Option<X5Chain>>andHeaderBuilder::x5chain(self, chain) -> Self.This mirrors the crate's existing pattern for non-core registered parameters:
CoseKey::to_sec1_octet_string()/CoseKeyBuilder::new_ec2_pub_key_sec1_octet_string(), which read/write typed values out of the genericparams/restbag rather than promoting them to dedicated struct fields. Keeping x5chain inrest(rather than adding a newHeaderfield) keeps this purely additive: no breaking change toHeader's public fields, no change to decode behavior for other header parameters, and the existing duplicate-label detection onrestalready guards against also setting label 33 via the raw.value()escape hatch.Scope: this is "Layer 1" (header parsing) from the proposal in #129 by @magickli. Basic shape validation is included (non-empty chain, non-empty per-certificate DER, CDDL-correct bstr/array selection); no size/count limits beyond what RFC 9360 itself states, and no PKIX/CRL/crypto verification ("Layer 2" from the issue), which is out of scope for this crate's types-first design and left for the maintainers to decide where it should live.
Addresses #129 (narrower than the full issue: Layer 1 only, as the issue itself proposes splitting out).
Testing
cargo test(default features),cargo test --all-features,cargo test --features=std: pass, 133/133cargo clippy --all-features --all-targets -- -Dwarnings: cleancargo fmt --all -- --check(current nightly toolchain; CI pinsnightly-2025-04-01, not available locally): cleanRUSTDOCFLAGS="-Dwarnings" cargo doc --no-deps --document-private-items: cleancargo build --release --target thumbv6m-none-eabi(no_std): cleancargo +1.82.0 build --release --all-features(MSRV is 1.81; the 1.81 toolchain wasn't available locally, 1.82 was): cleanCHANGELOG.md is left untouched; this repo's history shows it's only updated in dedicated "Prep for release" commits, not individual feature PRs.