package aes
import (
)
func ( int, *uint32, , *byte)
func ( int, *uint32, , *byte)
func ( int, *byte, *uint32, *uint32)
type aesCipherAsm struct {
aesCipher
}
var supportsAES = cpu.X86.HasAES || cpu.ARM64.HasAES
var supportsGFMUL = cpu.X86.HasPCLMULQDQ || cpu.ARM64.HasPMULL
func ( []byte) (cipher.Block, error) {
if !supportsAES {
return newCipherGeneric()
}
:= len() + 28
:= aesCipherAsm{aesCipher{make([]uint32, ), make([]uint32, )}}
var int
switch len() {
case 128 / 8:
= 10
case 192 / 8:
= 12
case 256 / 8:
= 14
}
expandKeyAsm(, &[0], &.enc[0], &.dec[0])
if supportsAES && supportsGFMUL {
return &aesCipherGCM{}, nil
}
return &, nil
}
func ( *aesCipherAsm) () int { return BlockSize }
func ( *aesCipherAsm) (, []byte) {
if len() < BlockSize {
panic("crypto/aes: input not full block")
}
if len() < BlockSize {
panic("crypto/aes: output not full block")
}
if subtle.InexactOverlap([:BlockSize], [:BlockSize]) {
panic("crypto/aes: invalid buffer overlap")
}
encryptBlockAsm(len(.enc)/4-1, &.enc[0], &[0], &[0])
}
func ( *aesCipherAsm) (, []byte) {
if len() < BlockSize {
panic("crypto/aes: input not full block")
}
if len() < BlockSize {
panic("crypto/aes: output not full block")
}
if subtle.InexactOverlap([:BlockSize], [:BlockSize]) {
panic("crypto/aes: invalid buffer overlap")
}
decryptBlockAsm(len(.dec)/4-1, &.dec[0], &[0], &[0])
}
func ( []byte, , []uint32) {
if supportsAES {
:= 10
switch len() {
case 192 / 8:
= 12
case 256 / 8:
= 14
}
expandKeyAsm(, &[0], &[0], &[0])
} else {
expandKeyGo(, , )
}
}