// RegisterSigningMethod registers the crypto.SigningMethod in the global map. // This is typically done inside the caller's init function. func RegisterSigningMethod(sm crypto.SigningMethod) { if GetSigningMethod(sm.Alg()) != nil { panic("jose/jws: cannot duplicate signing methods") } if !sm.Hasher().Available() { panic("jose/jws: specific hash is unavailable") } mu.Lock() signingMethods[sm.Alg()] = sm mu.Unlock() }
func (s *sigHead) verify(pl []byte, key interface{}, method crypto.SigningMethod) error { if s.method.Alg() != method.Alg() || s.method.Hasher() != method.Hasher() { return ErrMismatchedAlgorithms } return method.Verify(format(s.Protected, pl), s.Signature, key) }