xref: /freebsd/sys/crypto/openssl/powerpc/vpaes-ppc.S (revision f5463265955b829775bbb32e1fd0bc11dafc36ce)
1/* Do not modify. This file is auto-generated from vpaes-ppc.pl. */
2.machine	"any"
3
4.text
5
6.align	7
7_vpaes_consts:
8.Lk_mc_forward:
9.byte	0x01,0x02,0x03,0x00,0x05,0x06,0x07,0x04,0x09,0x0a,0x0b,0x08,0x0d,0x0e,0x0f,0x0c
10.byte	0x05,0x06,0x07,0x04,0x09,0x0a,0x0b,0x08,0x0d,0x0e,0x0f,0x0c,0x01,0x02,0x03,0x00
11.byte	0x09,0x0a,0x0b,0x08,0x0d,0x0e,0x0f,0x0c,0x01,0x02,0x03,0x00,0x05,0x06,0x07,0x04
12.byte	0x0d,0x0e,0x0f,0x0c,0x01,0x02,0x03,0x00,0x05,0x06,0x07,0x04,0x09,0x0a,0x0b,0x08
13.Lk_mc_backward:
14.byte	0x03,0x00,0x01,0x02,0x07,0x04,0x05,0x06,0x0b,0x08,0x09,0x0a,0x0f,0x0c,0x0d,0x0e
15.byte	0x0f,0x0c,0x0d,0x0e,0x03,0x00,0x01,0x02,0x07,0x04,0x05,0x06,0x0b,0x08,0x09,0x0a
16.byte	0x0b,0x08,0x09,0x0a,0x0f,0x0c,0x0d,0x0e,0x03,0x00,0x01,0x02,0x07,0x04,0x05,0x06
17.byte	0x07,0x04,0x05,0x06,0x0b,0x08,0x09,0x0a,0x0f,0x0c,0x0d,0x0e,0x03,0x00,0x01,0x02
18.Lk_sr:
19.byte	0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f
20.byte	0x00,0x05,0x0a,0x0f,0x04,0x09,0x0e,0x03,0x08,0x0d,0x02,0x07,0x0c,0x01,0x06,0x0b
21.byte	0x00,0x09,0x02,0x0b,0x04,0x0d,0x06,0x0f,0x08,0x01,0x0a,0x03,0x0c,0x05,0x0e,0x07
22.byte	0x00,0x0d,0x0a,0x07,0x04,0x01,0x0e,0x0b,0x08,0x05,0x02,0x0f,0x0c,0x09,0x06,0x03
23
24
25
26
27.Lk_inv:
28.byte	0xf0,0x01,0x08,0x0d,0x0f,0x06,0x05,0x0e,0x02,0x0c,0x0b,0x0a,0x09,0x03,0x07,0x04
29.byte	0xf0,0x07,0x0b,0x0f,0x06,0x0a,0x04,0x01,0x09,0x08,0x05,0x02,0x0c,0x0e,0x0d,0x03
30.Lk_ipt:
31.byte	0x00,0x70,0x2a,0x5a,0x98,0xe8,0xb2,0xc2,0x08,0x78,0x22,0x52,0x90,0xe0,0xba,0xca
32.byte	0x00,0x4d,0x7c,0x31,0x7d,0x30,0x01,0x4c,0x81,0xcc,0xfd,0xb0,0xfc,0xb1,0x80,0xcd
33.Lk_sbo:
34.byte	0x00,0xc7,0xbd,0x6f,0x17,0x6d,0xd2,0xd0,0x78,0xa8,0x02,0xc5,0x7a,0xbf,0xaa,0x15
35.byte	0x00,0x6a,0xbb,0x5f,0xa5,0x74,0xe4,0xcf,0xfa,0x35,0x2b,0x41,0xd1,0x90,0x1e,0x8e
36.Lk_sb1:
37.byte	0x00,0x23,0xe2,0xfa,0x15,0xd4,0x18,0x36,0xef,0xd9,0x2e,0x0d,0xc1,0xcc,0xf7,0x3b
38.byte	0x00,0x3e,0x50,0xcb,0x8f,0xe1,0x9b,0xb1,0x44,0xf5,0x2a,0x14,0x6e,0x7a,0xdf,0xa5
39.Lk_sb2:
40.byte	0x00,0x29,0xe1,0x0a,0x40,0x88,0xeb,0x69,0x4a,0x23,0x82,0xab,0xc8,0x63,0xa1,0xc2
41.byte	0x00,0x24,0x71,0x0b,0xc6,0x93,0x7a,0xe2,0xcd,0x2f,0x98,0xbc,0x55,0xe9,0xb7,0x5e
42
43
44
45
46.Lk_dipt:
47.byte	0x00,0x5f,0x54,0x0b,0x04,0x5b,0x50,0x0f,0x1a,0x45,0x4e,0x11,0x1e,0x41,0x4a,0x15
48.byte	0x00,0x65,0x05,0x60,0xe6,0x83,0xe3,0x86,0x94,0xf1,0x91,0xf4,0x72,0x17,0x77,0x12
49.Lk_dsbo:
50.byte	0x00,0x40,0xf9,0x7e,0x53,0xea,0x87,0x13,0x2d,0x3e,0x94,0xd4,0xb9,0x6d,0xaa,0xc7
51.byte	0x00,0x1d,0x44,0x93,0x0f,0x56,0xd7,0x12,0x9c,0x8e,0xc5,0xd8,0x59,0x81,0x4b,0xca
52.Lk_dsb9:
53.byte	0x00,0xd6,0x86,0x9a,0x53,0x03,0x1c,0x85,0xc9,0x4c,0x99,0x4f,0x50,0x1f,0xd5,0xca
54.byte	0x00,0x49,0xd7,0xec,0x89,0x17,0x3b,0xc0,0x65,0xa5,0xfb,0xb2,0x9e,0x2c,0x5e,0x72
55.Lk_dsbd:
56.byte	0x00,0xa2,0xb1,0xe6,0xdf,0xcc,0x57,0x7d,0x39,0x44,0x2a,0x88,0x13,0x9b,0x6e,0xf5
57.byte	0x00,0xcb,0xc6,0x24,0xf7,0xfa,0xe2,0x3c,0xd3,0xef,0xde,0x15,0x0d,0x18,0x31,0x29
58.Lk_dsbb:
59.byte	0x00,0x42,0xb4,0x96,0x92,0x64,0x22,0xd0,0x04,0xd4,0xf2,0xb0,0xf6,0x46,0x26,0x60
60.byte	0x00,0x67,0x59,0xcd,0xa6,0x98,0x94,0xc1,0x6b,0xaa,0x55,0x32,0x3e,0x0c,0xff,0xf3
61.Lk_dsbe:
62.byte	0x00,0xd0,0xd4,0x26,0x96,0x92,0xf2,0x46,0xb0,0xf6,0xb4,0x64,0x04,0x60,0x42,0x22
63.byte	0x00,0xc1,0xaa,0xff,0xcd,0xa6,0x55,0x0c,0x32,0x3e,0x59,0x98,0x6b,0xf3,0x67,0x94
64
65
66
67
68.Lk_dksd:
69.byte	0x00,0x47,0xe4,0xa3,0x5d,0x1a,0xb9,0xfe,0xf9,0xbe,0x1d,0x5a,0xa4,0xe3,0x40,0x07
70.byte	0x00,0x83,0x36,0xb5,0xf4,0x77,0xc2,0x41,0x1e,0x9d,0x28,0xab,0xea,0x69,0xdc,0x5f
71.Lk_dksb:
72.byte	0x00,0xd5,0x50,0x85,0x1f,0xca,0x4f,0x9a,0x99,0x4c,0xc9,0x1c,0x86,0x53,0xd6,0x03
73.byte	0x00,0x4a,0xfc,0xb6,0xa7,0xed,0x5b,0x11,0xc8,0x82,0x34,0x7e,0x6f,0x25,0x93,0xd9
74.Lk_dkse:
75.byte	0x00,0xd6,0xc9,0x1f,0xca,0x1c,0x03,0xd5,0x86,0x50,0x4f,0x99,0x4c,0x9a,0x85,0x53
76.byte	0xe8,0x7b,0xdc,0x4f,0x05,0x96,0x31,0xa2,0x87,0x14,0xb3,0x20,0x6a,0xf9,0x5e,0xcd
77.Lk_dks9:
78.byte	0x00,0xa7,0xd9,0x7e,0xc8,0x6f,0x11,0xb6,0xfc,0x5b,0x25,0x82,0x34,0x93,0xed,0x4a
79.byte	0x00,0x33,0x14,0x27,0x62,0x51,0x76,0x45,0xce,0xfd,0xda,0xe9,0xac,0x9f,0xb8,0x8b
80
81.Lk_rcon:
82.byte	0xb6,0xee,0x9d,0xaf,0xb9,0x91,0x83,0x1f,0x81,0x7d,0x7c,0x4d,0x08,0x98,0x2a,0x70
83.Lk_s63:
84.byte	0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b
85
86.Lk_opt:
87.byte	0x00,0x60,0xb6,0xd6,0x29,0x49,0x9f,0xff,0x08,0x68,0xbe,0xde,0x21,0x41,0x97,0xf7
88.byte	0x00,0xec,0xbc,0x50,0x51,0xbd,0xed,0x01,0xe0,0x0c,0x5c,0xb0,0xb1,0x5d,0x0d,0xe1
89.Lk_deskew:
90.byte	0x00,0xe3,0xa4,0x47,0x40,0xa3,0xe4,0x07,0x1a,0xf9,0xbe,0x5d,0x5a,0xb9,0xfe,0x1d
91.byte	0x00,0x69,0xea,0x83,0xdc,0xb5,0x36,0x5f,0x77,0x1e,0x9d,0xf4,0xab,0xc2,0x41,0x28
92.align	5
93.Lconsts:
94	mflr	0
95	bcl	20,31,$+4
96	mflr	12
97	addi	12,12,-0x308
98	mtlr	0
99	blr
100.long	0
101.byte	0,12,0x14,0,0,0,0,0
102.byte	86,101,99,116,111,114,32,80,101,114,109,117,116,97,116,105,111,110,32,65,69,83,32,102,111,114,32,65,108,116,105,86,101,99,44,77,105,107,101,32,72,97,109,98,117,114,103,32,40,83,116,97,110,102,111,114,100,32,85,110,105,118,101,114,115,105,116,121,41,0
103.align	2
104.align	6
105
106
107
108
109
110
111.align	4
112_vpaes_encrypt_preheat:
113	mflr	8
114	bl	.Lconsts
115	mtlr	8
116	li	11, 0xc0
117	li	10, 0xd0
118	li	9,  0xe0
119	li	8,  0xf0
120	vxor	7, 7, 7
121	vspltisb	8,4
122	vspltisb	9,0x0f
123	lvx	10, 12, 11
124	li	11, 0x100
125	lvx	11, 12, 10
126	li	10, 0x110
127	lvx	12, 12, 9
128	li	9,  0x120
129	lvx	13, 12, 8
130	li	8,  0x130
131	lvx	14, 12, 11
132	li	11, 0x140
133	lvx	15, 12, 10
134	li	10, 0x150
135	lvx	16, 12, 9
136	lvx	17, 12, 8
137	lvx	18, 12, 11
138	lvx	19, 12, 10
139	blr
140.long	0
141.byte	0,12,0x14,0,0,0,0,0
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157.align	5
158_vpaes_encrypt_core:
159	lwz	8, 240(5)
160	li	9, 16
161	lvx	5, 0, 5
162	li	11, 0x10
163	lvx	6, 9, 5
164	addi	9, 9, 16
165	vperm	5, 5, 6, 31
166	addi	10, 11, 0x40
167	vsrb	1, 0, 8
168	vperm	0, 12, 12, 0
169	vperm	1, 13, 13, 1
170	vxor	0, 0, 5
171	vxor	0, 0, 1
172	mtctr	8
173	b	.Lenc_entry
174
175.align	4
176.Lenc_loop:
177
178	vperm	4, 17, 7, 2
179	lvx	1, 12, 11
180	addi	11, 11, 16
181	vperm	0, 16, 7, 3
182	vxor	4, 4, 5
183	andi.	11, 11, 0x30
184	vperm	5, 19, 7, 2
185	vxor	0, 0, 4
186	vperm	2, 18, 7, 3
187	lvx	4, 12, 10
188	addi	10, 11, 0x40
189	vperm	3, 0, 7, 1
190	vxor	2, 2, 5
191	vperm	0, 0, 7, 4
192	vxor	3, 3, 2
193	vperm	4, 3, 7, 1
194	vxor	0, 0, 3
195	vxor	0, 0, 4
196
197.Lenc_entry:
198
199	vsrb	1, 0, 8
200	vperm	5, 11, 11, 0
201	vxor	0, 0, 1
202	vperm	3, 10, 10, 1
203	vperm	4, 10, 10, 0
204	vand	0, 0, 9
205	vxor	3, 3, 5
206	vxor	4, 4, 5
207	vperm	2, 10, 7, 3
208	vor	5,6,6
209	lvx	6, 9, 5
210	vperm	3, 10, 7, 4
211	addi	9, 9, 16
212	vxor	2, 2, 0
213	vperm	5, 5, 6, 31
214	vxor	3, 3, 1
215	bdnz	.Lenc_loop
216
217
218	addi	10, 11, 0x80
219
220
221	vperm	4, 14, 7, 2
222	lvx	1, 12, 10
223	vperm	0, 15, 7, 3
224	vxor	4, 4, 5
225	vxor	0, 0, 4
226	vperm	0, 0, 7, 1
227	blr
228.long	0
229.byte	0,12,0x14,0,0,0,0,0
230
231.globl	vpaes_encrypt
232.type	vpaes_encrypt,@function
233.align	5
234vpaes_encrypt:
235	stwu	1,-232(1)
236	li	10,39
237	li	11,55
238	mflr	6
239	mfspr	7,256
240	stvx	20,10,1
241	addi	10,10,32
242	stvx	21,11,1
243	addi	11,11,32
244	stvx	22,10,1
245	addi	10,10,32
246	stvx	23,11,1
247	addi	11,11,32
248	stvx	24,10,1
249	addi	10,10,32
250	stvx	25,11,1
251	addi	11,11,32
252	stvx	26,10,1
253	addi	10,10,32
254	stvx	27,11,1
255	addi	11,11,32
256	stvx	28,10,1
257	addi	10,10,32
258	stvx	29,11,1
259	addi	11,11,32
260	stvx	30,10,1
261	stvx	31,11,1
262	stw	7,228(1)
263	li	0, -1
264	stw	6,236(1)
265	mtspr	256,0
266
267	bl	_vpaes_encrypt_preheat
268
269	lvsl	27, 0, 3
270	lvx	0, 0, 3
271	addi	3, 3, 15
272	lvsr	29, 0, 4
273	lvsl	31, 0, 5
274	lvx	26, 0, 3
275	vperm	0, 0, 26, 27
276
277	bl	_vpaes_encrypt_core
278
279	andi.	8, 4, 15
280	li	9, 16
281	beq	.Lenc_out_aligned
282
283	vperm	0, 0, 0, 29
284	mtctr	9
285.Lenc_out_unaligned:
286	stvebx	0, 0, 4
287	addi	4, 4, 1
288	bdnz	.Lenc_out_unaligned
289	b	.Lenc_done
290
291.align	4
292.Lenc_out_aligned:
293	stvx	0, 0, 4
294.Lenc_done:
295
296	li	10,39
297	li	11,55
298	mtlr	6
299	mtspr	256,7
300	lvx	20,10,1
301	addi	10,10,32
302	lvx	21,11,1
303	addi	11,11,32
304	lvx	22,10,1
305	addi	10,10,32
306	lvx	23,11,1
307	addi	11,11,32
308	lvx	24,10,1
309	addi	10,10,32
310	lvx	25,11,1
311	addi	11,11,32
312	lvx	26,10,1
313	addi	10,10,32
314	lvx	27,11,1
315	addi	11,11,32
316	lvx	28,10,1
317	addi	10,10,32
318	lvx	29,11,1
319	addi	11,11,32
320	lvx	30,10,1
321	lvx	31,11,1
322	addi	1,1,232
323	blr
324.long	0
325.byte	0,12,0x04,1,0x80,0,3,0
326.long	0
327.size	vpaes_encrypt,.-vpaes_encrypt
328
329.align	4
330_vpaes_decrypt_preheat:
331	mflr	8
332	bl	.Lconsts
333	mtlr	8
334	li	11, 0xc0
335	li	10, 0xd0
336	li	9,  0x160
337	li	8,  0x170
338	vxor	7, 7, 7
339	vspltisb	8,4
340	vspltisb	9,0x0f
341	lvx	10, 12, 11
342	li	11, 0x180
343	lvx	11, 12, 10
344	li	10, 0x190
345	lvx	12, 12, 9
346	li	9,  0x1a0
347	lvx	13, 12, 8
348	li	8,  0x1b0
349	lvx	14, 12, 11
350	li	11, 0x1c0
351	lvx	15, 12, 10
352	li	10, 0x1d0
353	lvx	16, 12, 9
354	li	9,  0x1e0
355	lvx	17, 12, 8
356	li	8,  0x1f0
357	lvx	18, 12, 11
358	li	11, 0x200
359	lvx	19, 12, 10
360	li	10, 0x210
361	lvx	20, 12, 9
362	lvx	21, 12, 8
363	lvx	22, 12, 11
364	lvx	23, 12, 10
365	blr
366.long	0
367.byte	0,12,0x14,0,0,0,0,0
368
369
370
371
372
373
374.align	4
375_vpaes_decrypt_core:
376	lwz	8, 240(5)
377	li	9, 16
378	lvx	5, 0, 5
379	li	11, 0x30
380	lvx	6, 9, 5
381	addi	9, 9, 16
382	vperm	5, 5, 6, 31
383	vsrb	1, 0, 8
384	vperm	0, 12, 12, 0
385	vperm	1, 13, 13, 1
386	vxor	0, 0, 5
387	vxor	0, 0, 1
388	mtctr	8
389	b	.Ldec_entry
390
391.align	4
392.Ldec_loop:
393
394
395
396	lvx	0, 12, 11
397
398
399	vperm	4, 16, 7, 2
400	subi	11, 11, 16
401	vperm	1, 17, 7, 3
402	andi.	11, 11, 0x30
403	vxor	5, 5, 4
404
405	vxor	5, 5, 1
406
407
408	vperm	4, 18, 7, 2
409	vperm	5, 5, 7, 0
410	vperm	1, 19, 7, 3
411	vxor	5, 5, 4
412
413	vxor	5, 5, 1
414
415
416	vperm	4, 20, 7, 2
417	vperm	5, 5, 7, 0
418	vperm	1, 21, 7, 3
419	vxor	5, 5, 4
420
421	vxor	5, 5, 1
422
423
424	vperm	4, 22, 7, 2
425	vperm	5, 5, 7, 0
426	vperm	1, 23, 7, 3
427	vxor	0, 5, 4
428	vxor	0, 0, 1
429
430.Ldec_entry:
431
432	vsrb	1, 0, 8
433	vperm	2, 11, 11, 0
434	vxor	0, 0, 1
435	vperm	3, 10, 10, 1
436	vperm	4, 10, 10, 0
437	vand	0, 0, 9
438	vxor	3, 3, 2
439	vxor	4, 4, 2
440	vperm	2, 10, 7, 3
441	vor	5,6,6
442	lvx	6, 9, 5
443	vperm	3, 10, 7, 4
444	addi	9, 9, 16
445	vxor	2, 2, 0
446	vperm	5, 5, 6, 31
447	vxor	3, 3, 1
448	bdnz	.Ldec_loop
449
450
451	addi	10, 11, 0x80
452
453	vperm	4, 14, 7, 2
454
455	lvx	2, 12, 10
456	vperm	1, 15, 7, 3
457	vxor	4, 4, 5
458	vxor	0, 1, 4
459	vperm	0, 0, 7, 2
460	blr
461.long	0
462.byte	0,12,0x14,0,0,0,0,0
463
464.globl	vpaes_decrypt
465.type	vpaes_decrypt,@function
466.align	5
467vpaes_decrypt:
468	stwu	1,-232(1)
469	li	10,39
470	li	11,55
471	mflr	6
472	mfspr	7,256
473	stvx	20,10,1
474	addi	10,10,32
475	stvx	21,11,1
476	addi	11,11,32
477	stvx	22,10,1
478	addi	10,10,32
479	stvx	23,11,1
480	addi	11,11,32
481	stvx	24,10,1
482	addi	10,10,32
483	stvx	25,11,1
484	addi	11,11,32
485	stvx	26,10,1
486	addi	10,10,32
487	stvx	27,11,1
488	addi	11,11,32
489	stvx	28,10,1
490	addi	10,10,32
491	stvx	29,11,1
492	addi	11,11,32
493	stvx	30,10,1
494	stvx	31,11,1
495	stw	7,228(1)
496	li	0, -1
497	stw	6,236(1)
498	mtspr	256,0
499
500	bl	_vpaes_decrypt_preheat
501
502	lvsl	27, 0, 3
503	lvx	0, 0, 3
504	addi	3, 3, 15
505	lvsr	29, 0, 4
506	lvsl	31, 0, 5
507	lvx	26, 0, 3
508	vperm	0, 0, 26, 27
509
510	bl	_vpaes_decrypt_core
511
512	andi.	8, 4, 15
513	li	9, 16
514	beq	.Ldec_out_aligned
515
516	vperm	0, 0, 0, 29
517	mtctr	9
518.Ldec_out_unaligned:
519	stvebx	0, 0, 4
520	addi	4, 4, 1
521	bdnz	.Ldec_out_unaligned
522	b	.Ldec_done
523
524.align	4
525.Ldec_out_aligned:
526	stvx	0, 0, 4
527.Ldec_done:
528
529	li	10,39
530	li	11,55
531	mtlr	6
532	mtspr	256,7
533	lvx	20,10,1
534	addi	10,10,32
535	lvx	21,11,1
536	addi	11,11,32
537	lvx	22,10,1
538	addi	10,10,32
539	lvx	23,11,1
540	addi	11,11,32
541	lvx	24,10,1
542	addi	10,10,32
543	lvx	25,11,1
544	addi	11,11,32
545	lvx	26,10,1
546	addi	10,10,32
547	lvx	27,11,1
548	addi	11,11,32
549	lvx	28,10,1
550	addi	10,10,32
551	lvx	29,11,1
552	addi	11,11,32
553	lvx	30,10,1
554	lvx	31,11,1
555	addi	1,1,232
556	blr
557.long	0
558.byte	0,12,0x04,1,0x80,0,3,0
559.long	0
560.size	vpaes_decrypt,.-vpaes_decrypt
561
562.globl	vpaes_cbc_encrypt
563.type	vpaes_cbc_encrypt,@function
564.align	5
565vpaes_cbc_encrypt:
566	cmplwi	5,16
567	.long	0x4dc00020
568
569	stwu	1,-240(1)
570	mflr	0
571	li	10,39
572	li	11,55
573	mfspr	12,256
574	stvx	20,10,1
575	addi	10,10,32
576	stvx	21,11,1
577	addi	11,11,32
578	stvx	22,10,1
579	addi	10,10,32
580	stvx	23,11,1
581	addi	11,11,32
582	stvx	24,10,1
583	addi	10,10,32
584	stvx	25,11,1
585	addi	11,11,32
586	stvx	26,10,1
587	addi	10,10,32
588	stvx	27,11,1
589	addi	11,11,32
590	stvx	28,10,1
591	addi	10,10,32
592	stvx	29,11,1
593	addi	11,11,32
594	stvx	30,10,1
595	stvx	31,11,1
596	stw	12,228(1)
597	stw	30,232(1)
598	stw	31,236(1)
599	li	9, -16
600	stw	0, 244(1)
601
602	and	30, 5, 9
603	andi.	9, 4, 15
604	mr	5, 6
605	mr	31, 7
606	li	6, -1
607	mcrf	1, 0
608	mr	7, 12
609	mtspr	256,6
610
611	lvx	24, 0, 31
612	li	9, 15
613	lvsl	27, 0, 31
614	lvx	25, 9, 31
615	vperm	24, 24, 25, 27
616
617	cmpwi	8, 0
618	neg	8, 3
619	vxor	7, 7, 7
620	lvsl	31, 0, 5
621	lvsr	29, 0, 4
622	lvsr	27, 0, 8
623	vnor	30, 7, 7
624	lvx	26, 0, 3
625	vperm	30, 7, 30, 29
626	addi	3, 3, 15
627
628	beq	.Lcbc_decrypt
629
630	bl	_vpaes_encrypt_preheat
631	li	0, 16
632
633	beq	1, .Lcbc_enc_loop
634
635	vor	0,26,26
636	lvx	26, 0, 3
637	addi	3, 3, 16
638	vperm	0, 0, 26, 27
639	vxor	0, 0, 24
640
641	bl	_vpaes_encrypt_core
642
643	andi.	8, 4, 15
644	vor	24,0,0
645	sub	9, 4, 8
646	vperm	28, 0, 0, 29
647
648.Lcbc_enc_head:
649	stvebx	28, 8, 9
650	cmpwi	8, 15
651	addi	8, 8, 1
652	bne	.Lcbc_enc_head
653
654	sub.	30, 30, 0
655	addi	4, 4, 16
656	beq	.Lcbc_unaligned_done
657
658.Lcbc_enc_loop:
659	vor	0,26,26
660	lvx	26, 0, 3
661	addi	3, 3, 16
662	vperm	0, 0, 26, 27
663	vxor	0, 0, 24
664
665	bl	_vpaes_encrypt_core
666
667	vor	24,0,0
668	sub.	30, 30, 0
669	vperm	0, 0, 0, 29
670	vsel	1,28,0,30
671	vor	28,0,0
672	stvx	1, 0, 4
673	addi	4, 4, 16
674	bne	.Lcbc_enc_loop
675
676	b	.Lcbc_done
677
678.align	5
679.Lcbc_decrypt:
680	bl	_vpaes_decrypt_preheat
681	li	0, 16
682
683	beq	1, .Lcbc_dec_loop
684
685	vor	0,26,26
686	lvx	26, 0, 3
687	addi	3, 3, 16
688	vperm	0, 0, 26, 27
689	vor	25,0,0
690
691	bl	_vpaes_decrypt_core
692
693	andi.	8, 4, 15
694	vxor	0, 0, 24
695	vor	24,25,25
696	sub	9, 4, 8
697	vperm	28, 0, 0, 29
698
699.Lcbc_dec_head:
700	stvebx	28, 8, 9
701	cmpwi	8, 15
702	addi	8, 8, 1
703	bne	.Lcbc_dec_head
704
705	sub.	30, 30, 0
706	addi	4, 4, 16
707	beq	.Lcbc_unaligned_done
708
709.Lcbc_dec_loop:
710	vor	0,26,26
711	lvx	26, 0, 3
712	addi	3, 3, 16
713	vperm	0, 0, 26, 27
714	vor	25,0,0
715
716	bl	_vpaes_decrypt_core
717
718	vxor	0, 0, 24
719	vor	24,25,25
720	sub.	30, 30, 0
721	vperm	0, 0, 0, 29
722	vsel	1,28,0,30
723	vor	28,0,0
724	stvx	1, 0, 4
725	addi	4, 4, 16
726	bne	.Lcbc_dec_loop
727
728.Lcbc_done:
729	beq	1, .Lcbc_write_iv
730
731.Lcbc_unaligned_done:
732	andi.	8, 4, 15
733	sub	4, 4, 8
734	li	9, 0
735.Lcbc_tail:
736	stvebx	28, 9, 4
737	addi	9, 9, 1
738	cmpw	9, 8
739	bne	.Lcbc_tail
740
741.Lcbc_write_iv:
742	neg	8, 31
743	li	10, 4
744	lvsl	29, 0, 8
745	li	11, 8
746	li	12, 12
747	vperm	24, 24, 24, 29
748	stvewx	24, 0, 31
749	stvewx	24, 10, 31
750	stvewx	24, 11, 31
751	stvewx	24, 12, 31
752
753	mtspr	256,7
754	li	10,39
755	li	11,55
756	lvx	20,10,1
757	addi	10,10,32
758	lvx	21,11,1
759	addi	11,11,32
760	lvx	22,10,1
761	addi	10,10,32
762	lvx	23,11,1
763	addi	11,11,32
764	lvx	24,10,1
765	addi	10,10,32
766	lvx	25,11,1
767	addi	11,11,32
768	lvx	26,10,1
769	addi	10,10,32
770	lvx	27,11,1
771	addi	11,11,32
772	lvx	28,10,1
773	addi	10,10,32
774	lvx	29,11,1
775	addi	11,11,32
776	lvx	30,10,1
777	lvx	31,11,1
778.Lcbc_abort:
779	lwz	0, 244(1)
780	lwz	30,232(1)
781	lwz	31,236(1)
782	mtlr	0
783	addi	1,1,240
784	blr
785.long	0
786.byte	0,12,0x04,1,0x80,2,6,0
787.long	0
788.size	vpaes_cbc_encrypt,.-vpaes_cbc_encrypt
789
790
791
792
793
794.align	4
795_vpaes_key_preheat:
796	mflr	8
797	bl	.Lconsts
798	mtlr	8
799	li	11, 0xc0
800	li	10, 0xd0
801	li	9,  0xe0
802	li	8,  0xf0
803
804	vspltisb	8,4
805	vxor	9,9,9
806	lvx	10, 12, 11
807	li	11, 0x120
808	lvx	11, 12, 10
809	li	10, 0x130
810	lvx	12, 12, 9
811	li	9, 0x220
812	lvx	13, 12, 8
813	li	8, 0x230
814
815	lvx	14, 12, 11
816	li	11, 0x240
817	lvx	15, 12, 10
818	li	10, 0x250
819
820	lvx	16, 12, 9
821	li	9, 0x260
822	lvx	17, 12, 8
823	li	8, 0x270
824	lvx	18, 12, 11
825	li	11, 0x280
826	lvx	19, 12, 10
827	li	10, 0x290
828	lvx	20, 12, 9
829	li	9, 0x2a0
830	lvx	21, 12, 8
831	li	8, 0x2b0
832	lvx	22, 12, 11
833	lvx	23, 12, 10
834
835	lvx	24, 12, 9
836	lvx	25, 0, 12
837	lvx	26, 12, 8
838	blr
839.long	0
840.byte	0,12,0x14,0,0,0,0,0
841
842.align	4
843_vpaes_schedule_core:
844	mflr	7
845
846	bl	_vpaes_key_preheat
847
848
849	neg	8, 3
850	lvx	0, 0, 3
851	addi	3, 3, 15
852	lvsr	27, 0, 8
853	lvx	6, 0, 3
854	addi	3, 3, 8
855	vperm	0, 0, 6, 27
856
857
858	vor	3,0,0
859	bl	_vpaes_schedule_transform
860	vor	7,0,0
861
862	bne	1, .Lschedule_am_decrypting
863
864
865	li	8, 0x30
866	li	9, 4
867	li	10, 8
868	li	11, 12
869
870	lvsr	29, 0, 5
871	vnor	30, 9, 9
872	vperm	30, 9, 30, 29
873
874
875	vperm	28, 0, 0, 29
876	stvewx	28, 0, 5
877	stvewx	28, 9, 5
878	stvewx	28, 10, 5
879	addi	10, 12, 0x80
880	stvewx	28, 11, 5
881	b	.Lschedule_go
882
883.Lschedule_am_decrypting:
884	srwi	8, 4, 1
885	andi.	8, 8, 32
886	xori	8, 8, 32
887	addi	10, 12, 0x80
888
889	lvx	1, 8, 10
890	li	9, 4
891	li	10, 8
892	li	11, 12
893	vperm	4, 3, 3, 1
894
895	neg	0, 5
896	lvsl	29, 0, 0
897	vnor	30, 9, 9
898	vperm	30, 30, 9, 29
899
900
901	vperm	28, 4, 4, 29
902	stvewx	28, 0, 5
903	stvewx	28, 9, 5
904	stvewx	28, 10, 5
905	addi	10, 12, 0x80
906	stvewx	28, 11, 5
907	addi	5, 5, 15
908	xori	8, 8, 0x30
909
910.Lschedule_go:
911	cmplwi	4, 192
912	bgt	.Lschedule_256
913	beq	.Lschedule_192
914
915
916
917
918
919
920
921
922
923
924.Lschedule_128:
925	li	0, 10
926	mtctr	0
927
928.Loop_schedule_128:
929	bl	_vpaes_schedule_round
930	bdz	.Lschedule_mangle_last
931	bl	_vpaes_schedule_mangle
932	b	.Loop_schedule_128
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949.align	4
950.Lschedule_192:
951	li	0, 4
952	lvx	0, 0, 3
953	vperm	0, 6, 0, 27
954	vsldoi	0, 3, 0, 8
955	bl	_vpaes_schedule_transform
956	vsldoi	6, 0, 9, 8
957	vsldoi	6, 9, 6, 8
958	mtctr	0
959
960.Loop_schedule_192:
961	bl	_vpaes_schedule_round
962	vsldoi	0, 6, 0, 8
963	bl	_vpaes_schedule_mangle
964	bl	_vpaes_schedule_192_smear
965	bl	_vpaes_schedule_mangle
966	bl	_vpaes_schedule_round
967	bdz	.Lschedule_mangle_last
968	bl	_vpaes_schedule_mangle
969	bl	_vpaes_schedule_192_smear
970	b	.Loop_schedule_192
971
972
973
974
975
976
977
978
979
980
981
982.align	4
983.Lschedule_256:
984	li	0, 7
985	addi	3, 3, 8
986	lvx	0, 0, 3
987	vperm	0, 6, 0, 27
988	bl	_vpaes_schedule_transform
989	mtctr	0
990
991.Loop_schedule_256:
992	bl	_vpaes_schedule_mangle
993	vor	6,0,0
994
995
996	bl	_vpaes_schedule_round
997	bdz	.Lschedule_mangle_last
998	bl	_vpaes_schedule_mangle
999
1000
1001	vspltw	0, 0, 3
1002	vor	5,7,7
1003	vor	7,6,6
1004	bl	_vpaes_schedule_low_round
1005	vor	7,5,5
1006
1007	b	.Loop_schedule_256
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018.align	4
1019.Lschedule_mangle_last:
1020
1021	li	11, 0x2e0
1022	li	9,  0x2f0
1023	bne	1, .Lschedule_mangle_last_dec
1024
1025
1026	lvx	1, 8, 10
1027	li	11, 0x2c0
1028	li	9,  0x2d0
1029	vperm	0, 0, 0, 1
1030
1031	lvx	12, 11, 12
1032	lvx	13, 9, 12
1033	addi	5, 5, 16
1034	vxor	0, 0, 26
1035	bl	_vpaes_schedule_transform
1036
1037
1038	vperm	0, 0, 0, 29
1039	li	10, 4
1040	vsel	2,28,0,30
1041	li	11, 8
1042	stvx	2, 0, 5
1043	li	12, 12
1044	stvewx	0, 0, 5
1045	stvewx	0, 10, 5
1046	stvewx	0, 11, 5
1047	stvewx	0, 12, 5
1048	b	.Lschedule_mangle_done
1049
1050.align	4
1051.Lschedule_mangle_last_dec:
1052	lvx	12, 11, 12
1053	lvx	13, 9,  12
1054	addi	5, 5, -16
1055	vxor	0, 0, 26
1056	bl	_vpaes_schedule_transform
1057
1058
1059	addi	9, 5, -15
1060	vperm	0, 0, 0, 29
1061	li	10, 4
1062	vsel	2,28,0,30
1063	li	11, 8
1064	stvx	2, 0, 5
1065	li	12, 12
1066	stvewx	0, 0, 9
1067	stvewx	0, 10, 9
1068	stvewx	0, 11, 9
1069	stvewx	0, 12, 9
1070
1071
1072.Lschedule_mangle_done:
1073	mtlr	7
1074
1075	vxor	0, 0, 0
1076	vxor	1, 1, 1
1077	vxor	2, 2, 2
1078	vxor	3, 3, 3
1079	vxor	4, 4, 4
1080	vxor	5, 5, 5
1081	vxor	6, 6, 6
1082	vxor	7, 7, 7
1083
1084	blr
1085.long	0
1086.byte	0,12,0x14,0,0,0,0,0
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102.align	4
1103_vpaes_schedule_192_smear:
1104	vspltw	0, 7, 3
1105	vsldoi	1, 9, 6, 12
1106	vsldoi	0, 7, 0, 8
1107	vxor	6, 6, 1
1108	vxor	6, 6, 0
1109	vor	0,6,6
1110	vsldoi	6, 6, 9, 8
1111	vsldoi	6, 9, 6, 8
1112	blr
1113.long	0
1114.byte	0,12,0x14,0,0,0,0,0
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134.align	4
1135_vpaes_schedule_round:
1136
1137
1138	vsldoi	1, 24, 9, 15
1139	vsldoi	24, 24, 24, 15
1140	vxor	7, 7, 1
1141
1142
1143	vspltw	0, 0, 3
1144	vsldoi	0, 0, 0, 1
1145
1146
1147
1148
1149_vpaes_schedule_low_round:
1150
1151	vsldoi	1, 9, 7, 12
1152	vxor	7, 7, 1
1153	vspltisb	1,0x0f
1154	vsldoi	4, 9, 7, 8
1155
1156
1157	vand	1, 1, 0
1158	vsrb	0, 0, 8
1159	vxor	7, 7, 4
1160	vperm	2, 11, 9, 1
1161	vxor	1, 1, 0
1162	vperm	3, 10, 9, 0
1163	vxor	3, 3, 2
1164	vperm	4, 10, 9, 1
1165	vxor	7, 7, 26
1166	vperm	3, 10, 9, 3
1167	vxor	4, 4, 2
1168	vperm	2, 10, 9, 4
1169	vxor	3, 3, 1
1170	vxor	2, 2, 0
1171	vperm	4, 15, 9, 3
1172	vperm	1, 14, 9, 2
1173	vxor	1, 1, 4
1174
1175
1176	vxor	0, 1, 7
1177	vxor	7, 1, 7
1178	blr
1179.long	0
1180.byte	0,12,0x14,0,0,0,0,0
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191.align	4
1192_vpaes_schedule_transform:
1193
1194	vsrb	2, 0, 8
1195
1196	vperm	0, 12, 12, 0
1197
1198	vperm	2, 13, 13, 2
1199	vxor	0, 0, 2
1200	blr
1201.long	0
1202.byte	0,12,0x14,0,0,0,0,0
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227.align	4
1228_vpaes_schedule_mangle:
1229
1230
1231	bne	1, .Lschedule_mangle_dec
1232
1233
1234	vxor	4, 0, 26
1235	addi	5, 5, 16
1236	vperm	4, 4, 4, 25
1237	vperm	1, 4, 4, 25
1238	vperm	3, 1, 1, 25
1239	vxor	4, 4, 1
1240	lvx	1, 8, 10
1241	vxor	3, 3, 4
1242
1243	vperm	3, 3, 3, 1
1244	addi	8, 8, -16
1245	andi.	8, 8, 0x30
1246
1247
1248	vperm	1, 3, 3, 29
1249	vsel	2,28,1,30
1250	vor	28,1,1
1251	stvx	2, 0, 5
1252	blr
1253
1254.align	4
1255.Lschedule_mangle_dec:
1256
1257
1258	vsrb	1, 0, 8
1259
1260
1261
1262	vperm	2, 16, 16, 0
1263
1264	vperm	3, 17, 17, 1
1265	vxor	3, 3, 2
1266	vperm	3, 3, 9, 25
1267
1268
1269	vperm	2, 18, 18, 0
1270	vxor	2, 2, 3
1271
1272	vperm	3, 19, 19, 1
1273	vxor	3, 3, 2
1274	vperm	3, 3, 9, 25
1275
1276
1277	vperm	2, 20, 20, 0
1278	vxor	2, 2, 3
1279
1280	vperm	3, 21, 21, 1
1281	vxor	3, 3, 2
1282
1283
1284	vperm	2, 22, 22, 0
1285	vperm	3, 3, 9, 25
1286
1287	vperm	4, 23, 23, 1
1288	lvx	1, 8, 10
1289	vxor	2, 2, 3
1290	vxor	3, 4, 2
1291
1292	addi	5, 5, -16
1293
1294	vperm	3, 3, 3, 1
1295	addi	8, 8, -16
1296	andi.	8, 8, 0x30
1297
1298
1299	vperm	1, 3, 3, 29
1300	vsel	2,28,1,30
1301	vor	28,1,1
1302	stvx	2, 0, 5
1303	blr
1304.long	0
1305.byte	0,12,0x14,0,0,0,0,0
1306
1307.globl	vpaes_set_encrypt_key
1308.type	vpaes_set_encrypt_key,@function
1309.align	5
1310vpaes_set_encrypt_key:
1311	stwu	1,-232(1)
1312	li	10,39
1313	li	11,55
1314	mflr	0
1315	mfspr	6,256
1316	stvx	20,10,1
1317	addi	10,10,32
1318	stvx	21,11,1
1319	addi	11,11,32
1320	stvx	22,10,1
1321	addi	10,10,32
1322	stvx	23,11,1
1323	addi	11,11,32
1324	stvx	24,10,1
1325	addi	10,10,32
1326	stvx	25,11,1
1327	addi	11,11,32
1328	stvx	26,10,1
1329	addi	10,10,32
1330	stvx	27,11,1
1331	addi	11,11,32
1332	stvx	28,10,1
1333	addi	10,10,32
1334	stvx	29,11,1
1335	addi	11,11,32
1336	stvx	30,10,1
1337	stvx	31,11,1
1338	stw	6,228(1)
1339	li	7, -1
1340	stw	0, 236(1)
1341	mtspr	256,7
1342
1343	srwi	9, 4, 5
1344	addi	9, 9, 6
1345	stw	9, 240(5)
1346
1347	.long	0x7c842040
1348	li	8, 0x30
1349	bl	_vpaes_schedule_core
1350
1351	lwz	0, 236(1)
1352	li	10,39
1353	li	11,55
1354	mtspr	256,6
1355	mtlr	0
1356	xor	3, 3, 3
1357	lvx	20,10,1
1358	addi	10,10,32
1359	lvx	21,11,1
1360	addi	11,11,32
1361	lvx	22,10,1
1362	addi	10,10,32
1363	lvx	23,11,1
1364	addi	11,11,32
1365	lvx	24,10,1
1366	addi	10,10,32
1367	lvx	25,11,1
1368	addi	11,11,32
1369	lvx	26,10,1
1370	addi	10,10,32
1371	lvx	27,11,1
1372	addi	11,11,32
1373	lvx	28,10,1
1374	addi	10,10,32
1375	lvx	29,11,1
1376	addi	11,11,32
1377	lvx	30,10,1
1378	lvx	31,11,1
1379	addi	1,1,232
1380	blr
1381.long	0
1382.byte	0,12,0x04,1,0x80,0,3,0
1383.long	0
1384.size	vpaes_set_encrypt_key,.-vpaes_set_encrypt_key
1385
1386.globl	vpaes_set_decrypt_key
1387.type	vpaes_set_decrypt_key,@function
1388.align	4
1389vpaes_set_decrypt_key:
1390	stwu	1,-232(1)
1391	li	10,39
1392	li	11,55
1393	mflr	0
1394	mfspr	6,256
1395	stvx	20,10,1
1396	addi	10,10,32
1397	stvx	21,11,1
1398	addi	11,11,32
1399	stvx	22,10,1
1400	addi	10,10,32
1401	stvx	23,11,1
1402	addi	11,11,32
1403	stvx	24,10,1
1404	addi	10,10,32
1405	stvx	25,11,1
1406	addi	11,11,32
1407	stvx	26,10,1
1408	addi	10,10,32
1409	stvx	27,11,1
1410	addi	11,11,32
1411	stvx	28,10,1
1412	addi	10,10,32
1413	stvx	29,11,1
1414	addi	11,11,32
1415	stvx	30,10,1
1416	stvx	31,11,1
1417	stw	6,228(1)
1418	li	7, -1
1419	stw	0, 236(1)
1420	mtspr	256,7
1421
1422	srwi	9, 4, 5
1423	addi	9, 9, 6
1424	stw	9, 240(5)
1425
1426	slwi	9, 9, 4
1427	add	5, 5, 9
1428
1429	cmplwi	1, 4, 0
1430	srwi	8, 4, 1
1431	andi.	8, 8, 32
1432	xori	8, 8, 32
1433	bl	_vpaes_schedule_core
1434
1435	lwz	0,  236(1)
1436	li	10,39
1437	li	11,55
1438	mtspr	256,6
1439	mtlr	0
1440	xor	3, 3, 3
1441	lvx	20,10,1
1442	addi	10,10,32
1443	lvx	21,11,1
1444	addi	11,11,32
1445	lvx	22,10,1
1446	addi	10,10,32
1447	lvx	23,11,1
1448	addi	11,11,32
1449	lvx	24,10,1
1450	addi	10,10,32
1451	lvx	25,11,1
1452	addi	11,11,32
1453	lvx	26,10,1
1454	addi	10,10,32
1455	lvx	27,11,1
1456	addi	11,11,32
1457	lvx	28,10,1
1458	addi	10,10,32
1459	lvx	29,11,1
1460	addi	11,11,32
1461	lvx	30,10,1
1462	lvx	31,11,1
1463	addi	1,1,232
1464	blr
1465.long	0
1466.byte	0,12,0x04,1,0x80,0,3,0
1467.long	0
1468.size	vpaes_set_decrypt_key,.-vpaes_set_decrypt_key
1469