summaryrefslogtreecommitdiff
path: root/internal/configfile/config_file.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2018-06-25 22:27:15 +0200
committerJakob Unterwurzacher2018-07-01 20:56:22 +0200
commit9a15dfa494c76b5fcadcd32e2e46cbee84218a87 (patch)
tree5dcb84d222f355750d1b0773660b891b509dadb1 /internal/configfile/config_file.go
parent91de77943fba3cb993aad4e9756e159c4514764a (diff)
trezor: add TrezorPayload
TrezorPayload stores 32 random bytes used for unlocking the master key using a Trezor security module. The randomness makes sure that a unique unlock value is used for each gocryptfs filesystem.
Diffstat (limited to 'internal/configfile/config_file.go')
-rw-r--r--internal/configfile/config_file.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/internal/configfile/config_file.go b/internal/configfile/config_file.go
index a70a511..c856ad0 100644
--- a/internal/configfile/config_file.go
+++ b/internal/configfile/config_file.go
@@ -45,6 +45,10 @@ type ConfFile struct {
// mounting. This mechanism is analogous to the ext4 feature flags that are
// stored in the superblock.
FeatureFlags []string
+ // TrezorPayload stores 32 random bytes used for unlocking the master key using
+ // a Trezor security module. The randomness makes sure that a unique unlock
+ // value is used for each gocryptfs filesystem.
+ TrezorPayload []byte `json:",omitempty"`
// Filename is the name of the config file. Not exported to JSON.
filename string
}
@@ -68,7 +72,7 @@ func randBytesDevRandom(n int) []byte {
// "password" and write it to "filename".
// Uses scrypt with cost parameter logN.
func Create(filename string, password []byte, plaintextNames bool,
- logN int, creator string, aessiv bool, devrandom bool, trezor bool) error {
+ logN int, creator string, aessiv bool, devrandom bool, trezorPayload []byte) error {
var cf ConfFile
cf.filename = filename
cf.Creator = creator
@@ -88,8 +92,9 @@ func Create(filename string, password []byte, plaintextNames bool,
if aessiv {
cf.FeatureFlags = append(cf.FeatureFlags, knownFlags[FlagAESSIV])
}
- if trezor {
+ if len(trezorPayload) > 0 {
cf.FeatureFlags = append(cf.FeatureFlags, knownFlags[FlagTrezor])
+ cf.TrezorPayload = trezorPayload
}
{
// Generate new random master key