tests: add hkdf_sanity tests with broken example filesystem

These are deliberately corrupt.
This commit is contained in:
Jakob Unterwurzacher 2017-03-18 16:48:58 +01:00
parent cb47f65212
commit f1dbd19fe9
6 changed files with 72 additions and 0 deletions

View File

@ -0,0 +1,17 @@
{
"Creator": "gocryptfs v1.2.1-32-g14038a1-dirty",
"EncryptedKey": "b3888jnQC5GYem+YGtUkOTS13/YCOfA6J0/bkftfEoNA9fZTN2xMGw4c+LK+emg4L6P2wGvm44RUqCfFfgowxw==",
"ScryptObject": {
"Salt": "7YnR8bF7TzYNP5mIwmpQ1qj4e/QZkbH92Hx7YQctIZQ=",
"N": 1024,
"R": 8,
"P": 1,
"KeyLen": 32
},
"Version": 2,
"FeatureFlags": [
"GCMIV128",
"HKDF",
"PlaintextNames"
]
}

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,20 @@
{
"Creator": "gocryptfs v1.2.1-32-g14038a1-dirty",
"EncryptedKey": "0ymk/BtKEN1KmRLMquLinLIzXDaf+GLuP2f9R4VbLOglim9nXd5WxkCFl0DQg0J2FtCEke9MQBaCfL5OTJdR4g==",
"ScryptObject": {
"Salt": "tCrF2o5GoOyQt0LAlCWk47hyJsF5K6ID9uPzjTSBbh8=",
"N": 1024,
"R": 8,
"P": 1,
"KeyLen": 32
},
"Version": 2,
"FeatureFlags": [
"GCMIV128",
"HKDF",
"DirIV",
"EMENames",
"LongNames",
"Raw64"
]
}

View File

@ -0,0 +1 @@
ï%C´×xõ(E<>£!½dц

View File

@ -0,0 +1,34 @@
// We test two filesystems that have the "HKDF" feature flag in their config file
// set, but the actual file contents and names are encrypted with HKDF disabled.
// This test verifies that the "HKDF" feature flag in the config file takes effect.
package hkdf_sanity
import (
"io/ioutil"
"os"
"testing"
"github.com/rfjakob/gocryptfs/tests/test_helpers"
)
func TestBrokenContent(t *testing.T) {
cDir := "broken_content"
pDir := test_helpers.TmpDir + "/" + cDir
test_helpers.MountOrFatal(t, cDir, pDir, "-extpass", "echo test", "-wpanic=false")
_, err := ioutil.ReadFile(pDir + "/status.txt")
if err == nil {
t.Error("this should fail")
}
test_helpers.UnmountPanic(pDir)
}
func TestBrokenNames(t *testing.T) {
cDir := "broken_names"
pDir := test_helpers.TmpDir + "/" + cDir
test_helpers.MountOrFatal(t, cDir, pDir, "-extpass", "echo test", "-wpanic=false")
_, err := os.Stat(pDir + "/status.txt")
if err == nil {
t.Error("this should fail")
}
test_helpers.UnmountPanic(pDir)
}