feat/add static secret cryptor#151
Open
jithinkunjachan wants to merge 4 commits into
Open
Conversation
e9fd80b to
c48f798
Compare
jithinkunjachan
commented
Jun 4, 2026
jithinkunjachan
commented
Jun 4, 2026
apatsap
requested changes
Jun 4, 2026
| // Currently only [InfoNameStaticSecret] is supported. The secret must be non-nil and non-empty. | ||
| func NewStaticSecret(name InfoName, secret *securemem.Data) (*StaticSecret, error) { | ||
| if name != InfoNameStaticSecret { | ||
| return nil, ErrRequest |
| return nil, ErrRequest | ||
| } | ||
|
|
||
| if secret == nil || len(secret.SecureBytes()) == 0 { |
| } | ||
|
|
||
| if secret == nil || len(secret.SecureBytes()) == 0 { | ||
| return nil, ErrRequest |
Signed-off-by: jK <33685667+jithinkunjachan@users.noreply.github.com>
Signed-off-by: jK <33685667+jithinkunjachan@users.noreply.github.com>
…and introduce CryptorSecret type Signed-off-by: jK <33685667+jithinkunjachan@users.noreply.github.com>
a17d8f9 to
ea4f363
Compare
apatsap
requested changes
Jun 5, 2026
| @@ -34,36 +37,40 @@ var ErrAllocatedDataNotFound = errors.New("allocated data not found in vault") | |||
| // NewAES256GCM returns a ready-to-use AES-256-GCM cryptor. | |||
| func NewAES256GCM() *AES256GCM { | |||
|
|
||
| // NewStaticSecret returns a StaticSecret for the given algorithm name and key material. | ||
| // Currently only [InfoNameStaticSecret] is supported. The secret must be non-nil and non-empty. | ||
| func NewStaticSecret(name cryptor.InfoName, secret *securemem.Data) (*StaticSecret, error) { |
Comment on lines
+22
to
+26
| // InfoNameAES256GCM indicates that the Cryptor supports AES-256 in Galois/Counter Mode (GCM). | ||
| const InfoNameAES256GCM InfoName = "AES256-GCM" | ||
|
|
||
| // InfoNameStaticSecret indicates a Cryptor that manages its own static key material. | ||
| const InfoNameStaticSecret InfoName = "AES256-GCM-STATIC-SECRET" |
There was a problem hiding this comment.
they should go into their individual pkgs
Comment on lines
+122
to
+129
| if req.Secret != nil { | ||
| if req.Secret.Algorithm == "" { | ||
| return fmt.Errorf("invalid secret algorithm: %w", ErrRequest) | ||
| } | ||
| if req.Secret.Data == nil || len(req.Secret.Data.SecureBytes()) == 0 { | ||
| return fmt.Errorf("invalid secret data: %w", ErrRequest) | ||
| } | ||
| } |
There was a problem hiding this comment.
we should put this into CryptorSecret.Validate()error and then just call it here, because we also use it in the decrypt validation.
Comment on lines
+146
to
+153
| if req.Secret != nil { | ||
| if req.Secret.Algorithm == "" { | ||
| return fmt.Errorf("invalid secret algorithm: %w", ErrRequest) | ||
| } | ||
| if req.Secret.Data == nil || len(req.Secret.Data.SecureBytes()) == 0 { | ||
| return fmt.Errorf("invalid secret data: %w", ErrRequest) | ||
| } | ||
| } |
There was a problem hiding this comment.
we should put this into CryptorSecret.Validate()error and then just call it here, because we also use it in the encrypt validation.
…ctors Signed-off-by: jK <33685667+jithinkunjachan@users.noreply.github.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.
No description provided.