aboutsummaryrefslogtreecommitdiff
path: root/cryptfs/config_file.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2015-11-27 22:18:36 +0100
committerJakob Unterwurzacher2015-11-27 22:18:36 +0100
commit6acd772cf908908e3b0d817a78e64f98faaa8b7b (patch)
treed4ac426a5cf60a89b1b760bf392b3ba481c0d07c /cryptfs/config_file.go
parent798e5eb5e7c96384f40567bf7426621ca8373e15 (diff)
diriv: Define "DirIV" feature flag
(unused so far)
Diffstat (limited to 'cryptfs/config_file.go')
-rw-r--r--cryptfs/config_file.go31
1 files changed, 20 insertions, 11 deletions
diff --git a/cryptfs/config_file.go b/cryptfs/config_file.go
index f258a5e..1e7e3b3 100644
--- a/cryptfs/config_file.go
+++ b/cryptfs/config_file.go
@@ -4,14 +4,18 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
+ "log"
)
import "os"
const (
// The dot "." is not used in base64url (RFC4648), hence
// we can never clash with an encrypted file.
- ConfDefaultName = "gocryptfs.conf"
+ ConfDefaultName = "gocryptfs.conf"
+ // Understood Feature Flags
+ // Also teach isFeatureFlagKnown() about any additions
FlagPlaintextNames = "PlaintextNames"
+ FlagDirIV = "DirIV"
)
type ConfFile struct {
@@ -78,12 +82,8 @@ func LoadConfFile(filename string, password string) ([]byte, *ConfFile, error) {
return nil, nil, fmt.Errorf("Unsupported on-disk format %d\n", cf.Version)
}
- // Verify that we know all feature flags
for _, flag := range cf.FeatureFlags {
- switch flag {
- case FlagPlaintextNames:
- continue
- default:
+ if cf.isFeatureFlagKnown(flag) == false {
return nil, nil, fmt.Errorf("Unsupported feature flag %s\n", flag)
}
}
@@ -151,8 +151,21 @@ func (cf *ConfFile) WriteFile() error {
return nil
}
+// Verify that we understand a feature flag
+func (cf *ConfFile) isFeatureFlagKnown(flag string) bool {
+ switch flag {
+ case FlagPlaintextNames, FlagDirIV:
+ return true
+ default:
+ return false
+ }
+}
+
// isFeatureFlagSet - is the feature flag "flagWant" enabled?
-func (cf *ConfFile) isFeatureFlagSet(flagWant string) bool {
+func (cf *ConfFile) IsFeatureFlagSet(flagWant string) bool {
+ if !cf.isFeatureFlagKnown(flagWant) {
+ log.Panicf("BUG: Tried to use unsupported feature flag %s", flagWant)
+ }
for _, flag := range cf.FeatureFlags {
if flag == flagWant {
return true
@@ -160,7 +173,3 @@ func (cf *ConfFile) isFeatureFlagSet(flagWant string) bool {
}
return false
}
-
-func (cf *ConfFile) PlaintextNames() bool {
- return cf.isFeatureFlagSet(FlagPlaintextNames)
-}