summaryrefslogtreecommitdiffstats
path: root/arch/x86/crypto/salsa20-i586-asm_32.S
blob: 329452b8f79466eea6066ab6bcefa7981e4fd34e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
# salsa20_pm.s version 20051229
# D. J. Bernstein
# Public domain.

#include <linux/linkage.h>

.text

# enter salsa20_encrypt_bytes
ENTRY(salsa20_encrypt_bytes)
	mov	%esp,%eax
	and	$31,%eax
	add	$256,%eax
	sub	%eax,%esp
	# eax_stack = eax
	movl	%eax,80(%esp)
	# ebx_stack = ebx
	movl	%ebx,84(%esp)
	# esi_stack = esi
	movl	%esi,88(%esp)
	# edi_stack = edi
	movl	%edi,92(%esp)
	# ebp_stack = ebp
	movl	%ebp,96(%esp)
	# x = arg1
	movl	4(%esp,%eax),%edx
	# m = arg2
	movl	8(%esp,%eax),%esi
	# out = arg3
	movl	12(%esp,%eax),%edi
	# bytes = arg4
	movl	16(%esp,%eax),%ebx
	# bytes -= 0
	sub	$0,%ebx
	# goto done if unsigned<=
	jbe	._done
._start:
	# in0 = *(uint32 *) (x + 0)
	movl	0(%edx),%eax
	# in1 = *(uint32 *) (x + 4)
	movl	4(%edx),%ecx
	# in2 = *(uint32 *) (x + 8)
	movl	8(%edx),%ebp
	# j0 = in0
	movl	%eax,164(%esp)
	# in3 = *(uint32 *) (x + 12)
	movl	12(%edx),%eax
	# j1 = in1
	movl	%ecx,168(%esp)
	# in4 = *(uint32 *) (x + 16)
	movl	16(%edx),%ecx
	# j2 = in2
	movl	%ebp,172(%esp)
	# in5 = *(uint32 *) (x + 20)
	movl	20(%edx),%ebp
	# j3 = in3
	movl	%eax,176(%esp)
	# in6 = *(uint32 *) (x + 24)
	movl	24(%edx),%eax
	# j4 = in4
	movl	%ecx,180(%esp)
	# in7 = *(uint32 *) (x + 28)
	movl	28(%edx),%ecx
	# j5 = in5
	movl	%ebp,184(%esp)
	# in8 = *(uint32 *) (x + 32)
	movl	32(%edx),%ebp
	# j6 = in6
	movl	%eax,188(%esp)
	# in9 = *(uint32 *) (x + 36)
	movl	36(%edx),%eax
	# j7 = in7
	movl	%ecx,192(%esp)
	# in10 = *(uint32 *) (x + 40)
	movl	40(%edx),%ecx
	# j8 = in8
	movl	%ebp,196(%esp)
	# in11 = *(uint32 *) (x + 44)
	movl	44(%edx),%ebp
	# j9 = in9
	movl	%eax,200(%esp)
	# in12 = *(uint32 *) (x + 48)
	movl	48(%edx),%eax
	# j10 = in10
	movl	%ecx,204(%esp)
	# in13 = *(uint32 *) (x + 52)
	movl	52(%edx),%ecx
	# j11 = in11
	movl	%ebp,208(%esp)
	# in14 = *(uint32 *) (x + 56)
	movl	56(%edx),%ebp
	# j12 = in12
	movl	%eax,212(%esp)
	# in15 = *(uint32 *) (x + 60)
	movl	60(%edx),%eax
	# j13 = in13
	movl	%ecx,216(%esp)
	# j14 = in14
	movl	%ebp,220(%esp)
	# j15 = in15
	movl	%eax,224(%esp)
	# x_backup = x
	movl	%edx,64(%esp)
._bytesatleast1:
	#   bytes - 64
	cmp	$64,%ebx
	#   goto nocopy if unsigned>=
	jae	._nocopy
	#     ctarget = out
	movl	%edi,228(%esp)
	#     out = &tmp
	leal	0(%esp),%edi
	#     i = bytes
	mov	%ebx,%ecx
	#     while (i) { *out++ = *m++; --i }
	rep	movsb
	#     out = &tmp
	leal	0(%esp),%edi
	#     m = &tmp
	leal	0(%esp),%esi
