summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2020-05-09 16:10:22 +0200
committerJakob Unterwurzacher2020-05-09 16:10:22 +0200
commit7622c9f538d324ba4ed704ff836942af39d2b1f9 (patch)
treedd2a527c129d650ba0b1121b5050c55426878a59
parentc19baa10f8e8365ed9e3212a003a6b8f31f0320a (diff)
main: rename parseMasterKey() -> unhexMasterKey()
Make it clear that function does NOT parse the "-masterkey" command line argument, it just unhexes the payload.
-rw-r--r--main.go2
-rw-r--r--masterkey.go8
2 files changed, 5 insertions, 5 deletions
diff --git a/main.go b/main.go
index 8150499..3ec2f31 100644
--- a/main.go
+++ b/main.go
@@ -43,7 +43,7 @@ func loadConfig(args *argContainer) (masterkey []byte, cf *configfile.ConfFile,
// The user has passed the master key on the command line (probably because
// he forgot the password).
if args.masterkey != "" {
- masterkey = parseMasterKey(args.masterkey, false)
+ masterkey = unhexMasterKey(args.masterkey, false)
return masterkey, cf, nil
}
pw := readpassword.Once([]string(args.extpass), args.passfile, "")
diff --git a/masterkey.go b/masterkey.go
index 706eb68..3d3b951 100644
--- a/masterkey.go
+++ b/masterkey.go
@@ -12,9 +12,9 @@ import (
"github.com/rfjakob/gocryptfs/internal/tlog"
)
-// parseMasterKey - Parse a hex-encoded master key that was passed on the command line
-// Calls os.Exit on failure
-func parseMasterKey(masterkey string, fromStdin bool) []byte {
+// unhexMasterKey - Convert a hex-encoded master key to binary.
+// Calls os.Exit on failure.
+func unhexMasterKey(masterkey string, fromStdin bool) []byte {
masterkey = strings.Replace(masterkey, "-", "", -1)
key, err := hex.DecodeString(masterkey)
if err != nil {
@@ -48,7 +48,7 @@ func getMasterKey(args *argContainer) (masterkey []byte, confFile *configfile.Co
}
// "-masterkey=941a6029-3adc6a1c-..."
if args.masterkey != "" {
- return parseMasterKey(args.masterkey, masterkeyFromStdin), nil
+ return unhexMasterKey(args.masterkey, masterkeyFromStdin), nil
}
// "-zerokey"
if args.zerokey {