You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

chacha_arm64.go 745B

12345678910111213141516171819202122232425262728293031
  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. // +build go1.11
  5. // +build !gccgo
  6. package chacha20
  7. const (
  8. haveAsm = true
  9. bufSize = 256
  10. )
  11. //go:noescape
  12. func xorKeyStreamVX(dst, src []byte, key *[8]uint32, nonce *[3]uint32, counter *uint32)
  13. func (c *Cipher) xorKeyStreamAsm(dst, src []byte) {
  14. if len(src) >= bufSize {
  15. xorKeyStreamVX(dst, src, &c.key, &c.nonce, &c.counter)
  16. }
  17. if len(src)%bufSize != 0 {
  18. i := len(src) - len(src)%bufSize
  19. c.buf = [bufSize]byte{}
  20. copy(c.buf[:], src[i:])
  21. xorKeyStreamVX(c.buf[:], c.buf[:], &c.key, &c.nonce, &c.counter)
  22. c.len = bufSize - copy(dst[i:], c.buf[:len(src)%bufSize])
  23. }
  24. }