Skip to content

Commit

Permalink
Small v1.local fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cristaloleg committed Apr 12, 2024
1 parent 98ffb5a commit 01f0209
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 2 additions & 2 deletions v1loc.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (
)

const (
v1LocHeader = "v1.local."
v1LocNonceSize = 32
v1LocNonceHalf = v1LocNonceSize / 2
v1LocMacSize = 48 // const for crypty.SHA384.Size()
v1LocHeader = "v1.local."
)

func V1Encrypt(key []byte, payload, footer any, randBytes []byte) (string, error) {
Expand Down Expand Up @@ -96,7 +96,7 @@ func V1Decrypt(token string, key []byte, payload, footer any) error {
}

if !hmac.Equal(h.Sum(nil), mac) {
return fmt.Errorf("token signature: %w", ErrInvalidTokenAuth)
return ErrInvalidTokenAuth
}

block, err := aes.NewCipher(encKey)
Expand Down
4 changes: 1 addition & 3 deletions v1loc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ func TestV1Loc_Encrypt(t *testing.T) {
nonce := must(hex.DecodeString(tc.Nonce))

token, err := V1Encrypt(key, payload, footer, nonce)
if err != nil {
t.Fatal(err)
}
mustOk(t, err)
mustEqual(t, token, tc.Token)
})
}
Expand Down

0 comments on commit 01f0209

Please sign in to comment.