diff options
Diffstat (limited to 'libgo/go/crypto/blowfish/blowfish_test.go')
-rw-r--r-- | libgo/go/crypto/blowfish/blowfish_test.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/libgo/go/crypto/blowfish/blowfish_test.go b/libgo/go/crypto/blowfish/blowfish_test.go index 3a7ab6c2a8d..1038d2e39ee 100644 --- a/libgo/go/crypto/blowfish/blowfish_test.go +++ b/libgo/go/crypto/blowfish/blowfish_test.go @@ -190,3 +190,21 @@ func TestCipherDecrypt(t *testing.T) { } } } + +func TestSaltedCipherKeyLength(t *testing.T) { + var key []byte + for i := 0; i < 4; i++ { + _, err := NewSaltedCipher(key, []byte{'a'}) + if err != KeySizeError(i) { + t.Errorf("NewSaltedCipher with short key, gave error %#v, expected %#v", err, KeySizeError(i)) + } + key = append(key, 'a') + } + + // A 57-byte key. One over the typical blowfish restriction. + key = []byte("012345678901234567890123456789012345678901234567890123456") + _, err := NewSaltedCipher(key, []byte{'a'}) + if err != nil { + t.Errorf("NewSaltedCipher with long key, gave error %#v", err) + } +} |