From 40548c7ec86a59d0d2dbcea31891fffcd231e35c Mon Sep 17 00:00:00 2001 From: "Richard T. Carback III" <rick.carback@gmail.com> Date: Wed, 2 Mar 2022 22:05:36 +0000 Subject: [PATCH] Use byte arrays for passwords --- api/client.go | 6 +++--- bindings/client.go | 4 ++-- cmd/root.go | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/api/client.go b/api/client.go index 04ef12f03..6560fe673 100644 --- a/api/client.go +++ b/api/client.go @@ -171,11 +171,11 @@ func NewVanityClient(ndfJSON, storageDir string, password []byte, // is decrypted using the backupPassphrase. On success a successful client creation, //// the function will return a JSON encoded list of the E2E partners //// contained in the backup. -func NewClientFromBackup(ndfJSON, storageDir, sessionPassword, - backupPassphrase string, backupFileContents []byte) ([]*id.ID, error) { +func NewClientFromBackup(ndfJSON, storageDir string, sessionPassword, + backupPassphrase []byte, backupFileContents []byte) ([]*id.ID, error) { backUp := &backup.Backup{} - err := backUp.Decrypt(backupPassphrase, backupFileContents) + err := backUp.Decrypt(string(backupPassphrase), backupFileContents) if err != nil { return nil, errors.WithMessage(err, "Failed to unmarshal decrypted client contents.") } diff --git a/bindings/client.go b/bindings/client.go index aad174280..4cdfa338f 100644 --- a/bindings/client.go +++ b/bindings/client.go @@ -87,8 +87,8 @@ func NewPrecannedClient(precannedID int, network, storageDir string, password [] // is decrypted using the backupPassphrase. On success a successful client creation, // the function will return a JSON encoded list of the E2E partners // contained in the backup. -func NewClientFromBackup(ndfJSON, storageDir, sessionPassword, - backupPassphrase string, backupFileContents []byte) ([]byte, error) { +func NewClientFromBackup(ndfJSON, storageDir string, sessionPassword, + backupPassphrase, backupFileContents []byte) ([]byte, error) { backupPartnerIds, err := api.NewClientFromBackup(ndfJSON, storageDir, sessionPassword, backupPassphrase, backupFileContents) if err != nil { diff --git a/cmd/root.go b/cmd/root.go index 08b492714..28e3a988f 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -532,7 +532,7 @@ func createClient() *api.Client { userIDprefix := viper.GetString("userid-prefix") protoUserPath := viper.GetString("protoUserPath") backupPath := viper.GetString("backupIn") - backupPass := viper.GetString("backupPass") + backupPass := []byte(viper.GetString("backupPass")) // create a new client if none exist if _, err := os.Stat(storeDir); os.IsNotExist(err) { @@ -557,7 +557,7 @@ func createClient() *api.Client { []byte(pass), regCode, userIDprefix) } else if backupPath != "" { - b, backupFile := loadBackup(backupPath, backupPass) + b, backupFile := loadBackup(backupPath, string(backupPass)) // Marshal the backup object in JSON backupJson, err := json.Marshal(b) @@ -573,7 +573,7 @@ func createClient() *api.Client { // Construct client from backup data backupIdList, err := api.NewClientFromBackup(string(ndfJSON), storeDir, - pass, backupPass, backupFile) + []byte(pass), backupPass, backupFile) backupIdListPath := viper.GetString("backupIdList") if backupIdListPath != "" { -- GitLab