2016-06-05 12:53:10 +02:00
|
|
|
package configfile
|
|
|
|
|
|
|
|
type flagIota int
|
|
|
|
|
|
|
|
const (
|
|
|
|
FlagPlaintextNames flagIota = iota
|
|
|
|
FlagDirIV
|
|
|
|
FlagEMENames
|
|
|
|
FlagGCMIV128
|
|
|
|
FlagLongNames
|
2016-09-26 23:25:13 +02:00
|
|
|
FlagAESSIV
|
2016-06-05 12:53:10 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// knownFlags stores the known feature flags and their string representation
|
|
|
|
var knownFlags map[flagIota]string = map[flagIota]string{
|
|
|
|
FlagPlaintextNames: "PlaintextNames",
|
|
|
|
FlagDirIV: "DirIV",
|
|
|
|
FlagEMENames: "EMENames",
|
|
|
|
FlagGCMIV128: "GCMIV128",
|
|
|
|
FlagLongNames: "LongNames",
|
2016-09-26 23:25:13 +02:00
|
|
|
FlagAESSIV: "AESSIV",
|
2016-06-05 12:53:10 +02:00
|
|
|
}
|
|
|
|
|
2016-06-06 23:13:10 +02:00
|
|
|
// Filesystems that do not have these feature flags set are deprecated.
|
|
|
|
var requiredFlagsNormal []flagIota = []flagIota{
|
|
|
|
FlagDirIV,
|
|
|
|
FlagEMENames,
|
|
|
|
FlagGCMIV128,
|
|
|
|
}
|
|
|
|
|
|
|
|
// Filesystems without filename encryption obviously don't have or need the
|
2016-09-20 21:58:04 +02:00
|
|
|
// filename related feature flags.
|
2016-06-06 23:13:10 +02:00
|
|
|
var requiredFlagsPlaintextNames []flagIota = []flagIota{
|
|
|
|
FlagGCMIV128,
|
|
|
|
}
|
|
|
|
|
2016-06-05 12:53:10 +02:00
|
|
|
// isFeatureFlagKnown verifies that we understand a feature flag
|
|
|
|
func (cf *ConfFile) isFeatureFlagKnown(flag string) bool {
|
|
|
|
for _, knownFlag := range knownFlags {
|
|
|
|
if knownFlag == flag {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
// isFeatureFlagSet - is the feature flag "flagWant" enabled?
|
|
|
|
func (cf *ConfFile) IsFeatureFlagSet(flagWant flagIota) bool {
|
|
|
|
flagString := knownFlags[flagWant]
|
|
|
|
for _, flag := range cf.FeatureFlags {
|
|
|
|
if flag == flagString {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|