| 1 | // Copyright 2020 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 xor provides utility functions used by other Pion |
| 6 | // packages. ARM64 arch. |
| 7 | package xor |
| 8 | |
| 9 | // XorBytes xors the bytes in a and b. The destination should have enough |
| 10 | // space, otherwise xorBytes will panic. Returns the number of bytes xor'd. |
| 11 | // |
| 12 | //revive:disable-next-line |
| 13 | func XorBytes(dst, a, b []byte) int { |
| 14 | n := len(a) |
| 15 | if len(b) < n { |
| 16 | n = len(b) |
| 17 | } |
| 18 | if n == 0 { |
| 19 | return 0 |
| 20 | } |
| 21 | // make sure dst has enough space |
| 22 | _ = dst[n-1] |
| 23 | |
| 24 | xorBytesARM64(&dst[0], &a[0], &b[0], n) |
| 25 | return n |
| 26 | } |
| 27 | |
| 28 | //go:noescape |
| 29 | func xorBytesARM64(dst, a, b *byte, n int) |