ctr_asm.mx raw

   1  // Copyright 2024 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.
   4  
   5  //go:build (amd64 || arm64 || ppc64 || ppc64le) && !purego
   6  
   7  package aes
   8  
   9  //go:generate sh -c "go run ./ctr_arm64_gen.go | asmfmt > ctr_arm64.s"
  10  
  11  //go:noescape
  12  func ctrBlocks1Asm(nr int, xk *[60]uint32, dst, src *[BlockSize]byte, ivlo, ivhi uint64)
  13  
  14  //go:noescape
  15  func ctrBlocks2Asm(nr int, xk *[60]uint32, dst, src *[2 * BlockSize]byte, ivlo, ivhi uint64)
  16  
  17  //go:noescape
  18  func ctrBlocks4Asm(nr int, xk *[60]uint32, dst, src *[4 * BlockSize]byte, ivlo, ivhi uint64)
  19  
  20  //go:noescape
  21  func ctrBlocks8Asm(nr int, xk *[60]uint32, dst, src *[8 * BlockSize]byte, ivlo, ivhi uint64)
  22  
  23  func ctrBlocks1(b *Block, dst, src *[BlockSize]byte, ivlo, ivhi uint64) {
  24  	if !supportsAES {
  25  		ctrBlocks(b, dst[:], src[:], ivlo, ivhi)
  26  	} else {
  27  		ctrBlocks1Asm(b.rounds, &b.enc, dst, src, ivlo, ivhi)
  28  	}
  29  }
  30  
  31  func ctrBlocks2(b *Block, dst, src *[2 * BlockSize]byte, ivlo, ivhi uint64) {
  32  	if !supportsAES {
  33  		ctrBlocks(b, dst[:], src[:], ivlo, ivhi)
  34  	} else {
  35  		ctrBlocks2Asm(b.rounds, &b.enc, dst, src, ivlo, ivhi)
  36  	}
  37  }
  38  
  39  func ctrBlocks4(b *Block, dst, src *[4 * BlockSize]byte, ivlo, ivhi uint64) {
  40  	if !supportsAES {
  41  		ctrBlocks(b, dst[:], src[:], ivlo, ivhi)
  42  	} else {
  43  		ctrBlocks4Asm(b.rounds, &b.enc, dst, src, ivlo, ivhi)
  44  	}
  45  }
  46  
  47  func ctrBlocks8(b *Block, dst, src *[8 * BlockSize]byte, ivlo, ivhi uint64) {
  48  	if !supportsAES {
  49  		ctrBlocks(b, dst[:], src[:], ivlo, ivhi)
  50  	} else {
  51  		ctrBlocks8Asm(b.rounds, &b.enc, dst, src, ivlo, ivhi)
  52  	}
  53  }
  54