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
|
IF @Version LT 800
ECHO MASM version 8.00 or later is strongly recommended.
ENDIF
.686
.XMM
IF @Version LT 800
XMMWORD STRUCT 16
DQ 2 dup (?)
XMMWORD ENDS
ENDIF
.MODEL FLAT
OPTION DOTNAME
IF @Version LT 800
.text$ SEGMENT PAGE 'CODE'
ELSE
.text$ SEGMENT ALIGN(64) 'CODE'
ENDIF
ALIGN 16
_ChaCha20_ctr32 PROC PUBLIC
$L_ChaCha20_ctr32_begin::
push ebp
push ebx
push esi
push edi
xor eax,eax
cmp eax,DWORD PTR 28[esp]
je $L000no_data
call $Lpic_point
$Lpic_point::
pop eax
lea ebp,DWORD PTR _OPENSSL_ia32cap_P
test DWORD PTR [ebp],16777216
jz $L001x86
test DWORD PTR 4[ebp],512
jz $L001x86
jmp $Lssse3_shortcut
$L001x86:
mov esi,DWORD PTR 32[esp]
mov edi,DWORD PTR 36[esp]
sub esp,132
mov eax,DWORD PTR [esi]
mov ebx,DWORD PTR 4[esi]
mov ecx,DWORD PTR 8[esi]
mov edx,DWORD PTR 12[esi]
mov DWORD PTR 80[esp],eax
mov DWORD PTR 84[esp],ebx
mov DWORD PTR 88[esp],ecx
mov DWORD PTR 92[esp],edx
mov eax,DWORD PTR 16[esi]
mov ebx,DWORD PTR 20[esi]
mov ecx,DWORD PTR 24[esi]
mov edx,DWORD PTR 28[esi]
mov DWORD PTR 96[esp],eax
mov DWORD PTR 100[esp],ebx
mov DWORD PTR 104[esp],ecx
mov DWORD PTR 108[esp],edx
mov eax,DWORD PTR [edi]
mov ebx,DWORD PTR 4[edi]
mov ecx,DWORD PTR 8[edi]
mov edx,DWORD PTR 12[edi]
sub eax,1
mov DWORD PTR 112[esp],eax
mov DWORD PTR 116[esp],ebx
mov DWORD PTR 120[esp],ecx
mov DWORD PTR 124[esp],edx
jmp $L002entry
ALIGN 16
$L003outer_loop:
mov DWORD PTR 156[esp],ebx
mov DWORD PTR 152[esp],eax
mov DWORD PTR 160[esp],ecx
$L002entry:
mov eax,1634760805
mov DWORD PTR 4[esp],857760878
mov DWORD PTR 8[esp],2036477234
mov DWORD PTR 12[esp],1797285236
mov ebx,DWORD PTR 84[esp]
mov ebp,DWORD PTR 88[esp]
mov ecx,DWORD PTR 104[esp]
mov esi,DWORD PTR 108[esp]
mov edx,DWORD PTR 116[esp]
mov edi,DWORD PTR 120[esp]
mov DWORD PTR 20[esp],ebx
mov DWORD PTR 24[esp],ebp
mov DWORD PTR 40[esp],ecx
mov DWORD PTR 44[esp],esi
mov DWORD PTR 52[esp],edx
mov DWORD PTR 56[esp],edi
mov ebx,DWORD PTR 92[esp]
mov edi,DWORD PTR 124[esp]
mov edx,DWORD PTR 112[esp]
mov ebp,DWORD PTR 80[esp]
mov ecx,DWORD PTR 96[esp]
mov esi,DWORD PTR 100[esp]
add edx,1
mov DWORD PTR 28[esp],ebx
mov DWORD PTR 60[esp],edi
mov DWORD PTR 112[esp],edx
mov ebx,10
jmp $L004loop
ALIGN 16
$L004loop:
add eax,ebp
mov DWORD PTR 128[esp],ebx
mov ebx,ebp
xor edx,eax
rol edx,16
add ecx,edx
xor ebx,ecx
mov edi,DWORD PTR 52[esp]
rol ebx,12
mov ebp,DWORD PTR 20[esp]
add eax,ebx
xor edx,eax
mov DWORD PTR [esp],eax
rol edx,8
mov eax,DWORD PTR 4[esp]
add ecx,edx
mov DWORD PTR 48[esp],edx
xor ebx,ecx
add eax,ebp
rol ebx,7
xor edi,eax
mov DWORD PTR 32[esp],ecx
rol edi,16
mov DWORD PTR 16[esp],ebx
add esi,edi
mov ecx,DWORD PTR 40[esp]
xor ebp,esi
mov edx,DWORD PTR 56[esp]
rol ebp,12
mov ebx,DWORD PTR 24[esp]
add eax,ebp
xor edi,eax
mov DWORD PTR 4[esp],eax
rol edi,8
mov eax,DWORD PTR 8[esp]
add esi,edi
mov DWORD PTR 52[esp],edi
xor ebp,esi
add eax,ebx
rol ebp,7
xor edx,eax
mov DWORD PTR 36[esp],esi
rol edx,16
mov DWORD PTR 20[esp],ebp
add ecx,edx
mov esi,DWORD PTR 44[esp]
xor ebx,ecx
mov edi,DWORD PTR 60[esp]
rol ebx,12
mov ebp,DWORD PTR 28[esp]
add eax,ebx
xor edx,eax
mov DWORD PTR 8[esp],eax
rol edx,8
mov eax,DWORD PTR 12[esp]
add ecx,edx
mov DWORD PTR 56[esp],edx
xor ebx,ecx
add eax,ebp
rol ebx,7
xor edi,eax
rol edi,16
mov DWORD PTR 24[esp],ebx
add esi,edi
xor ebp,esi
rol ebp,12
mov ebx,DWORD PTR 20[esp]
add eax,ebp
xor edi,eax
mov DWORD PTR 12[esp],eax
rol edi,8
mov eax,DWORD PTR [esp]
add esi,edi
mov edx,edi
xor ebp,esi
add eax,ebx
rol ebp,7
xor edx,eax
rol edx,16
mov DWORD PTR 28[esp],ebp
add ecx,edx
xor ebx,ecx
mov edi,DWORD PTR 48[esp]
rol ebx,12
mov ebp,DWORD PTR 24[esp]
add eax,ebx
xor edx,eax
mov DWORD PTR [esp],eax
rol edx,8
mov eax,DWORD PTR 4[esp]
add ecx,edx
mov DWORD PTR 60[esp],edx
xor ebx,ecx
add eax,ebp
rol ebx,7
xor edi,eax
mov DWORD PTR 40[esp],ecx
rol edi,16
mov DWORD PTR 20[esp],ebx
add esi,edi
mov ecx,DWORD PTR 32[esp]
xor ebp,esi
mov edx,DWORD PTR 52[esp]
rol ebp,12
mov ebx,DWORD PTR 28[esp]
add eax,ebp
xor edi,eax
mov DWORD PTR 4[esp],eax
rol edi,8
mov eax,DWORD PTR 8[esp]
add esi,edi
mov DWORD PTR 48[esp],edi
xor ebp,esi
add eax,ebx
rol ebp,7
xor edx,eax
mov DWORD PTR 44[esp],esi
rol edx,16
mov DWORD PTR 24[esp],ebp
add ecx,edx
mov esi,DWORD PTR 36[esp]
xor ebx,ecx
mov edi,DWORD PTR 56[esp]
rol ebx,12
mov ebp,DWORD PTR 16[esp]
add eax,ebx
xor edx,eax
mov DWORD PTR 8[esp],eax
rol edx,8
mov eax,DWORD PTR 12[esp]
add ecx,edx
mov DWORD PTR 52[esp],edx
xor ebx,ecx
add eax,ebp
rol ebx,7
xor edi,eax
rol edi,16
mov DWORD PTR 28[esp],ebx
add esi,edi
xor ebp,esi
mov edx,DWORD PTR 48[esp]
rol ebp,12
mov ebx,DWORD PTR 128[esp]
add eax,ebp
xor edi,eax
mov DWORD PTR 12[esp],eax
rol edi,8
mov eax,DWORD PTR [esp]
add esi,edi
mov DWORD PTR 56[esp],edi
xor ebp,esi
rol ebp,7
dec ebx
jnz $L004loop
mov ebx,DWORD PTR 160[esp]
add eax,1634760805
add ebp,DWORD PTR 80[esp]
add ecx,DWORD PTR 96[esp]
add esi,DWORD PTR 100[esp]
cmp ebx,64
jb $L005tail
mov ebx,DWORD PTR 156[esp]
add edx,DWORD PTR 112[esp]
add edi,DWORD PTR 120[esp]
xor eax,DWORD PTR [ebx]
xor ebp,DWORD PTR 16[ebx]
mov DWORD PTR [esp],eax
mov eax,DWORD PTR 152[esp]
xor ecx,DWORD PTR 32[ebx]
xor esi,DWORD PTR 36[ebx]
xor edx,DWORD PTR 48[ebx]
xor edi,DWORD PTR 56[ebx]
mov DWORD PTR 16[eax],ebp
mov DWORD PTR 32[eax],ecx
mov DWORD PTR 36[eax],esi
mov DWORD PTR 48[eax],edx
mov DWORD PTR 56[eax],edi
mov ebp,DWORD PTR 4[esp]
mov ecx,DWORD PTR 8[esp]
mov esi,DWORD PTR 12[esp]
mov edx,DWORD PTR 20[esp]
mov edi,DWORD PTR 24[esp]
add ebp,857760878
add ecx,2036477234
add esi,1797285236
add edx,DWORD PTR 84[esp]
add edi,DWORD PTR 88[esp]
xor ebp,DWORD PTR 4[ebx]
xor ecx,DWORD PTR 8[ebx]
xor esi,DWORD PTR 12[ebx]
xor edx,DWORD PTR 20[ebx]
xor edi,DWORD PTR 24[ebx]
mov DWORD PTR 4[eax],ebp
mov DWORD PTR 8[eax],ecx
mov DWORD PTR 12[eax],esi
mov DWORD PTR 20[eax],edx
mov DWORD PTR 24[eax],edi
mov ebp,DWORD PTR 28[esp]
mov ecx,DWORD PTR 40[esp]
mov esi,DWORD PTR 44[esp]
mov edx,DWORD PTR 52[esp]
mov edi,DWORD PTR 60[esp]
add ebp,DWORD PTR 92[esp]
add ecx,DWORD PTR 104[esp]
add esi,DWORD PTR 108[esp]
add edx,DWORD PTR 116[esp]
add edi,DWORD PTR 124[esp]
xor ebp,DWORD PTR 28[ebx]
xor ecx,DWORD PTR 40[ebx]
xor esi,DWORD PTR 44[ebx]
xor edx,DWORD PTR 52[ebx]
xor edi,DWORD PTR 60[ebx]
lea ebx,DWORD PTR 64[ebx]
mov DWORD PTR 28[eax],ebp
mov ebp,DWORD PTR [esp]
mov DWORD PTR 40[eax],ecx
mov ecx,DWORD PTR 160[esp]
mov DWORD PTR 44[eax],esi
mov DWORD PTR 52[eax],edx
mov DWORD PTR 60[eax],edi
mov DWORD PTR [eax],ebp
lea eax,DWORD PTR 64[eax]
sub ecx,64
jnz $L003outer_loop
jmp $L006done
$L005tail:
add edx,DWORD PTR 112[esp]
add edi,DWORD PTR 120[esp]
mov DWORD PTR [esp],eax
mov DWORD PTR 16[esp],ebp
mov DWORD PTR 32[esp],ecx
mov DWORD PTR 36[esp],esi
mov DWORD PTR 48[esp],edx
mov DWORD PTR 56[esp],edi
mov ebp,DWORD PTR 4[esp]
mov ecx,DWORD PTR 8[esp]
mov esi,DWORD PTR 12[esp]
mov edx,DWORD PTR 20[esp]
mov edi,DWORD PTR 24[esp]
add ebp,857760878
add ecx,2036477234
add esi,1797285236
add edx,DWORD PTR 84[esp]
add edi,DWORD PTR 88[esp]
mov DWORD PTR 4[esp],ebp
mov DWORD PTR 8[esp],ecx
mov DWORD PTR 12[esp],esi
mov DWORD PTR 20[esp],edx
mov DWORD PTR 24[esp],edi
mov ebp,DWORD PTR 28[esp]
mov ecx,DWORD PTR 40[esp]
mov esi,DWORD PTR 44[esp]
mov edx,DWORD PTR 52[esp]
mov edi,DWORD PTR 60[esp]
add ebp,DWORD PTR 92[esp]
add ecx,DWORD PTR 104[esp]
add esi,DWORD PTR 108[esp]
add edx,DWORD PTR 116[esp]
add edi,DWORD PTR 124[esp]
mov DWORD PTR 28[esp],ebp
mov ebp,DWORD PTR 156[esp]
mov DWORD PTR 40[esp],ecx
mov ecx,DWORD PTR 152[esp]
mov DWORD PTR 44[esp],esi
xor esi,esi
mov DWORD PTR 52[esp],edx
mov DWORD PTR 60[esp],edi
xor eax,eax
xor edx,edx
$L007tail_loop:
mov al,BYTE PTR [ebp*1+esi]
mov dl,BYTE PTR [esi*1+esp]
lea esi,DWORD PTR 1[esi]
xor al,dl
mov BYTE PTR [esi*1+ecx-1],al
dec ebx
jnz $L007tail_loop
$L006done:
add esp,132
$L000no_data:
pop edi
pop esi
pop ebx
pop ebp
ret
_ChaCha20_ctr32 ENDP
ALIGN 16
_ChaCha20_ssse3 PROC PUBLIC
$L_ChaCha20_ssse3_begin::
push ebp
push ebx
push esi
push edi
$Lssse3_shortcut::
test DWORD PTR 4[ebp],2048
jnz $Lxop_shortcut
mov edi,DWORD PTR 20[esp]
mov esi,DWORD PTR 24[esp]
mov ecx,DWORD PTR 28[esp]
mov edx,DWORD PTR 32[esp]
mov ebx,DWORD PTR 36[esp]
mov ebp,esp
sub esp,524
and esp,-64
mov DWORD PTR 512[esp],ebp
lea eax,DWORD PTR ($Lssse3_data-$Lpic_point)[eax]
movdqu xmm3,XMMWORD PTR [ebx]
$L0081x:
movdqa xmm0,XMMWORD PTR 32[eax]
movdqu xmm1,XMMWORD PTR [edx]
movdqu xmm2,XMMWORD PTR 16[edx]
movdqa xmm6,XMMWORD PTR [eax]
movdqa xmm7,XMMWORD PTR 16[eax]
mov DWORD PTR 48[esp],ebp
movdqa XMMWORD PTR [esp],xmm0
movdqa XMMWORD PTR 16[esp],xmm1
movdqa XMMWORD PTR 32[esp],xmm2
movdqa XMMWORD PTR 48[esp],xmm3
mov edx,10
jmp $L009loop1x
ALIGN 16
$L010outer1x:
movdqa xmm3,XMMWORD PTR 80[eax]
movdqa xmm0,XMMWORD PTR [esp]
movdqa xmm1,XMMWORD PTR 16[esp]
movdqa xmm2,XMMWORD PTR 32[esp]
paddd xmm3,XMMWORD PTR 48[esp]
mov edx,10
movdqa XMMWORD PTR 48[esp],xmm3
jmp $L009loop1x
ALIGN 16
$L009loop1x:
paddd xmm0,xmm1
pxor xmm3,xmm0
DB 102,15,56,0,222
paddd xmm2,xmm3
pxor xmm1,xmm2
movdqa xmm4,xmm1
psrld xmm1,20
pslld xmm4,12
por xmm1,xmm4
paddd xmm0,xmm1
pxor xmm3,xmm0
DB 102,15,56,0,223
paddd xmm2,xmm3
pxor xmm1,xmm2
movdqa xmm4,xmm1
psrld xmm1,25
pslld xmm4,7
por xmm1,xmm4
pshufd xmm2,xmm2,78
pshufd xmm1,xmm1,57
pshufd xmm3,xmm3,147
nop
paddd xmm0,xmm1
pxor xmm3,xmm0
DB 102,15,56,0,222
paddd xmm2,xmm3
pxor xmm1,xmm2
movdqa xmm4,xmm1
psrld xmm1,20
pslld xmm4,12
por xmm1,xmm4
paddd xmm0,xmm1
pxor xmm3,xmm0
DB 102,15,56,0,223
paddd xmm2,xmm3
pxor xmm1,xmm2
movdqa xmm4,xmm1
psrld xmm1,25
pslld xmm4,7
por xmm1,xmm4
pshufd xmm2,xmm2,78
pshufd xmm1,xmm1,147
pshufd xmm3,xmm3,57
dec edx
jnz $L009loop1x
paddd xmm0,XMMWORD PTR [esp]
paddd xmm1,XMMWORD PTR 16[esp]
paddd xmm2,XMMWORD PTR 32[esp]
paddd xmm3,XMMWORD PTR 48[esp]
cmp ecx,64
jb $L011tail
movdqu xmm4,XMMWORD PTR [esi]
movdqu xmm5,XMMWORD PTR 16[esi]
pxor xmm0,xmm4
movdqu xmm4,XMMWORD PTR 32[esi]
pxor xmm1,xmm5
movdqu xmm5,XMMWORD PTR 48[esi]
pxor xmm2,xmm4
pxor xmm3,xmm5
lea esi,DWORD PTR 64[esi]
movdqu XMMWORD PTR [edi],xmm0
movdqu XMMWORD PTR 16[edi],xmm1
movdqu XMMWORD PTR 32[edi],xmm2
movdqu XMMWORD PTR 48[edi],xmm3
lea edi,DWORD PTR 64[edi]
sub ecx,64
jnz $L010outer1x
jmp $L012done
$L011tail:
movdqa XMMWORD PTR [esp],xmm0
movdqa XMMWORD PTR 16[esp],xmm1
movdqa XMMWORD PTR 32[esp],xmm2
movdqa XMMWORD PTR 48[esp],xmm3
xor eax,eax
xor edx,edx
xor ebp,ebp
$L013tail_loop:
mov al,BYTE PTR [ebp*1+esp]
mov dl,BYTE PTR [ebp*1+esi]
lea ebp,DWORD PTR 1[ebp]
xor al,dl
mov BYTE PTR [ebp*1+edi-1],al
dec ecx
jnz $L013tail_loop
$L012done:
mov esp,DWORD PTR 512[esp]
pop edi
pop esi
pop ebx
pop ebp
ret
_ChaCha20_ssse3 ENDP
ALIGN 64
$Lssse3_data::
DB 2,3,0,1,6,7,4,5,10,11,8,9,14,15,12,13
DB 3,0,1,2,7,4,5,6,11,8,9,10,15,12,13,14
DD 1634760805,857760878,2036477234,1797285236
DD 0,1,2,3
DD 4,4,4,4
DD 1,0,0,0
DD 4,0,0,0
DD 0,-1,-1,-1
ALIGN 64
DB 67,104,97,67,104,97,50,48,32,102,111,114,32,120,56,54
DB 44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32
DB 60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111
DB 114,103,62,0
ALIGN 16
_ChaCha20_xop PROC PUBLIC
$L_ChaCha20_xop_begin::
push ebp
push ebx
push esi
push edi
$Lxop_shortcut::
mov edi,DWORD PTR 20[esp]
mov esi,DWORD PTR 24[esp]
mov ecx,DWORD PTR 28[esp]
mov edx,DWORD PTR 32[esp]
mov ebx,DWORD PTR 36[esp]
vzeroupper
mov ebp,esp
sub esp,524
and esp,-64
mov DWORD PTR 512[esp],ebp
lea eax,DWORD PTR ($Lssse3_data-$Lpic_point)[eax]
vmovdqu xmm3,XMMWORD PTR [ebx]
cmp ecx,256
jb $L0141x
mov DWORD PTR 516[esp],edx
mov DWORD PTR 520[esp],ebx
sub ecx,256
lea ebp,DWORD PTR 384[esp]
vmovdqu xmm7,XMMWORD PTR [edx]
vpshufd xmm0,xmm3,0
vpshufd xmm1,xmm3,85
vpshufd xmm2,xmm3,170
vpshufd xmm3,xmm3,255
vpaddd xmm0,xmm0,XMMWORD PTR 48[eax]
vpshufd xmm4,xmm7,0
vpshufd xmm5,xmm7,85
vpsubd xmm0,xmm0,XMMWORD PTR 64[eax]
vpshufd xmm6,xmm7,170
vpshufd xmm7,xmm7,255
vmovdqa XMMWORD PTR 64[ebp],xmm0
vmovdqa XMMWORD PTR 80[ebp],xmm1
vmovdqa XMMWORD PTR 96[ebp],xmm2
vmovdqa XMMWORD PTR 112[ebp],xmm3
vmovdqu xmm3,XMMWORD PTR 16[edx]
vmovdqa XMMWORD PTR [ebp-64],xmm4
vmovdqa XMMWORD PTR [ebp-48],xmm5
vmovdqa XMMWORD PTR [ebp-32],xmm6
vmovdqa XMMWORD PTR [ebp-16],xmm7
vmovdqa xmm7,XMMWORD PTR 32[eax]
lea ebx,DWORD PTR 128[esp]
vpshufd xmm0,xmm3,0
vpshufd xmm1,xmm3,85
vpshufd xmm2,xmm3,170
vpshufd xmm3,xmm3,255
vpshufd xmm4,xmm7,0
vpshufd xmm5,xmm7,85
vpshufd xmm6,xmm7,170
vpshufd xmm7,xmm7,255
vmovdqa XMMWORD PTR [ebp],xmm0
vmovdqa XMMWORD PTR 16[ebp],xmm1
vmovdqa XMMWORD PTR 32[ebp],xmm2
vmovdqa XMMWORD PTR 48[ebp],xmm3
vmovdqa XMMWORD PTR [ebp-128],xmm4
vmovdqa XMMWORD PTR [ebp-112],xmm5
vmovdqa XMMWORD PTR [ebp-96],xmm6
vmovdqa XMMWORD PTR [ebp-80],xmm7
lea esi,DWORD PTR 128[esi]
lea edi,DWORD PTR 128[edi]
jmp $L015outer_loop
ALIGN 32
$L015outer_loop:
vmovdqa xmm1,XMMWORD PTR [ebp-112]
vmovdqa xmm2,XMMWORD PTR [ebp-96]
vmovdqa xmm3,XMMWORD PTR [ebp-80]
vmovdqa xmm5,XMMWORD PTR [ebp-48]
vmovdqa xmm6,XMMWORD PTR [ebp-32]
vmovdqa xmm7,XMMWORD PTR [ebp-16]
vmovdqa XMMWORD PTR [ebx-112],xmm1
vmovdqa XMMWORD PTR [ebx-96],xmm2
vmovdqa XMMWORD PTR [ebx-80],xmm3
vmovdqa XMMWORD PTR [ebx-48],xmm5
vmovdqa XMMWORD PTR [ebx-32],xmm6
vmovdqa XMMWORD PTR [ebx-16],xmm7
vmovdqa xmm2,XMMWORD PTR 32[ebp]
vmovdqa xmm3,XMMWORD PTR 48[ebp]
vmovdqa xmm4,XMMWORD PTR 64[ebp]
vmovdqa xmm5,XMMWORD PTR 80[ebp]
vmovdqa xmm6,XMMWORD PTR 96[ebp]
vmovdqa xmm7,XMMWORD PTR 112[ebp]
vpaddd xmm4,xmm4,XMMWORD PTR 64[eax]
vmovdqa XMMWORD PTR 32[ebx],xmm2
vmovdqa XMMWORD PTR 48[ebx],xmm3
vmovdqa XMMWORD PTR 64[ebx],xmm4
vmovdqa XMMWORD PTR 80[ebx],xmm5
vmovdqa XMMWORD PTR 96[ebx],xmm6
vmovdqa XMMWORD PTR 112[ebx],xmm7
vmovdqa XMMWORD PTR 64[ebp],xmm4
vmovdqa xmm0,XMMWORD PTR [ebp-128]
vmovdqa xmm6,xmm4
vmovdqa xmm3,XMMWORD PTR [ebp-64]
vmovdqa xmm4,XMMWORD PTR [ebp]
vmovdqa xmm5,XMMWORD PTR 16[ebp]
mov edx,10
nop
ALIGN 32
$L016loop:
vpaddd xmm0,xmm0,xmm3
vpxor xmm6,xmm6,xmm0
DB 143,232,120,194,246,16
vpaddd xmm4,xmm4,xmm6
vpxor xmm2,xmm3,xmm4
vmovdqa xmm1,XMMWORD PTR [ebx-112]
DB 143,232,120,194,210,12
vmovdqa xmm3,XMMWORD PTR [ebx-48]
vpaddd xmm0,xmm0,xmm2
vmovdqa xmm7,XMMWORD PTR 80[ebx]
vpxor xmm6,xmm6,xmm0
vpaddd xmm1,xmm1,xmm3
DB 143,232,120,194,246,8
vmovdqa XMMWORD PTR [ebx-128],xmm0
vpaddd xmm4,xmm4,xmm6
vmovdqa XMMWORD PTR 64[ebx],xmm6
vpxor xmm2,xmm2,xmm4
vpxor xmm7,xmm7,xmm1
DB 143,232,120,194,210,7
vmovdqa XMMWORD PTR [ebx],xmm4
DB 143,232,120,194,255,16
vmovdqa XMMWORD PTR [ebx-64],xmm2
vpaddd xmm5,xmm5,xmm7
vmovdqa xmm4,XMMWORD PTR 32[ebx]
vpxor xmm3,xmm3,xmm5
vmovdqa xmm0,XMMWORD PTR [ebx-96]
DB 143,232,120,194,219,12
vmovdqa xmm2,XMMWORD PTR [ebx-32]
vpaddd xmm1,xmm1,xmm3
vmovdqa xmm6,XMMWORD PTR 96[ebx]
vpxor xmm7,xmm7,xmm1
vpaddd xmm0,xmm0,xmm2
DB 143,232,120,194,255,8
vmovdqa XMMWORD PTR [ebx-112],xmm1
vpaddd xmm5,xmm5,xmm7
vmovdqa XMMWORD PTR 80[ebx],xmm7
vpxor xmm3,xmm3,xmm5
vpxor xmm6,xmm6,xmm0
DB 143,232,120,194,219,7
vmovdqa XMMWORD PTR 16[ebx],xmm5
DB 143,232,120,194,246,16
vmovdqa XMMWORD PTR [ebx-48],xmm3
vpaddd xmm4,xmm4,xmm6
vmovdqa xmm5,XMMWORD PTR 48[ebx]
vpxor xmm2,xmm2,xmm4
vmovdqa xmm1,XMMWORD PTR [ebx-80]
DB 143,232,120,194,210,12
vmovdqa xmm3,XMMWORD PTR [ebx-16]
vpaddd xmm0,xmm0,xmm2
vmovdqa xmm7,XMMWORD PTR 112[ebx]
vpxor xmm6,xmm6,xmm0
vpaddd xmm1,xmm1,xmm3
DB 143,232,120,194,246,8
vmovdqa XMMWORD PTR [ebx-96],xmm0
vpaddd xmm4,xmm4,xmm6
vmovdqa XMMWORD PTR 96[ebx],xmm6
vpxor xmm2,xmm2,xmm4
vpxor xmm7,xmm7,xmm1
DB 143,232,120,194,210,7
DB 143,232,120,194,255,16
vmovdqa XMMWORD PTR [ebx-32],xmm2
vpaddd xmm5,xmm5,xmm7
vpxor xmm3,xmm3,xmm5
vmovdqa xmm0,XMMWORD PTR [ebx-128]
DB 143,232,120,194,219,12
vmovdqa xmm2,XMMWORD PTR [ebx-48]
vpaddd xmm1,xmm1,xmm3
vpxor xmm7,xmm7,xmm1
vpaddd xmm0,xmm0,xmm2
DB 143,232,120,194,255,8
vmovdqa XMMWORD PTR [ebx-80],xmm1
vpaddd xmm5,xmm5,xmm7
vpxor xmm3,xmm3,xmm5
vpxor xmm6,xmm7,xmm0
DB 143,232,120,194,219,7
DB 143,232,120,194,246,16
vmovdqa XMMWORD PTR [ebx-16],xmm3
vpaddd xmm4,xmm4,xmm6
vpxor xmm2,xmm2,xmm4
vmovdqa xmm1,XMMWORD PTR [ebx-112]
DB 143,232,120,194,210,12
vmovdqa xmm3,XMMWORD PTR [ebx-32]
vpaddd xmm0,xmm0,xmm2
vmovdqa xmm7,XMMWORD PTR 64[ebx]
vpxor xmm6,xmm6,xmm0
vpaddd xmm1,xmm1,xmm3
DB 143,232,120,194,246,8
vmovdqa XMMWORD PTR [ebx-128],xmm0
vpaddd xmm4,xmm4,xmm6
vmovdqa XMMWORD PTR 112[ebx],xmm6
vpxor xmm2,xmm2,xmm4
vpxor xmm7,xmm7,xmm1
DB 143,232,120,194,210,7
vmovdqa XMMWORD PTR 32[ebx],xmm4
DB 143,232,120,194,255,16
vmovdqa XMMWORD PTR [ebx-48],xmm2
vpaddd xmm5,xmm5,xmm7
vmovdqa xmm4,XMMWORD PTR [ebx]
vpxor xmm3,xmm3,xmm5
vmovdqa xmm0,XMMWORD PTR [ebx-96]
DB 143,232,120,194,219,12
vmovdqa xmm2,XMMWORD PTR [ebx-16]
vpaddd xmm1,xmm1,xmm3
vmovdqa xmm6,XMMWORD PTR 80[ebx]
vpxor xmm7,xmm7,xmm1
vpaddd xmm0,xmm0,xmm2
DB 143,232,120,194,255,8
vmovdqa XMMWORD PTR [ebx-112],xmm1
vpaddd xmm5,xmm5,xmm7
vmovdqa XMMWORD PTR 64[ebx],xmm7
vpxor xmm3,xmm3,xmm5
vpxor xmm6,xmm6,xmm0
DB 143,232,120,194,219,7
vmovdqa XMMWORD PTR 48[ebx],xmm5
DB 143,232,120,194,246,16
vmovdqa XMMWORD PTR [ebx-32],xmm3
vpaddd xmm4,xmm4,xmm6
vmovdqa xmm5,XMMWORD PTR 16[ebx]
vpxor xmm2,xmm2,xmm4
vmovdqa xmm1,XMMWORD PTR [ebx-80]
DB 143,232,120,194,210,12
vmovdqa xmm3,XMMWORD PTR [ebx-64]
vpaddd xmm0,xmm0,xmm2
vmovdqa xmm7,XMMWORD PTR 96[ebx]
vpxor xmm6,xmm6,xmm0
vpaddd xmm1,xmm1,xmm3
DB 143,232,120,194,246,8
vmovdqa XMMWORD PTR [ebx-96],xmm0
vpaddd xmm4,xmm4,xmm6
vmovdqa XMMWORD PTR 80[ebx],xmm6
vpxor xmm2,xmm2,xmm4
vpxor xmm7,xmm7,xmm1
DB 143,232,120,194,210,7
DB 143,232,120,194,255,16
vmovdqa XMMWORD PTR [ebx-16],xmm2
vpaddd xmm5,xmm5,xmm7
vpxor xmm3,xmm3,xmm5
vmovdqa xmm0,XMMWORD PTR [ebx-128]
DB 143,232,120,194,219,12
vpaddd xmm1,xmm1,xmm3
vmovdqa xmm6,XMMWORD PTR 64[ebx]
vpxor xmm7,xmm7,xmm1
DB 143,232,120,194,255,8
vmovdqa XMMWORD PTR [ebx-80],xmm1
vpaddd xmm5,xmm5,xmm7
vmovdqa XMMWORD PTR 96[ebx],xmm7
vpxor xmm3,xmm3,xmm5
DB 143,232,120,194,219,7
dec edx
jnz $L016loop
vmovdqa XMMWORD PTR [ebx-64],xmm3
vmovdqa XMMWORD PTR [ebx],xmm4
vmovdqa XMMWORD PTR 16[ebx],xmm5
vmovdqa XMMWORD PTR 64[ebx],xmm6
vmovdqa XMMWORD PTR 96[ebx],xmm7
vmovdqa xmm1,XMMWORD PTR [ebx-112]
vmovdqa xmm2,XMMWORD PTR [ebx-96]
vmovdqa xmm3,XMMWORD PTR [ebx-80]
vpaddd xmm0,xmm0,XMMWORD PTR [ebp-128]
vpaddd xmm1,xmm1,XMMWORD PTR [ebp-112]
vpaddd xmm2,xmm2,XMMWORD PTR [ebp-96]
vpaddd xmm3,xmm3,XMMWORD PTR [ebp-80]
vpunpckldq xmm6,xmm0,xmm1
vpunpckldq xmm7,xmm2,xmm3
vpunpckhdq xmm0,xmm0,xmm1
vpunpckhdq xmm2,xmm2,xmm3
vpunpcklqdq xmm1,xmm6,xmm7
vpunpckhqdq xmm6,xmm6,xmm7
vpunpcklqdq xmm7,xmm0,xmm2
vpunpckhqdq xmm3,xmm0,xmm2
vpxor xmm4,xmm1,XMMWORD PTR [esi-128]
vpxor xmm5,xmm6,XMMWORD PTR [esi-64]
vpxor xmm6,xmm7,XMMWORD PTR [esi]
vpxor xmm7,xmm3,XMMWORD PTR 64[esi]
lea esi,QWORD PTR 16[esi]
vmovdqa xmm0,XMMWORD PTR [ebx-64]
vmovdqa xmm1,XMMWORD PTR [ebx-48]
vmovdqa xmm2,XMMWORD PTR [ebx-32]
vmovdqa xmm3,XMMWORD PTR [ebx-16]
vmovdqu XMMWORD PTR [edi-128],xmm4
vmovdqu XMMWORD PTR [edi-64],xmm5
vmovdqu XMMWORD PTR [edi],xmm6
vmovdqu XMMWORD PTR 64[edi],xmm7
lea edi,QWORD PTR 16[edi]
vpaddd xmm0,xmm0,XMMWORD PTR [ebp-64]
vpaddd xmm1,xmm1,XMMWORD PTR [ebp-48]
vpaddd xmm2,xmm2,XMMWORD PTR [ebp-32]
vpaddd xmm3,xmm3,XMMWORD PTR [ebp-16]
vpunpckldq xmm6,xmm0,xmm1
vpunpckldq xmm7,xmm2,xmm3
vpunpckhdq xmm0,xmm0,xmm1
vpunpckhdq xmm2,xmm2,xmm3
vpunpcklqdq xmm1,xmm6,xmm7
vpunpckhqdq xmm6,xmm6,xmm7
vpunpcklqdq xmm7,xmm0,xmm2
vpunpckhqdq xmm3,xmm0,xmm2
vpxor xmm4,xmm1,XMMWORD PTR [esi-128]
vpxor xmm5,xmm6,XMMWORD PTR [esi-64]
vpxor xmm6,xmm7,XMMWORD PTR [esi]
vpxor xmm7,xmm3,XMMWORD PTR 64[esi]
lea esi,QWORD PTR 16[esi]
vmovdqa xmm0,XMMWORD PTR [ebx]
vmovdqa xmm1,XMMWORD PTR 16[ebx]
vmovdqa xmm2,XMMWORD PTR 32[ebx]
vmovdqa xmm3,XMMWORD PTR 48[ebx]
vmovdqu XMMWORD PTR [edi-128],xmm4
vmovdqu XMMWORD PTR [edi-64],xmm5
vmovdqu XMMWORD PTR [edi],xmm6
vmovdqu XMMWORD PTR 64[edi],xmm7
lea edi,QWORD PTR 16[edi]
vpaddd xmm0,xmm0,XMMWORD PTR [ebp]
vpaddd xmm1,xmm1,XMMWORD PTR 16[ebp]
vpaddd xmm2,xmm2,XMMWORD PTR 32[ebp]
vpaddd xmm3,xmm3,XMMWORD PTR 48[ebp]
vpunpckldq xmm6,xmm0,xmm1
vpunpckldq xmm7,xmm2,xmm3
vpunpckhdq xmm0,xmm0,xmm1
vpunpckhdq xmm2,xmm2,xmm3
vpunpcklqdq xmm1,xmm6,xmm7
vpunpckhqdq xmm6,xmm6,xmm7
vpunpcklqdq xmm7,xmm0,xmm2
vpunpckhqdq xmm3,xmm0,xmm2
vpxor xmm4,xmm1,XMMWORD PTR [esi-128]
vpxor xmm5,xmm6,XMMWORD PTR [esi-64]
vpxor xmm6,xmm7,XMMWORD PTR [esi]
vpxor xmm7,xmm3,XMMWORD PTR 64[esi]
lea esi,QWORD PTR 16[esi]
vmovdqa xmm0,XMMWORD PTR 64[ebx]
vmovdqa xmm1,XMMWORD PTR 80[ebx]
vmovdqa xmm2,XMMWORD PTR 96[ebx]
vmovdqa xmm3,XMMWORD PTR 112[ebx]
vmovdqu XMMWORD PTR [edi-128],xmm4
vmovdqu XMMWORD PTR [edi-64],xmm5
vmovdqu XMMWORD PTR [edi],xmm6
vmovdqu XMMWORD PTR 64[edi],xmm7
lea edi,QWORD PTR 16[edi]
vpaddd xmm0,xmm0,XMMWORD PTR 64[ebp]
vpaddd xmm1,xmm1,XMMWORD PTR 80[ebp]
vpaddd xmm2,xmm2,XMMWORD PTR 96[ebp]
vpaddd xmm3,xmm3,XMMWORD PTR 112[ebp]
vpunpckldq xmm6,xmm0,xmm1
vpunpckldq xmm7,xmm2,xmm3
vpunpckhdq xmm0,xmm0,xmm1
vpunpckhdq xmm2,xmm2,xmm3
vpunpcklqdq xmm1,xmm6,xmm7
vpunpckhqdq xmm6,xmm6,xmm7
vpunpcklqdq xmm7,xmm0,xmm2
vpunpckhqdq xmm3,xmm0,xmm2
vpxor xmm4,xmm1,XMMWORD PTR [esi-128]
vpxor xmm5,xmm6,XMMWORD PTR [esi-64]
vpxor xmm6,xmm7,XMMWORD PTR [esi]
vpxor xmm7,xmm3,XMMWORD PTR 64[esi]
lea esi,QWORD PTR 208[esi]
vmovdqu XMMWORD PTR [edi-128],xmm4
vmovdqu XMMWORD PTR [edi-64],xmm5
vmovdqu XMMWORD PTR [edi],xmm6
vmovdqu XMMWORD PTR 64[edi],xmm7
lea edi,QWORD PTR 208[edi]
sub ecx,256
jnc $L015outer_loop
add ecx,256
jz $L017done
mov ebx,DWORD PTR 520[esp]
lea esi,DWORD PTR [esi-128]
mov edx,DWORD PTR 516[esp]
lea edi,DWORD PTR [edi-128]
vmovd xmm2,DWORD PTR 64[ebp]
vmovdqu xmm3,XMMWORD PTR [ebx]
vpaddd xmm2,xmm2,XMMWORD PTR 96[eax]
vpand xmm3,xmm3,XMMWORD PTR 112[eax]
vpor xmm3,xmm3,xmm2
$L0141x:
vmovdqa xmm0,XMMWORD PTR 32[eax]
vmovdqu xmm1,XMMWORD PTR [edx]
vmovdqu xmm2,XMMWORD PTR 16[edx]
vmovdqa xmm6,XMMWORD PTR [eax]
vmovdqa xmm7,XMMWORD PTR 16[eax]
mov DWORD PTR 48[esp],ebp
vmovdqa XMMWORD PTR [esp],xmm0
vmovdqa XMMWORD PTR 16[esp],xmm1
vmovdqa XMMWORD PTR 32[esp],xmm2
vmovdqa XMMWORD PTR 48[esp],xmm3
mov edx,10
jmp $L018loop1x
ALIGN 16
$L019outer1x:
vmovdqa xmm3,XMMWORD PTR 80[eax]
vmovdqa xmm0,XMMWORD PTR [esp]
vmovdqa xmm1,XMMWORD PTR 16[esp]
vmovdqa xmm2,XMMWORD PTR 32[esp]
vpaddd xmm3,xmm3,XMMWORD PTR 48[esp]
mov edx,10
vmovdqa XMMWORD PTR 48[esp],xmm3
jmp $L018loop1x
ALIGN 16
$L018loop1x:
vpaddd xmm0,xmm0,xmm1
vpxor xmm3,xmm3,xmm0
DB 143,232,120,194,219,16
vpaddd xmm2,xmm2,xmm3
vpxor xmm1,xmm1,xmm2
DB 143,232,120,194,201,12
vpaddd xmm0,xmm0,xmm1
vpxor xmm3,xmm3,xmm0
DB 143,232,120,194,219,8
vpaddd xmm2,xmm2,xmm3
vpxor xmm1,xmm1,xmm2
DB 143,232,120,194,201,7
vpshufd xmm2,xmm2,78
vpshufd xmm1,xmm1,57
vpshufd xmm3,xmm3,147
vpaddd xmm0,xmm0,xmm1
vpxor xmm3,xmm3,xmm0
DB 143,232,120,194,219,16
vpaddd xmm2,xmm2,xmm3
vpxor xmm1,xmm1,xmm2
DB 143,232,120,194,201,12
vpaddd xmm0,xmm0,xmm1
vpxor xmm3,xmm3,xmm0
DB 143,232,120,194,219,8
vpaddd xmm2,xmm2,xmm3
vpxor xmm1,xmm1,xmm2
DB 143,232,120,194,201,7
vpshufd xmm2,xmm2,78
vpshufd xmm1,xmm1,147
vpshufd xmm3,xmm3,57
dec edx
jnz $L018loop1x
vpaddd xmm0,xmm0,XMMWORD PTR [esp]
vpaddd xmm1,xmm1,XMMWORD PTR 16[esp]
vpaddd xmm2,xmm2,XMMWORD PTR 32[esp]
vpaddd xmm3,xmm3,XMMWORD PTR 48[esp]
cmp ecx,64
jb $L020tail
vpxor xmm0,xmm0,XMMWORD PTR [esi]
vpxor xmm1,xmm1,XMMWORD PTR 16[esi]
vpxor xmm2,xmm2,XMMWORD PTR 32[esi]
vpxor xmm3,xmm3,XMMWORD PTR 48[esi]
lea esi,DWORD PTR 64[esi]
vmovdqu XMMWORD PTR [edi],xmm0
vmovdqu XMMWORD PTR 16[edi],xmm1
vmovdqu XMMWORD PTR 32[edi],xmm2
vmovdqu XMMWORD PTR 48[edi],xmm3
lea edi,DWORD PTR 64[edi]
sub ecx,64
jnz $L019outer1x
jmp $L017done
$L020tail:
vmovdqa XMMWORD PTR [esp],xmm0
vmovdqa XMMWORD PTR 16[esp],xmm1
vmovdqa XMMWORD PTR 32[esp],xmm2
vmovdqa XMMWORD PTR 48[esp],xmm3
xor eax,eax
xor edx,edx
xor ebp,ebp
$L021tail_loop:
mov al,BYTE PTR [ebp*1+esp]
mov dl,BYTE PTR [ebp*1+esi]
lea ebp,DWORD PTR 1[ebp]
xor al,dl
mov BYTE PTR [ebp*1+edi-1],al
dec ecx
jnz $L021tail_loop
$L017done:
vzeroupper
mov esp,DWORD PTR 512[esp]
pop edi
pop esi
pop ebx
pop ebp
ret
_ChaCha20_xop ENDP
.text$ ENDS
.bss SEGMENT 'BSS'
COMM _OPENSSL_ia32cap_P:DWORD:4
.bss ENDS
END
|