From 9bc039a4bac6b51d9ebe116de5c311e90343a088 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Thu, 22 Mar 2018 00:02:10 +0100 Subject: Add `-masterkey=stdin` functionality https://github.com/rfjakob/gocryptfs/issues/218 --- .../example_filesystems_test.go | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'tests') diff --git a/tests/example_filesystems/example_filesystems_test.go b/tests/example_filesystems/example_filesystems_test.go index 5979bdc..4f29f8d 100644 --- a/tests/example_filesystems/example_filesystems_test.go +++ b/tests/example_filesystems/example_filesystems_test.go @@ -10,6 +10,7 @@ import ( "flag" "fmt" "os" + "os/exec" "syscall" "testing" @@ -252,6 +253,38 @@ func TestExampleFSv13(t *testing.T) { test_helpers.UnmountPanic(pDir) } +// Check that the masterkey=stdin cli option works. +func TestExampleFSv13MasterkeyStdin(t *testing.T) { + cDir := "v1.3" + pDir := test_helpers.TmpDir + "/TestExampleFSv13MasterkeyStdin.mnt" + err := os.Mkdir(pDir, 0777) + if err != nil { + t.Fatal(err) + } + args := []string{"-q", "-masterkey=stdin", opensslOpt, cDir, pDir} + cmd := exec.Command(test_helpers.GocryptfsBinary, args...) + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + p, err := cmd.StdinPipe() + if err != nil { + t.Fatal(err) + } + err = cmd.Start() + if err != nil { + t.Error(err) + } + // Write masterkey to stdin + p.Write([]byte("fd890dab-86bf61cf-ec5ad460-ad3ed01f-9c52d546-2a31783d-a56b088d-3d05232e")) + p.Close() + err = cmd.Wait() + if err != nil { + t.Error(err) + } + // Check that the fs decrypts ok & unmount + checkExampleFSLongnames(t, pDir) + test_helpers.UnmountPanic(pDir) +} + // gocryptfs v1.3 introduced HKDF. // We check the md5 sum of the encrypted version of a file to make sure we don't // accidentially change the ciphertext generation. -- cgit v1.2.3