diff options
author | Jakob Unterwurzacher | 2018-06-17 15:25:09 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2018-07-01 20:56:04 +0200 |
commit | c6f6e8ec4d71475a24ebbb0e64f19ad94249efd9 (patch) | |
tree | 387469668b60e5eeddf50cf1103af43f352c0192 /init_dir.go | |
parent | 02ab358451e23087cdba9cfdec6e8e31ae4adb4e (diff) |
trezor: add skeleton for Trezor support
readpassword.Trezor() is not implemented yet and returns
a hardcoded dummy key.
Diffstat (limited to 'init_dir.go')
-rw-r--r-- | init_dir.go | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/init_dir.go b/init_dir.go index 0e1ad95..ea6fff4 100644 --- a/init_dir.go +++ b/init_dir.go @@ -43,11 +43,12 @@ func isDir(dir string) error { return nil } -// initDir prepares a directory for use as a gocryptfs storage directory. +// initDir handles "gocryptfs -init". It prepares a directory for use as a +// gocryptfs storage directory. // In forward mode, this means creating the gocryptfs.conf and gocryptfs.diriv // files in an empty directory. // In reverse mode, we create .gocryptfs.reverse.conf and the directory does -// not to be empty. +// not need to be empty. func initDir(args *argContainer) { var err error if args.reverse { @@ -68,10 +69,18 @@ func initDir(args *argContainer) { tlog.Info.Printf("Choose a password for protecting your files.") } { + var password []byte + if args.trezor { + // Get binary data from from Trezor + password = readpassword.Trezor() + } else { + // Normal password entry + password = readpassword.Twice(args.extpass) + readpassword.CheckTrailingGarbage() + } creator := tlog.ProgramName + " " + GitVersion - password := readpassword.Twice(args.extpass) - readpassword.CheckTrailingGarbage() - err = configfile.CreateConfFile(args.config, password, args.plaintextnames, args.scryptn, creator, args.aessiv, args.devrandom) + err = configfile.CreateConfFile(args.config, password, args.plaintextnames, + args.scryptn, creator, args.aessiv, args.devrandom, args.trezor) if err != nil { tlog.Fatal.Println(err) os.Exit(exitcodes.WriteConf) @@ -81,7 +90,7 @@ func initDir(args *argContainer) { } // password runs out of scope here } - // Forward mode with filename encryption enabled needs a gocryptfs.diriv + // Forward mode with filename encryption enabled needs a gocryptfs.diriv file // in the root dir if !args.plaintextnames && !args.reverse { err = nametransform.WriteDirIV(nil, args.cipherdir) |