| 1 |
// Copyright 2025 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 |
//go:build !purego |
| 6 |
|
| 7 |
package subtle |
| 8 |
|
| 9 |
import ( |
| 10 |
"crypto/internal/fips140deps/cpu" |
| 11 |
"crypto/internal/impl" |
| 12 |
) |
| 13 |
|
| 14 |
var useLSX = cpu.LOONG64HasLSX |
| 15 |
var useLASX = cpu.LOONG64HasLASX |
| 16 |
|
| 17 |
func init() { |
| 18 |
impl.Register("subtle", "LSX", &useLSX) |
| 19 |
impl.Register("subtle", "LASX", &useLASX) |
| 20 |
} |
| 21 |
|
| 22 |
//go:noescape |
| 23 |
func xorBytesBasic(dst, a, b *byte, n int) |
| 24 |
|
| 25 |
//go:noescape |
| 26 |
func xorBytesLSX(dst, a, b *byte, n int) |
| 27 |
|
| 28 |
//go:noescape |
| 29 |
func xorBytesLASX(dst, a, b *byte, n int) |
| 30 |
|
| 31 |
func xorBytes(dst, a, b *byte, n int) { |
| 32 |
if useLASX { |
| 33 |
xorBytesLASX(dst, a, b, n) |
| 34 |
} else if useLSX { |
| 35 |
xorBytesLSX(dst, a, b, n) |
| 36 |
} else { |
| 37 |
xorBytesBasic(dst, a, b, n) |
| 38 |
} |
| 39 |
} |