From 2a9dea2973a6141e8efdf8bd26d8ddb2d2c35fc4 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Fri, 20 Aug 2021 15:57:40 +0200 Subject: -deterministic-names: accept flag on -init And store it in gocryptfs.conf (=remove DirIV feature flag). --- internal/configfile/config_file.go | 7 +++++-- internal/configfile/config_test.go | 8 ++++---- internal/configfile/feature_flags.go | 1 - 3 files changed, 9 insertions(+), 7 deletions(-) (limited to 'internal/configfile') diff --git a/internal/configfile/config_file.go b/internal/configfile/config_file.go index 40dda38..b54bd51 100644 --- a/internal/configfile/config_file.go +++ b/internal/configfile/config_file.go @@ -80,7 +80,8 @@ func randBytesDevRandom(n int) []byte { // "password" and write it to "filename". // Uses scrypt with cost parameter logN. func Create(filename string, password []byte, plaintextNames bool, - logN int, creator string, aessiv bool, devrandom bool, fido2CredentialID []byte, fido2HmacSalt []byte) error { + logN int, creator string, aessiv bool, devrandom bool, + fido2CredentialID []byte, fido2HmacSalt []byte, deterministicNames bool) error { var cf ConfFile cf.filename = filename cf.Creator = creator @@ -92,7 +93,9 @@ func Create(filename string, password []byte, plaintextNames bool, if plaintextNames { cf.FeatureFlags = append(cf.FeatureFlags, knownFlags[FlagPlaintextNames]) } else { - cf.FeatureFlags = append(cf.FeatureFlags, knownFlags[FlagDirIV]) + if !deterministicNames { + cf.FeatureFlags = append(cf.FeatureFlags, knownFlags[FlagDirIV]) + } cf.FeatureFlags = append(cf.FeatureFlags, knownFlags[FlagEMENames]) cf.FeatureFlags = append(cf.FeatureFlags, knownFlags[FlagLongNames]) cf.FeatureFlags = append(cf.FeatureFlags, knownFlags[FlagRaw64]) diff --git a/internal/configfile/config_test.go b/internal/configfile/config_test.go index ce35531..17ca80c 100644 --- a/internal/configfile/config_test.go +++ b/internal/configfile/config_test.go @@ -62,7 +62,7 @@ func TestLoadV2StrangeFeature(t *testing.T) { } func TestCreateConfDefault(t *testing.T) { - err := Create("config_test/tmp.conf", testPw, false, 10, "test", false, false, nil, nil) + err := Create("config_test/tmp.conf", testPw, false, 10, "test", false, false, nil, nil, false) if err != nil { t.Fatal(err) } @@ -83,14 +83,14 @@ func TestCreateConfDefault(t *testing.T) { } func TestCreateConfDevRandom(t *testing.T) { - err := Create("config_test/tmp.conf", testPw, false, 10, "test", false, true, nil, nil) + err := Create("config_test/tmp.conf", testPw, false, 10, "test", false, true, nil, nil, false) if err != nil { t.Fatal(err) } } func TestCreateConfPlaintextnames(t *testing.T) { - err := Create("config_test/tmp.conf", testPw, true, 10, "test", false, false, nil, nil) + err := Create("config_test/tmp.conf", testPw, true, 10, "test", false, false, nil, nil, false) if err != nil { t.Fatal(err) } @@ -111,7 +111,7 @@ func TestCreateConfPlaintextnames(t *testing.T) { // Reverse mode uses AESSIV func TestCreateConfFileAESSIV(t *testing.T) { - err := Create("config_test/tmp.conf", testPw, false, 10, "test", true, false, nil, nil) + err := Create("config_test/tmp.conf", testPw, false, 10, "test", true, false, nil, nil, false) if err != nil { t.Fatal(err) } diff --git a/internal/configfile/feature_flags.go b/internal/configfile/feature_flags.go index 5964a53..45e1853 100644 --- a/internal/configfile/feature_flags.go +++ b/internal/configfile/feature_flags.go @@ -45,7 +45,6 @@ var knownFlags = map[flagIota]string{ // Filesystems that do not have these feature flags set are deprecated. var requiredFlagsNormal = []flagIota{ - FlagDirIV, FlagEMENames, FlagGCMIV128, } -- cgit v1.2.3