PR c++/86342 - -Wdeprecated-copy and system headers.
[official-gcc.git] / libgo / go / crypto / aes / cbc_s390x.go
blob6b011b28b5f0f16328b11fb3a5a946937805aeee
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.
5 // +build ignore
7 package aes
9 import (
10 "crypto/cipher"
13 // Assert that aesCipherAsm implements the cbcEncAble and cbcDecAble interfaces.
14 var _ cbcEncAble = (*aesCipherAsm)(nil)
15 var _ cbcDecAble = (*aesCipherAsm)(nil)
17 type cbc struct {
18 b *aesCipherAsm
19 c code
20 iv [BlockSize]byte
23 func (b *aesCipherAsm) NewCBCEncrypter(iv []byte) cipher.BlockMode {
24 var c cbc
25 c.b = b
26 c.c = b.function
27 copy(c.iv[:], iv)
28 return &c
31 func (b *aesCipherAsm) NewCBCDecrypter(iv []byte) cipher.BlockMode {
32 var c cbc
33 c.b = b
34 c.c = b.function + 128 // decrypt function code is encrypt + 128
35 copy(c.iv[:], iv)
36 return &c
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).
43 //go:noescape
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")
53 if len(src) > 0 {
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")
62 copy(x.iv[:], iv)