Skip to content

feat(native-rust): encrypt behavior#921

Merged
lucasmcdonald3 merged 31 commits into
aws-crypto-rust/mainlinefrom
aws-crypto-rust/encrypt-review
Jun 29, 2026
Merged

feat(native-rust): encrypt behavior#921
lucasmcdonald3 merged 31 commits into
aws-crypto-rust/mainlinefrom
aws-crypto-rust/encrypt-review

Conversation

@lucasmcdonald3

Copy link
Copy Markdown
Contributor

Implements encrypt behavior per client-apis/encrypt.md.

Scope:

  • esdk/src/encrypt.rs — encrypt entry point, default-CMM wrapping, encryption-context validation, body and signature construction, output assembly.
  • Tests:
    • esdk/tests/test_encrypt_behavior.rs — top-level encrypt behavior.
    • esdk/tests/test_encrypt_missing_annotations.rs — coverage for spec requirements not directly tied to a sub-routine.
    • esdk/tests/test_construct_the_signature.rs — signature construction.
    • esdk/tests/test_cmm_algorithm_suite_override.rs — algorithm-suite override behavior.
    • esdk/tests/test_post_cmm_validation.rs — post-CMM-call material validation.
    • esdk/tests/test_keyring_to_default_cmm.rs — keyring-to-default-CMM wrapping.
    • esdk/tests/test_required_encryption_context.rs — required encryption context handling.

The public input/output types (EncryptInput, EncryptOutput) and streaming traits used by this entry point are reviewed in #919. Header, body, body-AAD, and footer serialization called from here are reviewed in their own PRs (#909, #918, #900, #898). Decrypt behavior is reviewed separately in a follow-up PR.


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/unreviewed branch.

If you want more context or to actually run the tests, see aws-crypto-rust/unreviewed.

Related spec:

Lucas McDonald added 21 commits May 27, 2026 10:09
@lucasmcdonald3
lucasmcdonald3 requested a review from Copilot June 12, 2026 19:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Implements the native Rust encrypt operation behavior per the spec, including CMM/materials acquisition, header/body/footer construction, and streaming support, with targeted behavior-driven tests validating key spec requirements.

Changes:

  • Added esdk/src/encrypt.rs implementing the encrypt entry point and its step-wise construction (materials → header → body → optional signature/footer).
  • Added tests covering encrypt behavior, signature construction/verification, CMM suite override behavior, post-CMM validation scenarios, keyring→default-CMM wrapping, and required encryption context handling.
  • Added cross-compatibility tests to prove keyring inputs are wrapped via the default CMM behaviorally (encrypt/decrypt interchange).

Reviewed changes

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

Show a summary per file
File Description
esdk/src/encrypt.rs Implements encrypt/streaming encrypt flow, header/body/footer assembly, and encryption-context validation.
esdk/tests/test_encrypt_behavior.rs Broad spec-driven tests for encrypt behavior and output structure.
esdk/tests/test_construct_the_signature.rs Validates signature/footer construction and verification semantics.
esdk/tests/test_cmm_algorithm_suite_override.rs Ensures encryption uses the suite returned by the CMM even if it differs from input.
esdk/tests/test_post_cmm_validation.rs Tests commitment-policy validation outcomes and identity-KDF decrypt coverage.
esdk/tests/test_keyring_to_default_cmm.rs Cross-compat tests proving keyring inputs are wrapped via default CMM behavior.
esdk/tests/test_required_encryption_context.rs Tests required encryption context filtering/reproduction through CMM and decrypt.

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

Comment thread esdk/src/encrypt.rs Outdated
Comment thread esdk/src/encrypt.rs
Comment thread esdk/tests/test_required_encryption_context.rs Outdated
Comment thread esdk/tests/test_required_encryption_context.rs Outdated
Comment thread esdk/tests/test_required_encryption_context.rs Outdated
Comment thread esdk/src/encrypt.rs Outdated
let per_frame_overhead = 4 + IV_LEN + AUTH_TAG_LEN;
let frame_len = frame_length_usize.saturating_add(per_frame_overhead);
let header_overhead = 1024_usize;
let total_size = frames

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Clarification: What will happen if frame length is u32 MAX for a tiny bit of plaintext? We would probably reserve a larger memory space which may not be required in real.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Correct, updated

@lucasmcdonald3
lucasmcdonald3 merged commit ae9edd8 into aws-crypto-rust/mainline Jun 29, 2026
1 check passed
@lucasmcdonald3
lucasmcdonald3 deleted the aws-crypto-rust/encrypt-review branch June 29, 2026 20:19
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.

3 participants