// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build ppc64 || ppc64le
+
// Based on CRYPTOGAMS code with the following comment:
// # ====================================================================
// # Written by Andy Polyakov <appro@openssl.org> for the OpenSSL
GLOBL ·rcon(SB), RODATA, $80
// Emulate unaligned BE vector load/stores on LE targets
+#ifdef GOARCH_ppc64le
#define P8_LXVB16X(RA,RB,VT) \
LXVD2X (RA+RB), VT \
VPERM VT, VT, ESPERM, VT
#define LXSDX_BE(RA,RB,VT) \
LXSDX (RA+RB), VT \
VPERM VT, VT, ESPERM, VT
+#else
+#define P8_LXVB16X(RA,RB,VT) \
+ LXVD2X (RA+RB), VT
+
+#define P8_STXVB16X(VS,RA,RB) \
+ STXVD2X VS, (RA+RB)
+
+#define P8_STXV(VS,RA,RB) \
+ STXVD2X VS, (RA+RB)
+
+#define P8_LXV(RA,RB,VT) \
+ LXVD2X (RA+RB), VT
+
+#define LXSDX_BE(RA,RB,VT) \
+ LXSDX (RA+RB), VT
+#endif
// func setEncryptKeyAsm(nr int, key *byte, enc *uint32, dec *uint32)
TEXT ·expandKeyAsm(SB), NOSPLIT|NOFRAME, $0
MOVD enc+16(FP), OUTENC
MOVD dec+24(FP), OUTDEC
+#ifdef GOARCH_ppc64le
MOVD $·rcon(SB), PTR // PTR point to rcon addr
LVX (PTR), ESPERM
ADD $0x10, PTR
+#else
+ MOVD $·rcon+0x10(SB), PTR // PTR point to rcon addr (skipping permute vector)
+#endif
// Get key from memory and write aligned into VR
P8_LXVB16X(INP, R0, IN0)
MOVD xk+8(FP), R5 // Key pointer
MOVD dst+16(FP), R3 // Dest pointer
MOVD src+24(FP), R4 // Src pointer
+#ifdef GOARCH_ppc64le
MOVD $·rcon(SB), R7
LVX (R7), ESPERM // Permute value for P8_ macros.
+#endif
// Set CR{1,2,3}EQ to hold the key size information.
CMPU R6, $10, CR1
MOVD xk+8(FP), R5 // Key pointer
MOVD dst+16(FP), R3 // Dest pointer
MOVD src+24(FP), R4 // Src pointer
+#ifdef GOARCH_ppc64le
MOVD $·rcon(SB), R7
LVX (R7), ESPERM // Permute value for P8_ macros.
+#endif
// Set CR{1,2,3}EQ to hold the key size information.
CMPU R6, $10, CR1
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build amd64 || arm64 || ppc64le
+//go:build amd64 || arm64 || ppc64 || ppc64le
package aes
aesCipherAsm
}
-var supportsAES = cpu.X86.HasAES || cpu.ARM64.HasAES || goarch.IsPpc64le == 1
+var supportsAES = cpu.X86.HasAES || cpu.ARM64.HasAES || goarch.IsPpc64 == 1 || goarch.IsPpc64le == 1
var supportsGFMUL = cpu.X86.HasPCLMULQDQ || cpu.ARM64.HasPMULL
func newCipher(key []byte) (cipher.Block, error) {