-
Notifications
You must be signed in to change notification settings - Fork 278
/
const.go
106 lines (93 loc) · 2.52 KB
/
const.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package kms
// KeyPurpose allows an application to specify the reason they need a key; this
// is used to select which DEK to return
type KeyPurpose uint
const (
// KeyPurposeUnknown is the default, and indicates that a correct purpose
// wasn't specified
KeyPurposeUnknown KeyPurpose = iota
// KeyPurposeDatabase is used for general encryption needs for most values
// in the database, excluding the oplog
KeyPurposeDatabase
// KeyPurposeOplog is used for oplogs
KeyPurposeOplog
// KeyPurposeRecovery is used for recovery access
KeyPurposeRecovery
// KeyPurposeTokens is used for token encryption
KeyPurposeTokens
// KeyPurposeSessions is used as a base key to derive session-specific encryption keys
KeyPurposeSessions
// KeyPurposeOidc is used for encrypting oidc states included in
// authentication URLs
KeyPurposeOidc
)
// String returns the key purpose cast as a string, just so it can be called as
// a function instead of direct casting elsewhere, yw
func (k KeyPurpose) String() string {
switch k {
case KeyPurposeDatabase:
return "database"
case KeyPurposeOplog:
return "oplog"
case KeyPurposeRecovery:
return "recovery"
case KeyPurposeTokens:
return "tokens"
case KeyPurposeSessions:
return "sessions"
case KeyPurposeOidc:
return "oidc"
default:
return "unknown"
}
}
// KeyType allows the kms repo to return a map[KeyType]Key which can be easily
// used without type casting.
type KeyType uint
const (
KeyTypeUnknown KeyType = iota
KeyTypeRootKey
KeyTypeRootKeyVersion
KeyTypeDatabaseKey
KeyTypeDatabaseKeyVersion
KeyTypeOplogKey
KeyTypeOplogKeyVersion
KeyTypeTokenKey
KeyTypeTokenKeyVersion
KeyTypeSessionKey
KeyTypeSessionKeyVersion
KeyTypeOidcKey
KeyTypeOidcKeyVersion
)
// String returns the key type cast as a string, just so it can be called as
// a function instead of direct casting elsewhere, yw
func (k KeyType) String() string {
switch k {
case KeyTypeRootKey:
return "rootKey"
case KeyTypeRootKeyVersion:
return "rootKeyVersion"
case KeyTypeDatabaseKey:
return "databaseKey"
case KeyTypeDatabaseKeyVersion:
return "databaseKeyVersion"
case KeyTypeOplogKey:
return "oplogKey"
case KeyTypeOplogKeyVersion:
return "oplogKeyVersion"
case KeyTypeTokenKey:
return "tokenKey"
case KeyTypeTokenKeyVersion:
return "tokenKeyVersion"
case KeyTypeSessionKey:
return "sessionKey"
case KeyTypeSessionKeyVersion:
return "sessionKeyVersion"
case KeyTypeOidcKey:
return "oidcKey"
case KeyTypeOidcKeyVersion:
return "oidcKeyVersion"
default:
return "unknown"
}
}