feat:Add AES-GCM encryption and decryption utilities with tests#237
Merged
inhere merged 3 commits intogookit:masterfrom Mar 16, 2026
Merged
feat:Add AES-GCM encryption and decryption utilities with tests#237inhere merged 3 commits intogookit:masterfrom
inhere merged 3 commits intogookit:masterfrom
Conversation
Implement AES-GCM encryption and decryption functions with key and nonce validation.
There was a problem hiding this comment.
Pull request overview
This PR adds AES-GCM encryption/decryption helpers to the x/encodes/secutil package, along with unit tests to validate round-trip behavior and key/nonce validation.
Changes:
- Introduced
EncryptGCMandDecryptGCMutilities backed bycrypto/cipherAES-GCM. - Added sentinel errors for invalid AES key sizes and invalid GCM nonce sizes.
- Added tests covering valid AES key sizes, empty plaintext, and invalid key/nonce error paths.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| x/encodes/secutil/aes_gcm.go | Adds AES-GCM encrypt/decrypt helpers with key-size validation and nonce generation. |
| x/encodes/secutil/aes_gcm_test.go | Adds unit tests for round-trip encryption/decryption and error handling. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Contributor
Author
|
Hi @inhere, please take a look at this PR when you have a moment. Thanks! |
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.
This pull request introduces AES-GCM encryption and decryption utilities to the
secutilpackage, along with comprehensive tests to ensure correct functionality and error handling. The most important changes are grouped below:AES-GCM Encryption/Decryption Implementation:
EncryptGCMandDecryptGCMfunctions toaes_gcm.gofor encrypting and decrypting data using AES-GCM, including random nonce generation and key validation.ErrInvalidAESKeySizeandErrInvalidGCMNonceSizefor precise error reporting on invalid key and nonce sizes.Testing and Validation:
aes_gcm_test.gowith tests covering valid AES key sizes, empty plaintext handling, and error cases for invalid key and nonce sizes, ensuring robust functionality and edge case coverage.