configfile: bake the "Creator" gocryptfs version into the file

This field is added for the convenience of users and
may help them to identify which gocryptfs version
they need to mount a filesystem.

The same information is essentially contained in FeatureFlags,
but this is more difficult to decode for humans.

It is completely ignored programmatically (also by older gocryptfs
versions).
This commit is contained in:
Jakob Unterwurzacher 2016-06-05 11:33:54 +02:00
parent a602e798b1
commit b97268c948
3 changed files with 11 additions and 5 deletions

View File

@ -19,8 +19,10 @@ const (
) )
type ConfFile struct { type ConfFile struct {
// File the config is saved to. Not exported to JSON. // gocryptfs version string
filename string // This only documents the config file for humans who look at it. The actual
// technical info is contained in FeatureFlags.
Creator string
// Encrypted AES key, unlocked using a password hashed with scrypt // Encrypted AES key, unlocked using a password hashed with scrypt
EncryptedKey []byte EncryptedKey []byte
// Stores parameters for scrypt hashing (key derivation) // Stores parameters for scrypt hashing (key derivation)
@ -32,14 +34,17 @@ type ConfFile struct {
// mounting. This mechanism is analogous to the ext4 feature flags that are // mounting. This mechanism is analogous to the ext4 feature flags that are
// stored in the superblock. // stored in the superblock.
FeatureFlags []string FeatureFlags []string
// File the config is saved to. Not exported to JSON.
filename string
} }
// 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) error { func CreateConfFile(filename string, password string, plaintextNames bool, logN int, creator string) error {
var cf ConfFile var cf ConfFile
cf.filename = filename cf.filename = filename
cf.Creator = creator
cf.Version = contentenc.CurrentVersion cf.Version = contentenc.CurrentVersion
// Generate new random master key // Generate new random master key

View File

@ -60,7 +60,7 @@ func TestLoadV2StrangeFeature(t *testing.T) {
} }
func TestCreateConfFile(t *testing.T) { func TestCreateConfFile(t *testing.T) {
err := CreateConfFile("config_test/tmp.conf", "test", false, 10) err := CreateConfFile("config_test/tmp.conf", "test", false, 10, "test")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@ -72,7 +72,8 @@ func initDir(args *argContainer) {
toggledlog.Info.Printf("Using password provided via -extpass.") toggledlog.Info.Printf("Using password provided via -extpass.")
} }
password := readPasswordTwice(args.extpass) password := readPasswordTwice(args.extpass)
err = configfile.CreateConfFile(args.config, password, args.plaintextnames, args.scryptn) creator := toggledlog.ProgramName + " " + GitVersion
err = configfile.CreateConfFile(args.config, password, args.plaintextnames, args.scryptn, creator)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
os.Exit(ERREXIT_INIT) os.Exit(ERREXIT_INIT)