libgocryptfs/internal/configfile/feature_flags.go

68 lines
1.8 KiB
Go
Raw Normal View History

package configfile
type flagIota int
const (
2016-10-02 06:14:18 +02:00
// FlagPlaintextNames indicates that filenames are unencrypted.
FlagPlaintextNames flagIota = iota
2016-10-02 06:14:18 +02:00
// FlagDirIV indicates that a per-directory IV file is used.
FlagDirIV
2016-10-02 06:14:18 +02:00
// FlagEMENames indicates EME (ECB-Mix-ECB) filename encryption.
// This flag is mandatory since gocryptfs v1.0.
FlagEMENames
2016-10-02 06:14:18 +02:00
// FlagGCMIV128 indicates 128-bit GCM IVs.
// This flag is mandatory since gocryptfs v1.0.
FlagGCMIV128
2016-10-02 06:14:18 +02:00
// FlagLongNames allows file names longer than 176 bytes.
FlagLongNames
2016-10-02 06:14:18 +02:00
// FlagAESSIV selects an AES-SIV based crypto backend.
FlagAESSIV
// FlagRaw64 enables raw (unpadded) base64 encoding for file names
FlagRaw64
)
// knownFlags stores the known feature flags and their string representation
2016-10-02 06:14:18 +02:00
var knownFlags = map[flagIota]string{
FlagPlaintextNames: "PlaintextNames",
FlagDirIV: "DirIV",
FlagEMENames: "EMENames",
FlagGCMIV128: "GCMIV128",
FlagLongNames: "LongNames",
FlagAESSIV: "AESSIV",
FlagRaw64: "Raw64",
}
// Filesystems that do not have these feature flags set are deprecated.
2016-10-02 06:14:18 +02:00
var requiredFlagsNormal = []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-10-02 06:14:18 +02:00
var requiredFlagsPlaintextNames = []flagIota{
FlagGCMIV128,
}
2016-10-02 06:14:18 +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
}
2016-10-02 06:14:18 +02:00
// IsFeatureFlagSet returns true if the feature flag "flagWant" is enabled.
func (cf *ConfFile) IsFeatureFlagSet(flagWant flagIota) bool {
flagString := knownFlags[flagWant]
for _, flag := range cf.FeatureFlags {
if flag == flagString {
return true
}
}
return false
}