From c12025f87bb4294468619ee47f3fdc2288a0f823 Mon Sep 17 00:00:00 2001 From: ss49919201 Date: Sun, 24 Dec 2023 10:50:45 +0900 Subject: [PATCH 1/2] fix: return ErrHashUnavailable when hash is unavailable --- hmac.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hmac.go b/hmac.go index 96c62722..594ca019 100644 --- a/hmac.go +++ b/hmac.go @@ -91,7 +91,7 @@ func (m *SigningMethodHMAC) Verify(signingString string, sig []byte, key interfa func (m *SigningMethodHMAC) Sign(signingString string, key interface{}) ([]byte, error) { if keyBytes, ok := key.([]byte); ok { if !m.Hash.Available() { - return nil, newError("HMAC sign expects []byte", ErrInvalidKeyType) + return nil, ErrHashUnavailable } hasher := hmac.New(m.Hash.New, keyBytes) From 3386e5508e9ab408f9b9e91090618709246849b8 Mon Sep 17 00:00:00 2001 From: ss49919201 Date: Sun, 24 Dec 2023 10:53:42 +0900 Subject: [PATCH 2/2] fix: return ErrInvalidKeyType with message when Key is invalid type --- hmac.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hmac.go b/hmac.go index 594ca019..aca600ce 100644 --- a/hmac.go +++ b/hmac.go @@ -100,5 +100,5 @@ func (m *SigningMethodHMAC) Sign(signingString string, key interface{}) ([]byte, return hasher.Sum(nil), nil } - return nil, ErrInvalidKeyType + return nil, newError("HMAC sign expects []byte", ErrInvalidKeyType) }