1
// Copyright 2016 The Gorilla WebSocket Authors. All rights reserved. Use of
2
// this source code is governed by a BSD-style license that can be found in the
11
const wordSize = int(unsafe.Sizeof(uintptr(0)))
13
func maskBytes(key [4]byte, pos int, b []byte) int {
15
// Mask one byte at a time for small buffers.
16
if len(b) < 2*wordSize {
24
// Mask one byte at a time to word boundary.
25
if n := int(uintptr(unsafe.Pointer(&b[0]))) % wordSize; n != 0 {
27
for i := range b[:n] {
34
// Create aligned word size key.
39
kw := *(*uintptr)(unsafe.Pointer(&k))
41
// Mask one word at a time.
42
n := (len(b) / wordSize) * wordSize
43
for i := 0; i < n; i += wordSize {
44
*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&b[0])) + uintptr(i))) ^= kw
47
// Mask one byte at a time for remaining bytes.