From b603169d2ccd47013d46bfcb33c1c105342cff95 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sat, 21 Aug 2021 14:04:04 +0200 Subject: configfile: pass struct to Create 2/2 Drop Create and rename Create2 to Create. --- init_dir.go | 2 +- internal/configfile/config_file.go | 21 +-------------------- internal/configfile/config_test.go | 8 ++++---- 3 files changed, 6 insertions(+), 25 deletions(-) diff --git a/init_dir.go b/init_dir.go index 7953870..ae00565 100644 --- a/init_dir.go +++ b/init_dir.go @@ -86,7 +86,7 @@ func initDir(args *argContainer) { fido2HmacSalt = nil } creator := tlog.ProgramName + " " + GitVersion - err = configfile.Create2(&configfile.CreateArgs{ + err = configfile.Create(&configfile.CreateArgs{ Filename: args.config, Password: password, PlaintextNames: args.plaintextnames, diff --git a/internal/configfile/config_file.go b/internal/configfile/config_file.go index db29f43..025e1c3 100644 --- a/internal/configfile/config_file.go +++ b/internal/configfile/config_file.go @@ -90,29 +90,10 @@ type CreateArgs struct { DeterministicNames bool } -func Create(filename string, password []byte, plaintextNames bool, - logN int, creator string, aessiv bool, devrandom bool, - fido2CredentialID []byte, fido2HmacSalt []byte, deterministicNames bool) error { - args := CreateArgs{ - Filename: filename, - Password: password, - PlaintextNames: plaintextNames, - LogN: logN, - Creator: creator, - AESSIV: aessiv, - Devrandom: devrandom, - Fido2CredentialID: fido2CredentialID, - Fido2HmacSalt: fido2HmacSalt, - DeterministicNames: deterministicNames, - } - log.Panicf("Use Create2(%#v) instead\n", args) - return nil -} - // Create - create a new config with a random key encrypted with // "Password" and write it to "Filename". // Uses scrypt with cost parameter "LogN". -func Create2(args *CreateArgs) error { +func Create(args *CreateArgs) error { var cf ConfFile cf.filename = args.Filename cf.Creator = args.Creator diff --git a/internal/configfile/config_test.go b/internal/configfile/config_test.go index 659ddd9..c03be90 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 := Create2(&CreateArgs{ + err := Create(&CreateArgs{ Filename: "config_test/tmp.conf", Password: testPw, LogN: 10, @@ -87,7 +87,7 @@ func TestCreateConfDefault(t *testing.T) { } func TestCreateConfDevRandom(t *testing.T) { - err := Create2(&CreateArgs{ + err := Create(&CreateArgs{ Filename: "config_test/tmp.conf", Password: testPw, LogN: 10, @@ -99,7 +99,7 @@ func TestCreateConfDevRandom(t *testing.T) { } func TestCreateConfPlaintextnames(t *testing.T) { - err := Create2(&CreateArgs{ + err := Create(&CreateArgs{ Filename: "config_test/tmp.conf", Password: testPw, PlaintextNames: true, @@ -125,7 +125,7 @@ func TestCreateConfPlaintextnames(t *testing.T) { // Reverse mode uses AESSIV func TestCreateConfFileAESSIV(t *testing.T) { - err := Create2(&CreateArgs{ + err := Create(&CreateArgs{ Filename: "config_test/tmp.conf", Password: testPw, LogN: 10, -- cgit v1.2.3