._nocopy:
	#   out_backup = out
	movl	%edi,72(%esp)
	#   m_backup = m
	movl	%esi,68(%esp)
	#   bytes_backup = bytes
	movl	%ebx,76(%esp)
	#   in0 = j0
	movl	164(%esp),%eax
	#   in1 = j1
	movl	168(%esp),%ecx
	#   in2 = j2
	movl	172(%esp),%edx
	#   in3 = j3
	movl	176(%esp),%ebx
	#   x0 = in0
	movl	%eax,100(%esp)
	#   x1 = in1
	movl	%ecx,104(%esp)
	#   x2 = in2
	movl	%edx,108(%esp)
	#   x3 = in3
	movl	%ebx,112(%esp)
	#   in4 = j4
	movl	180(%esp),%eax
	#   in5 = j5
	movl	184(%esp),%ecx
	#   in6 = j6
	movl	188(%esp),%edx
	#   in7 = j7
	movl	192(%esp),%ebx
	#   x4 = in4
	movl	%eax,116(%esp)
	#   x5 = in5
	movl	%ecx,120(%esp)
	#   x6 = in6
	movl	%edx,124(%esp)
	#   x7 = in7
	movl	%ebx,128(%esp)
	#   in8 = j8
	movl	196(%esp),%eax
	#   in9 = j9
	movl	200(%esp),%ecx
	#   in10 = j10
	movl	204(%esp),%edx
	#   in11 = j11
	movl	208(%esp),%ebx
	#   x8 = in8
	movl	%eax,132(%esp)
	#   x9 = in9
	movl	%ecx,136(%esp)
	#   x10 = in10
	movl	%edx,140(%esp)
	#   x11 = in11
	movl	%ebx,144(%esp)
	#   in12 = j12
	movl	212(%esp),%eax
	#   in13 = j13
	movl	216(%esp),%ecx
	#   in14 = j14
	movl	220(%esp),%edx
	#   in15 = j15
	movl	224(%esp),%ebx
	#   x12 = in12
	movl	%eax,148(%esp)
	#   x13 = in13
	movl	%ecx,152(%esp)
	#   x14 = in14
	movl	%edx,156(%esp)
	#   x15 = in15
	movl	%ebx,160(%esp)
	#   i = 20
	mov	$20,%ebp
	# p = x0
	movl	100(%esp),%eax
	# s = x5
	movl	120(%esp),%ecx
	# t = x10
	movl	140(%esp),%edx
	# w = x15
	movl	160(%esp),%ebx
