xref: /openbmc/linux/arch/sparc/crypto/des_asm.S (revision c5aac2df)
1c5aac2dfSDavid S. Miller#include <linux/linkage.h>
2c5aac2dfSDavid S. Miller#include <asm/visasm.h>
3c5aac2dfSDavid S. Miller
4c5aac2dfSDavid S. Miller#define F3F(x,y,z)	(((x)<<30)|((y)<<19)|((z)<<5))
5c5aac2dfSDavid S. Miller
6c5aac2dfSDavid S. Miller#define FPD_ENCODE(x)	(((x) >> 5) | ((x) & ~(0x20)))
7c5aac2dfSDavid S. Miller
8c5aac2dfSDavid S. Miller#define RS1(x)		(FPD_ENCODE(x) << 14)
9c5aac2dfSDavid S. Miller#define RS2(x)		(FPD_ENCODE(x) <<  0)
10c5aac2dfSDavid S. Miller#define RS3(x)		(FPD_ENCODE(x) <<  9)
11c5aac2dfSDavid S. Miller#define RD(x)		(FPD_ENCODE(x) << 25)
12c5aac2dfSDavid S. Miller#define IMM5(x)		((x)           <<  0)
13c5aac2dfSDavid S. Miller
14c5aac2dfSDavid S. Miller#define DES_IP(a,b)		\
15c5aac2dfSDavid S. Miller	.word		(F3F(2, 0x36, 0x134)|RS1(a)|RD(b));
16c5aac2dfSDavid S. Miller#define DES_IIP(a,b)		\
17c5aac2dfSDavid S. Miller	.word		(F3F(2, 0x36, 0x135)|RS1(a)|RD(b));
18c5aac2dfSDavid S. Miller#define DES_KEXPAND(a,b,c)	\
19c5aac2dfSDavid S. Miller	.word		(F3F(2, 0x36, 0x136)|RS1(a)|IMM5(b)|RD(c));
20c5aac2dfSDavid S. Miller#define DES_ROUND(a,b,c,d)	\
21c5aac2dfSDavid S. Miller	.word		(F3F(2, 0x19, 0x009)|RS1(a)|RS2(b)|RS3(c)|RD(d));
22c5aac2dfSDavid S. Miller
23c5aac2dfSDavid S. Miller#define MOVXTOD_G1_F60 \
24c5aac2dfSDavid S. Miller	.word		0xbbb02301
25c5aac2dfSDavid S. Miller#define MOVXTOD_G1_F62 \
26c5aac2dfSDavid S. Miller	.word		0xbfb02301
27c5aac2dfSDavid S. Miller
28c5aac2dfSDavid S. Miller	.align	32
29c5aac2dfSDavid S. MillerENTRY(des_sparc64_key_expand)
30c5aac2dfSDavid S. Miller	/* %o0=input_key, %o1=output_key */
31c5aac2dfSDavid S. Miller	VISEntryHalf
32c5aac2dfSDavid S. Miller	ld	[%o0 + 0x00], %f0
33c5aac2dfSDavid S. Miller	ld	[%o0 + 0x04], %f1
34c5aac2dfSDavid S. Miller	DES_KEXPAND(0, 0, 0)
35c5aac2dfSDavid S. Miller	DES_KEXPAND(0, 1, 2)
36c5aac2dfSDavid S. Miller	DES_KEXPAND(2, 3, 6)
37c5aac2dfSDavid S. Miller	DES_KEXPAND(2, 2, 4)
38c5aac2dfSDavid S. Miller	DES_KEXPAND(6, 3, 10)
39c5aac2dfSDavid S. Miller	DES_KEXPAND(6, 2, 8)
40c5aac2dfSDavid S. Miller	DES_KEXPAND(10, 3, 14)
41c5aac2dfSDavid S. Miller	DES_KEXPAND(10, 2, 12)
42c5aac2dfSDavid S. Miller	DES_KEXPAND(14, 1, 16)
43c5aac2dfSDavid S. Miller	DES_KEXPAND(16, 3, 20)
44c5aac2dfSDavid S. Miller	DES_KEXPAND(16, 2, 18)
45c5aac2dfSDavid S. Miller	DES_KEXPAND(20, 3, 24)
46c5aac2dfSDavid S. Miller	DES_KEXPAND(20, 2, 22)
47c5aac2dfSDavid S. Miller	DES_KEXPAND(24, 3, 28)
48c5aac2dfSDavid S. Miller	DES_KEXPAND(24, 2, 26)
49c5aac2dfSDavid S. Miller	DES_KEXPAND(28, 1, 30)
50c5aac2dfSDavid S. Miller	std	%f0, [%o1 + 0x00]
51c5aac2dfSDavid S. Miller	std	%f2, [%o1 + 0x08]
52c5aac2dfSDavid S. Miller	std	%f4, [%o1 + 0x10]
53c5aac2dfSDavid S. Miller	std	%f6, [%o1 + 0x18]
54c5aac2dfSDavid S. Miller	std	%f8, [%o1 + 0x20]
55c5aac2dfSDavid S. Miller	std	%f10, [%o1 + 0x28]
56c5aac2dfSDavid S. Miller	std	%f12, [%o1 + 0x30]
57c5aac2dfSDavid S. Miller	std	%f14, [%o1 + 0x38]
58c5aac2dfSDavid S. Miller	std	%f16, [%o1 + 0x40]
59c5aac2dfSDavid S. Miller	std	%f18, [%o1 + 0x48]
60c5aac2dfSDavid S. Miller	std	%f20, [%o1 + 0x50]
61c5aac2dfSDavid S. Miller	std	%f22, [%o1 + 0x58]
62c5aac2dfSDavid S. Miller	std	%f24, [%o1 + 0x60]
63c5aac2dfSDavid S. Miller	std	%f26, [%o1 + 0x68]
64c5aac2dfSDavid S. Miller	std	%f28, [%o1 + 0x70]
65c5aac2dfSDavid S. Miller	std	%f30, [%o1 + 0x78]
66c5aac2dfSDavid S. Miller	retl
67c5aac2dfSDavid S. Miller	 VISExitHalf
68c5aac2dfSDavid S. MillerENDPROC(des_sparc64_key_expand)
69c5aac2dfSDavid S. Miller
70c5aac2dfSDavid S. Miller	.align	32
71c5aac2dfSDavid S. MillerENTRY(des_sparc64_crypt)
72c5aac2dfSDavid S. Miller	/* %o0=key, %o1=input, %o2=output */
73c5aac2dfSDavid S. Miller	VISEntry
74c5aac2dfSDavid S. Miller	ldd	[%o1 + 0x00], %f32
75c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x00], %f0
76c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x08], %f2
77c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x10], %f4
78c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x18], %f6
79c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x20], %f8
80c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x28], %f10
81c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x30], %f12
82c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x38], %f14
83c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x40], %f16
84c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x48], %f18
85c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x50], %f20
86c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x58], %f22
87c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x60], %f24
88c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x68], %f26
89c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x70], %f28
90c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x78], %f30
91c5aac2dfSDavid S. Miller	DES_IP(32, 32)
92c5aac2dfSDavid S. Miller	DES_ROUND(0, 2, 32, 32)
93c5aac2dfSDavid S. Miller	DES_ROUND(4, 6, 32, 32)
94c5aac2dfSDavid S. Miller	DES_ROUND(8, 10, 32, 32)
95c5aac2dfSDavid S. Miller	DES_ROUND(12, 14, 32, 32)
96c5aac2dfSDavid S. Miller	DES_ROUND(16, 18, 32, 32)
97c5aac2dfSDavid S. Miller	DES_ROUND(20, 22, 32, 32)
98c5aac2dfSDavid S. Miller	DES_ROUND(24, 26, 32, 32)
99c5aac2dfSDavid S. Miller	DES_ROUND(28, 30, 32, 32)
100c5aac2dfSDavid S. Miller	DES_IIP(32, 32)
101c5aac2dfSDavid S. Miller	std	%f32, [%o2 + 0x00]
102c5aac2dfSDavid S. Miller	retl
103c5aac2dfSDavid S. Miller	 VISExit
104c5aac2dfSDavid S. MillerENDPROC(des_sparc64_crypt)
105c5aac2dfSDavid S. Miller
106c5aac2dfSDavid S. Miller	.align	32
107c5aac2dfSDavid S. MillerENTRY(des_sparc64_load_keys)
108c5aac2dfSDavid S. Miller	/* %o0=key */
109c5aac2dfSDavid S. Miller	VISEntry
110c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x00], %f0
111c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x08], %f2
112c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x10], %f4
113c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x18], %f6
114c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x20], %f8
115c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x28], %f10
116c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x30], %f12
117c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x38], %f14
118c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x40], %f16
119c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x48], %f18
120c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x50], %f20
121c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x58], %f22
122c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x60], %f24
123c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x68], %f26
124c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x70], %f28
125c5aac2dfSDavid S. Miller	retl
126c5aac2dfSDavid S. Miller	 ldd	[%o0 + 0x78], %f30
127c5aac2dfSDavid S. MillerENDPROC(des_sparc64_load_keys)
128c5aac2dfSDavid S. Miller
129c5aac2dfSDavid S. Miller	.align	32
130c5aac2dfSDavid S. MillerENTRY(des_sparc64_ecb_crypt)
131c5aac2dfSDavid S. Miller	/* %o0=input, %o1=output, %o2=len */
132c5aac2dfSDavid S. Miller1:	ldd	[%o0 + 0x00], %f32
133c5aac2dfSDavid S. Miller	add	%o0, 0x08, %o0
134c5aac2dfSDavid S. Miller	DES_IP(32, 32)
135c5aac2dfSDavid S. Miller	DES_ROUND(0, 2, 32, 32)
136c5aac2dfSDavid S. Miller	DES_ROUND(4, 6, 32, 32)
137c5aac2dfSDavid S. Miller	DES_ROUND(8, 10, 32, 32)
138c5aac2dfSDavid S. Miller	DES_ROUND(12, 14, 32, 32)
139c5aac2dfSDavid S. Miller	DES_ROUND(16, 18, 32, 32)
140c5aac2dfSDavid S. Miller	DES_ROUND(20, 22, 32, 32)
141c5aac2dfSDavid S. Miller	DES_ROUND(24, 26, 32, 32)
142c5aac2dfSDavid S. Miller	DES_ROUND(28, 30, 32, 32)
143c5aac2dfSDavid S. Miller	DES_IIP(32, 32)
144c5aac2dfSDavid S. Miller	std	%f32, [%o1 + 0x00]
145c5aac2dfSDavid S. Miller	subcc	%o2, 0x08, %o2
146c5aac2dfSDavid S. Miller	bne,pt	%icc, 1b
147c5aac2dfSDavid S. Miller	 add	%o1, 0x08, %o1
148c5aac2dfSDavid S. Miller	retl
149c5aac2dfSDavid S. Miller	 nop
150c5aac2dfSDavid S. MillerENDPROC(des_sparc64_ecb_crypt)
151c5aac2dfSDavid S. Miller
152c5aac2dfSDavid S. Miller	.align	32
153c5aac2dfSDavid S. MillerENTRY(des_sparc64_cbc_encrypt)
154c5aac2dfSDavid S. Miller	/* %o0=input, %o1=output, %o2=len, %o3=IV */
155c5aac2dfSDavid S. Miller	ldd	[%o3 + 0x00], %f32
156c5aac2dfSDavid S. Miller1:	ldd	[%o0 + 0x00], %f34
157c5aac2dfSDavid S. Miller	fxor	%f32, %f34, %f32
158c5aac2dfSDavid S. Miller	DES_IP(32, 32)
159c5aac2dfSDavid S. Miller	DES_ROUND(0, 2, 32, 32)
160c5aac2dfSDavid S. Miller	DES_ROUND(4, 6, 32, 32)
161c5aac2dfSDavid S. Miller	DES_ROUND(8, 10, 32, 32)
162c5aac2dfSDavid S. Miller	DES_ROUND(12, 14, 32, 32)
163c5aac2dfSDavid S. Miller	DES_ROUND(16, 18, 32, 32)
164c5aac2dfSDavid S. Miller	DES_ROUND(20, 22, 32, 32)
165c5aac2dfSDavid S. Miller	DES_ROUND(24, 26, 32, 32)
166c5aac2dfSDavid S. Miller	DES_ROUND(28, 30, 32, 32)
167c5aac2dfSDavid S. Miller	DES_IIP(32, 32)
168c5aac2dfSDavid S. Miller	std	%f32, [%o1 + 0x00]
169c5aac2dfSDavid S. Miller	add	%o0, 0x08, %o0
170c5aac2dfSDavid S. Miller	subcc	%o2, 0x08, %o2
171c5aac2dfSDavid S. Miller	bne,pt	%icc, 1b
172c5aac2dfSDavid S. Miller	 add	%o1, 0x08, %o1
173c5aac2dfSDavid S. Miller	retl
174c5aac2dfSDavid S. Miller	 std	%f32, [%o3 + 0x00]
175c5aac2dfSDavid S. MillerENDPROC(des_sparc64_cbc_encrypt)
176c5aac2dfSDavid S. Miller
177c5aac2dfSDavid S. Miller	.align	32
178c5aac2dfSDavid S. MillerENTRY(des_sparc64_cbc_decrypt)
179c5aac2dfSDavid S. Miller	/* %o0=input, %o1=output, %o2=len, %o3=IV */
180c5aac2dfSDavid S. Miller	ldd	[%o3 + 0x00], %f34
181c5aac2dfSDavid S. Miller1:	ldd	[%o0 + 0x00], %f36
182c5aac2dfSDavid S. Miller	DES_IP(36, 32)
183c5aac2dfSDavid S. Miller	DES_ROUND(0, 2, 32, 32)
184c5aac2dfSDavid S. Miller	DES_ROUND(4, 6, 32, 32)
185c5aac2dfSDavid S. Miller	DES_ROUND(8, 10, 32, 32)
186c5aac2dfSDavid S. Miller	DES_ROUND(12, 14, 32, 32)
187c5aac2dfSDavid S. Miller	DES_ROUND(16, 18, 32, 32)
188c5aac2dfSDavid S. Miller	DES_ROUND(20, 22, 32, 32)
189c5aac2dfSDavid S. Miller	DES_ROUND(24, 26, 32, 32)
190c5aac2dfSDavid S. Miller	DES_ROUND(28, 30, 32, 32)
191c5aac2dfSDavid S. Miller	DES_IIP(32, 32)
192c5aac2dfSDavid S. Miller	fxor	%f32, %f34, %f32
193c5aac2dfSDavid S. Miller	std	%f32, [%o1 + 0x00]
194c5aac2dfSDavid S. Miller	add	%o0, 0x08, %o0
195c5aac2dfSDavid S. Miller	subcc	%o2, 0x08, %o2
196c5aac2dfSDavid S. Miller	bne,pt	%icc, 1b
197c5aac2dfSDavid S. Miller	 add	%o1, 0x08, %o1
198c5aac2dfSDavid S. Miller	retl
199c5aac2dfSDavid S. Miller	 std	%f36, [%o3 + 0x00]
200c5aac2dfSDavid S. MillerENDPROC(des_sparc64_cbc_decrypt)
201c5aac2dfSDavid S. Miller
202c5aac2dfSDavid S. Miller	.align	32
203c5aac2dfSDavid S. MillerENTRY(des3_ede_sparc64_crypt)
204c5aac2dfSDavid S. Miller	/* %o0=key, %o1=input, %o2=output */
205c5aac2dfSDavid S. Miller	VISEntry
206c5aac2dfSDavid S. Miller	ldd	[%o1 + 0x00], %f32
207c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x00], %f0
208c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x08], %f2
209c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x10], %f4
210c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x18], %f6
211c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x20], %f8
212c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x28], %f10
213c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x30], %f12
214c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x38], %f14
215c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x40], %f16
216c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x48], %f18
217c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x50], %f20
218c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x58], %f22
219c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x60], %f24
220c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x68], %f26
221c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x70], %f28
222c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x78], %f30
223c5aac2dfSDavid S. Miller	DES_IP(32, 32)
224c5aac2dfSDavid S. Miller	DES_ROUND(0, 2, 32, 32)
225c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x80], %f0
226c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x88], %f2
227c5aac2dfSDavid S. Miller	DES_ROUND(4, 6, 32, 32)
228c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x90], %f4
229c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x98], %f6
230c5aac2dfSDavid S. Miller	DES_ROUND(8, 10, 32, 32)
231c5aac2dfSDavid S. Miller	ldd	[%o0 + 0xa0], %f8
232c5aac2dfSDavid S. Miller	ldd	[%o0 + 0xa8], %f10
233c5aac2dfSDavid S. Miller	DES_ROUND(12, 14, 32, 32)
234c5aac2dfSDavid S. Miller	ldd	[%o0 + 0xb0], %f12
235c5aac2dfSDavid S. Miller	ldd	[%o0 + 0xb8], %f14
236c5aac2dfSDavid S. Miller	DES_ROUND(16, 18, 32, 32)
237c5aac2dfSDavid S. Miller	ldd	[%o0 + 0xc0], %f16
238c5aac2dfSDavid S. Miller	ldd	[%o0 + 0xc8], %f18
239c5aac2dfSDavid S. Miller	DES_ROUND(20, 22, 32, 32)
240c5aac2dfSDavid S. Miller	ldd	[%o0 + 0xd0], %f20
241c5aac2dfSDavid S. Miller	ldd	[%o0 + 0xd8], %f22
242c5aac2dfSDavid S. Miller	DES_ROUND(24, 26, 32, 32)
243c5aac2dfSDavid S. Miller	ldd	[%o0 + 0xe0], %f24
244c5aac2dfSDavid S. Miller	ldd	[%o0 + 0xe8], %f26
245c5aac2dfSDavid S. Miller	DES_ROUND(28, 30, 32, 32)
246c5aac2dfSDavid S. Miller	ldd	[%o0 + 0xf0], %f28
247c5aac2dfSDavid S. Miller	ldd	[%o0 + 0xf8], %f30
248c5aac2dfSDavid S. Miller	DES_IIP(32, 32)
249c5aac2dfSDavid S. Miller	DES_IP(32, 32)
250c5aac2dfSDavid S. Miller	DES_ROUND(0, 2, 32, 32)
251c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x100], %f0
252c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x108], %f2
253c5aac2dfSDavid S. Miller	DES_ROUND(4, 6, 32, 32)
254c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x110], %f4
255c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x118], %f6
256c5aac2dfSDavid S. Miller	DES_ROUND(8, 10, 32, 32)
257c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x120], %f8
258c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x128], %f10
259c5aac2dfSDavid S. Miller	DES_ROUND(12, 14, 32, 32)
260c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x130], %f12
261c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x138], %f14
262c5aac2dfSDavid S. Miller	DES_ROUND(16, 18, 32, 32)
263c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x140], %f16
264c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x148], %f18
265c5aac2dfSDavid S. Miller	DES_ROUND(20, 22, 32, 32)
266c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x150], %f20
267c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x158], %f22
268c5aac2dfSDavid S. Miller	DES_ROUND(24, 26, 32, 32)
269c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x160], %f24
270c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x168], %f26
271c5aac2dfSDavid S. Miller	DES_ROUND(28, 30, 32, 32)
272c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x170], %f28
273c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x178], %f30
274c5aac2dfSDavid S. Miller	DES_IIP(32, 32)
275c5aac2dfSDavid S. Miller	DES_IP(32, 32)
276c5aac2dfSDavid S. Miller	DES_ROUND(0, 2, 32, 32)
277c5aac2dfSDavid S. Miller	DES_ROUND(4, 6, 32, 32)
278c5aac2dfSDavid S. Miller	DES_ROUND(8, 10, 32, 32)
279c5aac2dfSDavid S. Miller	DES_ROUND(12, 14, 32, 32)
280c5aac2dfSDavid S. Miller	DES_ROUND(16, 18, 32, 32)
281c5aac2dfSDavid S. Miller	DES_ROUND(20, 22, 32, 32)
282c5aac2dfSDavid S. Miller	DES_ROUND(24, 26, 32, 32)
283c5aac2dfSDavid S. Miller	DES_ROUND(28, 30, 32, 32)
284c5aac2dfSDavid S. Miller	DES_IIP(32, 32)
285c5aac2dfSDavid S. Miller
286c5aac2dfSDavid S. Miller	std	%f32, [%o2 + 0x00]
287c5aac2dfSDavid S. Miller	retl
288c5aac2dfSDavid S. Miller	 VISExit
289c5aac2dfSDavid S. MillerENDPROC(des3_ede_sparc64_crypt)
290c5aac2dfSDavid S. Miller
291c5aac2dfSDavid S. Miller	.align	32
292c5aac2dfSDavid S. MillerENTRY(des3_ede_sparc64_load_keys)
293c5aac2dfSDavid S. Miller	/* %o0=key */
294c5aac2dfSDavid S. Miller	VISEntry
295c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x00], %f0
296c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x08], %f2
297c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x10], %f4
298c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x18], %f6
299c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x20], %f8
300c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x28], %f10
301c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x30], %f12
302c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x38], %f14
303c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x40], %f16
304c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x48], %f18
305c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x50], %f20
306c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x58], %f22
307c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x60], %f24
308c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x68], %f26
309c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x70], %f28
310c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x78], %f30
311c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x80], %f32
312c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x88], %f34
313c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x90], %f36
314c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x98], %f38
315c5aac2dfSDavid S. Miller	ldd	[%o0 + 0xa0], %f40
316c5aac2dfSDavid S. Miller	ldd	[%o0 + 0xa8], %f42
317c5aac2dfSDavid S. Miller	ldd	[%o0 + 0xb0], %f44
318c5aac2dfSDavid S. Miller	ldd	[%o0 + 0xb8], %f46
319c5aac2dfSDavid S. Miller	ldd	[%o0 + 0xc0], %f48
320c5aac2dfSDavid S. Miller	ldd	[%o0 + 0xc8], %f50
321c5aac2dfSDavid S. Miller	ldd	[%o0 + 0xd0], %f52
322c5aac2dfSDavid S. Miller	ldd	[%o0 + 0xd8], %f54
323c5aac2dfSDavid S. Miller	ldd	[%o0 + 0xe0], %f56
324c5aac2dfSDavid S. Miller	retl
325c5aac2dfSDavid S. Miller	 ldd	[%o0 + 0xe8], %f58
326c5aac2dfSDavid S. MillerENDPROC(des3_ede_sparc64_load_keys)
327c5aac2dfSDavid S. Miller
328c5aac2dfSDavid S. Miller#define DES3_LOOP_BODY(X) \
329c5aac2dfSDavid S. Miller	DES_IP(X, X) \
330c5aac2dfSDavid S. Miller	DES_ROUND(0, 2, X, X) \
331c5aac2dfSDavid S. Miller	DES_ROUND(4, 6, X, X) \
332c5aac2dfSDavid S. Miller	DES_ROUND(8, 10, X, X) \
333c5aac2dfSDavid S. Miller	DES_ROUND(12, 14, X, X) \
334c5aac2dfSDavid S. Miller	DES_ROUND(16, 18, X, X) \
335c5aac2dfSDavid S. Miller	ldd	[%o0 + 0xf0], %f16; \
336c5aac2dfSDavid S. Miller	ldd	[%o0 + 0xf8], %f18; \
337c5aac2dfSDavid S. Miller	DES_ROUND(20, 22, X, X) \
338c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x100], %f20; \
339c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x108], %f22; \
340c5aac2dfSDavid S. Miller	DES_ROUND(24, 26, X, X) \
341c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x110], %f24; \
342c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x118], %f26; \
343c5aac2dfSDavid S. Miller	DES_ROUND(28, 30, X, X) \
344c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x120], %f28; \
345c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x128], %f30; \
346c5aac2dfSDavid S. Miller	DES_IIP(X, X) \
347c5aac2dfSDavid S. Miller	DES_IP(X, X) \
348c5aac2dfSDavid S. Miller	DES_ROUND(32, 34, X, X) \
349c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x130], %f0; \
350c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x138], %f2; \
351c5aac2dfSDavid S. Miller	DES_ROUND(36, 38, X, X) \
352c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x140], %f4; \
353c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x148], %f6; \
354c5aac2dfSDavid S. Miller	DES_ROUND(40, 42, X, X) \
355c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x150], %f8; \
356c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x158], %f10; \
357c5aac2dfSDavid S. Miller	DES_ROUND(44, 46, X, X) \
358c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x160], %f12; \
359c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x168], %f14; \
360c5aac2dfSDavid S. Miller	DES_ROUND(48, 50, X, X) \
361c5aac2dfSDavid S. Miller	DES_ROUND(52, 54, X, X) \
362c5aac2dfSDavid S. Miller	DES_ROUND(56, 58, X, X) \
363c5aac2dfSDavid S. Miller	DES_ROUND(16, 18, X, X) \
364c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x170], %f16; \
365c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x178], %f18; \
366c5aac2dfSDavid S. Miller	DES_IIP(X, X) \
367c5aac2dfSDavid S. Miller	DES_IP(X, X) \
368c5aac2dfSDavid S. Miller	DES_ROUND(20, 22, X, X) \
369c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x50], %f20; \
370c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x58], %f22; \
371c5aac2dfSDavid S. Miller	DES_ROUND(24, 26, X, X) \
372c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x60], %f24; \
373c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x68], %f26; \
374c5aac2dfSDavid S. Miller	DES_ROUND(28, 30, X, X) \
375c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x70], %f28; \
376c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x78], %f30; \
377c5aac2dfSDavid S. Miller	DES_ROUND(0, 2, X, X) \
378c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x00], %f0; \
379c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x08], %f2; \
380c5aac2dfSDavid S. Miller	DES_ROUND(4, 6, X, X) \
381c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x10], %f4; \
382c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x18], %f6; \
383c5aac2dfSDavid S. Miller	DES_ROUND(8, 10, X, X) \
384c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x20], %f8; \
385c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x28], %f10; \
386c5aac2dfSDavid S. Miller	DES_ROUND(12, 14, X, X) \
387c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x30], %f12; \
388c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x38], %f14; \
389c5aac2dfSDavid S. Miller	DES_ROUND(16, 18, X, X) \
390c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x40], %f16; \
391c5aac2dfSDavid S. Miller	ldd	[%o0 + 0x48], %f18; \
392c5aac2dfSDavid S. Miller	DES_IIP(X, X)
393c5aac2dfSDavid S. Miller
394c5aac2dfSDavid S. Miller	.align	32
395c5aac2dfSDavid S. MillerENTRY(des3_ede_sparc64_ecb_crypt)
396c5aac2dfSDavid S. Miller	/* %o0=key, %o1=input, %o2=output, %o3=len */
397c5aac2dfSDavid S. Miller1:	ldd	[%o1 + 0x00], %f60
398c5aac2dfSDavid S. Miller	DES3_LOOP_BODY(60)
399c5aac2dfSDavid S. Miller	std	%f60, [%o2 + 0x00]
400c5aac2dfSDavid S. Miller	subcc	%o3, 0x08, %o3
401c5aac2dfSDavid S. Miller	bne,pt	%icc, 1b
402c5aac2dfSDavid S. Miller	 add	%o2, 0x08, %o2
403c5aac2dfSDavid S. Miller	retl
404c5aac2dfSDavid S. Miller	 nop
405c5aac2dfSDavid S. MillerENDPROC(des3_ede_sparc64_ecb_crypt)
406c5aac2dfSDavid S. Miller
407c5aac2dfSDavid S. Miller	.align	32
408c5aac2dfSDavid S. MillerENTRY(des3_ede_sparc64_cbc_encrypt)
409c5aac2dfSDavid S. Miller	/* %o0=key, %o1=input, %o2=output, %o3=len, %o4=IV */
410c5aac2dfSDavid S. Miller	ldd	[%o4 + 0x00], %f60
411c5aac2dfSDavid S. Miller1:	ldd	[%o1 + 0x00], %f62
412c5aac2dfSDavid S. Miller	fxor	%f60, %f62, %f60
413c5aac2dfSDavid S. Miller	DES3_LOOP_BODY(60)
414c5aac2dfSDavid S. Miller	std	%f60, [%o2 + 0x00]
415c5aac2dfSDavid S. Miller	add	%o1, 0x08, %o1
416c5aac2dfSDavid S. Miller	subcc	%o3, 0x08, %o3
417c5aac2dfSDavid S. Miller	bne,pt	%icc, 1b
418c5aac2dfSDavid S. Miller	 add	%o2, 0x08, %o2
419c5aac2dfSDavid S. Miller	retl
420c5aac2dfSDavid S. Miller	 std	%f60, [%o4 + 0x00]
421c5aac2dfSDavid S. MillerENDPROC(des3_ede_sparc64_cbc_encrypt)
422c5aac2dfSDavid S. Miller
423c5aac2dfSDavid S. Miller	.align	32
424c5aac2dfSDavid S. MillerENTRY(des3_ede_sparc64_cbc_decrypt)
425c5aac2dfSDavid S. Miller	/* %o0=key, %o1=input, %o2=output, %o3=len, %o4=IV */
426c5aac2dfSDavid S. Miller	ldd	[%o4 + 0x00], %f62
427c5aac2dfSDavid S. Miller1:	ldx	[%o1 + 0x00], %g1
428c5aac2dfSDavid S. Miller	MOVXTOD_G1_F60
429c5aac2dfSDavid S. Miller	DES3_LOOP_BODY(60)
430c5aac2dfSDavid S. Miller	fxor	%f62, %f60, %f60
431c5aac2dfSDavid S. Miller	MOVXTOD_G1_F62
432c5aac2dfSDavid S. Miller	std	%f60, [%o2 + 0x00]
433c5aac2dfSDavid S. Miller	add	%o1, 0x08, %o1
434c5aac2dfSDavid S. Miller	subcc	%o3, 0x08, %o3
435c5aac2dfSDavid S. Miller	bne,pt	%icc, 1b
436c5aac2dfSDavid S. Miller	 add	%o2, 0x08, %o2
437c5aac2dfSDavid S. Miller	retl
438c5aac2dfSDavid S. Miller	 stx	%g1, [%o4 + 0x00]
439c5aac2dfSDavid S. MillerENDPROC(des3_ede_sparc64_cbc_decrypt)
440