2020-08-19 16:47:18 -04:00
|
|
|
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
|
2020-08-20 13:34:03 -04:00
|
|
|
KeyPurposeUnknown KeyPurpose = iota
|
2020-08-19 16:47:18 -04:00
|
|
|
|
|
|
|
|
// KeyPurposeDatabase is used for general encryption needs for most values
|
|
|
|
|
// in the database, excluding the oplog
|
2020-08-20 13:34:03 -04:00
|
|
|
KeyPurposeDatabase
|
2020-08-19 16:47:18 -04:00
|
|
|
|
|
|
|
|
// KeyPurposeOplog is used for oplogs
|
2020-08-20 13:34:03 -04:00
|
|
|
KeyPurposeOplog
|
|
|
|
|
|
|
|
|
|
// KeyPurposeRecovery is used for recovery access
|
|
|
|
|
KeyPurposeRecovery
|
2020-08-25 00:20:50 -04:00
|
|
|
|
|
|
|
|
// KeyPurposeTokens is used for token encryption
|
|
|
|
|
KeyPurposeTokens
|
2020-08-19 16:47:18 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// 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"
|
2020-08-20 13:34:03 -04:00
|
|
|
case KeyPurposeRecovery:
|
|
|
|
|
return "recovery"
|
2020-08-25 00:20:50 -04:00
|
|
|
case KeyPurposeTokens:
|
|
|
|
|
return "tokens"
|
2020-08-19 16:47:18 -04:00
|
|
|
default:
|
|
|
|
|
return "unknown"
|
|
|
|
|
}
|
|
|
|
|
}
|