Skip to content

Commit af11802

Browse files
committed
init_dir: use masterkey arg
1 parent 9958b63 commit af11802

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

init_dir.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ func initDir(args *argContainer) {
108108
DeterministicNames: args.deterministic_names,
109109
XChaCha20Poly1305: args.xchacha,
110110
LongNameMax: args.longnamemax,
111+
Masterkey: handleArgsMasterkey(args),
111112
})
112113
if err != nil {
113114
tlog.Fatal.Println(err)

internal/configfile/config_file.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ type CreateArgs struct {
7474
DeterministicNames bool
7575
XChaCha20Poly1305 bool
7676
LongNameMax uint8
77+
Masterkey []byte
7778
}
7879

7980
// Create - create a new config with a random key encrypted with
@@ -126,8 +127,11 @@ func Create(args *CreateArgs) error {
126127
return err
127128
}
128129
{
129-
// Generate new random master key
130-
key := cryptocore.RandBytes(cryptocore.KeyLen)
130+
key := args.Masterkey
131+
if key == nil {
132+
// Generate new random master key
133+
key := cryptocore.RandBytes(cryptocore.KeyLen)
134+
}
131135
tlog.PrintMasterkeyReminder(key)
132136
// Encrypt it using the password
133137
// This sets ScryptObject and EncryptedKey

0 commit comments

Comments
 (0)