refactor(kms): split create_key / encrypt / verify / create_alias#352
Merged
vieiralucas merged 1 commit intomainfrom Apr 13, 2026
Merged
refactor(kms): split create_key / encrypt / verify / create_alias#352vieiralucas merged 1 commit intomainfrom
vieiralucas merged 1 commit intomainfrom
Conversation
- create_key: extract CreateKeyInput::from_body for the 30-line parse + validate block (length checks, enum checks, key-spec validation, tag parsing). The remainder of create_key reads as state-mutation phases. - encrypt: extract decode_plaintext (length validation 1..=4096) and build_encrypt_ciphertext (the imported-material XOR vs. fakecloud envelope branch). - verify: extract require_non_empty_b64 (shared by Message + Signature), validate_key_usage_signing, and validate_signing_algorithm. - create_alias: extract validate_alias_name (prefix, reserved aws/, invalid characters, regex pattern) and validate_alias_target (alias-of-alias rejection); add a shared require_string_field helper for the AliasName/TargetKeyId required-string boilerplate.
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.
Summary
Apply the same `*Input::from_body` + per-phase helper pattern that PRs #329 (RDS) and #347 (RDS) used, to the four long KMS functions.
Test plan
Summary by cubic
Refactored KMS handlers to split long functions into small, focused helpers for clearer flow and reuse, with no behavior changes. Affects
create_key,encrypt,verify, andcreate_aliasincrates/fakecloud-kms/src/service.rs.create_key: addedCreateKeyInput::from_bodyfor parse/validate (lengths, enums, key-spec, tags); remaining code focuses on state changes.encrypt: addeddecode_plaintext(1..=4096 bytes) andbuild_encrypt_ciphertext(imported-material XOR vs. fake envelope).verify: addedrequire_non_empty_b64,validate_key_usage_signing,validate_signing_algorithm.create_alias: addedrequire_string_field,validate_alias_name(prefix/reserved/regex),validate_alias_target(no alias-of-alias).Written for commit 18cb646. Summary will update on new commits.