._mainloop:
	# x0 = p
	movl	%eax,100(%esp)
	# 				x10 = t
	movl	%edx,140(%esp)
	# p += x12
	addl	148(%esp),%eax
	# 		x5 = s
	movl	%ecx,120(%esp)
	# 				t += x6
	addl	124(%esp),%edx
	# 						x15 = w
	movl	%ebx,160(%esp)
	# 		r = x1
	movl	104(%esp),%esi
	# 		r += s
	add	%ecx,%esi
	# 						v = x11
	movl	144(%esp),%edi
	# 						v += w
	add	%ebx,%edi
	# p <<<= 7
	rol	$7,%eax
	# p ^= x4
	xorl	116(%esp),%eax
	# 				t <<<= 7
	rol	$7,%edx
	# 				t ^= x14
	xorl	156(%esp),%edx
	# 		r <<<= 7
	rol	$7,%esi
	# 		r ^= x9
	xorl	136(%esp),%esi
	# 						v <<<= 7
	rol	$7,%edi
	# 						v ^= x3
	xorl	112(%esp),%edi
	# x4 = p
	movl	%eax,116(%esp)
	# 				x14 = t
	movl	%edx,156(%esp)
	# p += x0
	addl	100(%esp),%eax
	# 		x9 = r
	movl	%esi,136(%esp)
	# 				t += x10
	addl	140(%esp),%edx
	# 						x3 = v
	movl	%edi,112(%esp)
	# p <<<= 9
	rol	$9,%eax
	# p ^= x8
	xorl	132(%esp),%eax
	# 				t <<<= 9
	rol	$9,%edx
	# 				t ^= x2
	xorl	108(%esp),%edx
	# 		s += r
	add	%esi,%ecx
	# 		s <<<= 9
	rol	$9,%ecx
	# 		s ^= x13
	xorl	152(%esp),%ecx
	# 						w += v
	add	%edi,%ebx
	# 						w <<<= 9
	rol	$9,%ebx
	# 						w ^= x7
	xorl	128(%esp),%ebx
	# x8 = p
	movl	%eax,132(%esp)
	# 				x2 = t
	movl	%edx,108(%esp)
	# p += x4
	addl	116(%esp),%eax
	# 		x13 = s
	movl	%ecx,152(%esp)
	# 				t += x14
	addl	156(%esp),%edx
	# 						x7 = w
	movl	%ebx,128(%esp)
	# p <<<= 13
	rol	$13,%eax
	# p ^= x12
	xorl	148(%esp),%eax
	# 				t <<<= 13
	rol	$13,%edx
	# 				t ^= x6
	xorl	124(%esp),%edx
	# 		r += s
	add	%ecx,%esi
	# 		r <<<= 13
	rol	$13,%esi
	# 		r ^= x1
	xorl	104(%esp),%esi
	# 						v += w
	add	%ebx,%edi
	# 						v <<<= 13
	rol	$13,%edi
	# 						v ^= x11
	xorl	144(%esp),%edi
	# x12 = p
	movl	%eax,148(%esp)
	# 				x6 = t
	movl	%edx,124(%esp)
	# p += x8
	addl	132(%esp),%eax
	# 		x1 = r
	movl	%esi,104(%esp)
	# 				t += x2
	addl	108(%esp),%edx
	# 						x11 = v
	movl	%edi,144(%esp)
	# p <<<= 18
	rol	$18,%eax
	# p ^= x0
	xorl	100(%esp),%eax
	# 				t <<<= 18
	rol	$18,%edx
	# 				t ^= x10
	xorl	140(%esp),%edx
	# 		s += r
	add	%esi,%ecx
	# 		s <<<= 18
	rol	$18,%ecx
	# 		s ^= x5
	xorl	120(%esp),%ecx
	# 						w += v
	add	%edi,%ebx
	# 						w <<<= 18
	rol	$18,%ebx
	# 						w ^= x15
	xorl	160(%esp),%ebx
	# x0 = p
	movl	%eax,100(%esp)
	# 				x10 = t
	movl	%edx,140(%esp)
	# p += x3
	addl	112(%esp),%eax
	# p <<<= 7
	rol	$7,%eax
	# 		x5 = s
	movl	%ecx,120(%esp)
	# 				t += x9
	addl	136(%esp),%edx
	# 						x15 = w
	movl	%ebx,160(%esp)
	# 		r = x4
	movl	116(%esp),%esi
	# 		r += s
	add	%ecx,%esi
	# 						v = x14
	movl	156(%esp),%edi
	# 						v += w
	add	%ebx,%edi
	# p ^= x1
	xorl	104(%esp),%eax
	# 				t <<<= 7
	rol	$7,%edx
	# 				t ^= x11
	xorl	144(%esp),%edx
	# 		r <<<= 7
	rol	$7,%esi
	# 		r ^= x6
	xorl	124(%esp),%esi
	# 						v <<<= 7
	rol	$7,%edi
	# 						v ^= x12
	xorl	148(%esp),%edi
	# x1 = p
	movl	%eax,104(%esp)
	# 				x11 = t
	movl	%edx,144(%esp)
	# p += x0
	addl	100(%esp),%eax
	# 		x6 = r
	movl	%esi,124(%esp)
	# 				t += x10
	addl	140(%esp),%edx
	# 						x12 = v
	movl	%edi,148(%esp)
	# p <<<= 9
	rol	$9,%eax
	# p ^= x2
	xorl	108(%esp),%eax
	# 				t <<<= 9
	rol	$9,%edx
	# 				t ^= x8
	xorl	132(%esp),%edx
	# 		s += r
	add	%esi,%ecx
	# 		s <<<= 9
	rol	$9,%ecx
	# 		s ^= x7
	xorl	128(%esp),%ecx
	# 						w += v
	add	%edi,%ebx
	# 						w <<<= 9
	rol	$9,%ebx
	# 						w ^= x13
	xorl	152(%esp),%ebx
	# x2 = p
	movl	%eax,108(%esp)
	# 				x8 = t
	movl	%edx,132(%esp)
	# p += x1
	addl	104(%esp),%eax
	# 		x7 = s
	movl	%ecx,128(%esp)
	# 				t += x11
	addl	144(%esp),%edx
	# 						x13 = w
	movl	%ebx,152(%esp)
	# p <<<= 13
	rol	$13,%eax
	# p ^= x3
	xorl	112(%esp),%eax
	# 				t <<<= 13
	rol	$13,%edx
	# 				t ^= x9
	xorl	136(%esp),%edx
	# 		r += s
	add	%ecx,%esi
	# 		r <<<= 13
	rol	$13,%esi
	# 		r ^= x4
	xorl	116(%esp),%esi
	# 						v += w
	add	%ebx,%edi
	# 						v <<<= 13
	rol	$13,%edi
	# 						v ^= x14
	xorl	156(%esp),%edi
	# x3 = p
	movl	%eax,112(%esp)
	# 				x9 = t
	movl	%edx,136(%esp)
	# p += x2
	addl	108(%esp),%eax
	# 		x4 = r
	movl	%esi,116(%esp)
	# 				t += x8
	addl	132(%esp),%edx
	# 						x14 = v
	movl	%edi,156(%esp)
	# p <<<= 18
	rol	$18,%eax
	# p ^= x0
	xorl	100(%esp),%eax
	# 				t <<<= 18
	rol	$18,%edx
	# 				t ^= x10
	xorl	140(%esp),%edx
	# 		s += r
	add	%esi,%ecx
	# 		s <<<= 18
	rol	$18,%ecx
	# 		s ^= x5
	xorl	120(%esp),%ecx
	# 						w += v
	add	%edi,%ebx
	# 						w <<<= 18
	rol	$18,%ebx
	# 						w ^= x15
	xorl	160(%esp),%ebx
	# x0 = p
	movl	%eax,100(%esp)
	# 				x10 = t
	movl	%edx,140(%esp)
	# p += x12
	addl	148(%esp),%eax
	# 		x5 = s
	movl	%ecx,120(%esp)
	# 				t += x6
	addl	124(%esp),%edx
	# 						x15 = w
	movl	%ebx,160(%esp)
	# 		r = x1
	movl	104(%esp),%esi
	# 		r += s
	add	%ecx,%esi
	# 						v = x11
	movl	144(%esp),%edi
	# 						v += w
	add	%ebx,%edi
	# p <<<= 7
	rol	$7,%eax
	# p ^= x4
	xorl	116(%esp),%eax
	# 				t <<<= 7
	rol	$7,%edx
	# 				t ^= x14
	xorl	156(%esp),%edx
	# 		r <<<= 7
	rol	$7,%esi
	# 		r ^= x9
	xorl	136(%esp),%esi
	# 						v <<<= 7
	rol	$7,%edi
	# 						v ^= x3
	xorl	112(%esp),%edi
	# x4 = p
	movl	%eax,116(%esp)
	# 				x14 = t
	movl	%edx,156(%esp)
	# p += x0
	addl	100(%esp),%eax
	# 		x9 = r
	movl	%esi,136(%esp)
	# 				t += x10
	addl	140(%esp),%edx
	# 						x3 = v
	movl	%edi,112(%esp)
	# p <<<= 9
	rol	$9,%eax
	# p ^= x8
	xorl	132(%esp),%eax
	# 				t <<<= 9
	rol	$9,%edx
	# 				t ^= x2
	xorl	108(%esp),%edx
	# 		s += r
	add	%esi,%ecx
	# 		s <<<= 9
	rol	$9,%ecx
	# 		s ^= x13
	xorl	152(%esp),%ecx
	# 						w += v
	add	%edi,%ebx
	# 						w <<<= 9
	rol	$9,%ebx
	# 						w ^= x7
	xorl	128(%esp),%ebx
	# x8 = p
	movl	%eax,132(%esp)
	# 				x2 = t
	movl	%edx,108(%esp)
	# p += x4
	addl	116(%esp),%eax
	# 		x13 = s
	movl	%ecx,152(%esp)
	# 				t += x14
	addl	156(%esp),%edx
	# 						x7 = w
	movl	%ebx,128(%esp)
	# p <<<= 13
	rol	$13,%eax
	# p ^= x12
	xorl	148(%esp),%eax
	# 				t <<<= 13
	rol	$13,%edx
	# 				t ^= x6
	xorl	124(%esp),%edx
	# 		r += s
	add	%ecx,%esi
	# 		r <<<= 13
	rol	$13,%esi
	# 		r ^= x1
	xorl	104(%esp),%esi
	# 						v += w
	add	%ebx,%edi
	# 						v <<<= 13
	rol	$13,%edi
	# 						v ^= x11
	xorl	144(%esp),%edi
	# x12 = p
	movl	%eax,148(%esp)
	# 				x6 = t
	movl	%edx,124(%esp)
	# p += x8
	addl	132(%esp),%eax
	# 		x1 = r
	movl	%esi,104(%esp)
	# 				t += x2
	addl	108(%esp),%edx
	# 						x11 = v
	movl	%edi,144(%esp)
	# p <<<= 18
	rol	$18,%eax
	# p ^= x0
	xorl	100(%esp),%eax
	# 				t <<<= 18
	rol	$18,%edx
	# 				t ^= x10
	xorl	140(%esp),%edx
	# 		s += r
	add	%esi,%ecx
	# 		s <<<= 18
	rol	$18,%ecx
	# 		s ^= x5
	xorl	120(%esp),%ecx
	# 						w += v
	add	%edi,%ebx
	# 						w <<<= 18
	rol	$18,%ebx
	# 						w ^= x15
	xorl	160(%esp),%ebx
	# x0 = p
	movl	%eax,100(%esp)
	# 				x10 = t
	movl	%edx,140(%esp)
	# p += x3
	addl	112(%esp),%eax
	# p <<<= 7
	rol	$7,%eax
	# 		x5 = s
	movl	%ecx,120(%esp)
	# 				t += x9
	addl	136(%esp),%edx
	# 						x15 = w
	movl	%ebx,160(%esp)
	# 		r = x4
	movl	116(%esp),%esi
	# 		r += s
	add	%ecx,%esi
	# 						v = x14
	movl	156(%esp),%edi
	# 						v += w
	add	%ebx,%edi
	# p ^= x1
	xorl	104(%esp),%eax
	# 				t <<<= 7
	rol	$7,%edx
	# 				t ^= x11
	xorl	144(%esp),%edx
	# 		r <<<= 7
	rol	$7,%esi
	# 		r ^= x6
	xorl	124(%esp),%esi
	# 						v <<<= 7
	rol	$7,%edi
	# 						v ^= x12
	xorl	148(%esp),%edi
	# x1 = p
	movl	%eax,104(%esp)
	# 				x11 = t
	movl	%edx,144(%esp)
	# p += x0
	addl	100(%esp),%eax
	# 		x6 = r
	movl	%esi,124(%esp)
	# 				t += x10
	addl	140(%esp),%edx
	# 						x12 = v
	movl	%edi,148(%esp)
	# p <<<= 9
	rol	$9,%eax
	# p ^= x2
	xorl	108(%esp),%eax
	# 				t <<<= 9
	rol	$9,%edx
	# 				t ^= x8
	xorl	132(%esp),%edx
	# 		s += r
	add	%esi,%ecx
	# 		s <<<= 9
	rol	$9,%ecx
	# 		s ^= x7
	xorl	128(%esp),%ecx
	# 						w += v
	add	%edi,%ebx
	# 						w <<<= 9
	rol	$9,%ebx
	# 						w ^= x13
	xorl	152(%esp),%ebx
	# x2 = p
	movl	%eax,108(%esp)
	# 				x8 = t
	movl	%edx,132(%esp)
	# p += x1
	addl	104(%esp),%eax
	# 		x7 = s
	movl	%ecx,128(%esp)
	# 				t += x11
	addl	144(%esp),%edx
	# 						x13 = w
	movl	%ebx,152(%esp)
	# p <<<= 13
	rol	$13,%eax
	# p ^= x3
	xorl	112(%esp),%eax
	# 				t <<<= 13
	rol	$13,%edx
	# 				t ^= x9
	xorl	136(%esp),%edx
	# 		r += s
	add	%ecx,%esi
	# 		r <<<= 13
	rol	$13,%esi
	# 		r ^= x4
	xorl	116(%esp),%esi
	# 						v += w
	add	%ebx,%edi
	# 						v <<<= 13
	rol	$13,%edi
	# 						v ^= x14
	xorl	156(%esp),%edi
	# x3 = p
	movl	%eax,112(%esp)
	# 				x9 = t
	movl	%edx,136(%esp)
	# p += x2
	addl	108(%esp),%eax
	# 		x4 = r
	movl	%esi,116(%esp)
	# 				t += x8
	addl	132(%esp),%edx
	# 						x14 = v
	movl	%edi,156(%esp)
	# p <<<= 18
	rol	$18,%eax
	# p ^= x0
	xorl	100(%esp),%eax
	# 				t <<<= 18
	rol	$18,%edx
	# 				t ^= x10
	xorl	140(%esp),%edx
	# 		s += r
	add	%esi,%ecx
	# 		s <<<= 18
	rol	$18,%ecx
	# 		s ^= x5
	xorl	120(%esp),%ecx
	# 						w += v
	add	%edi,%ebx
	# 						w <<<= 18
	rol	$18,%ebx
	# 						w ^= x15
	xorl	160(%esp),%ebx
	# i -= 4
	sub	$4,%ebp
	# goto mainloop if unsigned >
	ja	._mainloop
	# x0 = p
	movl	%eax,100(%esp)
	# x5 = s
	movl	%ecx,120(%esp)
	# x10 = t
	movl	%edx,140(%esp)
	# x15 = w
	movl	%ebx,160(%esp)
	#   out = out_backup
	movl	72(%esp),%edi
	#   m = m_backup
	movl	68(%esp),%esi
	#   in0 = x0
	movl	100(%esp),%eax
	#   in1 = x1
	movl	104(%esp),%ecx
	#   in0 += j0
	addl	164(%esp),%eax
	#   in1 += j1
	addl	168(%esp),%ecx
	#   in0 ^= *(uint32 *) (m + 0)
	xorl	0(%esi),%eax
	#   in1 ^= *(uint32 *) (m + 4)
	xorl	4(%esi),%ecx
	#   *(uint32 *) (out + 0) = in0
	movl	%eax,0(%edi)
	#   *(uint32 *) (out + 4) = in1
	movl	%ecx,4(%edi)
	#   in2 = x2
	movl	108(%esp),%eax
	#   in3 = x3
	movl	112(%esp),%ecx
	#   in2 += j2
	addl	172(%esp),%eax
	#   in3 += j3
	addl	176(%esp),%ecx
	#   in2 ^= *(uint32 *) (m + 8)
	xorl	8(%esi),%eax
	#   in3 ^= *(uint32 *) (m + 12)
	xorl	12(%esi),%ecx
	#   *(uint32 *) (out + 8) = in2
	movl	%eax,8(%edi)
	#   *(uint32 *) (out + 12) = in3
	movl	%ecx,12(%edi)
	#   in4 = x4
	movl	116(%esp),%eax
	#   in5 = x5
	movl	120(%esp),%ecx
	#   in4 += j4
	addl	180(%esp),%eax
	#   in5 += j5
	addl	184(%esp),%ecx
	#   in4 ^= *(uint32 *) (m + 16)
	xorl	16(%esi),%eax
	#   in5 ^= *(uint32 *) (m + 20)
	xorl	20(%esi),%ecx
	#   *(uint32 *) (out + 16) = in4
	movl	%eax,16(%edi)
	#   *(uint32 *) (out + 20) = in5
	movl	%ecx,20(%edi)
	#   in6 = x6
	movl	124(%esp),%eax
	#   in7 = x7
	movl	128(%esp),%ecx
	#   in6 += j6
	addl	188(%esp),%eax
	#   in7 += j7
	addl	192(%esp),%ecx
	#   in6 ^= *(uint32 *) (m + 24)
	xorl	24(%esi),%eax
	#   in7 ^= *(uint32 *) (m + 28)
	xorl	28(%esi),%ecx
	#   *(uint32 *) (out + 24) = in6
	movl	%eax,24(%edi)
	#   *(uint32 *) (out + 28) = in7
	movl	%ecx,28(%edi)
	#   in8 = x8
	movl	132(%esp),%eax
	#   in9 = x9
	movl	136(%esp),%ecx
	#   in8 += j8
	addl	196(%esp),%eax
	#   in9 += j9
	addl	200(%esp),%ecx
	#   in8 ^= *(uint32 *) (m + 32)
	xorl	32(%esi),%eax
	#   in9 ^= *(uint32 *) (m + 36)
	xorl	36(%esi),%ecx
	#   *(uint32 *) (out + 32) = in8
	movl	%eax,32(%edi)
	#   *(uint32 *) (out + 36) = in9
	movl	%ecx,36(%edi)
	#   in10 = x10
	movl	140(%esp),%eax
	#   in11 = x11
	movl	144(%esp),%ecx
	#   in10 += j10
	addl	204(%esp),%eax
	#   in11 += j11
	addl	208(%esp),%ecx
	#   in10 ^= *(uint32 *) (m + 40)
	xorl	40(%esi),%eax
	#   in11 ^= *(uint32 *) (m + 44)
	xorl	44(%esi),%ecx
	#   *(uint32 *) (out + 40) = in10
	movl	%eax,40(%edi)
	#   *(uint32 *) (out + 44) = in11
	movl	%ecx,44(%edi)
	#   in12 = x12
	movl	148(%esp),%eax
	#   in13 = x13
	movl	152(%esp),%ecx
	#   in12 += j12
	addl	212(%esp),%eax
	#   in13 += j13
	addl	216(%esp),%ecx
	#   in12 ^= *(uint32 *) (m + 48)
	xorl	48(%esi),%eax
	#   in13 ^= *(uint32 *) (m + 52)
	xorl	52(%esi),%ecx
	#   *(uint32 *) (out + 48) = in12
	movl	%eax,48(%edi)
	#   *(uint32 *) (out + 52) = in13
	movl	%ecx,52(%edi)
	#   in14 = x14
	movl	156(%esp),%eax
	#   in15 = x15
	movl	160(%esp),%ecx
	#   in14 += j14
	addl	220(%esp),%eax
	#   in15 += j15
	addl	224(%esp),%ecx
	#   in14 ^= *(uint32 *) (m + 56)
	xorl	56(%esi),%eax
	#   in15 ^= *(uint32 *) (m + 60)
	xorl	60(%esi),%ecx
	#   *(uint32 *) (out + 56) = in14
	movl	%eax,56(%edi)
	#   *(uint32 *) (out + 60) = in15
	movl	%ecx,60(%edi)
	#   bytes = bytes_backup
	movl	76(%esp),%ebx
	#   in8 = j8
	movl	196(%esp),%eax
	#   in9 = j9
	movl	200(%esp),%ecx
	#   in8 += 1
	add	$1,%eax
	#   in9 += 0 + carry
	adc	$0,%ecx
	#   j8 = in8
	movl	%eax,196(%esp)
	#   j9 = in9
	movl	%ecx,200(%esp)
	#   bytes - 64
	cmp	$64,%ebx
	#   goto bytesatleast65 if unsigned>
	ja	._bytesatleast65
	#     goto bytesatleast64 if unsigned>=
	jae	._bytesatleast64
	#       m = out
	mov	%edi,%esi
	#       out = ctarget
	movl	228(%esp),%edi
	#       i = bytes
	mov	%ebx,%ecx
	#       while (i) { *out++ = *m++; --i }
	rep	movsb
