-
Notifications
You must be signed in to change notification settings - Fork 0
/
key.go
57 lines (46 loc) · 1.08 KB
/
key.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package core
// Encryption key lifecycle states.
const (
StateActive = "ACTIVE"
StateDisabled = "DISABLED"
StateDeleted = "DELETED"
)
// KeyState presents encryption key lifecycle states
type KeyState string
// Key presents the plain text value of an encryption key
type Key string
// String overwrites the default to string behavior to protect the key sensitive value.
func (k Key) String() string {
return "KEY-*****"
}
// KeyMap presents a map of Keys indexed by keyID.
type KeyMap map[string]Key
// NewKeyMap returns a new empty KeyMap.
func NewKeyMap() KeyMap {
return make(map[string]Key)
}
// KeyIDs returns Key IDs.
func (km KeyMap) KeyIDs() []string {
subIDs := []string{}
for subID := range km {
subIDs = append(subIDs, subID)
}
return subIDs
}
// IDKey presents a pair to combine a Key and its ID.
type IDKey struct {
id string
key Key
}
// NewIDKey returns new IdKey value of the given Key and ID.
func NewIDKey(id, key string) IDKey {
return IDKey{
id, Key(key),
}
}
func (ik IDKey) ID() string {
return ik.id
}
func (ik IDKey) Key() Key {
return ik.key
}