1
0
mirror of https://github.com/drone/drone-cli.git synced 2024-11-23 09:21:56 +01:00
drone-cli/vendor/github.com/99designs/httpsignatures-go/algorithm.go
2018-08-31 18:24:14 -07:00

32 lines
578 B
Go

package httpsignatures
import (
"crypto/sha1"
"crypto/sha256"
"errors"
"hash"
)
var (
AlgorithmHmacSha256 = &Algorithm{"hmac-sha256", sha256.New}
AlgorithmHmacSha1 = &Algorithm{"hmac-sha1", sha1.New}
ErrorUnknownAlgorithm = errors.New("Unknown Algorithm")
)
type Algorithm struct {
name string
hash func() hash.Hash
}
func algorithmFromString(name string) (*Algorithm, error) {
switch name {
case AlgorithmHmacSha1.name:
return AlgorithmHmacSha1, nil
case AlgorithmHmacSha256.name:
return AlgorithmHmacSha256, nil
}
return nil, ErrorUnknownAlgorithm
}