._bytesatleast64:
	#     x = x_backup
	movl	64(%esp),%eax
	#     in8 = j8
	movl	196(%esp),%ecx
	#     in9 = j9
	movl	200(%esp),%edx
	#     *(uint32 *) (x + 32) = in8
	movl	%ecx,32(%eax)
	#     *(uint32 *) (x + 36) = in9
	movl	%edx,36(%eax)
._done:
	#     eax = eax_stack
	movl	80(%esp),%eax
	#     ebx = ebx_stack
	movl	84(%esp),%ebx
	#     esi = esi_stack
	movl	88(%esp),%esi
	#     edi = edi_stack
	movl	92(%esp),%edi
	#     ebp = ebp_stack
	movl	96(%esp),%ebp
	#     leave
	add	%eax,%esp
	ret
._bytesatleast65:
	#   bytes -= 64
	sub	$64,%ebx
	#   out += 64
	add	$64,%edi
	#   m += 64
	add	$64,%esi
	# goto bytesatleast1
	jmp	._bytesatleast1
ENDPROC(salsa20_encrypt_bytes)

# enter salsa20_keysetup
ENTRY(salsa20_keysetup)
	mov	%esp,%eax
	and	$31,%eax
	add	$256,%eax
	sub	%eax,%esp
	#   eax_stack = eax
	movl	%eax,64(%esp)
	#   ebx_stack = ebx
	movl	%ebx,68(%esp)
	#   esi_stack = esi
	movl	%esi,72(%esp)
	#   edi_stack = edi
	movl	%edi,76(%esp)
	#   ebp_stack = ebp
	movl	%ebp,80(%esp)
	#   k = arg2
	movl	8(%esp,%eax),%ecx
	#   kbits = arg3
	movl	12(%esp,%eax),%edx
	#   x = arg1
	movl	4(%esp,%eax),%eax
	#   in1 = *(uint32 *) (k + 0)
	movl	0(%ecx),%ebx
	#   in2 = *(uint32 *) (k + 4)
	movl	4(%ecx),%esi
	#   in3 = *(uint32 *) (k + 8)
	movl	8(%ecx),%edi
	#   in4 = *(uint32 *) (k + 12)
	movl	12(%ecx),%ebp
	#   *(uint32 *) (x + 4) = in1
	movl	%ebx,4(%eax)
	#   *(uint32 *) (x + 8) = in2
	movl	%esi,8(%eax)
	#   *(uint32 *) (x + 12) = in3
	movl	%edi,12(%eax)
	#   *(uint32 *) (x + 16) = in4
	movl	%ebp,16(%eax)
	#   kbits - 256
	cmp	$256,%edx
	#   goto kbits128 if unsigned<
	jb	._kbits128
