1package keysutil
2
3import (
4	"crypto/sha1"
5	"crypto/sha256"
6	"crypto/sha512"
7	"hash"
8)
9
10type HashType uint32
11
12const (
13	_                     = iota
14	HashTypeSHA1 HashType = iota
15	HashTypeSHA2224
16	HashTypeSHA2256
17	HashTypeSHA2384
18	HashTypeSHA2512
19)
20
21type MarshalingType uint32
22
23const (
24	_                                 = iota
25	MarshalingTypeASN1 MarshalingType = iota
26	MarshalingTypeJWS
27)
28
29var (
30	HashTypeMap = map[string]HashType{
31		"sha1":     HashTypeSHA1,
32		"sha2-224": HashTypeSHA2224,
33		"sha2-256": HashTypeSHA2256,
34		"sha2-384": HashTypeSHA2384,
35		"sha2-512": HashTypeSHA2512,
36	}
37
38	HashFuncMap = map[HashType]func() hash.Hash{
39		HashTypeSHA1:    sha1.New,
40		HashTypeSHA2224: sha256.New224,
41		HashTypeSHA2256: sha256.New,
42		HashTypeSHA2384: sha512.New384,
43		HashTypeSHA2512: sha512.New,
44	}
45
46	MarshalingTypeMap = map[string]MarshalingType{
47		"asn1": MarshalingTypeASN1,
48		"jws":  MarshalingTypeJWS,
49	}
50)
51