aboutsummaryrefslogtreecommitdiff
path: root/internal/configfile/config_file.go
diff options
context:
space:
mode:
authorPablo Mazzini2024-03-09 15:11:24 +0000
committerrfjakob2024-03-13 10:42:53 +0100
commit8ced867c4f2a26e00e32d7703fe13aa47d9df923 (patch)
treefdbd0dd9adab015503e8d728ec71b59716a82768 /internal/configfile/config_file.go
parent0dfa7f8fadfa200c62f8ed9d3d08f745aa182f5b (diff)
init_dir: use masterkey arg
Diffstat (limited to 'internal/configfile/config_file.go')
-rw-r--r--internal/configfile/config_file.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/internal/configfile/config_file.go b/internal/configfile/config_file.go
index 2d11346..3d59dc5 100644
--- a/internal/configfile/config_file.go
+++ b/internal/configfile/config_file.go
@@ -74,6 +74,7 @@ type CreateArgs struct {
DeterministicNames bool
XChaCha20Poly1305 bool
LongNameMax uint8
+ Masterkey []byte
}
// Create - create a new config with a random key encrypted with
@@ -126,8 +127,11 @@ func Create(args *CreateArgs) error {
return err
}
{
- // Generate new random master key
- key := cryptocore.RandBytes(cryptocore.KeyLen)
+ key := args.Masterkey
+ if key == nil {
+ // Generate new random master key
+ key = cryptocore.RandBytes(cryptocore.KeyLen)
+ }
tlog.PrintMasterkeyReminder(key)
// Encrypt it using the password
// This sets ScryptObject and EncryptedKey