diff options
| author | Joseph Richey <joerichey@google.com> | 2017-07-19 18:17:29 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-07-19 18:17:29 -0700 |
| commit | d32430055414762d8c62db5595b461b3087ea760 (patch) | |
| tree | d37a0569947deca92591bd996cd8df738101a3df /crypto/crypto_test.go | |
| parent | 8f4830c7715e5719780f195ce3400b8768c30688 (diff) | |
| parent | 16ec9949f831efd21c78d5f0cb589c40cbbeea33 (diff) | |
Merge pull request #27 from google/tests
coveralls: Adding Travis CI integration
Diffstat (limited to 'crypto/crypto_test.go')
| -rw-r--r-- | crypto/crypto_test.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/crypto/crypto_test.go b/crypto/crypto_test.go index a154fbf..58aca9e 100644 --- a/crypto/crypto_test.go +++ b/crypto/crypto_test.go @@ -423,6 +423,18 @@ func TestWrongWrappingKeyLength(t *testing.T) { } } +// Wrong length of unwrapping key should fail +func TestWrongUnwrappingKeyLength(t *testing.T) { + data, err := Wrap(fakeWrappingKey, fakeWrappingKey) + if err != nil { + t.Fatal(err) + } + if k, err := Unwrap(fakeValidPolicyKey, data); err == nil { + k.Wipe() + t.Fatal("using a policy key for unwrapping should fail") + } +} + // Wraping twice with the same keys should give different components func TestWrapTwiceDistinct(t *testing.T) { data1, err := Wrap(fakeWrappingKey, fakeValidPolicyKey) @@ -546,6 +558,19 @@ func TestBadParallelism(t *testing.T) { } } +func TestBadSalt(t *testing.T) { + pk, err := fakePassphraseKey() + if err != nil { + t.Fatal(err) + } + defer pk.Wipe() + + _, err = PassphraseHash(pk, []byte{1, 2, 3, 4}, hashTestCases[0].costs) + if err == nil { + t.Error("too short of salt should be invalid") + } +} + func BenchmarkWrap(b *testing.B) { for n := 0; n < b.N; n++ { Wrap(fakeWrappingKey, fakeValidPolicyKey) |