._kbits256:
	#     in11 = *(uint32 *) (k + 16)
	movl	16(%ecx),%edx
	#     in12 = *(uint32 *) (k + 20)
	movl	20(%ecx),%ebx
	#     in13 = *(uint32 *) (k + 24)
	movl	24(%ecx),%esi
	#     in14 = *(uint32 *) (k + 28)
	movl	28(%ecx),%ecx
	#     *(uint32 *) (x + 44) = in11
	movl	%edx,44(%eax)
	#     *(uint32 *) (x + 48) = in12
	movl	%ebx,48(%eax)
	#     *(uint32 *) (x + 52) = in13
	movl	%esi,52(%eax)
	#     *(uint32 *) (x + 56) = in14
	movl	%ecx,56(%eax)
	#     in0 = 1634760805
	mov	$1634760805,%ecx
	#     in5 = 857760878
	mov	$857760878,%edx
	#     in10 = 2036477234
	mov	$2036477234,%ebx
	#     in15 = 1797285236
	mov	$1797285236,%esi
	#     *(uint32 *) (x + 0) = in0
	movl	%ecx,0(%eax)
	#     *(uint32 *) (x + 20) = in5
	movl	%edx,20(%eax)
	#     *(uint32 *) (x + 40) = in10
	movl	%ebx,40(%eax)
	#     *(uint32 *) (x + 60) = in15
	movl	%esi,60(%eax)
	#   goto keysetupdone
	jmp	._keysetupdone
