feat(native-rust): message-header structure (V1/V2 header, header auth)#909
Open
lucasmcdonald3 wants to merge 7 commits into
Open
feat(native-rust): message-header structure (V1/V2 header, header auth)#909lucasmcdonald3 wants to merge 7 commits into
lucasmcdonald3 wants to merge 7 commits into
Conversation
added 6 commits
April 30, 2026 14:26
There was a problem hiding this comment.
Pull request overview
Implements core Rust-side serialization/deserialization for AWS Encryption SDK message headers, focusing on V1/V2 header bodies, header authentication, and associated field types as defined in the message-header spec.
Changes:
- Adds V1/V2 header body read/write implementations and shared header field types (version/type/content type, suite ID, message ID).
- Adds header authentication (V1 IV+tag, V2 tag-only) read/write.
- Introduces a suite of spec-assertion tests for header structure, header types, header auth, and V1/V2 header body layouts.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| esdk/src/message/mod.rs | Introduces the message module layout plus helper writers (NoopWriter, DigestWriter). |
| esdk/src/message/header.rs | Top-level header read/write orchestration and validation helpers. |
| esdk/src/message/header_types.rs | Defines header field enums/structs and shared read/write helpers (version/type/content type, suite ID, message ID). |
| esdk/src/message/header_auth.rs | Implements header authentication tag serialization/deserialization for V1 and V2. |
| esdk/src/message/v1_header_body.rs | Implements V1 header body serialization/deserialization (reserved bytes, IV length, frame length, etc.). |
| esdk/src/message/v2_header_body.rs | Implements V2 header body serialization/deserialization (commitment/suite data handling, etc.). |
| esdk/tests/test_header_structure.rs | Adds structure-level tests (endianness, ordering, EDK count constraints, frame length constraints). |
| esdk/tests/test_header_types.rs | Adds tests for version/type/content-type parsing and negative cases (including Base64-like input). |
| esdk/tests/test_header_auth.rs | Adds tests for V1/V2 header auth layout and tamper detection. |
| esdk/tests/test_v1_header_body.rs | Adds detailed V1 header body layout/field-size/order and negative-tamper tests. |
| esdk/tests/test_v2_header_body.rs | Adds detailed V2 header body layout/field-size/order tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+197
to
+218
| let mut header_buf = Vec::new(); | ||
|
|
||
| //= spec/data-format/message-header.md#structure | ||
| //# The header MUST consist of, in order, | ||
| //# Header Body, | ||
| //# and Header Authentication. | ||
|
|
||
| // Header Body | ||
|
|
||
| serialize_functions::write_bytes(&mut header_buf, &header.raw_header)?; | ||
|
|
||
| // Header Authentication | ||
|
|
||
| header_auth::write_header_auth_tag(&mut header_buf, &header.header_auth, &header.suite)?; | ||
| serialize_functions::write_bytes(ciphertext, &header_buf)?; | ||
|
|
||
| //= spec/client-apis/encrypt.md#authentication-tag | ||
| //# If the algorithm suite contains a signature algorithm and | ||
| //# this operation is [streaming](streaming.md) the encrypted message output to the caller, | ||
| //# this operation MUST input the serialized header to the signature algorithm as soon as it is serialized, | ||
| //# such that the serialized header isn't required to remain in memory to [construct the signature](#construct-the-signature). | ||
| serialize_functions::write_bytes(sig_digest, &header_buf)?; |
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.
Implements the message header body itself — V1 and V2 header bodies, header authentication, header-level types, and shared header helpers — per message-header.md.
Scope:
esdk/src/message/mod.rs— shared machinery (DigestWriter,NoopWriter).esdk/src/message/header.rs— top-level header wrapper.esdk/src/message/header_types.rs— header-level types (version, algorithm suite id, content type, etc.).esdk/src/message/header_auth.rs— header IV + auth tag.esdk/src/message/v1_header_body.rs— V1 header body serialization/deserialization.esdk/src/message/v2_header_body.rs— V2 header body serialization/deserialization.esdk/src/message/shared_header_functions.rs— helpers shared between V1 and V2.esdk/tests/test_header_structure.rs,esdk/tests/test_header_types.rs,esdk/tests/test_header_auth.rs,esdk/tests/test_v1_header_body.rs,esdk/tests/test_v2_header_body.rs.The reusable sub-structures the header embeds (encrypted data keys, encryption context, low-level serialize helpers) are reviewed separately in #901.
data-format/message.mdcitations are absorbed into this PR since they mostly live alongside the header machinery and have no dedicated implementation file.Note: CI does not run on this PR. This branch is scoped for focused review and intentionally omits test helpers, scaffolding, and other supporting code. Full code — including helpers, test infrastructure, and working tests — lives on the
aws-crypto-rust/unreviewedbranch.If you want more context or to actually run the tests, see
aws-crypto-rust/unreviewed.Related spec: data-format/message-header.md