github.com/neatlab/neatio@v1.7.3-0.20220425043230-d903e92fcc75/utilities/crypto/sha3/xor_generic.go (about) 1 // Copyright 2015 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 package sha3 6 7 import "encoding/binary" 8 9 // xorInGeneric xors the bytes in buf into the state; it 10 // makes no non-portable assumptions about memory layout 11 // or alignment. 12 func xorInGeneric(d *state, buf []byte) { 13 n := len(buf) / 8 14 15 for i := 0; i < n; i++ { 16 a := binary.LittleEndian.Uint64(buf) 17 d.a[i] ^= a 18 buf = buf[8:] 19 } 20 } 21 22 // copyOutGeneric copies ulint64s to a byte buffer. 23 func copyOutGeneric(d *state, b []byte) { 24 for i := 0; len(b) >= 8; i++ { 25 binary.LittleEndian.PutUint64(b, d.a[i]) 26 b = b[8:] 27 } 28 }