MCPcopy Create free account
hub / github.com/SermoDigital/jose / Verify

Method Verify

crypto/hmac.go:47–58  ·  view source on GitHub ↗

Verify implements the Verify method from SigningMethod. For this signing method, must be a []byte.

(raw []byte, signature Signature, key interface{})

Source from the content-addressed store, hash-verified

45// Verify implements the Verify method from SigningMethod.
46// For this signing method, must be a []byte.
47func (m *SigningMethodHMAC) Verify(raw []byte, signature Signature, key interface{}) error {
48 keyBytes, ok := key.([]byte)
49 if !ok {
50 return ErrInvalidKey
51 }
52 hasher := hmac.New(m.Hash.New, keyBytes)
53 hasher.Write(raw)
54 if hmac.Equal(signature, hasher.Sum(nil)) {
55 return nil
56 }
57 return ErrSignatureInvalid
58}
59
60// Sign implements the Sign method from SigningMethod for this signing method.
61// Key must be a []byte.

Callers

nothing calls this directly

Calls 1

SumMethod · 0.45

Tested by

no test coverage detected