._kbits128:
	#     in11 = *(uint32 *) (k + 0)
	movl	0(%ecx),%edx
	#     in12 = *(uint32 *) (k + 4)
	movl	4(%ecx),%ebx
	#     in13 = *(uint32 *) (k + 8)
	movl	8(%ecx),%esi
	#     in14 = *(uint32 *) (k + 12)
	movl	12(%ecx),%ecx
	#     *(uint32 *) (x + 44) = in11
	movl	%edx,44(%eax)
	#     *(uint32 *) (x + 48) = in12
	movl	%ebx,48(%eax)
	#     *(uint32 *) (x + 52) = in13
	movl	%esi,52(%eax)
	#     *(uint32 *) (x + 56) = in14
	movl	%ecx,56(%eax)
	#     in0 = 1634760805
	mov	$1634760805,%ecx
	#     in5 = 824206446
	mov	$824206446,%edx
	#     in10 = 2036477238
	mov	$2036477238,%ebx
	#     in15 = 1797285236
	mov	$1797285236,%esi
	#     *(uint32 *) (x + 0) = in0
	movl	%ecx,0(%eax)
	#     *(uint32 *) (x + 20) = in5
	movl	%edx,20(%eax)
	#     *(uint32 *) (x + 40) = in10
	movl	%ebx,40(%eax)
	#     *(uint32 *) (x + 60) = in15
	movl	%esi,60(%eax)
