aboutsummaryrefslogtreecommitdiff
path: root/internal/configfile
diff options
context:
space:
mode:
authorJakob Unterwurzacher2016-11-01 18:43:22 +0100
committerJakob Unterwurzacher2016-11-01 18:43:22 +0100
commit2b991c9743caa5edf38fbcdadb129ca61ffa702f (patch)
tree307059774772110a6aa63fbd35e00ac2747ab4f9 /internal/configfile
parent964e0e6b3634973fb9512858b4ae8707c825aaaf (diff)
Add support for unpadded base64 filenames, "-raw64"
Through base64.RawURLEncoding. New command-line parameter "-raw64".
Diffstat (limited to 'internal/configfile')
-rw-r--r--internal/configfile/config_file.go5
-rw-r--r--internal/configfile/config_test.go19
-rw-r--r--internal/configfile/feature_flags.go3
3 files changed, 23 insertions, 4 deletions
diff --git a/internal/configfile/config_file.go b/internal/configfile/config_file.go
index 603f276..0bee16f 100644
--- a/internal/configfile/config_file.go
+++ b/internal/configfile/config_file.go
@@ -49,7 +49,7 @@ type ConfFile struct {
// CreateConfFile - create a new config with a random key encrypted with
// "password" and write it to "filename".
// Uses scrypt with cost parameter logN.
-func CreateConfFile(filename string, password string, plaintextNames bool, logN int, creator string, aessiv bool) error {
+func CreateConfFile(filename string, password string, plaintextNames bool, logN int, creator string, aessiv bool, raw64 bool) error {
var cf ConfFile
cf.filename = filename
cf.Creator = creator
@@ -70,6 +70,9 @@ func CreateConfFile(filename string, password string, plaintextNames bool, logN
cf.FeatureFlags = append(cf.FeatureFlags, knownFlags[FlagDirIV])
cf.FeatureFlags = append(cf.FeatureFlags, knownFlags[FlagEMENames])
cf.FeatureFlags = append(cf.FeatureFlags, knownFlags[FlagLongNames])
+ if raw64 {
+ cf.FeatureFlags = append(cf.FeatureFlags, knownFlags[FlagRaw64])
+ }
}
if aessiv {
cf.FeatureFlags = append(cf.FeatureFlags, knownFlags[FlagAESSIV])
diff --git a/internal/configfile/config_test.go b/internal/configfile/config_test.go
index 81984fe..f993803 100644
--- a/internal/configfile/config_test.go
+++ b/internal/configfile/config_test.go
@@ -60,7 +60,7 @@ func TestLoadV2StrangeFeature(t *testing.T) {
}
func TestCreateConfFile(t *testing.T) {
- err := CreateConfFile("config_test/tmp.conf", "test", false, 10, "test", false)
+ err := CreateConfFile("config_test/tmp.conf", "test", false, 10, "test", false, false)
if err != nil {
t.Fatal(err)
}
@@ -68,11 +68,10 @@ func TestCreateConfFile(t *testing.T) {
if err != nil {
t.Fatal(err)
}
-
}
func TestCreateConfFileAESSIV(t *testing.T) {
- err := CreateConfFile("config_test/tmp.conf", "test", false, 10, "test", true)
+ err := CreateConfFile("config_test/tmp.conf", "test", false, 10, "test", true, false)
if err != nil {
t.Fatal(err)
}
@@ -85,6 +84,20 @@ 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) {
// Test a few hardcoded values
testKnownFlags := []string{"DirIV", "PlaintextNames", "EMENames", "GCMIV128", "LongNames", "AESSIV"}
diff --git a/internal/configfile/feature_flags.go b/internal/configfile/feature_flags.go
index d3601b1..8d4aa6e 100644
--- a/internal/configfile/feature_flags.go
+++ b/internal/configfile/feature_flags.go
@@ -17,6 +17,8 @@ const (
FlagLongNames
// 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
@@ -27,6 +29,7 @@ var knownFlags = map[flagIota]string{
FlagGCMIV128: "GCMIV128",
FlagLongNames: "LongNames",
FlagAESSIV: "AESSIV",
+ FlagRaw64: "Raw64",
}
// Filesystems that do not have these feature flags set are deprecated.