AES key wrapping (AES-KW RFC 3394 / AES-KWP RFC 5649)#96
Merged
Conversation
Adds CASAES128KeyWrap / CASAES256KeyWrap traits implemented by the new CASAES128KW / CASAES256KW structs in symmetric::aes_kw, backed by the RustCrypto aes-kw crate. Supports unpadded KW and padded KWP wrap/unwrap plus KEK generation, with input validation per NIST SP 800-38F. Tested against the RFC 3394 section 4 known-answer vectors (128/256-bit KEKs) and the full Wycheproof AES-WRAP and AES-KWP vector files, plus round-trip, KEK-rotation, and tamper/negative cases. Closes #95 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Closes #95
Adds AES Key Wrap (AES-KW, RFC 3394 / NIST SP 800-38F KW) and AES Key Wrap with Padding (AES-KWP, RFC 5649 / KWP) so users can rotate the KEK protecting a data key by re-wrapping it instead of re-encrypting the data.
Implementation
CASAES128KeyWrap/CASAES256KeyWraptraits insymmetric::cas_symmetric_encryption, implemented by the newCASAES128KW/CASAES256KWstructs insymmetric::aes_kw, following the existing two-file module pattern.aes-kwcrate (v0.2.1, matching the project'saes0.8 stack), as suggested in the issue.generate_kek,wrap_key/unwrap_key(unpadded KW) andwrap_key_with_padding/unwrap_key_with_padding(KWP).CasErrorvariants (no ABI change): wrong KEK length →InvalidKey; KW key data below two semiblocks or not semiblock-aligned, empty KWP key data, or malformed wrapped-key lengths →InvalidInput; integrity-check/padding failures on unwrap →DecryptionFailed.Tests (
tests/aes_kw.rs, 14 tests)tests/data/aes/:aes_wrap_test.json(165 cases) andaes_kwp_test.json(254 cases). All 128/256-bit groups run:validcases must wrap to the exact ciphertext and unwrap back;invalidcases must be rejected;acceptablecases (64-bit key data, below the SP 800-38F two-semiblock minimum) are rejected by our strict validation. The RFC 5649 worked examples both use a 192-bit KEK, so KWP known-answer coverage comes from these vectors.Also adds an AES Key Wrapping section to
docs/EXAMPLES.mdand bumps the version to 0.2.89.🤖 Generated with Claude Code