1 // Copyright 2016 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 // Assert that aesCipherAsm implements the cbcEncAble and cbcDecAble interfaces.
14 var _ cbcEncAble
= (*aesCipherAsm
)(nil)
15 var _ cbcDecAble
= (*aesCipherAsm
)(nil)
23 func (b
*aesCipherAsm
) NewCBCEncrypter(iv
[]byte) cipher
.BlockMode
{
31 func (b
*aesCipherAsm
) NewCBCDecrypter(iv
[]byte) cipher
.BlockMode
{
34 c
.c
= b
.function
+ 128 // decrypt function code is encrypt + 128
39 func (x
*cbc
) BlockSize() int { return BlockSize
}
41 // cryptBlocksChain invokes the cipher message with chaining (KMC) instruction
42 // with the given function code. The length must be a multiple of BlockSize (16).
44 func cryptBlocksChain(c code
, iv
, key
, dst
, src
*byte, length
int)
46 func (x
*cbc
) CryptBlocks(dst
, src
[]byte) {
47 if len(src
)%BlockSize
!= 0 {
48 panic("crypto/cipher: input not full blocks")
50 if len(dst
) < len(src
) {
51 panic("crypto/cipher: output smaller than input")
54 cryptBlocksChain(x
.c
, &x
.iv
[0], &x
.b
.key
[0], &dst
[0], &src
[0], len(src
))
58 func (x
*cbc
) SetIV(iv
[]byte) {
59 if len(iv
) != BlockSize
{
60 panic("cipher: incorrect length IV")