gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

chacha_s390x.go (764B)


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