1 /* SPDX-License-Identifier: GPL-2.0 */
2 #include <linux/linkage.h>
3 #include <asm/visasm.h>
8 ENTRY(des_sparc64_key_expand)
9 /* %o0=input_key, %o1=output_key */
19 DES_KEXPAND(10, 3, 14)
20 DES_KEXPAND(10, 2, 12)
21 DES_KEXPAND(14, 1, 16)
22 DES_KEXPAND(16, 3, 20)
23 DES_KEXPAND(16, 2, 18)
24 DES_KEXPAND(20, 3, 24)
25 DES_KEXPAND(20, 2, 22)
26 DES_KEXPAND(24, 3, 28)
27 DES_KEXPAND(24, 2, 26)
28 DES_KEXPAND(28, 1, 30)
34 std %f10, [%o1 + 0x28]
35 std %f12, [%o1 + 0x30]
36 std %f14, [%o1 + 0x38]
37 std %f16, [%o1 + 0x40]
38 std %f18, [%o1 + 0x48]
39 std %f20, [%o1 + 0x50]
40 std %f22, [%o1 + 0x58]
41 std %f24, [%o1 + 0x60]
42 std %f26, [%o1 + 0x68]
43 std %f28, [%o1 + 0x70]
44 std %f30, [%o1 + 0x78]
47 ENDPROC(des_sparc64_key_expand)
50 ENTRY(des_sparc64_crypt)
51 /* %o0=key, %o1=input, %o2=output */
53 ldd [%o1 + 0x00], %f32
59 ldd [%o0 + 0x28], %f10
60 ldd [%o0 + 0x30], %f12
61 ldd [%o0 + 0x38], %f14
62 ldd [%o0 + 0x40], %f16
63 ldd [%o0 + 0x48], %f18
64 ldd [%o0 + 0x50], %f20
65 ldd [%o0 + 0x58], %f22
66 ldd [%o0 + 0x60], %f24
67 ldd [%o0 + 0x68], %f26
68 ldd [%o0 + 0x70], %f28
69 ldd [%o0 + 0x78], %f30
71 DES_ROUND(0, 2, 32, 32)
72 DES_ROUND(4, 6, 32, 32)
73 DES_ROUND(8, 10, 32, 32)
74 DES_ROUND(12, 14, 32, 32)
75 DES_ROUND(16, 18, 32, 32)
76 DES_ROUND(20, 22, 32, 32)
77 DES_ROUND(24, 26, 32, 32)
78 DES_ROUND(28, 30, 32, 32)
80 std %f32, [%o2 + 0x00]
83 ENDPROC(des_sparc64_crypt)
86 ENTRY(des_sparc64_load_keys)
94 ldd [%o0 + 0x28], %f10
95 ldd [%o0 + 0x30], %f12
96 ldd [%o0 + 0x38], %f14
97 ldd [%o0 + 0x40], %f16
98 ldd [%o0 + 0x48], %f18
99 ldd [%o0 + 0x50], %f20
100 ldd [%o0 + 0x58], %f22
101 ldd [%o0 + 0x60], %f24
102 ldd [%o0 + 0x68], %f26
103 ldd [%o0 + 0x70], %f28
105 ldd [%o0 + 0x78], %f30
106 ENDPROC(des_sparc64_load_keys)
109 ENTRY(des_sparc64_ecb_crypt)
110 /* %o0=input, %o1=output, %o2=len */
111 1: ldd [%o0 + 0x00], %f32
114 DES_ROUND(0, 2, 32, 32)
115 DES_ROUND(4, 6, 32, 32)
116 DES_ROUND(8, 10, 32, 32)
117 DES_ROUND(12, 14, 32, 32)
118 DES_ROUND(16, 18, 32, 32)
119 DES_ROUND(20, 22, 32, 32)
120 DES_ROUND(24, 26, 32, 32)
121 DES_ROUND(28, 30, 32, 32)
123 std %f32, [%o1 + 0x00]
129 ENDPROC(des_sparc64_ecb_crypt)
132 ENTRY(des_sparc64_cbc_encrypt)
133 /* %o0=input, %o1=output, %o2=len, %o3=IV */
134 ldd [%o3 + 0x00], %f32
135 1: ldd [%o0 + 0x00], %f34
136 fxor %f32, %f34, %f32
138 DES_ROUND(0, 2, 32, 32)
139 DES_ROUND(4, 6, 32, 32)
140 DES_ROUND(8, 10, 32, 32)
141 DES_ROUND(12, 14, 32, 32)
142 DES_ROUND(16, 18, 32, 32)
143 DES_ROUND(20, 22, 32, 32)
144 DES_ROUND(24, 26, 32, 32)
145 DES_ROUND(28, 30, 32, 32)
147 std %f32, [%o1 + 0x00]
153 std %f32, [%o3 + 0x00]
154 ENDPROC(des_sparc64_cbc_encrypt)
157 ENTRY(des_sparc64_cbc_decrypt)
158 /* %o0=input, %o1=output, %o2=len, %o3=IV */
159 ldd [%o3 + 0x00], %f34
160 1: ldd [%o0 + 0x00], %f36
162 DES_ROUND(0, 2, 32, 32)
163 DES_ROUND(4, 6, 32, 32)
164 DES_ROUND(8, 10, 32, 32)
165 DES_ROUND(12, 14, 32, 32)
166 DES_ROUND(16, 18, 32, 32)
167 DES_ROUND(20, 22, 32, 32)
168 DES_ROUND(24, 26, 32, 32)
169 DES_ROUND(28, 30, 32, 32)
171 fxor %f32, %f34, %f32
173 std %f32, [%o1 + 0x00]
179 std %f36, [%o3 + 0x00]
180 ENDPROC(des_sparc64_cbc_decrypt)
183 ENTRY(des3_ede_sparc64_crypt)
184 /* %o0=key, %o1=input, %o2=output */
186 ldd [%o1 + 0x00], %f32
187 ldd [%o0 + 0x00], %f0
188 ldd [%o0 + 0x08], %f2
189 ldd [%o0 + 0x10], %f4
190 ldd [%o0 + 0x18], %f6
191 ldd [%o0 + 0x20], %f8
192 ldd [%o0 + 0x28], %f10
193 ldd [%o0 + 0x30], %f12
194 ldd [%o0 + 0x38], %f14
195 ldd [%o0 + 0x40], %f16
196 ldd [%o0 + 0x48], %f18
197 ldd [%o0 + 0x50], %f20
198 ldd [%o0 + 0x58], %f22
199 ldd [%o0 + 0x60], %f24
200 ldd [%o0 + 0x68], %f26
201 ldd [%o0 + 0x70], %f28
202 ldd [%o0 + 0x78], %f30
204 DES_ROUND(0, 2, 32, 32)
205 ldd [%o0 + 0x80], %f0
206 ldd [%o0 + 0x88], %f2
207 DES_ROUND(4, 6, 32, 32)
208 ldd [%o0 + 0x90], %f4
209 ldd [%o0 + 0x98], %f6
210 DES_ROUND(8, 10, 32, 32)
211 ldd [%o0 + 0xa0], %f8
212 ldd [%o0 + 0xa8], %f10
213 DES_ROUND(12, 14, 32, 32)
214 ldd [%o0 + 0xb0], %f12
215 ldd [%o0 + 0xb8], %f14
216 DES_ROUND(16, 18, 32, 32)
217 ldd [%o0 + 0xc0], %f16
218 ldd [%o0 + 0xc8], %f18
219 DES_ROUND(20, 22, 32, 32)
220 ldd [%o0 + 0xd0], %f20
221 ldd [%o0 + 0xd8], %f22
222 DES_ROUND(24, 26, 32, 32)
223 ldd [%o0 + 0xe0], %f24
224 ldd [%o0 + 0xe8], %f26
225 DES_ROUND(28, 30, 32, 32)
226 ldd [%o0 + 0xf0], %f28
227 ldd [%o0 + 0xf8], %f30
230 DES_ROUND(0, 2, 32, 32)
231 ldd [%o0 + 0x100], %f0
232 ldd [%o0 + 0x108], %f2
233 DES_ROUND(4, 6, 32, 32)
234 ldd [%o0 + 0x110], %f4
235 ldd [%o0 + 0x118], %f6
236 DES_ROUND(8, 10, 32, 32)
237 ldd [%o0 + 0x120], %f8
238 ldd [%o0 + 0x128], %f10
239 DES_ROUND(12, 14, 32, 32)
240 ldd [%o0 + 0x130], %f12
241 ldd [%o0 + 0x138], %f14
242 DES_ROUND(16, 18, 32, 32)
243 ldd [%o0 + 0x140], %f16
244 ldd [%o0 + 0x148], %f18
245 DES_ROUND(20, 22, 32, 32)
246 ldd [%o0 + 0x150], %f20
247 ldd [%o0 + 0x158], %f22
248 DES_ROUND(24, 26, 32, 32)
249 ldd [%o0 + 0x160], %f24
250 ldd [%o0 + 0x168], %f26
251 DES_ROUND(28, 30, 32, 32)
252 ldd [%o0 + 0x170], %f28
253 ldd [%o0 + 0x178], %f30
256 DES_ROUND(0, 2, 32, 32)
257 DES_ROUND(4, 6, 32, 32)
258 DES_ROUND(8, 10, 32, 32)
259 DES_ROUND(12, 14, 32, 32)
260 DES_ROUND(16, 18, 32, 32)
261 DES_ROUND(20, 22, 32, 32)
262 DES_ROUND(24, 26, 32, 32)
263 DES_ROUND(28, 30, 32, 32)
266 std %f32, [%o2 + 0x00]
269 ENDPROC(des3_ede_sparc64_crypt)
272 ENTRY(des3_ede_sparc64_load_keys)
275 ldd [%o0 + 0x00], %f0
276 ldd [%o0 + 0x08], %f2
277 ldd [%o0 + 0x10], %f4
278 ldd [%o0 + 0x18], %f6
279 ldd [%o0 + 0x20], %f8
280 ldd [%o0 + 0x28], %f10
281 ldd [%o0 + 0x30], %f12
282 ldd [%o0 + 0x38], %f14
283 ldd [%o0 + 0x40], %f16
284 ldd [%o0 + 0x48], %f18
285 ldd [%o0 + 0x50], %f20
286 ldd [%o0 + 0x58], %f22
287 ldd [%o0 + 0x60], %f24
288 ldd [%o0 + 0x68], %f26
289 ldd [%o0 + 0x70], %f28
290 ldd [%o0 + 0x78], %f30
291 ldd [%o0 + 0x80], %f32
292 ldd [%o0 + 0x88], %f34
293 ldd [%o0 + 0x90], %f36
294 ldd [%o0 + 0x98], %f38
295 ldd [%o0 + 0xa0], %f40
296 ldd [%o0 + 0xa8], %f42
297 ldd [%o0 + 0xb0], %f44
298 ldd [%o0 + 0xb8], %f46
299 ldd [%o0 + 0xc0], %f48
300 ldd [%o0 + 0xc8], %f50
301 ldd [%o0 + 0xd0], %f52
302 ldd [%o0 + 0xd8], %f54
303 ldd [%o0 + 0xe0], %f56
305 ldd [%o0 + 0xe8], %f58
306 ENDPROC(des3_ede_sparc64_load_keys)
308 #define DES3_LOOP_BODY(X) \
310 DES_ROUND(0, 2, X, X) \
311 DES_ROUND(4, 6, X, X) \
312 DES_ROUND(8, 10, X, X) \
313 DES_ROUND(12, 14, X, X) \
314 DES_ROUND(16, 18, X, X) \
315 ldd [%o0 + 0xf0], %f16; \
316 ldd [%o0 + 0xf8], %f18; \
317 DES_ROUND(20, 22, X, X) \
318 ldd [%o0 + 0x100], %f20; \
319 ldd [%o0 + 0x108], %f22; \
320 DES_ROUND(24, 26, X, X) \
321 ldd [%o0 + 0x110], %f24; \
322 ldd [%o0 + 0x118], %f26; \
323 DES_ROUND(28, 30, X, X) \
324 ldd [%o0 + 0x120], %f28; \
325 ldd [%o0 + 0x128], %f30; \
328 DES_ROUND(32, 34, X, X) \
329 ldd [%o0 + 0x130], %f0; \
330 ldd [%o0 + 0x138], %f2; \
331 DES_ROUND(36, 38, X, X) \
332 ldd [%o0 + 0x140], %f4; \
333 ldd [%o0 + 0x148], %f6; \
334 DES_ROUND(40, 42, X, X) \
335 ldd [%o0 + 0x150], %f8; \
336 ldd [%o0 + 0x158], %f10; \
337 DES_ROUND(44, 46, X, X) \
338 ldd [%o0 + 0x160], %f12; \
339 ldd [%o0 + 0x168], %f14; \
340 DES_ROUND(48, 50, X, X) \
341 DES_ROUND(52, 54, X, X) \
342 DES_ROUND(56, 58, X, X) \
343 DES_ROUND(16, 18, X, X) \
344 ldd [%o0 + 0x170], %f16; \
345 ldd [%o0 + 0x178], %f18; \
348 DES_ROUND(20, 22, X, X) \
349 ldd [%o0 + 0x50], %f20; \
350 ldd [%o0 + 0x58], %f22; \
351 DES_ROUND(24, 26, X, X) \
352 ldd [%o0 + 0x60], %f24; \
353 ldd [%o0 + 0x68], %f26; \
354 DES_ROUND(28, 30, X, X) \
355 ldd [%o0 + 0x70], %f28; \
356 ldd [%o0 + 0x78], %f30; \
357 DES_ROUND(0, 2, X, X) \
358 ldd [%o0 + 0x00], %f0; \
359 ldd [%o0 + 0x08], %f2; \
360 DES_ROUND(4, 6, X, X) \
361 ldd [%o0 + 0x10], %f4; \
362 ldd [%o0 + 0x18], %f6; \
363 DES_ROUND(8, 10, X, X) \
364 ldd [%o0 + 0x20], %f8; \
365 ldd [%o0 + 0x28], %f10; \
366 DES_ROUND(12, 14, X, X) \
367 ldd [%o0 + 0x30], %f12; \
368 ldd [%o0 + 0x38], %f14; \
369 DES_ROUND(16, 18, X, X) \
370 ldd [%o0 + 0x40], %f16; \
371 ldd [%o0 + 0x48], %f18; \
375 ENTRY(des3_ede_sparc64_ecb_crypt)
376 /* %o0=key, %o1=input, %o2=output, %o3=len */
377 1: ldd [%o1 + 0x00], %f60
379 std %f60, [%o2 + 0x00]
386 ENDPROC(des3_ede_sparc64_ecb_crypt)
389 ENTRY(des3_ede_sparc64_cbc_encrypt)
390 /* %o0=key, %o1=input, %o2=output, %o3=len, %o4=IV */
391 ldd [%o4 + 0x00], %f60
392 1: ldd [%o1 + 0x00], %f62
393 fxor %f60, %f62, %f60
395 std %f60, [%o2 + 0x00]
401 std %f60, [%o4 + 0x00]
402 ENDPROC(des3_ede_sparc64_cbc_encrypt)
405 ENTRY(des3_ede_sparc64_cbc_decrypt)
406 /* %o0=key, %o1=input, %o2=output, %o3=len, %o4=IV */
407 ldd [%o4 + 0x00], %f62
408 1: ldx [%o1 + 0x00], %g1
411 fxor %f62, %f60, %f60
413 std %f60, [%o2 + 0x00]
419 stx %g1, [%o4 + 0x00]
420 ENDPROC(des3_ede_sparc64_cbc_decrypt)