configfile: switch on Raw64 by default

As we have dropped Go 1.4 compatibility already, and will add
a new feature flag for gocryptfs v1.3 anyway, this is a good
time to enable Raw64 as well.
This commit is contained in:
Jakob Unterwurzacher 2017-03-05 18:13:56 +01:00
parent b732881518
commit decda6d255
3 changed files with 10 additions and 22 deletions

View File

@ -38,7 +38,7 @@ func initDir(args *argContainer) {
password := readpassword.Twice(args.extpass) password := readpassword.Twice(args.extpass)
readpassword.CheckTrailingGarbage() readpassword.CheckTrailingGarbage()
creator := tlog.ProgramName + " " + GitVersion creator := tlog.ProgramName + " " + GitVersion
err = configfile.CreateConfFile(args.config, password, args.plaintextnames, args.scryptn, creator, args.aessiv, args.raw64) err = configfile.CreateConfFile(args.config, password, args.plaintextnames, args.scryptn, creator, args.aessiv)
if err != nil { if err != nil {
tlog.Fatal.Println(err) tlog.Fatal.Println(err)
os.Exit(ErrExitInit) os.Exit(ErrExitInit)

View File

@ -50,7 +50,7 @@ type ConfFile struct {
// CreateConfFile - create a new config with a random key encrypted with // CreateConfFile - create a new config with a random key encrypted with
// "password" and write it to "filename". // "password" and write it to "filename".
// Uses scrypt with cost parameter logN. // Uses scrypt with cost parameter logN.
func CreateConfFile(filename string, password string, plaintextNames bool, logN int, creator string, aessiv bool, raw64 bool) error { func CreateConfFile(filename string, password string, plaintextNames bool, logN int, creator string, aessiv bool) error {
var cf ConfFile var cf ConfFile
cf.filename = filename cf.filename = filename
cf.Creator = creator cf.Creator = creator
@ -71,10 +71,8 @@ func CreateConfFile(filename string, password string, plaintextNames bool, logN
cf.FeatureFlags = append(cf.FeatureFlags, knownFlags[FlagDirIV]) cf.FeatureFlags = append(cf.FeatureFlags, knownFlags[FlagDirIV])
cf.FeatureFlags = append(cf.FeatureFlags, knownFlags[FlagEMENames]) cf.FeatureFlags = append(cf.FeatureFlags, knownFlags[FlagEMENames])
cf.FeatureFlags = append(cf.FeatureFlags, knownFlags[FlagLongNames]) cf.FeatureFlags = append(cf.FeatureFlags, knownFlags[FlagLongNames])
if raw64 {
cf.FeatureFlags = append(cf.FeatureFlags, knownFlags[FlagRaw64]) cf.FeatureFlags = append(cf.FeatureFlags, knownFlags[FlagRaw64])
} }
}
if aessiv { if aessiv {
cf.FeatureFlags = append(cf.FeatureFlags, knownFlags[FlagAESSIV]) cf.FeatureFlags = append(cf.FeatureFlags, knownFlags[FlagAESSIV])
} }

View File

@ -60,18 +60,22 @@ func TestLoadV2StrangeFeature(t *testing.T) {
} }
func TestCreateConfFile(t *testing.T) { func TestCreateConfFile(t *testing.T) {
err := CreateConfFile("config_test/tmp.conf", "test", false, 10, "test", false, false) err := CreateConfFile("config_test/tmp.conf", "test", false, 10, "test", false)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
_, _, err = LoadConfFile("config_test/tmp.conf", "test") _, c, err := LoadConfFile("config_test/tmp.conf", "test")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
// Raw64 is set by default since gocryptfs v1.3
if !c.IsFeatureFlagSet(FlagRaw64) {
t.Error("FlagRaw64 flag should be set but is not")
}
} }
func TestCreateConfFileAESSIV(t *testing.T) { func TestCreateConfFileAESSIV(t *testing.T) {
err := CreateConfFile("config_test/tmp.conf", "test", false, 10, "test", true, false) err := CreateConfFile("config_test/tmp.conf", "test", false, 10, "test", true)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -84,20 +88,6 @@ func TestCreateConfFileAESSIV(t *testing.T) {
} }
} }
func TestCreateConfFileRaw64(t *testing.T) {
err := CreateConfFile("config_test/tmp.conf", "test", false, 10, "test", false, true)
if err != nil {
t.Fatal(err)
}
_, c, err := LoadConfFile("config_test/tmp.conf", "test")
if err != nil {
t.Fatal(err)
}
if !c.IsFeatureFlagSet(FlagRaw64) {
t.Error("FlagRaw64 flag should be set but is not")
}
}
func TestIsFeatureFlagKnown(t *testing.T) { func TestIsFeatureFlagKnown(t *testing.T) {
// Test a few hardcoded values // Test a few hardcoded values
testKnownFlags := []string{"DirIV", "PlaintextNames", "EMENames", "GCMIV128", "LongNames", "AESSIV"} testKnownFlags := []string{"DirIV", "PlaintextNames", "EMENames", "GCMIV128", "LongNames", "AESSIV"}