hmac.go
func NewHMACSigner(alg Algorithm) func(Store, crypto.Hash) (Signer, error) {
	return func(store Store, hash crypto.Hash) (Signer, error) {
		var ok bool
		var keyRaw interface{}
		var key []byte

		// check private key
		if keyRaw, ok = store.PrivateKey(); !ok {
			return nil, ErrMissingPrivateKey
		}

		// check key type
		if key, ok = keyRaw.([]byte); !ok {
			return nil, ErrInvalidPrivateKey
		}

		return &HmacSigner{
			alg:  alg,
			hash: hash,
			key:  key,
		}, nil
	}
}
func NewHMACSigner(alg Algorithm) func(Store, crypto.Hash) (Signer, error) {
	return func(store Store, hash crypto.Hash) (Signer, error) {
		var ok bool
		var keyRaw interface{}
		var key []byte

		// check private key
		if keyRaw, ok = store.PrivateKey(); !ok {
			return nil, ErrMissingPrivateKey
		}

		// check key type
		if key, ok = keyRaw.([]byte); !ok {
			return nil, ErrInvalidPrivateKey
		}

		return &HmacSigner{
			alg:  alg,
			hash: hash,
			key:  key,
		}, nil
	}
}
func NewHMACSigner ( alg Algorithm ) func ( Store , crypto . Hash ) ( Signer , error ) { return func ( store Store , hash crypto . Hash ) ( Signer , error ) { var ok bool var keyRaw interface { } var key [ ] byte // check private key if keyRaw , ok = store . PrivateKey ( ) ; ! ok { return nil , ErrMissingPrivateKey } // check key type if key , ok = keyRaw . ( [ ] byte ) ; ! ok { return nil , ErrInvalidPrivateKey } return & HmacSigner { alg : alg , hash : hash , key : key , } , nil } }
// NewHMACSigner creates a HMAC Signer for the specified Algorithm.
NewHMACSigner creates a HMAC Signer for the specified Algorithm .