...

Source file src/pkg/vendor/golang.org/x/crypto/internal/chacha20/chacha_arm64.go

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

View as plain text