refactor: follow the google go style guide
Document every package and exported identifier, return the log level from NewLogger instead of keeping it in a package variable, and stop tests from mutating the argon2 parameters. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
048e114fd9
commit
d20225982a
21 files changed
+147
-36
No files matched your search
@@ -12,6 +12,8 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// ErrUnknownKey is returned for values sealed with a key that was removed
|
||||
// from the keyring.
|
||||
var ErrUnknownKey = errors.New("sealed: unknown key id")
|
||||
|
||||
// Keyring holds one active key for sealing and any number of retired keys
|
||||
@@ -62,6 +64,7 @@ func (k *Keyring) Seal(plain, aad []byte) []byte {
|
||||
return aead.Seal(out, nonce, plain, aad)
|
||||
}
|
||||
|
||||
// Open decrypts a value produced by Seal with the same aad.
|
||||
func (k *Keyring) Open(sealed, aad []byte) ([]byte, error) {
|
||||
id, rest, ok := strings.Cut(string(sealed), ":")
|
||||
if !ok {
|
||||
@@ -78,6 +81,8 @@ func (k *Keyring) Open(sealed, aad []byte) ([]byte, error) {
|
||||
return aead.Open(nil, body[:aead.NonceSize()], body[aead.NonceSize():], aad)
|
||||
}
|
||||
|
||||
// NeedsReseal reports whether sealed was produced with a retired key and
|
||||
// should be rewritten.
|
||||
func (k *Keyring) NeedsReseal(sealed []byte) bool {
|
||||
id, _, _ := strings.Cut(string(sealed), ":")
|
||||
return id != k.active
|
||||
|
||||
Reference in new issue
Block a user