...
Source file
src/crypto/aes/cbc_s390x.go
1
2
3
4
5 package aes
6
7 import (
8 "crypto/cipher"
9 "crypto/internal/alias"
10 )
11
12
13 var _ cbcEncAble = (*aesCipherAsm)(nil)
14 var _ cbcDecAble = (*aesCipherAsm)(nil)
15
16 type cbc struct {
17 b *aesCipherAsm
18 c code
19 iv [BlockSize]byte
20 }
21
22 func (b *aesCipherAsm) NewCBCEncrypter(iv []byte) cipher.BlockMode {
23 var c cbc
24 c.b = b
25 c.c = b.function
26 copy(c.iv[:], iv)
27 return &c
28 }
29
30 func (b *aesCipherAsm) NewCBCDecrypter(iv []byte) cipher.BlockMode {
31 var c cbc
32 c.b = b
33 c.c = b.function + 128
34 copy(c.iv[:], iv)
35 return &c
36 }
37
38 func (x *cbc) BlockSize() int { return BlockSize }
39
40
41
42
43
44 func cryptBlocksChain(c code, iv, key, dst, src *byte, length int)
45
46 func (x *cbc) CryptBlocks(dst, src []byte) {
47 if len(src)%BlockSize != 0 {
48 panic("crypto/cipher: input not full blocks")
49 }
50 if len(dst) < len(src) {
51 panic("crypto/cipher: output smaller than input")
52 }
53 if alias.InexactOverlap(dst[:len(src)], src) {
54 panic("crypto/cipher: invalid buffer overlap")
55 }
56 if len(src) > 0 {
57 cryptBlocksChain(x.c, &x.iv[0], &x.b.key[0], &dst[0], &src[0], len(src))
58 }
59 }
60
61 func (x *cbc) SetIV(iv []byte) {
62 if len(iv) != BlockSize {
63 panic("cipher: incorrect length IV")
64 }
65 copy(x.iv[:], iv)
66 }
67
View as plain text