Skip to content

Avoid phdr/payload copy on TBS#22

Merged
maxtropets merged 1 commit intomainfrom
f/perf-serialise
Mar 20, 2026
Merged

Avoid phdr/payload copy on TBS#22
maxtropets merged 1 commit intomainfrom
f/perf-serialise

Conversation

@maxtropets
Copy link
Copy Markdown
Owner

@maxtropets maxtropets commented Mar 20, 2026

CborValue is convenient for handling owned vecs, but results in extra-copy for TBS construction.

This PR avoids that extra copy, and does not change the lib interface.

This also pins dependencies via commit hashes rather than tags for better reproducibility prospective.

Copy link
Copy Markdown
Contributor

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 reduces allocations/copies during COSE Sig_structure (TBS) construction by switching from owned CborValue building to a borrowed-slice CBOR serialization path, while keeping the crate’s externally re-exported API unchanged.

Changes:

  • Fixes an error message typo in sign_with_ctx.
  • Introduces CborSlice + serialize_array for CBOR array serialization from borrowed data.
  • Updates COSE sig_structure construction to serialize directly from phdr/payload slices to avoid intermediate Vec<u8> copies.

Reviewed changes

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

File Description
src/sign.rs Improves the signature-size error message text.
src/cose.rs Uses borrowed-slice CBOR array serialization for TBS construction to avoid copying phdr/payload.
src/cbor.rs Adds a small borrowed CBOR representation (CborSlice) and a helper to serialize an array without intermediate copies.

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

@maxtropets maxtropets merged commit d78ba0d into main Mar 20, 2026
1 check passed
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.

2 participants