From e43eb36da3e72cd0f59ac978cf76a94fa87ca7cd Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 28 May 2017 19:02:22 +0200 Subject: [PATCH] tests: add v1.3-reverse example filesystem We check the md5 sum of the encrypted version of a file to make sure we don't accidentially change the ciphertext generation. --- .../example_filesystems_test.go | 54 ++++++++++++++++++ .../v1.3-reverse/.gocryptfs.reverse.conf | 21 +++++++ tests/example_filesystems/v1.3-reverse/abs | 1 + .../v1.3-reverse/dir1/dir2/file | Bin 0 -> 10000 bytes ...xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | 1 + tests/example_filesystems/v1.3-reverse/rel | 1 + .../v1.3-reverse/status.txt | 1 + 7 files changed, 79 insertions(+) create mode 100644 tests/example_filesystems/v1.3-reverse/.gocryptfs.reverse.conf create mode 120000 tests/example_filesystems/v1.3-reverse/abs create mode 100644 tests/example_filesystems/v1.3-reverse/dir1/dir2/file create mode 100644 tests/example_filesystems/v1.3-reverse/longname_255_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx create mode 120000 tests/example_filesystems/v1.3-reverse/rel create mode 100644 tests/example_filesystems/v1.3-reverse/status.txt diff --git a/tests/example_filesystems/example_filesystems_test.go b/tests/example_filesystems/example_filesystems_test.go index d7411e6..cbea251 100644 --- a/tests/example_filesystems/example_filesystems_test.go +++ b/tests/example_filesystems/example_filesystems_test.go @@ -250,3 +250,57 @@ func TestExampleFSv13(t *testing.T) { 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. +func TestExampleFSv13reverse(t *testing.T) { + // Prepare directories + dirA := "v1.3-reverse" + dirB := test_helpers.TmpDir + "/" + dirA + ".B" + err := os.Mkdir(dirB, 0700) + if err != nil { + t.Fatal(err) + } + dirC := test_helpers.TmpDir + "/" + dirA + ".C" + err = os.Mkdir(dirC, 0700) + if err != nil { + t.Fatal(err) + } + // Mount using password + test_helpers.MountOrFatal(t, dirA, dirB, "-reverse", "-extpass", "echo test", opensslOpt) + c := dirB + "/gocryptfs.conf" + if !test_helpers.VerifyExistence(c) { + t.Errorf("%s missing", c) + } + test_helpers.MountOrFatal(t, dirB, dirC, "-extpass", "echo test", opensslOpt) + // Test + checkExampleFSrw(t, dirC, false) + // Encrypted version of dir1/dir2/file (10000 zero bytes) + cPath := dirB + "/zOsW1-BUX54hC2hmhu2EOw/4ZqrpGQdw5r07KR1qw2ZeQ/tfCm9Sp9J_Dvc-jD7J6p8g" + want := "9818501d214c5eb42ca2472caf6c82a1" + actual := test_helpers.Md5fn(cPath) + if actual != want { + t.Errorf("wrong md5") + } + // Unmount + test_helpers.UnmountPanic(dirC) + test_helpers.UnmountPanic(dirB) + + // Mount using masterkey + m := "2290a7f4-3e1908fb-b006f7d9-261bdaf1-4b72bc38-3b24956c-db7d8a8d-d996076a" + test_helpers.MountOrFatal(t, dirA, dirB, "-reverse", "-masterkey", m, opensslOpt) + if !test_helpers.VerifyExistence(c) { + t.Errorf("%s missing", c) + } + test_helpers.MountOrFatal(t, dirB, dirC, "-aessiv", "-masterkey", m, opensslOpt) + // Test + checkExampleFSrw(t, dirC, false) + actual = test_helpers.Md5fn(cPath) + if actual != want { + t.Errorf("wrong md5") + } + // Unmmount + test_helpers.UnmountPanic(dirC) + test_helpers.UnmountPanic(dirB) +} diff --git a/tests/example_filesystems/v1.3-reverse/.gocryptfs.reverse.conf b/tests/example_filesystems/v1.3-reverse/.gocryptfs.reverse.conf new file mode 100644 index 0000000..4241280 --- /dev/null +++ b/tests/example_filesystems/v1.3-reverse/.gocryptfs.reverse.conf @@ -0,0 +1,21 @@ +{ + "Creator": "gocryptfs v1.3", + "EncryptedKey": "o6yhOpoaToWqs7iZMgx2J+dmrRcL8TOjqd7ntlqy4Y/g/ygNRADJXGITtEIDukf7FbGyn2JNZtWs/4ZOgLNmYw==", + "ScryptObject": { + "Salt": "8a64zpm0vXFg9uretHuwbxijzQmx2QF4hKOYM0yK/S8=", + "N": 65536, + "R": 8, + "P": 1, + "KeyLen": 32 + }, + "Version": 2, + "FeatureFlags": [ + "GCMIV128", + "HKDF", + "DirIV", + "EMENames", + "LongNames", + "Raw64", + "AESSIV" + ] +} diff --git a/tests/example_filesystems/v1.3-reverse/abs b/tests/example_filesystems/v1.3-reverse/abs new file mode 120000 index 0000000..e1740fa --- /dev/null +++ b/tests/example_filesystems/v1.3-reverse/abs @@ -0,0 +1 @@ +/a/b/c/d \ No newline at end of file diff --git a/tests/example_filesystems/v1.3-reverse/dir1/dir2/file b/tests/example_filesystems/v1.3-reverse/dir1/dir2/file new file mode 100644 index 0000000000000000000000000000000000000000..e64c723ad5aeec49f2d1447b9f523fe09c522566 GIT binary patch literal 10000 zcmeIu0Sy2E0K%a6Pi+o2h(KY$fB^#r3>YwAz<>b*1`HT5V8DO@0|pEjFkrxd0RsjM O7%*VKfB^#r{s#sp5C8!H literal 0 HcmV?d00001 diff --git a/tests/example_filesystems/v1.3-reverse/longname_255_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx b/tests/example_filesystems/v1.3-reverse/longname_255_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx new file mode 100644 index 0000000..68300b8 --- /dev/null +++ b/tests/example_filesystems/v1.3-reverse/longname_255_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx @@ -0,0 +1 @@ +It works! diff --git a/tests/example_filesystems/v1.3-reverse/rel b/tests/example_filesystems/v1.3-reverse/rel new file mode 120000 index 0000000..8279c75 --- /dev/null +++ b/tests/example_filesystems/v1.3-reverse/rel @@ -0,0 +1 @@ +status.txt \ No newline at end of file diff --git a/tests/example_filesystems/v1.3-reverse/status.txt b/tests/example_filesystems/v1.3-reverse/status.txt new file mode 100644 index 0000000..68300b8 --- /dev/null +++ b/tests/example_filesystems/v1.3-reverse/status.txt @@ -0,0 +1 @@ +It works!