package aes
import (
)
func ( int, *uint32, , *byte)
func ( int, *uint32, , *byte)
func ( int, *byte, *uint32, *uint32)
var supportsAES = cpu.X86HasAES && cpu.X86HasSSE41 && cpu.X86HasSSSE3 ||
cpu.ARM64HasAES || cpu.PPC64 || cpu.PPC64le
func () {
if cpu.AMD64 {
impl.Register("aes", "AES-NI", &supportsAES)
}
if cpu.ARM64 {
impl.Register("aes", "Armv8.0", &supportsAES)
}
if cpu.PPC64 || cpu.PPC64le {
if godebug.Value("#ppc64aes") == "off" {
supportsAES = false
}
impl.Register("aes", "POWER8", &supportsAES)
}
}
func () {
if supportsAES {
panic("crypto/aes: internal error: using generic implementation despite hardware support")
}
}
type block struct {
blockExpanded
}
func ( *Block, []byte) *Block {
switch len() {
case aes128KeySize:
.rounds = aes128Rounds
case aes192KeySize:
.rounds = aes192Rounds
case aes256KeySize:
.rounds = aes256Rounds
}
if supportsAES {
expandKeyAsm(.rounds, &[0], &.enc[0], &.dec[0])
} else {
expandKeyGeneric(&.blockExpanded, )
}
return
}
func ( *Block) []uint32 {
return .enc[:.roundKeysSize()]
}
func ( *Block, , []byte) {
if supportsAES {
encryptBlockAsm(.rounds, &.enc[0], &[0], &[0])
} else {
encryptBlockGeneric(&.blockExpanded, , )
}
}
func ( *Block, , []byte) {
if supportsAES {
decryptBlockAsm(.rounds, &.dec[0], &[0], &[0])
} else {
decryptBlockGeneric(&.blockExpanded, , )
}
}