-
Notifications
You must be signed in to change notification settings - Fork 28.2k
/
aesni-x86.asm
3202 lines (3202 loc) Β· 59.2 KB
/
aesni-x86.asm
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
%ifidn __OUTPUT_FORMAT__,obj
section code use32 class=code align=64
%elifidn __OUTPUT_FORMAT__,win32
$@feat.00 equ 1
section .text code align=64
%else
section .text code
%endif
;extern _OPENSSL_ia32cap_P
global _aesni_encrypt
align 16
_aesni_encrypt:
L$_aesni_encrypt_begin:
mov eax,DWORD [4+esp]
mov edx,DWORD [12+esp]
movups xmm2,[eax]
mov ecx,DWORD [240+edx]
mov eax,DWORD [8+esp]
movups xmm0,[edx]
movups xmm1,[16+edx]
lea edx,[32+edx]
xorps xmm2,xmm0
L$000enc1_loop_1:
db 102,15,56,220,209
dec ecx
movups xmm1,[edx]
lea edx,[16+edx]
jnz NEAR L$000enc1_loop_1
db 102,15,56,221,209
pxor xmm0,xmm0
pxor xmm1,xmm1
movups [eax],xmm2
pxor xmm2,xmm2
ret
global _aesni_decrypt
align 16
_aesni_decrypt:
L$_aesni_decrypt_begin:
mov eax,DWORD [4+esp]
mov edx,DWORD [12+esp]
movups xmm2,[eax]
mov ecx,DWORD [240+edx]
mov eax,DWORD [8+esp]
movups xmm0,[edx]
movups xmm1,[16+edx]
lea edx,[32+edx]
xorps xmm2,xmm0
L$001dec1_loop_2:
db 102,15,56,222,209
dec ecx
movups xmm1,[edx]
lea edx,[16+edx]
jnz NEAR L$001dec1_loop_2
db 102,15,56,223,209
pxor xmm0,xmm0
pxor xmm1,xmm1
movups [eax],xmm2
pxor xmm2,xmm2
ret
align 16
__aesni_encrypt2:
movups xmm0,[edx]
shl ecx,4
movups xmm1,[16+edx]
xorps xmm2,xmm0
pxor xmm3,xmm0
movups xmm0,[32+edx]
lea edx,[32+ecx*1+edx]
neg ecx
add ecx,16
L$002enc2_loop:
db 102,15,56,220,209
db 102,15,56,220,217
movups xmm1,[ecx*1+edx]
add ecx,32
db 102,15,56,220,208
db 102,15,56,220,216
movups xmm0,[ecx*1+edx-16]
jnz NEAR L$002enc2_loop
db 102,15,56,220,209
db 102,15,56,220,217
db 102,15,56,221,208
db 102,15,56,221,216
ret
align 16
__aesni_decrypt2:
movups xmm0,[edx]
shl ecx,4
movups xmm1,[16+edx]
xorps xmm2,xmm0
pxor xmm3,xmm0
movups xmm0,[32+edx]
lea edx,[32+ecx*1+edx]
neg ecx
add ecx,16
L$003dec2_loop:
db 102,15,56,222,209
db 102,15,56,222,217
movups xmm1,[ecx*1+edx]
add ecx,32
db 102,15,56,222,208
db 102,15,56,222,216
movups xmm0,[ecx*1+edx-16]
jnz NEAR L$003dec2_loop
db 102,15,56,222,209
db 102,15,56,222,217
db 102,15,56,223,208
db 102,15,56,223,216
ret
align 16
__aesni_encrypt3:
movups xmm0,[edx]
shl ecx,4
movups xmm1,[16+edx]
xorps xmm2,xmm0
pxor xmm3,xmm0
pxor xmm4,xmm0
movups xmm0,[32+edx]
lea edx,[32+ecx*1+edx]
neg ecx
add ecx,16
L$004enc3_loop:
db 102,15,56,220,209
db 102,15,56,220,217
db 102,15,56,220,225
movups xmm1,[ecx*1+edx]
add ecx,32
db 102,15,56,220,208
db 102,15,56,220,216
db 102,15,56,220,224
movups xmm0,[ecx*1+edx-16]
jnz NEAR L$004enc3_loop
db 102,15,56,220,209
db 102,15,56,220,217
db 102,15,56,220,225
db 102,15,56,221,208
db 102,15,56,221,216
db 102,15,56,221,224
ret
align 16
__aesni_decrypt3:
movups xmm0,[edx]
shl ecx,4
movups xmm1,[16+edx]
xorps xmm2,xmm0
pxor xmm3,xmm0
pxor xmm4,xmm0
movups xmm0,[32+edx]
lea edx,[32+ecx*1+edx]
neg ecx
add ecx,16
L$005dec3_loop:
db 102,15,56,222,209
db 102,15,56,222,217
db 102,15,56,222,225
movups xmm1,[ecx*1+edx]
add ecx,32
db 102,15,56,222,208
db 102,15,56,222,216
db 102,15,56,222,224
movups xmm0,[ecx*1+edx-16]
jnz NEAR L$005dec3_loop
db 102,15,56,222,209
db 102,15,56,222,217
db 102,15,56,222,225
db 102,15,56,223,208
db 102,15,56,223,216
db 102,15,56,223,224
ret
align 16
__aesni_encrypt4:
movups xmm0,[edx]
movups xmm1,[16+edx]
shl ecx,4
xorps xmm2,xmm0
pxor xmm3,xmm0
pxor xmm4,xmm0
pxor xmm5,xmm0
movups xmm0,[32+edx]
lea edx,[32+ecx*1+edx]
neg ecx
db 15,31,64,0
add ecx,16
L$006enc4_loop:
db 102,15,56,220,209
db 102,15,56,220,217
db 102,15,56,220,225
db 102,15,56,220,233
movups xmm1,[ecx*1+edx]
add ecx,32
db 102,15,56,220,208
db 102,15,56,220,216
db 102,15,56,220,224
db 102,15,56,220,232
movups xmm0,[ecx*1+edx-16]
jnz NEAR L$006enc4_loop
db 102,15,56,220,209
db 102,15,56,220,217
db 102,15,56,220,225
db 102,15,56,220,233
db 102,15,56,221,208
db 102,15,56,221,216
db 102,15,56,221,224
db 102,15,56,221,232
ret
align 16
__aesni_decrypt4:
movups xmm0,[edx]
movups xmm1,[16+edx]
shl ecx,4
xorps xmm2,xmm0
pxor xmm3,xmm0
pxor xmm4,xmm0
pxor xmm5,xmm0
movups xmm0,[32+edx]
lea edx,[32+ecx*1+edx]
neg ecx
db 15,31,64,0
add ecx,16
L$007dec4_loop:
db 102,15,56,222,209
db 102,15,56,222,217
db 102,15,56,222,225
db 102,15,56,222,233
movups xmm1,[ecx*1+edx]
add ecx,32
db 102,15,56,222,208
db 102,15,56,222,216
db 102,15,56,222,224
db 102,15,56,222,232
movups xmm0,[ecx*1+edx-16]
jnz NEAR L$007dec4_loop
db 102,15,56,222,209
db 102,15,56,222,217
db 102,15,56,222,225
db 102,15,56,222,233
db 102,15,56,223,208
db 102,15,56,223,216
db 102,15,56,223,224
db 102,15,56,223,232
ret
align 16
__aesni_encrypt6:
movups xmm0,[edx]
shl ecx,4
movups xmm1,[16+edx]
xorps xmm2,xmm0
pxor xmm3,xmm0
pxor xmm4,xmm0
db 102,15,56,220,209
pxor xmm5,xmm0
pxor xmm6,xmm0
db 102,15,56,220,217
lea edx,[32+ecx*1+edx]
neg ecx
db 102,15,56,220,225
pxor xmm7,xmm0
movups xmm0,[ecx*1+edx]
add ecx,16
jmp NEAR L$008_aesni_encrypt6_inner
align 16
L$009enc6_loop:
db 102,15,56,220,209
db 102,15,56,220,217
db 102,15,56,220,225
L$008_aesni_encrypt6_inner:
db 102,15,56,220,233
db 102,15,56,220,241
db 102,15,56,220,249
L$_aesni_encrypt6_enter:
movups xmm1,[ecx*1+edx]
add ecx,32
db 102,15,56,220,208
db 102,15,56,220,216
db 102,15,56,220,224
db 102,15,56,220,232
db 102,15,56,220,240
db 102,15,56,220,248
movups xmm0,[ecx*1+edx-16]
jnz NEAR L$009enc6_loop
db 102,15,56,220,209
db 102,15,56,220,217
db 102,15,56,220,225
db 102,15,56,220,233
db 102,15,56,220,241
db 102,15,56,220,249
db 102,15,56,221,208
db 102,15,56,221,216
db 102,15,56,221,224
db 102,15,56,221,232
db 102,15,56,221,240
db 102,15,56,221,248
ret
align 16
__aesni_decrypt6:
movups xmm0,[edx]
shl ecx,4
movups xmm1,[16+edx]
xorps xmm2,xmm0
pxor xmm3,xmm0
pxor xmm4,xmm0
db 102,15,56,222,209
pxor xmm5,xmm0
pxor xmm6,xmm0
db 102,15,56,222,217
lea edx,[32+ecx*1+edx]
neg ecx
db 102,15,56,222,225
pxor xmm7,xmm0
movups xmm0,[ecx*1+edx]
add ecx,16
jmp NEAR L$010_aesni_decrypt6_inner
align 16
L$011dec6_loop:
db 102,15,56,222,209
db 102,15,56,222,217
db 102,15,56,222,225
L$010_aesni_decrypt6_inner:
db 102,15,56,222,233
db 102,15,56,222,241
db 102,15,56,222,249
L$_aesni_decrypt6_enter:
movups xmm1,[ecx*1+edx]
add ecx,32
db 102,15,56,222,208
db 102,15,56,222,216
db 102,15,56,222,224
db 102,15,56,222,232
db 102,15,56,222,240
db 102,15,56,222,248
movups xmm0,[ecx*1+edx-16]
jnz NEAR L$011dec6_loop
db 102,15,56,222,209
db 102,15,56,222,217
db 102,15,56,222,225
db 102,15,56,222,233
db 102,15,56,222,241
db 102,15,56,222,249
db 102,15,56,223,208
db 102,15,56,223,216
db 102,15,56,223,224
db 102,15,56,223,232
db 102,15,56,223,240
db 102,15,56,223,248
ret
global _aesni_ecb_encrypt
align 16
_aesni_ecb_encrypt:
L$_aesni_ecb_encrypt_begin:
push ebp
push ebx
push esi
push edi
mov esi,DWORD [20+esp]
mov edi,DWORD [24+esp]
mov eax,DWORD [28+esp]
mov edx,DWORD [32+esp]
mov ebx,DWORD [36+esp]
and eax,-16
jz NEAR L$012ecb_ret
mov ecx,DWORD [240+edx]
test ebx,ebx
jz NEAR L$013ecb_decrypt
mov ebp,edx
mov ebx,ecx
cmp eax,96
jb NEAR L$014ecb_enc_tail
movdqu xmm2,[esi]
movdqu xmm3,[16+esi]
movdqu xmm4,[32+esi]
movdqu xmm5,[48+esi]
movdqu xmm6,[64+esi]
movdqu xmm7,[80+esi]
lea esi,[96+esi]
sub eax,96
jmp NEAR L$015ecb_enc_loop6_enter
align 16
L$016ecb_enc_loop6:
movups [edi],xmm2
movdqu xmm2,[esi]
movups [16+edi],xmm3
movdqu xmm3,[16+esi]
movups [32+edi],xmm4
movdqu xmm4,[32+esi]
movups [48+edi],xmm5
movdqu xmm5,[48+esi]
movups [64+edi],xmm6
movdqu xmm6,[64+esi]
movups [80+edi],xmm7
lea edi,[96+edi]
movdqu xmm7,[80+esi]
lea esi,[96+esi]
L$015ecb_enc_loop6_enter:
call __aesni_encrypt6
mov edx,ebp
mov ecx,ebx
sub eax,96
jnc NEAR L$016ecb_enc_loop6
movups [edi],xmm2
movups [16+edi],xmm3
movups [32+edi],xmm4
movups [48+edi],xmm5
movups [64+edi],xmm6
movups [80+edi],xmm7
lea edi,[96+edi]
add eax,96
jz NEAR L$012ecb_ret
L$014ecb_enc_tail:
movups xmm2,[esi]
cmp eax,32
jb NEAR L$017ecb_enc_one
movups xmm3,[16+esi]
je NEAR L$018ecb_enc_two
movups xmm4,[32+esi]
cmp eax,64
jb NEAR L$019ecb_enc_three
movups xmm5,[48+esi]
je NEAR L$020ecb_enc_four
movups xmm6,[64+esi]
xorps xmm7,xmm7
call __aesni_encrypt6
movups [edi],xmm2
movups [16+edi],xmm3
movups [32+edi],xmm4
movups [48+edi],xmm5
movups [64+edi],xmm6
jmp NEAR L$012ecb_ret
align 16
L$017ecb_enc_one:
movups xmm0,[edx]
movups xmm1,[16+edx]
lea edx,[32+edx]
xorps xmm2,xmm0
L$021enc1_loop_3:
db 102,15,56,220,209
dec ecx
movups xmm1,[edx]
lea edx,[16+edx]
jnz NEAR L$021enc1_loop_3
db 102,15,56,221,209
movups [edi],xmm2
jmp NEAR L$012ecb_ret
align 16
L$018ecb_enc_two:
call __aesni_encrypt2
movups [edi],xmm2
movups [16+edi],xmm3
jmp NEAR L$012ecb_ret
align 16
L$019ecb_enc_three:
call __aesni_encrypt3
movups [edi],xmm2
movups [16+edi],xmm3
movups [32+edi],xmm4
jmp NEAR L$012ecb_ret
align 16
L$020ecb_enc_four:
call __aesni_encrypt4
movups [edi],xmm2
movups [16+edi],xmm3
movups [32+edi],xmm4
movups [48+edi],xmm5
jmp NEAR L$012ecb_ret
align 16
L$013ecb_decrypt:
mov ebp,edx
mov ebx,ecx
cmp eax,96
jb NEAR L$022ecb_dec_tail
movdqu xmm2,[esi]
movdqu xmm3,[16+esi]
movdqu xmm4,[32+esi]
movdqu xmm5,[48+esi]
movdqu xmm6,[64+esi]
movdqu xmm7,[80+esi]
lea esi,[96+esi]
sub eax,96
jmp NEAR L$023ecb_dec_loop6_enter
align 16
L$024ecb_dec_loop6:
movups [edi],xmm2
movdqu xmm2,[esi]
movups [16+edi],xmm3
movdqu xmm3,[16+esi]
movups [32+edi],xmm4
movdqu xmm4,[32+esi]
movups [48+edi],xmm5
movdqu xmm5,[48+esi]
movups [64+edi],xmm6
movdqu xmm6,[64+esi]
movups [80+edi],xmm7
lea edi,[96+edi]
movdqu xmm7,[80+esi]
lea esi,[96+esi]
L$023ecb_dec_loop6_enter:
call __aesni_decrypt6
mov edx,ebp
mov ecx,ebx
sub eax,96
jnc NEAR L$024ecb_dec_loop6
movups [edi],xmm2
movups [16+edi],xmm3
movups [32+edi],xmm4
movups [48+edi],xmm5
movups [64+edi],xmm6
movups [80+edi],xmm7
lea edi,[96+edi]
add eax,96
jz NEAR L$012ecb_ret
L$022ecb_dec_tail:
movups xmm2,[esi]
cmp eax,32
jb NEAR L$025ecb_dec_one
movups xmm3,[16+esi]
je NEAR L$026ecb_dec_two
movups xmm4,[32+esi]
cmp eax,64
jb NEAR L$027ecb_dec_three
movups xmm5,[48+esi]
je NEAR L$028ecb_dec_four
movups xmm6,[64+esi]
xorps xmm7,xmm7
call __aesni_decrypt6
movups [edi],xmm2
movups [16+edi],xmm3
movups [32+edi],xmm4
movups [48+edi],xmm5
movups [64+edi],xmm6
jmp NEAR L$012ecb_ret
align 16
L$025ecb_dec_one:
movups xmm0,[edx]
movups xmm1,[16+edx]
lea edx,[32+edx]
xorps xmm2,xmm0
L$029dec1_loop_4:
db 102,15,56,222,209
dec ecx
movups xmm1,[edx]
lea edx,[16+edx]
jnz NEAR L$029dec1_loop_4
db 102,15,56,223,209
movups [edi],xmm2
jmp NEAR L$012ecb_ret
align 16
L$026ecb_dec_two:
call __aesni_decrypt2
movups [edi],xmm2
movups [16+edi],xmm3
jmp NEAR L$012ecb_ret
align 16
L$027ecb_dec_three:
call __aesni_decrypt3
movups [edi],xmm2
movups [16+edi],xmm3
movups [32+edi],xmm4
jmp NEAR L$012ecb_ret
align 16
L$028ecb_dec_four:
call __aesni_decrypt4
movups [edi],xmm2
movups [16+edi],xmm3
movups [32+edi],xmm4
movups [48+edi],xmm5
L$012ecb_ret:
pxor xmm0,xmm0
pxor xmm1,xmm1
pxor xmm2,xmm2
pxor xmm3,xmm3
pxor xmm4,xmm4
pxor xmm5,xmm5
pxor xmm6,xmm6
pxor xmm7,xmm7
pop edi
pop esi
pop ebx
pop ebp
ret
global _aesni_ccm64_encrypt_blocks
align 16
_aesni_ccm64_encrypt_blocks:
L$_aesni_ccm64_encrypt_blocks_begin:
push ebp
push ebx
push esi
push edi
mov esi,DWORD [20+esp]
mov edi,DWORD [24+esp]
mov eax,DWORD [28+esp]
mov edx,DWORD [32+esp]
mov ebx,DWORD [36+esp]
mov ecx,DWORD [40+esp]
mov ebp,esp
sub esp,60
and esp,-16
mov DWORD [48+esp],ebp
movdqu xmm7,[ebx]
movdqu xmm3,[ecx]
mov ecx,DWORD [240+edx]
mov DWORD [esp],202182159
mov DWORD [4+esp],134810123
mov DWORD [8+esp],67438087
mov DWORD [12+esp],66051
mov ebx,1
xor ebp,ebp
mov DWORD [16+esp],ebx
mov DWORD [20+esp],ebp
mov DWORD [24+esp],ebp
mov DWORD [28+esp],ebp
shl ecx,4
mov ebx,16
lea ebp,[edx]
movdqa xmm5,[esp]
movdqa xmm2,xmm7
lea edx,[32+ecx*1+edx]
sub ebx,ecx
db 102,15,56,0,253
L$030ccm64_enc_outer:
movups xmm0,[ebp]
mov ecx,ebx
movups xmm6,[esi]
xorps xmm2,xmm0
movups xmm1,[16+ebp]
xorps xmm0,xmm6
xorps xmm3,xmm0
movups xmm0,[32+ebp]
L$031ccm64_enc2_loop:
db 102,15,56,220,209
db 102,15,56,220,217
movups xmm1,[ecx*1+edx]
add ecx,32
db 102,15,56,220,208
db 102,15,56,220,216
movups xmm0,[ecx*1+edx-16]
jnz NEAR L$031ccm64_enc2_loop
db 102,15,56,220,209
db 102,15,56,220,217
paddq xmm7,[16+esp]
dec eax
db 102,15,56,221,208
db 102,15,56,221,216
lea esi,[16+esi]
xorps xmm6,xmm2
movdqa xmm2,xmm7
movups [edi],xmm6
db 102,15,56,0,213
lea edi,[16+edi]
jnz NEAR L$030ccm64_enc_outer
mov esp,DWORD [48+esp]
mov edi,DWORD [40+esp]
movups [edi],xmm3
pxor xmm0,xmm0
pxor xmm1,xmm1
pxor xmm2,xmm2
pxor xmm3,xmm3
pxor xmm4,xmm4
pxor xmm5,xmm5
pxor xmm6,xmm6
pxor xmm7,xmm7
pop edi
pop esi
pop ebx
pop ebp
ret
global _aesni_ccm64_decrypt_blocks
align 16
_aesni_ccm64_decrypt_blocks:
L$_aesni_ccm64_decrypt_blocks_begin:
push ebp
push ebx
push esi
push edi
mov esi,DWORD [20+esp]
mov edi,DWORD [24+esp]
mov eax,DWORD [28+esp]
mov edx,DWORD [32+esp]
mov ebx,DWORD [36+esp]
mov ecx,DWORD [40+esp]
mov ebp,esp
sub esp,60
and esp,-16
mov DWORD [48+esp],ebp
movdqu xmm7,[ebx]
movdqu xmm3,[ecx]
mov ecx,DWORD [240+edx]
mov DWORD [esp],202182159
mov DWORD [4+esp],134810123
mov DWORD [8+esp],67438087
mov DWORD [12+esp],66051
mov ebx,1
xor ebp,ebp
mov DWORD [16+esp],ebx
mov DWORD [20+esp],ebp
mov DWORD [24+esp],ebp
mov DWORD [28+esp],ebp
movdqa xmm5,[esp]
movdqa xmm2,xmm7
mov ebp,edx
mov ebx,ecx
db 102,15,56,0,253
movups xmm0,[edx]
movups xmm1,[16+edx]
lea edx,[32+edx]
xorps xmm2,xmm0
L$032enc1_loop_5:
db 102,15,56,220,209
dec ecx
movups xmm1,[edx]
lea edx,[16+edx]
jnz NEAR L$032enc1_loop_5
db 102,15,56,221,209
shl ebx,4
mov ecx,16
movups xmm6,[esi]
paddq xmm7,[16+esp]
lea esi,[16+esi]
sub ecx,ebx
lea edx,[32+ebx*1+ebp]
mov ebx,ecx
jmp NEAR L$033ccm64_dec_outer
align 16
L$033ccm64_dec_outer:
xorps xmm6,xmm2
movdqa xmm2,xmm7
movups [edi],xmm6
lea edi,[16+edi]
db 102,15,56,0,213
sub eax,1
jz NEAR L$034ccm64_dec_break
movups xmm0,[ebp]
mov ecx,ebx
movups xmm1,[16+ebp]
xorps xmm6,xmm0
xorps xmm2,xmm0
xorps xmm3,xmm6
movups xmm0,[32+ebp]
L$035ccm64_dec2_loop:
db 102,15,56,220,209
db 102,15,56,220,217
movups xmm1,[ecx*1+edx]
add ecx,32
db 102,15,56,220,208
db 102,15,56,220,216
movups xmm0,[ecx*1+edx-16]
jnz NEAR L$035ccm64_dec2_loop
movups xmm6,[esi]
paddq xmm7,[16+esp]
db 102,15,56,220,209
db 102,15,56,220,217
db 102,15,56,221,208
db 102,15,56,221,216
lea esi,[16+esi]
jmp NEAR L$033ccm64_dec_outer
align 16
L$034ccm64_dec_break:
mov ecx,DWORD [240+ebp]
mov edx,ebp
movups xmm0,[edx]
movups xmm1,[16+edx]
xorps xmm6,xmm0
lea edx,[32+edx]
xorps xmm3,xmm6
L$036enc1_loop_6:
db 102,15,56,220,217
dec ecx
movups xmm1,[edx]
lea edx,[16+edx]
jnz NEAR L$036enc1_loop_6
db 102,15,56,221,217
mov esp,DWORD [48+esp]
mov edi,DWORD [40+esp]
movups [edi],xmm3
pxor xmm0,xmm0
pxor xmm1,xmm1
pxor xmm2,xmm2
pxor xmm3,xmm3
pxor xmm4,xmm4
pxor xmm5,xmm5
pxor xmm6,xmm6
pxor xmm7,xmm7
pop edi
pop esi
pop ebx
pop ebp
ret
global _aesni_ctr32_encrypt_blocks
align 16
_aesni_ctr32_encrypt_blocks:
L$_aesni_ctr32_encrypt_blocks_begin:
push ebp
push ebx
push esi
push edi
mov esi,DWORD [20+esp]
mov edi,DWORD [24+esp]
mov eax,DWORD [28+esp]
mov edx,DWORD [32+esp]
mov ebx,DWORD [36+esp]
mov ebp,esp
sub esp,88
and esp,-16
mov DWORD [80+esp],ebp
cmp eax,1
je NEAR L$037ctr32_one_shortcut
movdqu xmm7,[ebx]
mov DWORD [esp],202182159
mov DWORD [4+esp],134810123
mov DWORD [8+esp],67438087
mov DWORD [12+esp],66051
mov ecx,6
xor ebp,ebp
mov DWORD [16+esp],ecx
mov DWORD [20+esp],ecx
mov DWORD [24+esp],ecx
mov DWORD [28+esp],ebp
db 102,15,58,22,251,3
db 102,15,58,34,253,3
mov ecx,DWORD [240+edx]
bswap ebx
pxor xmm0,xmm0
pxor xmm1,xmm1
movdqa xmm2,[esp]
db 102,15,58,34,195,0
lea ebp,[3+ebx]
db 102,15,58,34,205,0
inc ebx
db 102,15,58,34,195,1
inc ebp
db 102,15,58,34,205,1
inc ebx
db 102,15,58,34,195,2
inc ebp
db 102,15,58,34,205,2
movdqa [48+esp],xmm0
db 102,15,56,0,194
movdqu xmm6,[edx]
movdqa [64+esp],xmm1
db 102,15,56,0,202
pshufd xmm2,xmm0,192
pshufd xmm3,xmm0,128
cmp eax,6
jb NEAR L$038ctr32_tail
pxor xmm7,xmm6
shl ecx,4
mov ebx,16
movdqa [32+esp],xmm7
mov ebp,edx
sub ebx,ecx
lea edx,[32+ecx*1+edx]
sub eax,6
jmp NEAR L$039ctr32_loop6
align 16
L$039ctr32_loop6:
pshufd xmm4,xmm0,64
movdqa xmm0,[32+esp]
pshufd xmm5,xmm1,192
pxor xmm2,xmm0
pshufd xmm6,xmm1,128
pxor xmm3,xmm0
pshufd xmm7,xmm1,64
movups xmm1,[16+ebp]
pxor xmm4,xmm0
pxor xmm5,xmm0
db 102,15,56,220,209
pxor xmm6,xmm0
pxor xmm7,xmm0
db 102,15,56,220,217
movups xmm0,[32+ebp]
mov ecx,ebx
db 102,15,56,220,225
db 102,15,56,220,233
db 102,15,56,220,241
db 102,15,56,220,249
call L$_aesni_encrypt6_enter
movups xmm1,[esi]
movups xmm0,[16+esi]
xorps xmm2,xmm1
movups xmm1,[32+esi]
xorps xmm3,xmm0
movups [edi],xmm2
movdqa xmm0,[16+esp]
xorps xmm4,xmm1
movdqa xmm1,[64+esp]
movups [16+edi],xmm3
movups [32+edi],xmm4
paddd xmm1,xmm0
paddd xmm0,[48+esp]
movdqa xmm2,[esp]
movups xmm3,[48+esi]
movups xmm4,[64+esi]
xorps xmm5,xmm3
movups xmm3,[80+esi]
lea esi,[96+esi]
movdqa [48+esp],xmm0
db 102,15,56,0,194
xorps xmm6,xmm4
movups [48+edi],xmm5
xorps xmm7,xmm3
movdqa [64+esp],xmm1
db 102,15,56,0,202
movups [64+edi],xmm6
pshufd xmm2,xmm0,192
movups [80+edi],xmm7
lea edi,[96+edi]
pshufd xmm3,xmm0,128
sub eax,6
jnc NEAR L$039ctr32_loop6
add eax,6
jz NEAR L$040ctr32_ret
movdqu xmm7,[ebp]
mov edx,ebp
pxor xmm7,[32+esp]
mov ecx,DWORD [240+ebp]
L$038ctr32_tail:
por xmm2,xmm7
cmp eax,2
jb NEAR L$041ctr32_one
pshufd xmm4,xmm0,64
por xmm3,xmm7
je NEAR L$042ctr32_two
pshufd xmm5,xmm1,192
por xmm4,xmm7
cmp eax,4
jb NEAR L$043ctr32_three
pshufd xmm6,xmm1,128
por xmm5,xmm7
je NEAR L$044ctr32_four
por xmm6,xmm7
call __aesni_encrypt6
movups xmm1,[esi]
movups xmm0,[16+esi]
xorps xmm2,xmm1
movups xmm1,[32+esi]
xorps xmm3,xmm0
movups xmm0,[48+esi]
xorps xmm4,xmm1
movups xmm1,[64+esi]
xorps xmm5,xmm0
movups [edi],xmm2
xorps xmm6,xmm1
movups [16+edi],xmm3
movups [32+edi],xmm4
movups [48+edi],xmm5
movups [64+edi],xmm6
jmp NEAR L$040ctr32_ret
align 16
L$037ctr32_one_shortcut:
movups xmm2,[ebx]
mov ecx,DWORD [240+edx]
L$041ctr32_one:
movups xmm0,[edx]
movups xmm1,[16+edx]
lea edx,[32+edx]
xorps xmm2,xmm0
L$045enc1_loop_7:
db 102,15,56,220,209
dec ecx
movups xmm1,[edx]
lea edx,[16+edx]
jnz NEAR L$045enc1_loop_7
db 102,15,56,221,209
movups xmm6,[esi]
xorps xmm6,xmm2
movups [edi],xmm6
jmp NEAR L$040ctr32_ret
align 16
L$042ctr32_two:
call __aesni_encrypt2
movups xmm5,[esi]
movups xmm6,[16+esi]
xorps xmm2,xmm5
xorps xmm3,xmm6
movups [edi],xmm2
movups [16+edi],xmm3
jmp NEAR L$040ctr32_ret
align 16
L$043ctr32_three:
call __aesni_encrypt3
movups xmm5,[esi]
movups xmm6,[16+esi]
xorps xmm2,xmm5
movups xmm7,[32+esi]
xorps xmm3,xmm6
movups [edi],xmm2
xorps xmm4,xmm7
movups [16+edi],xmm3
movups [32+edi],xmm4
jmp NEAR L$040ctr32_ret
align 16
L$044ctr32_four:
call __aesni_encrypt4
movups xmm6,[esi]
movups xmm7,[16+esi]
movups xmm1,[32+esi]
xorps xmm2,xmm6
movups xmm0,[48+esi]
xorps xmm3,xmm7
movups [edi],xmm2
xorps xmm4,xmm1
movups [16+edi],xmm3