diff --git a/util/cryp/cryp.go b/util/cryp/cryp.go index 78501ed6..f920235f 100644 --- a/util/cryp/cryp.go +++ b/util/cryp/cryp.go @@ -17,6 +17,7 @@ package cryp import ( "crypto/aes" "crypto/cipher" + "errors" "github.com/abcum/surreal/util/rand" ) @@ -53,7 +54,7 @@ func Decrypt(key []byte, src []byte) (dst []byte, err error) { // Corrupt if len(src) < 12 { - return src, nil + return src, errors.New("Invalid data") } // Initiate AES diff --git a/util/cryp/cryp_test.go b/util/cryp/cryp_test.go index cb198f0f..2dd89dcf 100644 --- a/util/cryp/cryp_test.go +++ b/util/cryp/cryp_test.go @@ -62,8 +62,9 @@ func TestCorrupt(t *testing.T) { enc := []byte("corrupt") Convey("Cryptography should fail", t, func() { - dec, _ := Decrypt(key, enc) + dec, err := Decrypt(key, enc) Convey("Decrypt", func() { + So(err, ShouldNotBeNil) So(dec, ShouldResemble, enc) }) })