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 // defined in asm_ppc64le.s
17 func setEncryptKeyAsm(key
*byte, keylen
int, enc
*uint32) int
21 func setDecryptKeyAsm(key
*byte, keylen
int, dec
*uint32) int
25 func doEncryptKeyAsm(key
*byte, keylen
int, dec
*uint32) int
29 func encryptBlockAsm(dst
, src
*byte, enc
*uint32)
33 func decryptBlockAsm(dst
, src
*byte, dec
*uint32)
35 type aesCipherAsm
struct {
39 func newCipher(key
[]byte) (cipher
.Block
, error
) {
40 n
:= 64 // size is fixed for all and round value is stored inside it too
41 c
:= aesCipherAsm
{aesCipher
{make([]uint32, n
), make([]uint32, n
)}}
45 ret
+= setEncryptKeyAsm(&key
[0], k
*8, &c
.enc
[0])
46 ret
+= setDecryptKeyAsm(&key
[0], k
*8, &c
.dec
[0])
49 return nil, KeySizeError(k
)
55 func (c
*aesCipherAsm
) BlockSize() int { return BlockSize
}
57 func (c
*aesCipherAsm
) Encrypt(dst
, src
[]byte) {
58 if len(src
) < BlockSize
{
59 panic("crypto/aes: input not full block")
61 if len(dst
) < BlockSize
{
62 panic("crypto/aes: output not full block")
64 encryptBlockAsm(&dst
[0], &src
[0], &c
.enc
[0])
67 func (c
*aesCipherAsm
) Decrypt(dst
, src
[]byte) {
68 if len(src
) < BlockSize
{
69 panic("crypto/aes: input not full block")
71 if len(dst
) < BlockSize
{
72 panic("crypto/aes: output not full block")
74 decryptBlockAsm(&dst
[0], &src
[0], &c
.dec
[0])
77 // expandKey is used by BenchmarkExpand to ensure that the asm implementation
78 // of key expansion is used for the benchmark when it is available.
79 func expandKey(key
[]byte, enc
, dec
[]uint32) {
80 setEncryptKeyAsm(&key
[0], len(key
)*8, &enc
[0])
81 setDecryptKeyAsm(&key
[0], len(key
)*8, &dec
[0])