aboutsummaryrefslogtreecommitdiff
path: root/internal/configfile
diff options
context:
space:
mode:
authorJakob Unterwurzacher2021-08-20 15:57:40 +0200
committerJakob Unterwurzacher2021-08-20 15:57:40 +0200
commit2a9dea2973a6141e8efdf8bd26d8ddb2d2c35fc4 (patch)
tree3af78126e573b5a9963111c1bdea6f8d1100fbd1 /internal/configfile
parent195d9d18a90d88ff2cb0530d832c59d98934fd1f (diff)
-deterministic-names: accept flag on -init
And store it in gocryptfs.conf (=remove DirIV feature flag).
Diffstat (limited to 'internal/configfile')
-rw-r--r--internal/configfile/config_file.go7
-rw-r--r--internal/configfile/config_test.go8
-rw-r--r--internal/configfile/feature_flags.go1
3 files changed, 9 insertions, 7 deletions
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,
}