File tree Expand file tree Collapse file tree 3 files changed +155
-2
lines changed
src/crypto/internal/fips140/subtle Expand file tree Collapse file tree 3 files changed +155
-2
lines changed Original file line number Diff line number Diff line change 22// Use of this source code is governed by a BSD-style
33// license that can be found in the LICENSE file.
44
5- //go:build (amd64 || arm64 || loong64 || ppc64 || ppc64le || riscv64) && !purego
5+ //go:build (amd64 || arm64 || loong64 || mips64 || mips64le || ppc64 || ppc64le || riscv64) && !purego
66
77package subtle
88
Original file line number Diff line number Diff line change 22// Use of this source code is governed by a BSD-style
33// license that can be found in the LICENSE file.
44
5- //go:build (!amd64 && !arm64 && !loong64 && !ppc64 && !ppc64le && !riscv64) || purego
5+ //go:build (!amd64 && !arm64 && !loong64 && !mips64 && !mips64le && ! ppc64 && !ppc64le && !riscv64) || purego
66
77package subtle
88
Original file line number Diff line number Diff line change 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 (mips64 || mips64le) && !purego
6+
7+ #include "textflag.h"
8+
9+ // func xorBytes(dst, a, b *byte, n int)
10+ TEXT ·xorBytes(SB), NOSPLIT|NOFRAME, $0
11+ MOVV dst+0 (FP), R1
12+ MOVV a+8 (FP), R2
13+ MOVV b+16 (FP), R3
14+ MOVV n+24 (FP), R4
15+
16+ xor_64_check:
17+ SGTU $64 , R4, R5 // R5 = 1 if (64 > R4)
18+ BNE R5, xor_32_check
19+ xor_64:
20+ MOVV (R2), R6
21+ MOVV 8 (R2), R7
22+ MOVV 16 (R2), R8
23+ MOVV 24 (R2), R9
24+ MOVV (R3), R10
25+ MOVV 8 (R3), R11
26+ MOVV 16 (R3), R12
27+ MOVV 24 (R3), R13
28+ XOR R6, R10
29+ XOR R7, R11
30+ XOR R8, R12
31+ XOR R9, R13
32+ MOVV R10, (R1)
33+ MOVV R11, 8 (R1)
34+ MOVV R12, 16 (R1)
35+ MOVV R13, 24 (R1)
36+ MOVV 32 (R2), R6
37+ MOVV 40 (R2), R7
38+ MOVV 48 (R2), R8
39+ MOVV 56 (R2), R9
40+ MOVV 32 (R3), R10
41+ MOVV 40 (R3), R11
42+ MOVV 48 (R3), R12
43+ MOVV 56 (R3), R13
44+ XOR R6, R10
45+ XOR R7, R11
46+ XOR R8, R12
47+ XOR R9, R13
48+ MOVV R10, 32 (R1)
49+ MOVV R11, 40 (R1)
50+ MOVV R12, 48 (R1)
51+ MOVV R13, 56 (R1)
52+ ADDV $64 , R2
53+ ADDV $64 , R3
54+ ADDV $64 , R1
55+ SUBV $64 , R4
56+ SGTU $64 , R4, R5
57+ BEQ R0, R5, xor_64
58+ BEQ R0, R4, end
59+
60+ xor_32_check:
61+ SGTU $32 , R4, R5
62+ BNE R5, xor_16_check
63+ xor_32:
64+ MOVV (R2), R6
65+ MOVV 8 (R2), R7
66+ MOVV 16 (R2), R8
67+ MOVV 24 (R2), R9
68+ MOVV (R3), R10
69+ MOVV 8 (R3), R11
70+ MOVV 16 (R3), R12
71+ MOVV 24 (R3), R13
72+ XOR R6, R10
73+ XOR R7, R11
74+ XOR R8, R12
75+ XOR R9, R13
76+ MOVV R10, (R1)
77+ MOVV R11, 8 (R1)
78+ MOVV R12, 16 (R1)
79+ MOVV R13, 24 (R1)
80+ ADDV $32 , R2
81+ ADDV $32 , R3
82+ ADDV $32 , R1
83+ SUBV $32 , R4
84+ BEQ R0, R4, end
85+
86+ xor_16_check:
87+ SGTU $16 , R4, R5
88+ BNE R5, xor_8_check
89+ xor_16:
90+ MOVV (R2), R6
91+ MOVV 8 (R2), R7
92+ MOVV (R3), R8
93+ MOVV 8 (R3), R9
94+ XOR R6, R8
95+ XOR R7, R9
96+ MOVV R8, (R1)
97+ MOVV R9, 8 (R1)
98+ ADDV $16 , R2
99+ ADDV $16 , R3
100+ ADDV $16 , R1
101+ SUBV $16 , R4
102+ BEQ R0, R4, end
103+
104+ xor_8_check:
105+ SGTU $8 , R4, R5
106+ BNE R5, xor_4_check
107+ xor_8:
108+ MOVV (R2), R6
109+ MOVV (R3), R7
110+ XOR R6, R7
111+ MOVV R7, (R1)
112+ ADDV $8 , R1
113+ ADDV $8 , R2
114+ ADDV $8 , R3
115+ SUBV $8 , R4
116+ BEQ R0, R4, end
117+
118+ xor_4_check:
119+ SGTU $4 , R4, R5
120+ BNE R5, xor_2_check
121+ xor_4:
122+ MOVW (R2), R6
123+ MOVW (R3), R7
124+ XOR R6, R7
125+ MOVW R7, (R1)
126+ ADDV $4 , R2
127+ ADDV $4 , R3
128+ ADDV $4 , R1
129+ SUBV $4 , R4
130+ BEQ R0, R4, end
131+
132+ xor_2_check:
133+ SGTU $2 , R4, R5
134+ BNE R5, xor_1
135+ xor_2:
136+ MOVH (R2), R6
137+ MOVH (R3), R7
138+ XOR R6, R7
139+ MOVH R7, (R1)
140+ ADDV $2 , R2
141+ ADDV $2 , R3
142+ ADDV $2 , R1
143+ SUBV $2 , R4
144+ BEQ R0, R4, end
145+
146+ xor_1:
147+ MOVB (R2), R6
148+ MOVB (R3), R7
149+ XOR R6, R7
150+ MOVB R7, (R1)
151+
152+ end:
153+ RET
You can’t perform that action at this time.
0 commit comments