PR c++/86342 - -Wdeprecated-copy and system headers.
[official-gcc.git] / libgo / go / crypto / aes / cipher_ppc64le.go
blob1d16fe03f0409edb0f555ebfae5559d8f1b0d48c
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 // defined in asm_ppc64le.s
15 //go:noescape
17 func setEncryptKeyAsm(key *byte, keylen int, enc *uint32) int
19 //go:noescape
21 func setDecryptKeyAsm(key *byte, keylen int, dec *uint32) int
23 //go:noescape
25 func doEncryptKeyAsm(key *byte, keylen int, dec *uint32) int
27 //go:noescape
29 func encryptBlockAsm(dst, src *byte, enc *uint32)
31 //go:noescape
33 func decryptBlockAsm(dst, src *byte, dec *uint32)
35 type aesCipherAsm struct {
36 aesCipher
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)}}
42 k := len(key)
44 ret := 0
45 ret += setEncryptKeyAsm(&key[0], k*8, &c.enc[0])
46 ret += setDecryptKeyAsm(&key[0], k*8, &c.dec[0])
48 if ret > 0 {
49 return nil, KeySizeError(k)
52 return &c, nil
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])