feat: add AES Key Wrap/Unwrap (RFC 3394) support#26
Conversation
Co-Authored-By: Claude <noreply@anthropic.com>
|
Comment
You can also request review from a specific team by commenting 💡 If you see something that doesn't look right, check the configuration guide. |
There was a problem hiding this comment.
Pull request overview
Changes: New feature (1), Test improvement (1)
This PR adds AES Key Wrap/Unwrap support (RFC 3394) to the existing AES Cipher wrapper by delegating to the github.com/ProtonMail/go-crypto keywrap implementation, and introduces tests to validate round-trips and an RFC 3394 test vector.
Changes:
- Add
KeyWrap/KeyUnwrapmethods onaes.Cipherusing ProtonMail’skeywrapimplementation. - Add unit tests covering wrap/unwrap round-trip, an RFC 3394 known-answer vector, and invalid unwrap input.
- Promote
github.com/ProtonMail/go-cryptoto a direct dependency and bump the library version.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| VERSION.txt | Bumps module version to 1.13.0. |
| go.mod | Promotes github.com/ProtonMail/go-crypto to a direct dependency (required by new keywrap import). |
| aes/aes_cipher.go | Adds KeyWrap and KeyUnwrap methods implementing RFC 3394 via keywrap.Wrap/Unwrap. |
| aes/aes_cipher_test.go | Adds tests for wrap/unwrap round-trip, RFC 3394 test vector, and invalid unwrap input. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| wrapped, err := cipher.KeyWrap(plainKeyBytes) | ||
| if err != nil { | ||
| t.Fatalf("Did not expect a KeyWrap error but got %q", err) | ||
| } | ||
|
|
||
| unwrapped, err := cipher.KeyUnwrap(wrapped) | ||
| if err != nil { | ||
| t.Fatalf("Did not expect a KeyUnwrap error but got %q", err) | ||
| } |
| wrapped, err := cipher.KeyWrap(plainKeyBytes) | ||
| if err != nil { | ||
| t.Fatalf("Did not expect a KeyWrap error but got %q", err) | ||
| } |
Context
Add
KeyWrapandKeyUnwrapmethods to the AES Cipher struct, implementing RFC 3394 AES Key Wrap using the existinggithub.com/ProtonMail/go-cryptolibrary (already an indirect dependency, now promoted to direct).Summary:
KeyWrap(plainKeyBytes)andKeyUnwrap(wrappedKeyBytes)methods toCipherChecklist
User prompts that led to this change
"add a function KeyWrap in aes/aes_cipher.go, use existing library if needed. should implement AES Key Wrap (RFC 3394)"
"hmm that's a lot of code, any library that can just wrap, unwrap?"
"can you double check the code will work if I send in plainKeyBytes for wrap?"
"rename it to plainKeyBytes then, add test in aes/aes_cipher_test.go too."
🤖 Generated with Claude Code