コード例 #1
0
ファイル: signing_methods.go プロジェクト: andrefreitas/jose
// 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()
}
コード例 #2
0
ファイル: jws_validate.go プロジェクト: fujitsu-cf/cli
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)
}