._keysetupdone:
	#   eax = eax_stack
	movl	64(%esp),%eax
	#   ebx = ebx_stack
	movl	68(%esp),%ebx
	#   esi = esi_stack
	movl	72(%esp),%esi
	#   edi = edi_stack
	movl	76(%esp),%edi
	#   ebp = ebp_stack
	movl	80(%esp),%ebp
	# leave
	add	%eax,%esp
	ret
ENDPROC(salsa20_keysetup)

# enter salsa20_ivsetup
ENTRY(salsa20_ivsetup)
	mov	%esp,%eax
	and	$31,%eax
	add	$256,%eax
	sub	%eax,%esp
	#   eax_stack = eax
	movl	%eax,64(%esp)
	#   ebx_stack = ebx
	movl	%ebx,68(%esp)
	#   esi_stack = esi
	movl	%esi,72(%esp)
	#   edi_stack = edi
	movl	%edi,76(%esp)
	#   ebp_stack = ebp
	movl	%ebp,80(%esp)
	#   iv = arg2
	movl	8(%esp,%eax),%ecx
	#   x = arg1
	movl	4(%esp,%eax),%eax
	#   in6 = *(uint32 *) (iv + 0)
	movl	0(%ecx),%edx
	#   in7 = *(uint32 *) (iv + 4)
	movl	4(%ecx),%ecx
	#   in8 = 0
	mov	$0,%ebx
	#   in9 = 0
	mov	$0,%esi
	#   *(uint32 *) (x + 24) = in6
	movl	%edx,24(%eax)
	#   *(uint32 *) (x + 28) = in7
	movl	%ecx,28(%eax)
	#   *(uint32 *) (x + 32) = in8
	movl	%ebx,32(%eax)
	#   *(uint32 *) (x + 36) = in9
	movl	%esi,36(%eax)
	#   eax = eax_stack
	movl	64(%esp),%eax
	#   ebx = ebx_stack
	movl	68(%esp),%ebx
	#   esi = esi_stack
	movl	72(%esp),%esi
	#   edi = edi_stack
	movl	76(%esp),%edi
	#   ebp = ebp_stack
	movl	80(%esp),%ebp
	# leave
	add	%eax,%esp
	ret
ENDPROC(salsa20_ivsetup)
OpenPOWER on IntegriCloud