Debian Codegraph @

hash/shake/xor_generic.go

raw
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 // +build !amd64,!386,!ppc64le
6
7 package shake
8
9 import "encoding/binary"
10
11 // xorInGeneric xors the bytes in buf into the state; it
12 // makes no non-portable assumptions about memory layout
13 // or alignment.
14 func xorIn(d *state, buf []byte) {
15 n := len(buf) / 8
16
17 for i := 0; i < n; i++ {
18 a := binary.LittleEndian.Uint64(buf)
19 d.a[i] ^= a
20 buf = buf[8:]
21 }
22 }
23
24 // copyOutGeneric copies ulint64s to a byte buffer.
25 func copyOut(d *state, b []byte) {
26 for i := 0; len(b) >= 8; i++ {
27 binary.LittleEndian.PutUint64(b, d.a[i])
28 b = b[8:]
29 }
30 }