// RegisterSigningMethod registers the crypto.SigningMethod in the global map. // This is typically done inside the caller's init function. func RegisterSigningMethod(sm crypto.SigningMethod) { alg := sm.Alg() if GetSigningMethod(alg) != nil { panic("jose/jws: cannot duplicate signing methods") } if !sm.Hasher().Available() { panic("jose/jws: specific hash is unavailable") } mu.Lock() signingMethods[alg] = sm mu.Unlock() }
// RemoveSigningMethod removes the crypto.SigningMethod from the global map. func RemoveSigningMethod(sm crypto.SigningMethod) { mu.Lock() delete(signingMethods, sm.Alg()) 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) }