git.sr.ht/~pingoo/stdx@v0.0.0-20240218134121-094174641f6e/crypto/chacha/chacha_noasm.go (about) 1 // Copyright (c) 2016 Andreas Auernhammer. All rights reserved. 2 // Use of this source code is governed by a license that can be 3 // found in the LICENSE file. 4 5 //go:build (!amd64 && !386) || gccgo || appengine || nacl 6 7 package chacha 8 9 import "encoding/binary" 10 11 func init() { 12 useSSE2 = false 13 useSSSE3 = false 14 useAVX = false 15 useAVX2 = false 16 } 17 18 func initialize(state *[64]byte, key []byte, nonce *[16]byte) { 19 binary.LittleEndian.PutUint32(state[0:], chachaConstants[0]) 20 binary.LittleEndian.PutUint32(state[4:], chachaConstants[1]) 21 binary.LittleEndian.PutUint32(state[8:], chachaConstants[2]) 22 binary.LittleEndian.PutUint32(state[12:], chachaConstants[3]) 23 copy(state[16:], key[:]) 24 copy(state[48:], nonce[:]) 25 } 26 27 func xorKeyStream(dst, src []byte, block, state *[64]byte, rounds int) int { 28 return xorKeyStreamGeneric(dst, src, block, state, rounds) 29 }