2019-01-23 17:31:34 +00:00
|
|
|
package keysutil
|
|
|
|
|
|
|
|
import (
|
2019-02-07 23:31:31 +00:00
|
|
|
"crypto/sha1"
|
2019-01-23 17:31:34 +00:00
|
|
|
"crypto/sha256"
|
|
|
|
"crypto/sha512"
|
|
|
|
"hash"
|
|
|
|
)
|
|
|
|
|
|
|
|
type HashType uint32
|
|
|
|
|
|
|
|
const (
|
2019-02-07 23:31:31 +00:00
|
|
|
_ = iota
|
|
|
|
HashTypeSHA1 HashType = iota
|
|
|
|
HashTypeSHA2224
|
2019-01-23 17:31:34 +00:00
|
|
|
HashTypeSHA2256
|
|
|
|
HashTypeSHA2384
|
|
|
|
HashTypeSHA2512
|
|
|
|
)
|
|
|
|
|
|
|
|
type MarshalingType uint32
|
|
|
|
|
|
|
|
const (
|
|
|
|
_ = iota
|
|
|
|
MarshalingTypeASN1 MarshalingType = iota
|
|
|
|
MarshalingTypeJWS
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
HashTypeMap = map[string]HashType{
|
2019-02-07 23:31:31 +00:00
|
|
|
"sha1": HashTypeSHA1,
|
2019-01-23 17:31:34 +00:00
|
|
|
"sha2-224": HashTypeSHA2224,
|
|
|
|
"sha2-256": HashTypeSHA2256,
|
|
|
|
"sha2-384": HashTypeSHA2384,
|
|
|
|
"sha2-512": HashTypeSHA2512,
|
|
|
|
}
|
|
|
|
|
|
|
|
HashFuncMap = map[HashType]func() hash.Hash{
|
2019-02-07 23:31:31 +00:00
|
|
|
HashTypeSHA1: sha1.New,
|
2019-01-23 17:31:34 +00:00
|
|
|
HashTypeSHA2224: sha256.New224,
|
|
|
|
HashTypeSHA2256: sha256.New,
|
|
|
|
HashTypeSHA2384: sha512.New384,
|
|
|
|
HashTypeSHA2512: sha512.New,
|
|
|
|
}
|
|
|
|
|
|
|
|
MarshalingTypeMap = map[string]MarshalingType{
|
|
|
|
"asn1": MarshalingTypeASN1,
|
|
|
|
"jws": MarshalingTypeJWS,
|
|
|
|
}
|
|
|
|
)
|