From 39e243b7ff79e9b9fc68907b9d3937a9d37eea52 Mon Sep 17 00:00:00 2001 From: Oleg Kovalov Date: Fri, 12 Apr 2024 23:55:33 +0200 Subject: [PATCH] Small v1.local fixes (#7) --- v1loc.go | 4 ++-- v1loc_test.go | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/v1loc.go b/v1loc.go index 0e3551e..ea01e39 100644 --- a/v1loc.go +++ b/v1loc.go @@ -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) { @@ -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) diff --git a/v1loc_test.go b/v1loc_test.go index 7c284ef..25f9398 100644 --- a/v1loc_test.go +++ b/v1loc_test.go @@ -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) }) }