]> git.ipfire.org Git - thirdparty/openssl.git/blob - crypto/des/asm/des_enc.m4
546043b1013914d03e3a9c18e0eb5f7340d5d373
[thirdparty/openssl.git] / crypto / des / asm / des_enc.m4
1 ! des_enc.m4
2 ! des_enc.S (generated from des_enc.m4)
3 !
4 ! UltraSPARC assembler version of the LibDES/SSLeay/OpenSSL des_enc.c file.
5 !
6 ! Version 1.0. 32-bit version.
7 !
8 ! June 8, 2000.
9 !
10 ! Version 2.0. 32/64-bit, PIC-ification, blended CPU adaptation
11 ! by Andy Polyakov.
12 !
13 ! January 1, 2003.
14 !
15 ! Assembler version: Copyright Svend Olaf Mikkelsen.
16 !
17 ! Original C code: Copyright Eric A. Young.
18 !
19 ! This code can be freely used by LibDES/SSLeay/OpenSSL users.
20 !
21 ! The LibDES/SSLeay/OpenSSL copyright notices must be respected.
22 !
23 ! This version can be redistributed.
24 !
25 ! To expand the m4 macros: m4 -B 8192 des_enc.m4 > des_enc.S
26 !
27 ! Global registers 1 to 5 are used. This is the same as done by the
28 ! cc compiler. The UltraSPARC load/store little endian feature is used.
29 !
30 ! Instruction grouping often refers to one CPU cycle.
31 !
32 ! Assemble through gcc: gcc -c -mcpu=ultrasparc -o des_enc.o des_enc.S
33 !
34 ! Assemble through cc: cc -c -xarch=v8plusa -o des_enc.o des_enc.S
35 !
36 ! Performance improvement according to './apps/openssl speed des'
37 !
38 ! 32-bit build:
39 ! 23% faster than cc-5.2 -xarch=v8plus -xO5
40 ! 115% faster than gcc-3.2.1 -m32 -mcpu=ultrasparc -O5
41 ! 64-bit build:
42 ! 50% faster than cc-5.2 -xarch=v9 -xO5
43 ! 100% faster than gcc-3.2.1 -m64 -mcpu=ultrasparc -O5
44 !
45
46 .ident "des_enc.m4 2.1"
47 .file "des_enc-sparc.S"
48
49 #include <openssl/opensslconf.h>
50
51 #ifdef OPENSSL_FIPSCANISTER
52 #include <openssl/fipssyms.h>
53 #endif
54
55 #if defined(__SUNPRO_C) && defined(__sparcv9)
56 # define ABI64 /* They've said -xarch=v9 at command line */
57 #elif defined(__GNUC__) && defined(__arch64__)
58 # define ABI64 /* They've said -m64 at command line */
59 #endif
60
61 #ifdef ABI64
62 .register %g2,#scratch
63 .register %g3,#scratch
64 # define FRAME -192
65 # define BIAS 2047
66 # define LDPTR ldx
67 # define STPTR stx
68 # define ARG0 128
69 # define ARGSZ 8
70 # ifndef OPENSSL_SYSNAME_ULTRASPARC
71 # define OPENSSL_SYSNAME_ULTRASPARC
72 # endif
73 #else
74 # define FRAME -96
75 # define BIAS 0
76 # define LDPTR ld
77 # define STPTR st
78 # define ARG0 68
79 # define ARGSZ 4
80 #endif
81
82 #define LOOPS 7
83
84 #define global0 %g0
85 #define global1 %g1
86 #define global2 %g2
87 #define global3 %g3
88 #define global4 %g4
89 #define global5 %g5
90
91 #define local0 %l0
92 #define local1 %l1
93 #define local2 %l2
94 #define local3 %l3
95 #define local4 %l4
96 #define local5 %l5
97 #define local7 %l6
98 #define local6 %l7
99
100 #define in0 %i0
101 #define in1 %i1
102 #define in2 %i2
103 #define in3 %i3
104 #define in4 %i4
105 #define in5 %i5
106 #define in6 %i6
107 #define in7 %i7
108
109 #define out0 %o0
110 #define out1 %o1
111 #define out2 %o2
112 #define out3 %o3
113 #define out4 %o4
114 #define out5 %o5
115 #define out6 %o6
116 #define out7 %o7
117
118 #define stub stb
119
120 changequote({,})
121
122
123 ! Macro definitions:
124
125
126 ! {ip_macro}
127 !
128 ! The logic used in initial and final permutations is the same as in
129 ! the C code. The permutations are done with a clever shift, xor, and
130 ! technique.
131 !
132 ! The macro also loads address sbox 1 to 5 to global 1 to 5, address
133 ! sbox 6 to local6, and addres sbox 8 to out3.
134 !
135 ! Rotates the halfs 3 left to bring the sbox bits in convenient positions.
136 !
137 ! Loads key first round from address in parameter 5 to out0, out1.
138 !
139 ! After the the original LibDES initial permutation, the resulting left
140 ! is in the variable initially used for right and vice versa. The macro
141 ! implements the possibility to keep the halfs in the original registers.
142 !
143 ! parameter 1 left
144 ! parameter 2 right
145 ! parameter 3 result left (modify in first round)
146 ! parameter 4 result right (use in first round)
147 ! parameter 5 key address
148 ! parameter 6 1/2 for include encryption/decryption
149 ! parameter 7 1 for move in1 to in3
150 ! parameter 8 1 for move in3 to in4, 2 for move in4 to in3
151 ! parameter 9 1 for load ks3 and ks2 to in4 and in3
152
153 define(ip_macro, {
154
155 ! {ip_macro}
156 ! $1 $2 $4 $3 $5 $6 $7 $8 $9
157
158 ld [out2+256], local1
159 srl $2, 4, local4
160
161 xor local4, $1, local4
162 ifelse($7,1,{mov in1, in3},{nop})
163
164 ld [out2+260], local2
165 and local4, local1, local4
166 ifelse($8,1,{mov in3, in4},{})
167 ifelse($8,2,{mov in4, in3},{})
168
169 ld [out2+280], out4 ! loop counter
170 sll local4, 4, local1
171 xor $1, local4, $1
172
173 ld [out2+264], local3
174 srl $1, 16, local4
175 xor $2, local1, $2
176
177 ifelse($9,1,{LDPTR KS3, in4},{})
178 xor local4, $2, local4
179 nop !sethi %hi(DES_SPtrans), global1 ! sbox addr
180
181 ifelse($9,1,{LDPTR KS2, in3},{})
182 and local4, local2, local4
183 nop !or global1, %lo(DES_SPtrans), global1 ! sbox addr
184
185 sll local4, 16, local1
186 xor $2, local4, $2
187
188 srl $2, 2, local4
189 xor $1, local1, $1
190
191 sethi %hi(16711680), local5
192 xor local4, $1, local4
193
194 and local4, local3, local4
195 or local5, 255, local5
196
197 sll local4, 2, local2
198 xor $1, local4, $1
199
200 srl $1, 8, local4
201 xor $2, local2, $2
202
203 xor local4, $2, local4
204 add global1, 768, global4
205
206 and local4, local5, local4
207 add global1, 1024, global5
208
209 ld [out2+272], local7
210 sll local4, 8, local1
211 xor $2, local4, $2
212
213 srl $2, 1, local4
214 xor $1, local1, $1
215
216 ld [$5], out0 ! key 7531
217 xor local4, $1, local4
218 add global1, 256, global2
219
220 ld [$5+4], out1 ! key 8642
221 and local4, local7, local4
222 add global1, 512, global3
223
224 sll local4, 1, local1
225 xor $1, local4, $1
226
227 sll $1, 3, local3
228 xor $2, local1, $2
229
230 sll $2, 3, local2
231 add global1, 1280, local6 ! address sbox 8
232
233 srl $1, 29, local4
234 add global1, 1792, out3 ! address sbox 8
235
236 srl $2, 29, local1
237 or local4, local3, $4
238
239 or local2, local1, $3
240
241 ifelse($6, 1, {
242
243 ld [out2+284], local5 ! 0x0000FC00 used in the rounds
244 or local2, local1, $3
245 xor $4, out0, local1
246
247 call .des_enc.1
248 and local1, 252, local1
249
250 },{})
251
252 ifelse($6, 2, {
253
254 ld [out2+284], local5 ! 0x0000FC00 used in the rounds
255 or local2, local1, $3
256 xor $4, out0, local1
257
258 call .des_dec.1
259 and local1, 252, local1
260
261 },{})
262 })
263
264
265 ! {rounds_macro}
266 !
267 ! The logic used in the DES rounds is the same as in the C code,
268 ! except that calculations for sbox 1 and sbox 5 begin before
269 ! the previous round is finished.
270 !
271 ! In each round one half (work) is modified based on key and the
272 ! other half (use).
273 !
274 ! In this version we do two rounds in a loop repeated 7 times
275 ! and two rounds seperately.
276 !
277 ! One half has the bits for the sboxes in the following positions:
278 !
279 ! 777777xx555555xx333333xx111111xx
280 !
281 ! 88xx666666xx444444xx222222xx8888
282 !
283 ! The bits for each sbox are xor-ed with the key bits for that box.
284 ! The above xx bits are cleared, and the result used for lookup in
285 ! the sbox table. Each sbox entry contains the 4 output bits permuted
286 ! into 32 bits according to the P permutation.
287 !
288 ! In the description of DES, left and right are switched after
289 ! each round, except after last round. In this code the original
290 ! left and right are kept in the same register in all rounds, meaning
291 ! that after the 16 rounds the result for right is in the register
292 ! originally used for left.
293 !
294 ! parameter 1 first work (left in first round)
295 ! parameter 2 first use (right in first round)
296 ! parameter 3 enc/dec 1/-1
297 ! parameter 4 loop label
298 ! parameter 5 key address register
299 ! parameter 6 optional address for key next encryption/decryption
300 ! parameter 7 not empty for include retl
301 !
302 ! also compares in2 to 8
303
304 define(rounds_macro, {
305
306 ! {rounds_macro}
307 ! $1 $2 $3 $4 $5 $6 $7 $8 $9
308
309 xor $2, out0, local1
310
311 ld [out2+284], local5 ! 0x0000FC00
312 ba $4
313 and local1, 252, local1
314
315 .align 32
316
317 $4:
318 ! local6 is address sbox 6
319 ! out3 is address sbox 8
320 ! out4 is loop counter
321
322 ld [global1+local1], local1
323 xor $2, out1, out1 ! 8642
324 xor $2, out0, out0 ! 7531
325 ! fmovs %f0, %f0 ! fxor used for alignment
326
327 srl out1, 4, local0 ! rotate 4 right
328 and out0, local5, local3 ! 3
329 ! fmovs %f0, %f0
330
331 ld [$5+$3*8], local7 ! key 7531 next round
332 srl local3, 8, local3 ! 3
333 and local0, 252, local2 ! 2
334 ! fmovs %f0, %f0
335
336 ld [global3+local3],local3 ! 3
337 sll out1, 28, out1 ! rotate
338 xor $1, local1, $1 ! 1 finished, local1 now sbox 7
339
340 ld [global2+local2], local2 ! 2
341 srl out0, 24, local1 ! 7
342 or out1, local0, out1 ! rotate
343
344 ldub [out2+local1], local1 ! 7 (and 0xFC)
345 srl out1, 24, local0 ! 8
346 and out1, local5, local4 ! 4
347
348 ldub [out2+local0], local0 ! 8 (and 0xFC)
349 srl local4, 8, local4 ! 4
350 xor $1, local2, $1 ! 2 finished local2 now sbox 6
351
352 ld [global4+local4],local4 ! 4
353 srl out1, 16, local2 ! 6
354 xor $1, local3, $1 ! 3 finished local3 now sbox 5
355
356 ld [out3+local0],local0 ! 8
357 and local2, 252, local2 ! 6
358 add global1, 1536, local5 ! address sbox 7
359
360 ld [local6+local2], local2 ! 6
361 srl out0, 16, local3 ! 5
362 xor $1, local4, $1 ! 4 finished
363
364 ld [local5+local1],local1 ! 7
365 and local3, 252, local3 ! 5
366 xor $1, local0, $1 ! 8 finished
367
368 ld [global5+local3],local3 ! 5
369 xor $1, local2, $1 ! 6 finished
370 subcc out4, 1, out4
371
372 ld [$5+$3*8+4], out0 ! key 8642 next round
373 xor $1, local7, local2 ! sbox 5 next round
374 xor $1, local1, $1 ! 7 finished
375
376 srl local2, 16, local2 ! sbox 5 next round
377 xor $1, local3, $1 ! 5 finished
378
379 ld [$5+$3*16+4], out1 ! key 8642 next round again
380 and local2, 252, local2 ! sbox5 next round
381 ! next round
382 xor $1, local7, local7 ! 7531
383
384 ld [global5+local2], local2 ! 5
385 srl local7, 24, local3 ! 7
386 xor $1, out0, out0 ! 8642
387
388 ldub [out2+local3], local3 ! 7 (and 0xFC)
389 srl out0, 4, local0 ! rotate 4 right
390 and local7, 252, local1 ! 1
391
392 sll out0, 28, out0 ! rotate
393 xor $2, local2, $2 ! 5 finished local2 used
394
395 srl local0, 8, local4 ! 4
396 and local0, 252, local2 ! 2
397 ld [local5+local3], local3 ! 7
398
399 srl local0, 16, local5 ! 6
400 or out0, local0, out0 ! rotate
401 ld [global2+local2], local2 ! 2
402
403 srl out0, 24, local0
404 ld [$5+$3*16], out0 ! key 7531 next round
405 and local4, 252, local4 ! 4
406
407 and local5, 252, local5 ! 6
408 ld [global4+local4], local4 ! 4
409 xor $2, local3, $2 ! 7 finished local3 used
410
411 and local0, 252, local0 ! 8
412 ld [local6+local5], local5 ! 6
413 xor $2, local2, $2 ! 2 finished local2 now sbox 3
414
415 srl local7, 8, local2 ! 3 start
416 ld [out3+local0], local0 ! 8
417 xor $2, local4, $2 ! 4 finished
418
419 and local2, 252, local2 ! 3
420 ld [global1+local1], local1 ! 1
421 xor $2, local5, $2 ! 6 finished local5 used
422
423 ld [global3+local2], local2 ! 3
424 xor $2, local0, $2 ! 8 finished
425 add $5, $3*16, $5 ! enc add 8, dec add -8 to key pointer
426
427 ld [out2+284], local5 ! 0x0000FC00
428 xor $2, out0, local4 ! sbox 1 next round
429 xor $2, local1, $2 ! 1 finished
430
431 xor $2, local2, $2 ! 3 finished
432 #ifdef OPENSSL_SYSNAME_ULTRASPARC
433 bne,pt %icc, $4
434 #else
435 bne $4
436 #endif
437 and local4, 252, local1 ! sbox 1 next round
438
439 ! two rounds more:
440
441 ld [global1+local1], local1
442 xor $2, out1, out1
443 xor $2, out0, out0
444
445 srl out1, 4, local0 ! rotate
446 and out0, local5, local3
447
448 ld [$5+$3*8], local7 ! key 7531
449 srl local3, 8, local3
450 and local0, 252, local2
451
452 ld [global3+local3],local3
453 sll out1, 28, out1 ! rotate
454 xor $1, local1, $1 ! 1 finished, local1 now sbox 7
455
456 ld [global2+local2], local2
457 srl out0, 24, local1
458 or out1, local0, out1 ! rotate
459
460 ldub [out2+local1], local1
461 srl out1, 24, local0
462 and out1, local5, local4
463
464 ldub [out2+local0], local0
465 srl local4, 8, local4
466 xor $1, local2, $1 ! 2 finished local2 now sbox 6
467
468 ld [global4+local4],local4
469 srl out1, 16, local2
470 xor $1, local3, $1 ! 3 finished local3 now sbox 5
471
472 ld [out3+local0],local0
473 and local2, 252, local2
474 add global1, 1536, local5 ! address sbox 7
475
476 ld [local6+local2], local2
477 srl out0, 16, local3
478 xor $1, local4, $1 ! 4 finished
479
480 ld [local5+local1],local1
481 and local3, 252, local3
482 xor $1, local0, $1
483
484 ld [global5+local3],local3
485 xor $1, local2, $1 ! 6 finished
486 cmp in2, 8
487
488 ifelse($6,{}, {}, {ld [out2+280], out4}) ! loop counter
489 xor $1, local7, local2 ! sbox 5 next round
490 xor $1, local1, $1 ! 7 finished
491
492 ld [$5+$3*8+4], out0
493 srl local2, 16, local2 ! sbox 5 next round
494 xor $1, local3, $1 ! 5 finished
495
496 and local2, 252, local2
497 ! next round (two rounds more)
498 xor $1, local7, local7 ! 7531
499
500 ld [global5+local2], local2
501 srl local7, 24, local3
502 xor $1, out0, out0 ! 8642
503
504 ldub [out2+local3], local3
505 srl out0, 4, local0 ! rotate
506 and local7, 252, local1
507
508 sll out0, 28, out0 ! rotate
509 xor $2, local2, $2 ! 5 finished local2 used
510
511 srl local0, 8, local4
512 and local0, 252, local2
513 ld [local5+local3], local3
514
515 srl local0, 16, local5
516 or out0, local0, out0 ! rotate
517 ld [global2+local2], local2
518
519 srl out0, 24, local0
520 ifelse($6,{}, {}, {ld [$6], out0}) ! key next encryption/decryption
521 and local4, 252, local4
522
523 and local5, 252, local5
524 ld [global4+local4], local4
525 xor $2, local3, $2 ! 7 finished local3 used
526
527 and local0, 252, local0
528 ld [local6+local5], local5
529 xor $2, local2, $2 ! 2 finished local2 now sbox 3
530
531 srl local7, 8, local2 ! 3 start
532 ld [out3+local0], local0
533 xor $2, local4, $2
534
535 and local2, 252, local2
536 ld [global1+local1], local1
537 xor $2, local5, $2 ! 6 finished local5 used
538
539 ld [global3+local2], local2
540 srl $1, 3, local3
541 xor $2, local0, $2
542
543 ifelse($6,{}, {}, {ld [$6+4], out1}) ! key next encryption/decryption
544 sll $1, 29, local4
545 xor $2, local1, $2
546
547 ifelse($7,{}, {}, {retl})
548 xor $2, local2, $2
549 })
550
551
552 ! {fp_macro}
553 !
554 ! parameter 1 right (original left)
555 ! parameter 2 left (original right)
556 ! parameter 3 1 for optional store to [in0]
557 ! parameter 4 1 for load input/output address to local5/7
558 !
559 ! The final permutation logic switches the halfes, meaning that
560 ! left and right ends up the the registers originally used.
561
562 define(fp_macro, {
563
564 ! {fp_macro}
565 ! $1 $2 $3 $4 $5 $6 $7 $8 $9
566
567 ! initially undo the rotate 3 left done after initial permutation
568 ! original left is received shifted 3 right and 29 left in local3/4
569
570 sll $2, 29, local1
571 or local3, local4, $1
572
573 srl $2, 3, $2
574 sethi %hi(0x55555555), local2
575
576 or $2, local1, $2
577 or local2, %lo(0x55555555), local2
578
579 srl $2, 1, local3
580 sethi %hi(0x00ff00ff), local1
581 xor local3, $1, local3
582 or local1, %lo(0x00ff00ff), local1
583 and local3, local2, local3
584 sethi %hi(0x33333333), local4
585 sll local3, 1, local2
586
587 xor $1, local3, $1
588
589 srl $1, 8, local3
590 xor $2, local2, $2
591 xor local3, $2, local3
592 or local4, %lo(0x33333333), local4
593 and local3, local1, local3
594 sethi %hi(0x0000ffff), local1
595 sll local3, 8, local2
596
597 xor $2, local3, $2
598
599 srl $2, 2, local3
600 xor $1, local2, $1
601 xor local3, $1, local3
602 or local1, %lo(0x0000ffff), local1
603 and local3, local4, local3
604 sethi %hi(0x0f0f0f0f), local4
605 sll local3, 2, local2
606
607 ifelse($4,1, {LDPTR INPUT, local5})
608 xor $1, local3, $1
609
610 ifelse($4,1, {LDPTR OUTPUT, local7})
611 srl $1, 16, local3
612 xor $2, local2, $2
613 xor local3, $2, local3
614 or local4, %lo(0x0f0f0f0f), local4
615 and local3, local1, local3
616 sll local3, 16, local2
617
618 xor $2, local3, local1
619
620 srl local1, 4, local3
621 xor $1, local2, $1
622 xor local3, $1, local3
623 and local3, local4, local3
624 sll local3, 4, local2
625
626 xor $1, local3, $1
627
628 ! optional store:
629
630 ifelse($3,1, {st $1, [in0]})
631
632 xor local1, local2, $2
633
634 ifelse($3,1, {st $2, [in0+4]})
635
636 })
637
638
639 ! {fp_ip_macro}
640 !
641 ! Does initial permutation for next block mixed with
642 ! final permutation for current block.
643 !
644 ! parameter 1 original left
645 ! parameter 2 original right
646 ! parameter 3 left ip
647 ! parameter 4 right ip
648 ! parameter 5 1: load ks1/ks2 to in3/in4, add 120 to in4
649 ! 2: mov in4 to in3
650 !
651 ! also adds -8 to length in2 and loads loop counter to out4
652
653 define(fp_ip_macro, {
654
655 ! {fp_ip_macro}
656 ! $1 $2 $3 $4 $5 $6 $7 $8 $9
657
658 define({temp1},{out4})
659 define({temp2},{local3})
660
661 define({ip1},{local1})
662 define({ip2},{local2})
663 define({ip4},{local4})
664 define({ip5},{local5})
665
666 ! $1 in local3, local4
667
668 ld [out2+256], ip1
669 sll out5, 29, temp1
670 or local3, local4, $1
671
672 srl out5, 3, $2
673 ifelse($5,2,{mov in4, in3})
674
675 ld [out2+272], ip5
676 srl $4, 4, local0
677 or $2, temp1, $2
678
679 srl $2, 1, temp1
680 xor temp1, $1, temp1
681
682 and temp1, ip5, temp1
683 xor local0, $3, local0
684
685 sll temp1, 1, temp2
686 xor $1, temp1, $1
687
688 and local0, ip1, local0
689 add in2, -8, in2
690
691 sll local0, 4, local7
692 xor $3, local0, $3
693
694 ld [out2+268], ip4
695 srl $1, 8, temp1
696 xor $2, temp2, $2
697 ld [out2+260], ip2
698 srl $3, 16, local0
699 xor $4, local7, $4
700 xor temp1, $2, temp1
701 xor local0, $4, local0
702 and temp1, ip4, temp1
703 and local0, ip2, local0
704 sll temp1, 8, temp2
705 xor $2, temp1, $2
706 sll local0, 16, local7
707 xor $4, local0, $4
708
709 srl $2, 2, temp1
710 xor $1, temp2, $1
711
712 ld [out2+264], temp2 ! ip3
713 srl $4, 2, local0
714 xor $3, local7, $3
715 xor temp1, $1, temp1
716 xor local0, $3, local0
717 and temp1, temp2, temp1
718 and local0, temp2, local0
719 sll temp1, 2, temp2
720 xor $1, temp1, $1
721 sll local0, 2, local7
722 xor $3, local0, $3
723
724 srl $1, 16, temp1
725 xor $2, temp2, $2
726 srl $3, 8, local0
727 xor $4, local7, $4
728 xor temp1, $2, temp1
729 xor local0, $4, local0
730 and temp1, ip2, temp1
731 and local0, ip4, local0
732 sll temp1, 16, temp2
733 xor $2, temp1, local4
734 sll local0, 8, local7
735 xor $4, local0, $4
736
737 srl $4, 1, local0
738 xor $3, local7, $3
739
740 srl local4, 4, temp1
741 xor local0, $3, local0
742
743 xor $1, temp2, $1
744 and local0, ip5, local0
745
746 sll local0, 1, local7
747 xor temp1, $1, temp1
748
749 xor $3, local0, $3
750 xor $4, local7, $4
751
752 sll $3, 3, local5
753 and temp1, ip1, temp1
754
755 sll temp1, 4, temp2
756 xor $1, temp1, $1
757
758 ifelse($5,1,{LDPTR KS2, in4})
759 sll $4, 3, local2
760 xor local4, temp2, $2
761
762 ! reload since used as temporar:
763
764 ld [out2+280], out4 ! loop counter
765
766 srl $3, 29, local0
767 ifelse($5,1,{add in4, 120, in4})
768
769 ifelse($5,1,{LDPTR KS1, in3})
770 srl $4, 29, local7
771
772 or local0, local5, $4
773 or local2, local7, $3
774
775 })
776
777
778
779 ! {load_little_endian}
780 !
781 ! parameter 1 address
782 ! parameter 2 destination left
783 ! parameter 3 destination right
784 ! parameter 4 temporar
785 ! parameter 5 label
786
787 define(load_little_endian, {
788
789 ! {load_little_endian}
790 ! $1 $2 $3 $4 $5 $6 $7 $8 $9
791
792 ! first in memory to rightmost in register
793
794 #ifdef OPENSSL_SYSNAME_ULTRASPARC
795 andcc $1, 3, global0
796 bne,pn %icc, $5
797 nop
798
799 lda [$1] 0x88, $2
800 add $1, 4, $4
801
802 ba,pt %icc, $5a
803 lda [$4] 0x88, $3
804 #endif
805
806 $5:
807 ldub [$1+3], $2
808
809 ldub [$1+2], $4
810 sll $2, 8, $2
811 or $2, $4, $2
812
813 ldub [$1+1], $4
814 sll $2, 8, $2
815 or $2, $4, $2
816
817 ldub [$1+0], $4
818 sll $2, 8, $2
819 or $2, $4, $2
820
821
822 ldub [$1+3+4], $3
823
824 ldub [$1+2+4], $4
825 sll $3, 8, $3
826 or $3, $4, $3
827
828 ldub [$1+1+4], $4
829 sll $3, 8, $3
830 or $3, $4, $3
831
832 ldub [$1+0+4], $4
833 sll $3, 8, $3
834 or $3, $4, $3
835 $5a:
836
837 })
838
839
840 ! {load_little_endian_inc}
841 !
842 ! parameter 1 address
843 ! parameter 2 destination left
844 ! parameter 3 destination right
845 ! parameter 4 temporar
846 ! parameter 4 label
847 !
848 ! adds 8 to address
849
850 define(load_little_endian_inc, {
851
852 ! {load_little_endian_inc}
853 ! $1 $2 $3 $4 $5 $6 $7 $8 $9
854
855 ! first in memory to rightmost in register
856
857 #ifdef OPENSSL_SYSNAME_ULTRASPARC
858 andcc $1, 3, global0
859 bne,pn %icc, $5
860 nop
861
862 lda [$1] 0x88, $2
863 add $1, 4, $1
864
865 lda [$1] 0x88, $3
866 ba,pt %icc, $5a
867 add $1, 4, $1
868 #endif
869
870 $5:
871 ldub [$1+3], $2
872
873 ldub [$1+2], $4
874 sll $2, 8, $2
875 or $2, $4, $2
876
877 ldub [$1+1], $4
878 sll $2, 8, $2
879 or $2, $4, $2
880
881 ldub [$1+0], $4
882 sll $2, 8, $2
883 or $2, $4, $2
884
885 ldub [$1+3+4], $3
886 add $1, 8, $1
887
888 ldub [$1+2+4-8], $4
889 sll $3, 8, $3
890 or $3, $4, $3
891
892 ldub [$1+1+4-8], $4
893 sll $3, 8, $3
894 or $3, $4, $3
895
896 ldub [$1+0+4-8], $4
897 sll $3, 8, $3
898 or $3, $4, $3
899 $5a:
900
901 })
902
903
904 ! {load_n_bytes}
905 !
906 ! Loads 1 to 7 bytes little endian
907 ! Remaining bytes are zeroed.
908 !
909 ! parameter 1 address
910 ! parameter 2 length
911 ! parameter 3 destination register left
912 ! parameter 4 destination register right
913 ! parameter 5 temp
914 ! parameter 6 temp2
915 ! parameter 7 label
916 ! parameter 8 return label
917
918 define(load_n_bytes, {
919
920 ! {load_n_bytes}
921 ! $1 $2 $5 $6 $7 $8 $7 $8 $9
922
923 $7.0: call .+8
924 sll $2, 2, $6
925
926 add %o7,$7.jmp.table-$7.0,$5
927
928 add $5, $6, $5
929 mov 0, $4
930
931 ld [$5], $5
932
933 jmp %o7+$5
934 mov 0, $3
935
936 $7.7:
937 ldub [$1+6], $5
938 sll $5, 16, $5
939 or $3, $5, $3
940 $7.6:
941 ldub [$1+5], $5
942 sll $5, 8, $5
943 or $3, $5, $3
944 $7.5:
945 ldub [$1+4], $5
946 or $3, $5, $3
947 $7.4:
948 ldub [$1+3], $5
949 sll $5, 24, $5
950 or $4, $5, $4
951 $7.3:
952 ldub [$1+2], $5
953 sll $5, 16, $5
954 or $4, $5, $4
955 $7.2:
956 ldub [$1+1], $5
957 sll $5, 8, $5
958 or $4, $5, $4
959 $7.1:
960 ldub [$1+0], $5
961 ba $8
962 or $4, $5, $4
963
964 .align 4
965
966 $7.jmp.table:
967 .word 0
968 .word $7.1-$7.0
969 .word $7.2-$7.0
970 .word $7.3-$7.0
971 .word $7.4-$7.0
972 .word $7.5-$7.0
973 .word $7.6-$7.0
974 .word $7.7-$7.0
975 })
976
977
978 ! {store_little_endian}
979 !
980 ! parameter 1 address
981 ! parameter 2 source left
982 ! parameter 3 source right
983 ! parameter 4 temporar
984
985 define(store_little_endian, {
986
987 ! {store_little_endian}
988 ! $1 $2 $3 $4 $5 $6 $7 $8 $9
989
990 ! rightmost in register to first in memory
991
992 #ifdef OPENSSL_SYSNAME_ULTRASPARC
993 andcc $1, 3, global0
994 bne,pn %icc, $5
995 nop
996
997 sta $2, [$1] 0x88
998 add $1, 4, $4
999
1000 ba,pt %icc, $5a
1001 sta $3, [$4] 0x88
1002 #endif
1003
1004 $5:
1005 and $2, 255, $4
1006 stub $4, [$1+0]
1007
1008 srl $2, 8, $4
1009 and $4, 255, $4
1010 stub $4, [$1+1]
1011
1012 srl $2, 16, $4
1013 and $4, 255, $4
1014 stub $4, [$1+2]
1015
1016 srl $2, 24, $4
1017 stub $4, [$1+3]
1018
1019
1020 and $3, 255, $4
1021 stub $4, [$1+0+4]
1022
1023 srl $3, 8, $4
1024 and $4, 255, $4
1025 stub $4, [$1+1+4]
1026
1027 srl $3, 16, $4
1028 and $4, 255, $4
1029 stub $4, [$1+2+4]
1030
1031 srl $3, 24, $4
1032 stub $4, [$1+3+4]
1033
1034 $5a:
1035
1036 })
1037
1038
1039 ! {store_n_bytes}
1040 !
1041 ! Stores 1 to 7 bytes little endian
1042 !
1043 ! parameter 1 address
1044 ! parameter 2 length
1045 ! parameter 3 source register left
1046 ! parameter 4 source register right
1047 ! parameter 5 temp
1048 ! parameter 6 temp2
1049 ! parameter 7 label
1050 ! parameter 8 return label
1051
1052 define(store_n_bytes, {
1053
1054 ! {store_n_bytes}
1055 ! $1 $2 $5 $6 $7 $8 $7 $8 $9
1056
1057 $7.0: call .+8
1058 sll $2, 2, $6
1059
1060 add %o7,$7.jmp.table-$7.0,$5
1061
1062 add $5, $6, $5
1063
1064 ld [$5], $5
1065
1066 jmp %o7+$5
1067 nop
1068
1069 $7.7:
1070 srl $3, 16, $5
1071 and $5, 0xff, $5
1072 stub $5, [$1+6]
1073 $7.6:
1074 srl $3, 8, $5
1075 and $5, 0xff, $5
1076 stub $5, [$1+5]
1077 $7.5:
1078 and $3, 0xff, $5
1079 stub $5, [$1+4]
1080 $7.4:
1081 srl $4, 24, $5
1082 stub $5, [$1+3]
1083 $7.3:
1084 srl $4, 16, $5
1085 and $5, 0xff, $5
1086 stub $5, [$1+2]
1087 $7.2:
1088 srl $4, 8, $5
1089 and $5, 0xff, $5
1090 stub $5, [$1+1]
1091 $7.1:
1092 and $4, 0xff, $5
1093
1094
1095 ba $8
1096 stub $5, [$1]
1097
1098 .align 4
1099
1100 $7.jmp.table:
1101
1102 .word 0
1103 .word $7.1-$7.0
1104 .word $7.2-$7.0
1105 .word $7.3-$7.0
1106 .word $7.4-$7.0
1107 .word $7.5-$7.0
1108 .word $7.6-$7.0
1109 .word $7.7-$7.0
1110 })
1111
1112
1113 define(testvalue,{1})
1114
1115 define(register_init, {
1116
1117 ! For test purposes:
1118
1119 sethi %hi(testvalue), local0
1120 or local0, %lo(testvalue), local0
1121
1122 ifelse($1,{},{}, {mov local0, $1})
1123 ifelse($2,{},{}, {mov local0, $2})
1124 ifelse($3,{},{}, {mov local0, $3})
1125 ifelse($4,{},{}, {mov local0, $4})
1126 ifelse($5,{},{}, {mov local0, $5})
1127 ifelse($6,{},{}, {mov local0, $6})
1128 ifelse($7,{},{}, {mov local0, $7})
1129 ifelse($8,{},{}, {mov local0, $8})
1130
1131 mov local0, local1
1132 mov local0, local2
1133 mov local0, local3
1134 mov local0, local4
1135 mov local0, local5
1136 mov local0, local7
1137 mov local0, local6
1138 mov local0, out0
1139 mov local0, out1
1140 mov local0, out2
1141 mov local0, out3
1142 mov local0, out4
1143 mov local0, out5
1144 mov local0, global1
1145 mov local0, global2
1146 mov local0, global3
1147 mov local0, global4
1148 mov local0, global5
1149
1150 })
1151
1152 .section ".text"
1153
1154 .align 32
1155
1156 .des_enc:
1157
1158 ! key address in3
1159 ! loads key next encryption/decryption first round from [in4]
1160
1161 rounds_macro(in5, out5, 1, .des_enc.1, in3, in4, retl)
1162
1163
1164 .align 32
1165
1166 .des_dec:
1167
1168 ! implemented with out5 as first parameter to avoid
1169 ! register exchange in ede modes
1170
1171 ! key address in4
1172 ! loads key next encryption/decryption first round from [in3]
1173
1174 rounds_macro(out5, in5, -1, .des_dec.1, in4, in3, retl)
1175
1176
1177
1178 ! void DES_encrypt1(data, ks, enc)
1179 ! *******************************
1180
1181 .align 32
1182 .global DES_encrypt1
1183 .type DES_encrypt1,#function
1184
1185 DES_encrypt1:
1186
1187 save %sp, FRAME, %sp
1188
1189 sethi %hi(.PIC.DES_SPtrans-1f),global1
1190 or global1,%lo(.PIC.DES_SPtrans-1f),global1
1191 1: call .+8
1192 add %o7,global1,global1
1193 sub global1,.PIC.DES_SPtrans-.des_and,out2
1194
1195 ld [in0], in5 ! left
1196 cmp in2, 0 ! enc
1197
1198 #ifdef OPENSSL_SYSNAME_ULTRASPARC
1199 be,pn %icc, .encrypt.dec ! enc/dec
1200 #else
1201 be .encrypt.dec
1202 #endif
1203 ld [in0+4], out5 ! right
1204
1205 ! parameter 6 1/2 for include encryption/decryption
1206 ! parameter 7 1 for move in1 to in3
1207 ! parameter 8 1 for move in3 to in4, 2 for move in4 to in3
1208
1209 ip_macro(in5, out5, in5, out5, in3, 0, 1, 1)
1210
1211 rounds_macro(in5, out5, 1, .des_encrypt1.1, in3, in4) ! in4 not used
1212
1213 fp_macro(in5, out5, 1) ! 1 for store to [in0]
1214
1215 ret
1216 restore
1217
1218 .encrypt.dec:
1219
1220 add in1, 120, in3 ! use last subkey for first round
1221
1222 ! parameter 6 1/2 for include encryption/decryption
1223 ! parameter 7 1 for move in1 to in3
1224 ! parameter 8 1 for move in3 to in4, 2 for move in4 to in3
1225
1226 ip_macro(in5, out5, out5, in5, in4, 2, 0, 1) ! include dec, ks in4
1227
1228 fp_macro(out5, in5, 1) ! 1 for store to [in0]
1229
1230 ret
1231 restore
1232
1233 .DES_encrypt1.end:
1234 .size DES_encrypt1,.DES_encrypt1.end-DES_encrypt1
1235
1236
1237 ! void DES_encrypt2(data, ks, enc)
1238 !*********************************
1239
1240 ! encrypts/decrypts without initial/final permutation
1241
1242 .align 32
1243 .global DES_encrypt2
1244 .type DES_encrypt2,#function
1245
1246 DES_encrypt2:
1247
1248 save %sp, FRAME, %sp
1249
1250 sethi %hi(.PIC.DES_SPtrans-1f),global1
1251 or global1,%lo(.PIC.DES_SPtrans-1f),global1
1252 1: call .+8
1253 add %o7,global1,global1
1254 sub global1,.PIC.DES_SPtrans-.des_and,out2
1255
1256 ! Set sbox address 1 to 6 and rotate halfs 3 left
1257 ! Errors caught by destest? Yes. Still? *NO*
1258
1259 !sethi %hi(DES_SPtrans), global1 ! address sbox 1
1260
1261 !or global1, %lo(DES_SPtrans), global1 ! sbox 1
1262
1263 add global1, 256, global2 ! sbox 2
1264 add global1, 512, global3 ! sbox 3
1265
1266 ld [in0], out5 ! right
1267 add global1, 768, global4 ! sbox 4
1268 add global1, 1024, global5 ! sbox 5
1269
1270 ld [in0+4], in5 ! left
1271 add global1, 1280, local6 ! sbox 6
1272 add global1, 1792, out3 ! sbox 8
1273
1274 ! rotate
1275
1276 sll in5, 3, local5
1277 mov in1, in3 ! key address to in3
1278
1279 sll out5, 3, local7
1280 srl in5, 29, in5
1281
1282 srl out5, 29, out5
1283 add in5, local5, in5
1284
1285 add out5, local7, out5
1286 cmp in2, 0
1287
1288 ! we use our own stackframe
1289
1290 #ifdef OPENSSL_SYSNAME_ULTRASPARC
1291 be,pn %icc, .encrypt2.dec ! decryption
1292 #else
1293 be .encrypt2.dec
1294 #endif
1295 STPTR in0, [%sp+BIAS+ARG0+0*ARGSZ]
1296
1297 ld [in3], out0 ! key 7531 first round
1298 mov LOOPS, out4 ! loop counter
1299
1300 ld [in3+4], out1 ! key 8642 first round
1301 sethi %hi(0x0000FC00), local5
1302
1303 call .des_enc
1304 mov in3, in4
1305
1306 ! rotate
1307 sll in5, 29, in0
1308 srl in5, 3, in5
1309 sll out5, 29, in1
1310 add in5, in0, in5
1311 srl out5, 3, out5
1312 LDPTR [%sp+BIAS+ARG0+0*ARGSZ], in0
1313 add out5, in1, out5
1314 st in5, [in0]
1315 st out5, [in0+4]
1316
1317 ret
1318 restore
1319
1320
1321 .encrypt2.dec:
1322
1323 add in3, 120, in4
1324
1325 ld [in4], out0 ! key 7531 first round
1326 mov LOOPS, out4 ! loop counter
1327
1328 ld [in4+4], out1 ! key 8642 first round
1329 sethi %hi(0x0000FC00), local5
1330
1331 mov in5, local1 ! left expected in out5
1332 mov out5, in5
1333
1334 call .des_dec
1335 mov local1, out5
1336
1337 .encrypt2.finish:
1338
1339 ! rotate
1340 sll in5, 29, in0
1341 srl in5, 3, in5
1342 sll out5, 29, in1
1343 add in5, in0, in5
1344 srl out5, 3, out5
1345 LDPTR [%sp+BIAS+ARG0+0*ARGSZ], in0
1346 add out5, in1, out5
1347 st out5, [in0]
1348 st in5, [in0+4]
1349
1350 ret
1351 restore
1352
1353 .DES_encrypt2.end:
1354 .size DES_encrypt2, .DES_encrypt2.end-DES_encrypt2
1355
1356
1357 ! void DES_encrypt3(data, ks1, ks2, ks3)
1358 ! **************************************
1359
1360 .align 32
1361 .global DES_encrypt3
1362 .type DES_encrypt3,#function
1363
1364 DES_encrypt3:
1365
1366 save %sp, FRAME, %sp
1367
1368 sethi %hi(.PIC.DES_SPtrans-1f),global1
1369 or global1,%lo(.PIC.DES_SPtrans-1f),global1
1370 1: call .+8
1371 add %o7,global1,global1
1372 sub global1,.PIC.DES_SPtrans-.des_and,out2
1373
1374 ld [in0], in5 ! left
1375 add in2, 120, in4 ! ks2
1376
1377 ld [in0+4], out5 ! right
1378 mov in3, in2 ! save ks3
1379
1380 ! parameter 6 1/2 for include encryption/decryption
1381 ! parameter 7 1 for mov in1 to in3
1382 ! parameter 8 1 for mov in3 to in4
1383 ! parameter 9 1 for load ks3 and ks2 to in4 and in3
1384
1385 ip_macro(in5, out5, in5, out5, in3, 1, 1, 0, 0)
1386
1387 call .des_dec
1388 mov in2, in3 ! preload ks3
1389
1390 call .des_enc
1391 nop
1392
1393 fp_macro(in5, out5, 1)
1394
1395 ret
1396 restore
1397
1398 .DES_encrypt3.end:
1399 .size DES_encrypt3,.DES_encrypt3.end-DES_encrypt3
1400
1401
1402 ! void DES_decrypt3(data, ks1, ks2, ks3)
1403 ! **************************************
1404
1405 .align 32
1406 .global DES_decrypt3
1407 .type DES_decrypt3,#function
1408
1409 DES_decrypt3:
1410
1411 save %sp, FRAME, %sp
1412
1413 sethi %hi(.PIC.DES_SPtrans-1f),global1
1414 or global1,%lo(.PIC.DES_SPtrans-1f),global1
1415 1: call .+8
1416 add %o7,global1,global1
1417 sub global1,.PIC.DES_SPtrans-.des_and,out2
1418
1419 ld [in0], in5 ! left
1420 add in3, 120, in4 ! ks3
1421
1422 ld [in0+4], out5 ! right
1423 mov in2, in3 ! ks2
1424
1425 ! parameter 6 1/2 for include encryption/decryption
1426 ! parameter 7 1 for mov in1 to in3
1427 ! parameter 8 1 for mov in3 to in4
1428 ! parameter 9 1 for load ks3 and ks2 to in4 and in3
1429
1430 ip_macro(in5, out5, out5, in5, in4, 2, 0, 0, 0)
1431
1432 call .des_enc
1433 add in1, 120, in4 ! preload ks1
1434
1435 call .des_dec
1436 nop
1437
1438 fp_macro(out5, in5, 1)
1439
1440 ret
1441 restore
1442
1443 .DES_decrypt3.end:
1444 .size DES_decrypt3,.DES_decrypt3.end-DES_decrypt3
1445
1446 ! void DES_ncbc_encrypt(input, output, length, schedule, ivec, enc)
1447 ! *****************************************************************
1448
1449
1450 .align 32
1451 .global DES_ncbc_encrypt
1452 .type DES_ncbc_encrypt,#function
1453
1454 DES_ncbc_encrypt:
1455
1456 save %sp, FRAME, %sp
1457
1458 define({INPUT}, { [%sp+BIAS+ARG0+0*ARGSZ] })
1459 define({OUTPUT}, { [%sp+BIAS+ARG0+1*ARGSZ] })
1460 define({IVEC}, { [%sp+BIAS+ARG0+4*ARGSZ] })
1461
1462 sethi %hi(.PIC.DES_SPtrans-1f),global1
1463 or global1,%lo(.PIC.DES_SPtrans-1f),global1
1464 1: call .+8
1465 add %o7,global1,global1
1466 sub global1,.PIC.DES_SPtrans-.des_and,out2
1467
1468 cmp in5, 0 ! enc
1469
1470 #ifdef OPENSSL_SYSNAME_ULTRASPARC
1471 be,pn %icc, .ncbc.dec
1472 #else
1473 be .ncbc.dec
1474 #endif
1475 STPTR in4, IVEC
1476
1477 ! addr left right temp label
1478 load_little_endian(in4, in5, out5, local3, .LLE1) ! iv
1479
1480 addcc in2, -8, in2 ! bytes missing when first block done
1481
1482 #ifdef OPENSSL_SYSNAME_ULTRASPARC
1483 bl,pn %icc, .ncbc.enc.seven.or.less
1484 #else
1485 bl .ncbc.enc.seven.or.less
1486 #endif
1487 mov in3, in4 ! schedule
1488
1489 .ncbc.enc.next.block:
1490
1491 load_little_endian(in0, out4, global4, local3, .LLE2) ! block
1492
1493 .ncbc.enc.next.block_1:
1494
1495 xor in5, out4, in5 ! iv xor
1496 xor out5, global4, out5 ! iv xor
1497
1498 ! parameter 8 1 for move in3 to in4, 2 for move in4 to in3
1499 ip_macro(in5, out5, in5, out5, in3, 0, 0, 2)
1500
1501 .ncbc.enc.next.block_2:
1502
1503 !// call .des_enc ! compares in2 to 8
1504 ! rounds inlined for alignment purposes
1505
1506 add global1, 768, global4 ! address sbox 4 since register used below
1507
1508 rounds_macro(in5, out5, 1, .ncbc.enc.1, in3, in4) ! include encryption ks in3
1509
1510 #ifdef OPENSSL_SYSNAME_ULTRASPARC
1511 bl,pn %icc, .ncbc.enc.next.block_fp
1512 #else
1513 bl .ncbc.enc.next.block_fp
1514 #endif
1515 add in0, 8, in0 ! input address
1516
1517 ! If 8 or more bytes are to be encrypted after this block,
1518 ! we combine final permutation for this block with initial
1519 ! permutation for next block. Load next block:
1520
1521 load_little_endian(in0, global3, global4, local5, .LLE12)
1522
1523 ! parameter 1 original left
1524 ! parameter 2 original right
1525 ! parameter 3 left ip
1526 ! parameter 4 right ip
1527 ! parameter 5 1: load ks1/ks2 to in3/in4, add 120 to in4
1528 ! 2: mov in4 to in3
1529 !
1530 ! also adds -8 to length in2 and loads loop counter to out4
1531
1532 fp_ip_macro(out0, out1, global3, global4, 2)
1533
1534 store_little_endian(in1, out0, out1, local3, .SLE10) ! block
1535
1536 ld [in3], out0 ! key 7531 first round next block
1537 mov in5, local1
1538 xor global3, out5, in5 ! iv xor next block
1539
1540 ld [in3+4], out1 ! key 8642
1541 add global1, 512, global3 ! address sbox 3 since register used
1542 xor global4, local1, out5 ! iv xor next block
1543
1544 ba .ncbc.enc.next.block_2
1545 add in1, 8, in1 ! output adress
1546
1547 .ncbc.enc.next.block_fp:
1548
1549 fp_macro(in5, out5)
1550
1551 store_little_endian(in1, in5, out5, local3, .SLE1) ! block
1552
1553 addcc in2, -8, in2 ! bytes missing when next block done
1554
1555 #ifdef OPENSSL_SYSNAME_ULTRASPARC
1556 bpos,pt %icc, .ncbc.enc.next.block ! also jumps if 0
1557 #else
1558 bpos .ncbc.enc.next.block
1559 #endif
1560 add in1, 8, in1
1561
1562 .ncbc.enc.seven.or.less:
1563
1564 cmp in2, -8
1565
1566 #ifdef OPENSSL_SYSNAME_ULTRASPARC
1567 ble,pt %icc, .ncbc.enc.finish
1568 #else
1569 ble .ncbc.enc.finish
1570 #endif
1571 nop
1572
1573 add in2, 8, local1 ! bytes to load
1574
1575 ! addr, length, dest left, dest right, temp, temp2, label, ret label
1576 load_n_bytes(in0, local1, global4, out4, local2, local3, .LNB1, .ncbc.enc.next.block_1)
1577
1578 ! Loads 1 to 7 bytes little endian to global4, out4
1579
1580
1581 .ncbc.enc.finish:
1582
1583 LDPTR IVEC, local4
1584 store_little_endian(local4, in5, out5, local5, .SLE2) ! ivec
1585
1586 ret
1587 restore
1588
1589
1590 .ncbc.dec:
1591
1592 STPTR in0, INPUT
1593 cmp in2, 0 ! length
1594 add in3, 120, in3
1595
1596 LDPTR IVEC, local7 ! ivec
1597 #ifdef OPENSSL_SYSNAME_ULTRASPARC
1598 ble,pn %icc, .ncbc.dec.finish
1599 #else
1600 ble .ncbc.dec.finish
1601 #endif
1602 mov in3, in4 ! schedule
1603
1604 STPTR in1, OUTPUT
1605 mov in0, local5 ! input
1606
1607 load_little_endian(local7, in0, in1, local3, .LLE3) ! ivec
1608
1609 .ncbc.dec.next.block:
1610
1611 load_little_endian(local5, in5, out5, local3, .LLE4) ! block
1612
1613 ! parameter 6 1/2 for include encryption/decryption
1614 ! parameter 7 1 for mov in1 to in3
1615 ! parameter 8 1 for mov in3 to in4
1616
1617 ip_macro(in5, out5, out5, in5, in4, 2, 0, 1) ! include decryprion ks in4
1618
1619 fp_macro(out5, in5, 0, 1) ! 1 for input and output address to local5/7
1620
1621 ! in2 is bytes left to be stored
1622 ! in2 is compared to 8 in the rounds
1623
1624 xor out5, in0, out4 ! iv xor
1625 #ifdef OPENSSL_SYSNAME_ULTRASPARC
1626 bl,pn %icc, .ncbc.dec.seven.or.less
1627 #else
1628 bl .ncbc.dec.seven.or.less
1629 #endif
1630 xor in5, in1, global4 ! iv xor
1631
1632 ! Load ivec next block now, since input and output address might be the same.
1633
1634 load_little_endian_inc(local5, in0, in1, local3, .LLE5) ! iv
1635
1636 store_little_endian(local7, out4, global4, local3, .SLE3)
1637
1638 STPTR local5, INPUT
1639 add local7, 8, local7
1640 addcc in2, -8, in2
1641
1642 #ifdef OPENSSL_SYSNAME_ULTRASPARC
1643 bg,pt %icc, .ncbc.dec.next.block
1644 #else
1645 bg .ncbc.dec.next.block
1646 #endif
1647 STPTR local7, OUTPUT
1648
1649
1650 .ncbc.dec.store.iv:
1651
1652 LDPTR IVEC, local4 ! ivec
1653 store_little_endian(local4, in0, in1, local5, .SLE4)
1654
1655 .ncbc.dec.finish:
1656
1657 ret
1658 restore
1659
1660 .ncbc.dec.seven.or.less:
1661
1662 load_little_endian_inc(local5, in0, in1, local3, .LLE13) ! ivec
1663
1664 store_n_bytes(local7, in2, global4, out4, local3, local4, .SNB1, .ncbc.dec.store.iv)
1665
1666
1667 .DES_ncbc_encrypt.end:
1668 .size DES_ncbc_encrypt, .DES_ncbc_encrypt.end-DES_ncbc_encrypt
1669
1670
1671 ! void DES_ede3_cbc_encrypt(input, output, lenght, ks1, ks2, ks3, ivec, enc)
1672 ! **************************************************************************
1673
1674
1675 .align 32
1676 .global DES_ede3_cbc_encrypt
1677 .type DES_ede3_cbc_encrypt,#function
1678
1679 DES_ede3_cbc_encrypt:
1680
1681 save %sp, FRAME, %sp
1682
1683 define({KS1}, { [%sp+BIAS+ARG0+3*ARGSZ] })
1684 define({KS2}, { [%sp+BIAS+ARG0+4*ARGSZ] })
1685 define({KS3}, { [%sp+BIAS+ARG0+5*ARGSZ] })
1686
1687 sethi %hi(.PIC.DES_SPtrans-1f),global1
1688 or global1,%lo(.PIC.DES_SPtrans-1f),global1
1689 1: call .+8
1690 add %o7,global1,global1
1691 sub global1,.PIC.DES_SPtrans-.des_and,out2
1692
1693 LDPTR [%fp+BIAS+ARG0+7*ARGSZ], local3 ! enc
1694 LDPTR [%fp+BIAS+ARG0+6*ARGSZ], local4 ! ivec
1695 cmp local3, 0 ! enc
1696
1697 #ifdef OPENSSL_SYSNAME_ULTRASPARC
1698 be,pn %icc, .ede3.dec
1699 #else
1700 be .ede3.dec
1701 #endif
1702 STPTR in4, KS2
1703
1704 STPTR in5, KS3
1705
1706 load_little_endian(local4, in5, out5, local3, .LLE6) ! ivec
1707
1708 addcc in2, -8, in2 ! bytes missing after next block
1709
1710 #ifdef OPENSSL_SYSNAME_ULTRASPARC
1711 bl,pn %icc, .ede3.enc.seven.or.less
1712 #else
1713 bl .ede3.enc.seven.or.less
1714 #endif
1715 STPTR in3, KS1
1716
1717 .ede3.enc.next.block:
1718
1719 load_little_endian(in0, out4, global4, local3, .LLE7)
1720
1721 .ede3.enc.next.block_1:
1722
1723 LDPTR KS2, in4
1724 xor in5, out4, in5 ! iv xor
1725 xor out5, global4, out5 ! iv xor
1726
1727 LDPTR KS1, in3
1728 add in4, 120, in4 ! for decryption we use last subkey first
1729 nop
1730
1731 ip_macro(in5, out5, in5, out5, in3)
1732
1733 .ede3.enc.next.block_2:
1734
1735 call .des_enc ! ks1 in3
1736 nop
1737
1738 call .des_dec ! ks2 in4
1739 LDPTR KS3, in3
1740
1741 call .des_enc ! ks3 in3 compares in2 to 8
1742 nop
1743
1744 #ifdef OPENSSL_SYSNAME_ULTRASPARC
1745 bl,pn %icc, .ede3.enc.next.block_fp
1746 #else
1747 bl .ede3.enc.next.block_fp
1748 #endif
1749 add in0, 8, in0
1750
1751 ! If 8 or more bytes are to be encrypted after this block,
1752 ! we combine final permutation for this block with initial
1753 ! permutation for next block. Load next block:
1754
1755 load_little_endian(in0, global3, global4, local5, .LLE11)
1756
1757 ! parameter 1 original left
1758 ! parameter 2 original right
1759 ! parameter 3 left ip
1760 ! parameter 4 right ip
1761 ! parameter 5 1: load ks1/ks2 to in3/in4, add 120 to in4
1762 ! 2: mov in4 to in3
1763 !
1764 ! also adds -8 to length in2 and loads loop counter to out4
1765
1766 fp_ip_macro(out0, out1, global3, global4, 1)
1767
1768 store_little_endian(in1, out0, out1, local3, .SLE9) ! block
1769
1770 mov in5, local1
1771 xor global3, out5, in5 ! iv xor next block
1772
1773 ld [in3], out0 ! key 7531
1774 add global1, 512, global3 ! address sbox 3
1775 xor global4, local1, out5 ! iv xor next block
1776
1777 ld [in3+4], out1 ! key 8642
1778 add global1, 768, global4 ! address sbox 4
1779 ba .ede3.enc.next.block_2
1780 add in1, 8, in1
1781
1782 .ede3.enc.next.block_fp:
1783
1784 fp_macro(in5, out5)
1785
1786 store_little_endian(in1, in5, out5, local3, .SLE5) ! block
1787
1788 addcc in2, -8, in2 ! bytes missing when next block done
1789
1790 #ifdef OPENSSL_SYSNAME_ULTRASPARC
1791 bpos,pt %icc, .ede3.enc.next.block
1792 #else
1793 bpos .ede3.enc.next.block
1794 #endif
1795 add in1, 8, in1
1796
1797 .ede3.enc.seven.or.less:
1798
1799 cmp in2, -8
1800
1801 #ifdef OPENSSL_SYSNAME_ULTRASPARC
1802 ble,pt %icc, .ede3.enc.finish
1803 #else
1804 ble .ede3.enc.finish
1805 #endif
1806 nop
1807
1808 add in2, 8, local1 ! bytes to load
1809
1810 ! addr, length, dest left, dest right, temp, temp2, label, ret label
1811 load_n_bytes(in0, local1, global4, out4, local2, local3, .LNB2, .ede3.enc.next.block_1)
1812
1813 .ede3.enc.finish:
1814
1815 LDPTR [%fp+BIAS+ARG0+6*ARGSZ], local4 ! ivec
1816 store_little_endian(local4, in5, out5, local5, .SLE6) ! ivec
1817
1818 ret
1819 restore
1820
1821 .ede3.dec:
1822
1823 STPTR in0, INPUT
1824 add in5, 120, in5
1825
1826 STPTR in1, OUTPUT
1827 mov in0, local5
1828 add in3, 120, in3
1829
1830 STPTR in3, KS1
1831 cmp in2, 0
1832
1833 #ifdef OPENSSL_SYSNAME_ULTRASPARC
1834 ble %icc, .ede3.dec.finish
1835 #else
1836 ble .ede3.dec.finish
1837 #endif
1838 STPTR in5, KS3
1839
1840 LDPTR [%fp+BIAS+ARG0+6*ARGSZ], local7 ! iv
1841 load_little_endian(local7, in0, in1, local3, .LLE8)
1842
1843 .ede3.dec.next.block:
1844
1845 load_little_endian(local5, in5, out5, local3, .LLE9)
1846
1847 ! parameter 6 1/2 for include encryption/decryption
1848 ! parameter 7 1 for mov in1 to in3
1849 ! parameter 8 1 for mov in3 to in4
1850 ! parameter 9 1 for load ks3 and ks2 to in4 and in3
1851
1852 ip_macro(in5, out5, out5, in5, in4, 2, 0, 0, 1) ! inc .des_dec ks3 in4
1853
1854 call .des_enc ! ks2 in3
1855 LDPTR KS1, in4
1856
1857 call .des_dec ! ks1 in4
1858 nop
1859
1860 fp_macro(out5, in5, 0, 1) ! 1 for input and output address local5/7
1861
1862 ! in2 is bytes left to be stored
1863 ! in2 is compared to 8 in the rounds
1864
1865 xor out5, in0, out4
1866 #ifdef OPENSSL_SYSNAME_ULTRASPARC
1867 bl,pn %icc, .ede3.dec.seven.or.less
1868 #else
1869 bl .ede3.dec.seven.or.less
1870 #endif
1871 xor in5, in1, global4
1872
1873 load_little_endian_inc(local5, in0, in1, local3, .LLE10) ! iv next block
1874
1875 store_little_endian(local7, out4, global4, local3, .SLE7) ! block
1876
1877 STPTR local5, INPUT
1878 addcc in2, -8, in2
1879 add local7, 8, local7
1880
1881 #ifdef OPENSSL_SYSNAME_ULTRASPARC
1882 bg,pt %icc, .ede3.dec.next.block
1883 #else
1884 bg .ede3.dec.next.block
1885 #endif
1886 STPTR local7, OUTPUT
1887
1888 .ede3.dec.store.iv:
1889
1890 LDPTR [%fp+BIAS+ARG0+6*ARGSZ], local4 ! ivec
1891 store_little_endian(local4, in0, in1, local5, .SLE8) ! ivec
1892
1893 .ede3.dec.finish:
1894
1895 ret
1896 restore
1897
1898 .ede3.dec.seven.or.less:
1899
1900 load_little_endian_inc(local5, in0, in1, local3, .LLE14) ! iv
1901
1902 store_n_bytes(local7, in2, global4, out4, local3, local4, .SNB2, .ede3.dec.store.iv)
1903
1904
1905 .DES_ede3_cbc_encrypt.end:
1906 .size DES_ede3_cbc_encrypt,.DES_ede3_cbc_encrypt.end-DES_ede3_cbc_encrypt
1907
1908 .align 256
1909 .type .des_and,#object
1910 .size .des_and,284
1911
1912 .des_and:
1913
1914 ! This table is used for AND 0xFC when it is known that register
1915 ! bits 8-31 are zero. Makes it possible to do three arithmetic
1916 ! operations in one cycle.
1917
1918 .byte 0, 0, 0, 0, 4, 4, 4, 4
1919 .byte 8, 8, 8, 8, 12, 12, 12, 12
1920 .byte 16, 16, 16, 16, 20, 20, 20, 20
1921 .byte 24, 24, 24, 24, 28, 28, 28, 28
1922 .byte 32, 32, 32, 32, 36, 36, 36, 36
1923 .byte 40, 40, 40, 40, 44, 44, 44, 44
1924 .byte 48, 48, 48, 48, 52, 52, 52, 52
1925 .byte 56, 56, 56, 56, 60, 60, 60, 60
1926 .byte 64, 64, 64, 64, 68, 68, 68, 68
1927 .byte 72, 72, 72, 72, 76, 76, 76, 76
1928 .byte 80, 80, 80, 80, 84, 84, 84, 84
1929 .byte 88, 88, 88, 88, 92, 92, 92, 92
1930 .byte 96, 96, 96, 96, 100, 100, 100, 100
1931 .byte 104, 104, 104, 104, 108, 108, 108, 108
1932 .byte 112, 112, 112, 112, 116, 116, 116, 116
1933 .byte 120, 120, 120, 120, 124, 124, 124, 124
1934 .byte 128, 128, 128, 128, 132, 132, 132, 132
1935 .byte 136, 136, 136, 136, 140, 140, 140, 140
1936 .byte 144, 144, 144, 144, 148, 148, 148, 148
1937 .byte 152, 152, 152, 152, 156, 156, 156, 156
1938 .byte 160, 160, 160, 160, 164, 164, 164, 164
1939 .byte 168, 168, 168, 168, 172, 172, 172, 172
1940 .byte 176, 176, 176, 176, 180, 180, 180, 180
1941 .byte 184, 184, 184, 184, 188, 188, 188, 188
1942 .byte 192, 192, 192, 192, 196, 196, 196, 196
1943 .byte 200, 200, 200, 200, 204, 204, 204, 204
1944 .byte 208, 208, 208, 208, 212, 212, 212, 212
1945 .byte 216, 216, 216, 216, 220, 220, 220, 220
1946 .byte 224, 224, 224, 224, 228, 228, 228, 228
1947 .byte 232, 232, 232, 232, 236, 236, 236, 236
1948 .byte 240, 240, 240, 240, 244, 244, 244, 244
1949 .byte 248, 248, 248, 248, 252, 252, 252, 252
1950
1951 ! 5 numbers for initil/final permutation
1952
1953 .word 0x0f0f0f0f ! offset 256
1954 .word 0x0000ffff ! 260
1955 .word 0x33333333 ! 264
1956 .word 0x00ff00ff ! 268
1957 .word 0x55555555 ! 272
1958
1959 .word 0 ! 276
1960 .word LOOPS ! 280
1961 .word 0x0000FC00 ! 284
1962
1963 .global DES_SPtrans
1964 .type DES_SPtrans,#object
1965 .size DES_SPtrans,2048
1966 .align 64
1967 DES_SPtrans:
1968 .PIC.DES_SPtrans:
1969 ! nibble 0
1970 .word 0x02080800, 0x00080000, 0x02000002, 0x02080802
1971 .word 0x02000000, 0x00080802, 0x00080002, 0x02000002
1972 .word 0x00080802, 0x02080800, 0x02080000, 0x00000802
1973 .word 0x02000802, 0x02000000, 0x00000000, 0x00080002
1974 .word 0x00080000, 0x00000002, 0x02000800, 0x00080800
1975 .word 0x02080802, 0x02080000, 0x00000802, 0x02000800
1976 .word 0x00000002, 0x00000800, 0x00080800, 0x02080002
1977 .word 0x00000800, 0x02000802, 0x02080002, 0x00000000
1978 .word 0x00000000, 0x02080802, 0x02000800, 0x00080002
1979 .word 0x02080800, 0x00080000, 0x00000802, 0x02000800
1980 .word 0x02080002, 0x00000800, 0x00080800, 0x02000002
1981 .word 0x00080802, 0x00000002, 0x02000002, 0x02080000
1982 .word 0x02080802, 0x00080800, 0x02080000, 0x02000802
1983 .word 0x02000000, 0x00000802, 0x00080002, 0x00000000
1984 .word 0x00080000, 0x02000000, 0x02000802, 0x02080800
1985 .word 0x00000002, 0x02080002, 0x00000800, 0x00080802
1986 ! nibble 1
1987 .word 0x40108010, 0x00000000, 0x00108000, 0x40100000
1988 .word 0x40000010, 0x00008010, 0x40008000, 0x00108000
1989 .word 0x00008000, 0x40100010, 0x00000010, 0x40008000
1990 .word 0x00100010, 0x40108000, 0x40100000, 0x00000010
1991 .word 0x00100000, 0x40008010, 0x40100010, 0x00008000
1992 .word 0x00108010, 0x40000000, 0x00000000, 0x00100010
1993 .word 0x40008010, 0x00108010, 0x40108000, 0x40000010
1994 .word 0x40000000, 0x00100000, 0x00008010, 0x40108010
1995 .word 0x00100010, 0x40108000, 0x40008000, 0x00108010
1996 .word 0x40108010, 0x00100010, 0x40000010, 0x00000000
1997 .word 0x40000000, 0x00008010, 0x00100000, 0x40100010
1998 .word 0x00008000, 0x40000000, 0x00108010, 0x40008010
1999 .word 0x40108000, 0x00008000, 0x00000000, 0x40000010
2000 .word 0x00000010, 0x40108010, 0x00108000, 0x40100000
2001 .word 0x40100010, 0x00100000, 0x00008010, 0x40008000
2002 .word 0x40008010, 0x00000010, 0x40100000, 0x00108000
2003 ! nibble 2
2004 .word 0x04000001, 0x04040100, 0x00000100, 0x04000101
2005 .word 0x00040001, 0x04000000, 0x04000101, 0x00040100
2006 .word 0x04000100, 0x00040000, 0x04040000, 0x00000001
2007 .word 0x04040101, 0x00000101, 0x00000001, 0x04040001
2008 .word 0x00000000, 0x00040001, 0x04040100, 0x00000100
2009 .word 0x00000101, 0x04040101, 0x00040000, 0x04000001
2010 .word 0x04040001, 0x04000100, 0x00040101, 0x04040000
2011 .word 0x00040100, 0x00000000, 0x04000000, 0x00040101
2012 .word 0x04040100, 0x00000100, 0x00000001, 0x00040000
2013 .word 0x00000101, 0x00040001, 0x04040000, 0x04000101
2014 .word 0x00000000, 0x04040100, 0x00040100, 0x04040001
2015 .word 0x00040001, 0x04000000, 0x04040101, 0x00000001
2016 .word 0x00040101, 0x04000001, 0x04000000, 0x04040101
2017 .word 0x00040000, 0x04000100, 0x04000101, 0x00040100
2018 .word 0x04000100, 0x00000000, 0x04040001, 0x00000101
2019 .word 0x04000001, 0x00040101, 0x00000100, 0x04040000
2020 ! nibble 3
2021 .word 0x00401008, 0x10001000, 0x00000008, 0x10401008
2022 .word 0x00000000, 0x10400000, 0x10001008, 0x00400008
2023 .word 0x10401000, 0x10000008, 0x10000000, 0x00001008
2024 .word 0x10000008, 0x00401008, 0x00400000, 0x10000000
2025 .word 0x10400008, 0x00401000, 0x00001000, 0x00000008
2026 .word 0x00401000, 0x10001008, 0x10400000, 0x00001000
2027 .word 0x00001008, 0x00000000, 0x00400008, 0x10401000
2028 .word 0x10001000, 0x10400008, 0x10401008, 0x00400000
2029 .word 0x10400008, 0x00001008, 0x00400000, 0x10000008
2030 .word 0x00401000, 0x10001000, 0x00000008, 0x10400000
2031 .word 0x10001008, 0x00000000, 0x00001000, 0x00400008
2032 .word 0x00000000, 0x10400008, 0x10401000, 0x00001000
2033 .word 0x10000000, 0x10401008, 0x00401008, 0x00400000
2034 .word 0x10401008, 0x00000008, 0x10001000, 0x00401008
2035 .word 0x00400008, 0x00401000, 0x10400000, 0x10001008
2036 .word 0x00001008, 0x10000000, 0x10000008, 0x10401000
2037 ! nibble 4
2038 .word 0x08000000, 0x00010000, 0x00000400, 0x08010420
2039 .word 0x08010020, 0x08000400, 0x00010420, 0x08010000
2040 .word 0x00010000, 0x00000020, 0x08000020, 0x00010400
2041 .word 0x08000420, 0x08010020, 0x08010400, 0x00000000
2042 .word 0x00010400, 0x08000000, 0x00010020, 0x00000420
2043 .word 0x08000400, 0x00010420, 0x00000000, 0x08000020
2044 .word 0x00000020, 0x08000420, 0x08010420, 0x00010020
2045 .word 0x08010000, 0x00000400, 0x00000420, 0x08010400
2046 .word 0x08010400, 0x08000420, 0x00010020, 0x08010000
2047 .word 0x00010000, 0x00000020, 0x08000020, 0x08000400
2048 .word 0x08000000, 0x00010400, 0x08010420, 0x00000000
2049 .word 0x00010420, 0x08000000, 0x00000400, 0x00010020
2050 .word 0x08000420, 0x00000400, 0x00000000, 0x08010420
2051 .word 0x08010020, 0x08010400, 0x00000420, 0x00010000
2052 .word 0x00010400, 0x08010020, 0x08000400, 0x00000420
2053 .word 0x00000020, 0x00010420, 0x08010000, 0x08000020
2054 ! nibble 5
2055 .word 0x80000040, 0x00200040, 0x00000000, 0x80202000
2056 .word 0x00200040, 0x00002000, 0x80002040, 0x00200000
2057 .word 0x00002040, 0x80202040, 0x00202000, 0x80000000
2058 .word 0x80002000, 0x80000040, 0x80200000, 0x00202040
2059 .word 0x00200000, 0x80002040, 0x80200040, 0x00000000
2060 .word 0x00002000, 0x00000040, 0x80202000, 0x80200040
2061 .word 0x80202040, 0x80200000, 0x80000000, 0x00002040
2062 .word 0x00000040, 0x00202000, 0x00202040, 0x80002000
2063 .word 0x00002040, 0x80000000, 0x80002000, 0x00202040
2064 .word 0x80202000, 0x00200040, 0x00000000, 0x80002000
2065 .word 0x80000000, 0x00002000, 0x80200040, 0x00200000
2066 .word 0x00200040, 0x80202040, 0x00202000, 0x00000040
2067 .word 0x80202040, 0x00202000, 0x00200000, 0x80002040
2068 .word 0x80000040, 0x80200000, 0x00202040, 0x00000000
2069 .word 0x00002000, 0x80000040, 0x80002040, 0x80202000
2070 .word 0x80200000, 0x00002040, 0x00000040, 0x80200040
2071 ! nibble 6
2072 .word 0x00004000, 0x00000200, 0x01000200, 0x01000004
2073 .word 0x01004204, 0x00004004, 0x00004200, 0x00000000
2074 .word 0x01000000, 0x01000204, 0x00000204, 0x01004000
2075 .word 0x00000004, 0x01004200, 0x01004000, 0x00000204
2076 .word 0x01000204, 0x00004000, 0x00004004, 0x01004204
2077 .word 0x00000000, 0x01000200, 0x01000004, 0x00004200
2078 .word 0x01004004, 0x00004204, 0x01004200, 0x00000004
2079 .word 0x00004204, 0x01004004, 0x00000200, 0x01000000
2080 .word 0x00004204, 0x01004000, 0x01004004, 0x00000204
2081 .word 0x00004000, 0x00000200, 0x01000000, 0x01004004
2082 .word 0x01000204, 0x00004204, 0x00004200, 0x00000000
2083 .word 0x00000200, 0x01000004, 0x00000004, 0x01000200
2084 .word 0x00000000, 0x01000204, 0x01000200, 0x00004200
2085 .word 0x00000204, 0x00004000, 0x01004204, 0x01000000
2086 .word 0x01004200, 0x00000004, 0x00004004, 0x01004204
2087 .word 0x01000004, 0x01004200, 0x01004000, 0x00004004
2088 ! nibble 7
2089 .word 0x20800080, 0x20820000, 0x00020080, 0x00000000
2090 .word 0x20020000, 0x00800080, 0x20800000, 0x20820080
2091 .word 0x00000080, 0x20000000, 0x00820000, 0x00020080
2092 .word 0x00820080, 0x20020080, 0x20000080, 0x20800000
2093 .word 0x00020000, 0x00820080, 0x00800080, 0x20020000
2094 .word 0x20820080, 0x20000080, 0x00000000, 0x00820000
2095 .word 0x20000000, 0x00800000, 0x20020080, 0x20800080
2096 .word 0x00800000, 0x00020000, 0x20820000, 0x00000080
2097 .word 0x00800000, 0x00020000, 0x20000080, 0x20820080
2098 .word 0x00020080, 0x20000000, 0x00000000, 0x00820000
2099 .word 0x20800080, 0x20020080, 0x20020000, 0x00800080
2100 .word 0x20820000, 0x00000080, 0x00800080, 0x20020000
2101 .word 0x20820080, 0x00800000, 0x20800000, 0x20000080
2102 .word 0x00820000, 0x00020080, 0x20020080, 0x20800000
2103 .word 0x00000080, 0x20820000, 0x00820080, 0x00000000
2104 .word 0x20000000, 0x20800080, 0x00020000, 0x00820080
2105