chacha_s390x.go 764 B

12345678910111213141516171819202122232425262728
  1. // Copyright 2018 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. //go:build gc && !purego
  5. // +build gc,!purego
  6. package chacha20
  7. import "golang.org/x/sys/cpu"
  8. var haveAsm = cpu.S390X.HasVX
  9. const bufSize = 256
  10. // xorKeyStreamVX is an assembly implementation of XORKeyStream. It must only
  11. // be called when the vector facility is available. Implementation in asm_s390x.s.
  12. //
  13. //go:noescape
  14. func xorKeyStreamVX(dst, src []byte, key *[8]uint32, nonce *[3]uint32, counter *uint32)
  15. func (c *Cipher) xorKeyStreamBlocks(dst, src []byte) {
  16. if cpu.S390X.HasVX {
  17. xorKeyStreamVX(dst, src, &c.key, &c.nonce, &c.counter)
  18. } else {
  19. c.xorKeyStreamBlocksGeneric(dst, src)
  20. }
  21. }