1
// Copyright 2013 The Go Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
13
func TestCryptBlocks(t *testing.T) {
14
buf := make([]byte, 16)
15
block, _ := aes.NewCipher(buf)
17
mode := cipher.NewCBCDecrypter(block, buf)
18
mustPanic(t, "crypto/cipher: input not full blocks", func() { mode.CryptBlocks(buf, buf[:3]) })
19
mustPanic(t, "crypto/cipher: output smaller than input", func() { mode.CryptBlocks(buf[:3], buf) })
21
mode = cipher.NewCBCEncrypter(block, buf)
22
mustPanic(t, "crypto/cipher: input not full blocks", func() { mode.CryptBlocks(buf, buf[:3]) })
23
mustPanic(t, "crypto/cipher: output smaller than input", func() { mode.CryptBlocks(buf[:3], buf) })
26
func mustPanic(t *testing.T, msg string, f func()) {
30
t.Errorf("function did not panic, wanted %q", msg)
31
} else if err != msg {
32
t.Errorf("got panic %v, wanted %q", err, msg)