forked from synopse/mORMot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SynEcc32asm.inc
2359 lines (2315 loc) · 70.3 KB
/
SynEcc32asm.inc
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
(*
32-bit version of easy-ecc for secp256r1 curve for static linking as x86 asm
used by SynEcc.pas unit e.g. for Kylix; compiled using gcc -g -O1 -c ecc.c
with some manual enhancements by Arnaud Bouchez to the generated asm
This file is part of Synopse framework.
Synopse framework. Copyright (c) Arnaud Bouchez
Synopse Informatique - https://synopse.info
Using secp256r1 curve from "simple and secure ECDH and ECDSA library"
Copyright (c) 2013, Kenneth MacKay - BSD 2-clause license
https://github.com/esxgx/easy-ecc
*** BEGIN LICENSE BLOCK *****
Copyright (c) 2013, Kenneth MacKay
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***** END LICENSE BLOCK *****
Version 1.18
- first public release, corresponding to SQLite3 Framework 1.18
*)
procedure _curve_n;
asm
db 51H, 25H, 63H, 0FCH, 0C2H, 0CAH, 0B9H, 0F3H
db 84H, 9EH, 17H, 0A7H, 0ADH, 0FAH, 0E6H, 0BCH
db 0FFH, 0FFH, 0FFH, 0FFH, 0FFH, 0FFH, 0FFH, 0FFH
db 00H, 00H, 00H, 00H, 0FFH, 0FFH, 0FFH, 0FFH
end;
procedure _curve_G;
asm
db 96H, 0C2H, 98H, 0D8H, 45H, 39H, 0A1H, 0F4H
db 0A0H, 33H, 0EBH, 2DH, 81H, 7DH, 03H, 77H
db 0F2H, 40H, 0A4H, 63H, 0E5H, 0E6H, 0BCH, 0F8H
db 47H, 42H, 2CH, 0E1H, 0F2H, 0D1H, 17H, 6BH
db 0F5H, 51H, 0BFH, 37H, 68H, 40H, 0B6H, 0CBH
db 0CEH, 5EH, 31H, 6BH, 57H, 33H, 0CEH, 2BH
db 16H, 9EH, 0FH, 7CH, 4AH, 0EBH, 0E7H, 8EH
db 9BH, 7FH, 1AH, 0FEH, 0E2H, 42H, 0E3H, 4FH
end;
procedure _curve_b;
asm
db 4BH, 60H, 0D2H, 27H, 3EH, 3CH, 0CEH, 3BH
db 0F6H, 0B0H, 53H, 0CCH, 0B0H, 06H, 1DH, 65H
db 0BCH, 86H, 98H, 76H, 55H, 0BDH, 0EBH, 0B3H
db 0E7H, 93H, 3AH, 0AAH, 0D8H, 35H, 0C6H, 5AH
end;
procedure _curve_p;
asm
db 0FFH, 0FFH, 0FFH, 0FFH, 0FFH, 0FFH, 0FFH, 0FFH
db 0FFH, 0FFH, 0FFH, 0FFH, 00H, 00H, 00H, 00H
db 00H, 00H, 00H, 00H, 00H, 00H, 00H, 00H
db 01H, 00H, 00H, 00H, 0FFH, 0FFH, 0FFH, 0FFH
end;
procedure _vli_clear;
asm
xor edx, edx
mov dword ptr[eax + 00H], edx
mov dword ptr[eax + 04H], edx
mov dword ptr[eax + 08H], edx
mov dword ptr[eax + 0CH], edx
mov dword ptr[eax + 10H], edx
mov dword ptr[eax + 14H], edx
mov dword ptr[eax + 18H], edx
mov dword ptr[eax + 1CH], edx
end;
procedure _vli_isZero;
asm
mov edx, dword ptr[eax + 00H]
or edx, dword ptr[eax + 04H]
jnz @003
mov edx, dword ptr[eax + 08H]
or edx, dword ptr[eax + 0CH]
jnz @003
mov edx, dword ptr[eax + 10H]
or edx, dword ptr[eax + 14H]
jnz @003
mov edx, dword ptr[eax + 18H]
or edx, dword ptr[eax + 1CH]
jnz @003
mov eax, 1
ret
@003: mov eax, 0
end;
procedure _vli_testBit;
asm
push ebp
push edi
push esi
push ebx
mov ebx, eax
mov ebp, edx
shr ebp, 6
mov ecx, edx
and ecx, 3FH
mov edi, ecx
shr edi, 5
and edi, 01H
mov esi, edi
xor esi, 01H
shl esi, cl
shl edi, cl
mov eax, esi
and eax, dword ptr[ebx + ebp * 8]
mov edx, edi
and edx, dword ptr[ebx + ebp * 8 + 4H]
pop ebx
pop esi
pop edi
pop ebp
end;
procedure _vli_numBits;
asm
push esi
push ebx
mov ecx, dword ptr[eax + 1CH]
mov edx, 2
or ecx, dword ptr[eax + 18H]
jz @006
mov edx, 4
jmp @007
@005: sub edx, 1
cmp edx, - 1
jz @011
@006: mov ecx, dword ptr[eax + edx * 8 + 4H]
or ecx, dword ptr[eax + edx * 8]
jz @005
add edx, 1
jz @012
@007: mov ecx, dword ptr[eax + edx * 8 - 8H]
mov ebx, dword ptr[eax + edx * 8 - 4H]
mov eax, ebx
or eax, ecx
jz @009
mov eax, 0
@008: shrd ecx, ebx, 1
shr ebx, 1
add eax, 1
mov esi, ebx
or esi, ecx
jnz @008
jmp @010
@009: mov eax, 0
@010: add edx, 67108863
shl edx, 6
add edx, eax
jmp @012
@011: mov edx, 0
@012: mov eax, edx
pop ebx
pop esi
end;
procedure _vli_set;
asm
mov ecx, dword ptr[edx + 00H]
mov dword ptr[eax + 00H], ecx
mov ecx, dword ptr[edx + 04H]
mov dword ptr[eax + 04H], ecx
mov ecx, dword ptr[edx + 08H]
mov dword ptr[eax + 08H], ecx
mov ecx, dword ptr[edx + 0CH]
mov dword ptr[eax + 0CH], ecx
mov ecx, dword ptr[edx + 10H]
mov dword ptr[eax + 10H], ecx
mov ecx, dword ptr[edx + 14H]
mov dword ptr[eax + 14H], ecx
mov ecx, dword ptr[edx + 18H]
mov dword ptr[eax + 18H], ecx
mov ecx, dword ptr[edx + 1CH]
mov dword ptr[eax + 1CH], ecx
end;
procedure _vli_cmp;
asm
mov ecx, dword ptr[eax + 1CH]
cmp ecx, dword ptr[edx + 1CH]
ja @a
jc @c
mov ecx, dword ptr[eax + 18H]
cmp ecx, dword ptr[edx + 18H]
ja @a
jc @c
mov ecx, dword ptr[eax + 14H]
cmp ecx, dword ptr[edx + 14H]
ja @a
jc @c
mov ecx, dword ptr[eax + 10H]
cmp ecx, dword ptr[edx + 10H]
ja @a
jc @c
mov ecx, dword ptr[eax + 0CH]
cmp ecx, dword ptr[edx + 0CH]
ja @a
jc @c
mov ecx, dword ptr[eax + 08H]
cmp ecx, dword ptr[edx + 08H]
ja @a
jc @c
mov ecx, dword ptr[eax + 04H]
cmp ecx, dword ptr[edx + 04H]
ja @a
jc @c
mov ecx, dword ptr[eax + 00H]
cmp ecx, dword ptr[edx + 00H]
ja @a
jc @c
mov eax, 0
ret
@a: mov eax, 1
ret
@c: mov eax, -1
end;
procedure _vli_lshift;
asm
push ebp
push edi
push esi
push ebx
sub esp, 28
mov dword ptr[esp + 8H], eax
mov dword ptr[esp + 0CH], edx
mov ebx, ecx
mov dword ptr[esp + 10H], ecx
mov ebp, 0
mov eax, 0
mov edx, 0
mov ecx, 64
mov edi, ecx
sub edi, ebx
mov dword ptr[esp + 14H], edi
mov dword ptr[esp], eax
mov dword ptr[esp + 4H], edx
@024: mov eax, dword ptr[esp + 0CH]
mov esi, dword ptr[eax + ebp * 8]
mov edi, dword ptr[eax + ebp * 8 + 4H]
mov eax, esi
mov edx, edi
movzx ecx, byte ptr[esp + 10H]
shld edx, esi, cl
shl eax, cl
test cl, 20H
jz @025
mov edx, eax
xor eax, eax
@025: mov ecx, eax
mov ebx, edx
or ecx, dword ptr[esp]
mov edx, dword ptr[esp + 8H]
mov dword ptr[edx + ebp * 8], ecx
mov eax, ebx
or eax, dword ptr[esp + 4H]
mov dword ptr[edx + ebp * 8 + 4H], eax
mov eax, esi
mov edx, edi
movzx ecx, byte ptr[esp + 14H]
shrd eax, edi, cl
shr edx, cl
test cl, 20H
jz @026
mov eax, edx
xor edx, edx
@026: mov dword ptr[esp], eax
mov dword ptr[esp + 4H], edx
add ebp, 1
cmp ebp, 4
jnz @024
add esp, 28
pop ebx
pop esi
pop edi
pop ebp
end;
procedure _vli_rshift1;
asm
push ebp
push edi
push esi
push ebx
sub esp, 20
lea ebx, [eax + 18H]
mov dword ptr[esp + 0CH], ebx
lea edx, [eax + 20H]
cmp eax, edx
jnc @028
mov edx, 0
mov ebx, 0
mov ebp, 0
@027: mov esi, dword ptr[eax + edx + 18H]
mov edi, dword ptr[eax + edx + 1CH]
mov dword ptr[esp], esi
mov dword ptr[esp + 4H], edi
shrd esi, edi, 1
shr edi, 1
or ebx, esi
mov dword ptr[eax + edx + 18H], ebx
or ebp, edi
mov dword ptr[eax + edx + 1CH], ebp
mov ebp, dword ptr[esp]
shl ebp, 31
mov ebx, 0
mov ecx, dword ptr[esp + 0CH]
add ecx, edx
lea edx, [edx - 8H]
cmp ecx, eax
ja @027
@028: add esp, 20
pop ebx
pop esi
pop edi
pop ebp
end;
procedure _vli_add;
asm
push ebp
push edi
push esi
push ebx
sub esp, 28
mov dword ptr[esp + 0CH], eax
mov dword ptr[esp + 10H], edx
mov dword ptr[esp + 14H], ecx
mov ebp, 0
mov eax, 0
mov edx, 0
mov dword ptr[esp], eax
mov dword ptr[esp + 4H], edx
@029: mov eax, dword ptr[esp + 10H]
mov ecx, dword ptr[eax + ebp * 8]
mov ebx, dword ptr[eax + ebp * 8 + 4H]
mov eax, dword ptr[esp + 14H]
mov esi, ecx
mov edi, ebx
add esi, dword ptr[eax + ebp * 8]
adc edi, dword ptr[eax + ebp * 8 + 4H]
add esi, dword ptr[esp]
adc edi, dword ptr[esp + 4H]
mov eax, ebx
xor eax, edi
mov edx, ecx
xor edx, esi
or eax, edx
jz @032
mov eax, 1
mov edx, 0
cmp ebx, edi
ja @031
jc @030
cmp ecx, esi
ja @031
@030: mov eax, 0
mov edx, 0
@031: mov dword ptr[esp], eax
mov dword ptr[esp + 4H], edx
@032: mov eax, dword ptr[esp + 0CH]
mov dword ptr[eax + ebp * 8], esi
mov dword ptr[eax + ebp * 8 + 4H], edi
add ebp, 1
cmp ebp, 4
jnz @029
mov eax, dword ptr[esp]
mov edx, dword ptr[esp + 4H]
add esp, 28
pop ebx
pop esi
pop edi
pop ebp
end;
procedure _vli_sub;
asm
push ebp
push edi
push esi
push ebx
sub esp, 28
mov dword ptr[esp + 0CH], eax
mov dword ptr[esp + 10H], edx
mov dword ptr[esp + 14H], ecx
mov ebp, 0
mov eax, 0
mov edx, 0
mov dword ptr[esp], eax
mov dword ptr[esp + 4H], edx
@033: mov eax, dword ptr[esp + 10H]
mov ecx, dword ptr[eax + ebp * 8]
mov ebx, dword ptr[eax + ebp * 8 + 4H]
mov eax, dword ptr[esp + 14H]
mov esi, ecx
mov edi, ebx
sub esi, dword ptr[eax + ebp * 8]
sbb edi, dword ptr[eax + ebp * 8 + 4H]
sub esi, dword ptr[esp]
sbb edi, dword ptr[esp + 4H]
mov eax, ebx
xor eax, edi
mov edx, ecx
xor edx, esi
or eax, edx
jz @036
mov eax, 1
mov edx, 0
cmp ebx, edi
jc @035
ja @034
cmp ecx, esi
jc @035
@034: mov eax, 0
mov edx, 0
@035: mov dword ptr[esp], eax
mov dword ptr[esp + 4H], edx
@036: mov eax, dword ptr[esp + 0CH]
mov dword ptr[eax + ebp * 8], esi
mov dword ptr[eax + ebp * 8 + 4H], edi
add ebp, 1
cmp ebp, 4
jnz @033
mov eax, dword ptr[esp]
mov edx, dword ptr[esp + 4H]
add esp, 28
pop ebx
pop esi
pop edi
pop ebp
end;
procedure _vli_mult;
asm
push ebp
push edi
push esi
push ebx
sub esp, 84
mov dword ptr[esp + 48H], eax
mov dword ptr[esp + 4CH], ecx
mov dword ptr[esp + 44H], - 3
mov dword ptr[esp], 0
mov dword ptr[esp + 4H], 0
mov dword ptr[esp + 38H], 0
mov dword ptr[esp + 3CH], 0
mov dword ptr[esp + 34H], 0
mov dword ptr[esp + 40H], edx
@037: mov ebp, 0
mov eax, dword ptr[esp + 34H]
cmp eax, 3
jbe @038
mov ebx, dword ptr[esp + 44H]
cmp ebx, eax
ja @047
cmp ebx, 3
ja @047
mov ebp, ebx
@038: mov eax, dword ptr[esp + 34H]
sub eax, ebp
mov ebx, dword ptr[esp + 4CH]
lea eax, [ebx + eax * 8]
mov edi, eax
mov eax, dword ptr[esp + 38H]
mov edx, dword ptr[esp + 3CH]
mov dword ptr[esp + 20H], eax
mov dword ptr[esp + 24H], edx
mov dword ptr[esp + 38H], 0
mov dword ptr[esp + 3CH], 0
jmp @040
@039: mov eax, dword ptr[esp + 8H]
mov edx, dword ptr[esp + 0CH]
mov dword ptr[esp], eax
mov dword ptr[esp + 4H], edx
@040: mov eax, dword ptr[esp + 40H]
mov ecx, dword ptr[eax + ebp * 8]
mov esi, dword ptr[eax + ebp * 8 + 4H]
mov eax, ecx
mul dword ptr[edi]
mov dword ptr[esp + 8H], eax
mov dword ptr[esp + 0CH], edx
mov eax, ecx
mul dword ptr[edi + 4H]
mov ecx, eax
mov ebx, edx
mov eax, esi
mul dword ptr[edi + 4H]
mov dword ptr[esp + 28H], eax
mov dword ptr[esp + 2CH], edx
mov eax, esi
mul dword ptr[edi]
add eax, ecx
adc edx, ebx
mov dword ptr[esp + 10H], eax
mov dword ptr[esp + 14H], edx
mov edx, dword ptr[esp + 0CH]
mov eax, edx
xor edx, edx
add eax, dword ptr[esp + 10H]
adc edx, dword ptr[esp + 14H]
mov dword ptr[esp + 10H], eax
mov dword ptr[esp + 14H], edx
cmp ebx, edx
jc @042
ja @041
cmp ecx, eax
jbe @042
@041: add dword ptr[esp + 28H], 0
adc dword ptr[esp + 2CH], 1
@042: mov ebx, dword ptr[esp + 14H]
mov ecx, ebx
xor ebx, ebx
add ecx, dword ptr[esp + 28H]
adc ebx, dword ptr[esp + 2CH]
mov edx, dword ptr[esp + 8H]
mov eax, dword ptr[esp + 10H]
mov dword ptr[esp + 18H], edx
mov dword ptr[esp + 1CH], eax
mov eax, dword ptr[esp + 18H]
mov edx, dword ptr[esp + 1CH]
add eax, dword ptr[esp]
adc edx, dword ptr[esp + 4H]
mov dword ptr[esp + 8H], eax
mov dword ptr[esp + 0CH], edx
mov eax, 1
mov edx, 0
mov esi, dword ptr[esp + 4H]
cmp dword ptr[esp + 0CH], esi
jc @044
ja @043
mov esi, dword ptr[esp]
cmp dword ptr[esp + 8H], esi
jc @044
@043: mov eax, 0
mov edx, 0
@044: add eax, ecx
adc edx, ebx
add dword ptr[esp + 20H], eax
adc dword ptr[esp + 24H], edx
mov eax, 1
mov edx, 0
cmp dword ptr[esp + 24H], ebx
jc @046
ja @045
cmp dword ptr[esp + 20H], ecx
jc @046
@045: mov eax, 0
mov edx, 0
@046: add dword ptr[esp + 38H], eax
adc dword ptr[esp + 3CH], edx
add ebp, 1
sub edi, 8
cmp ebp, dword ptr[esp + 34H]
ja @048
cmp ebp, 3
jbe @039
mov esi, dword ptr[esp + 8H]
mov edi, dword ptr[esp + 0CH]
jmp @049
@047: mov esi, dword ptr[esp]
mov edi, dword ptr[esp + 4H]
mov eax, dword ptr[esp + 38H]
mov edx, dword ptr[esp + 3CH]
mov dword ptr[esp + 20H], eax
mov dword ptr[esp + 24H], edx
mov dword ptr[esp + 38H], 0
mov dword ptr[esp + 3CH], 0
jmp @049
@048: mov esi, dword ptr[esp + 8H]
mov edi, dword ptr[esp + 0CH]
@049: mov ebx, dword ptr[esp + 48H]
mov eax, dword ptr[esp + 34H]
mov dword ptr[ebx + eax * 8], esi
mov dword ptr[ebx + eax * 8 + 4H], edi
add eax, 1
mov dword ptr[esp + 34H], eax
mov ebx, dword ptr[esp + 20H]
mov esi, dword ptr[esp + 24H]
mov dword ptr[esp], ebx
mov dword ptr[esp + 4H], esi
mov ebx, dword ptr[esp + 44H]
lea ebx, [ebx + 1H]
mov dword ptr[esp + 44H], ebx
cmp eax, 7
jne @037
mov ebx, dword ptr[esp + 48H]
mov eax, dword ptr[esp + 20H]
mov edx, dword ptr[esp + 24H]
mov dword ptr[ebx + 38H], eax
mov dword ptr[ebx + 3CH], edx
add esp, 84
pop ebx
pop esi
pop edi
pop ebp
end;
procedure _vli_modAdd;
asm
push esi
push ebx
sub esp, 4
mov ebx, eax
mov esi, dword ptr[esp + 10H]
call _vli_add
or edx, eax
jnz @050
mov edx, esi
mov eax, ebx
call _vli_cmp
test eax, eax
js @051
@050: mov ecx, esi
mov edx, ebx
mov eax, ebx
call _vli_sub
@051: add esp, 4
pop ebx
pop esi
end;
procedure _vli_modSub;
asm
push ebx
mov ebx, eax
call _vli_sub
or edx, eax
jz @052
mov ecx, dword ptr[esp + 8H]
mov edx, ebx
mov eax, ebx
call _vli_add
@052: pop ebx
end;
procedure _vli_mmod_fast;
asm
push ebp
push edi
push esi
push ebx
sub esp, 36
mov ebx, eax
mov edi, edx
call _vli_set
mov dword ptr[esp], 0
mov dword ptr[esp + 4H], 0
mov dword ptr[esp + 8H], 0
mov eax, dword ptr[edi + 2CH]
mov dword ptr[esp + 0CH], eax
mov eax, dword ptr[edi + 30H]
mov edx, dword ptr[edi + 34H]
mov dword ptr[esp + 10H], eax
mov dword ptr[esp + 14H], edx
mov eax, dword ptr[edi + 38H]
mov edx, dword ptr[edi + 3CH]
mov dword ptr[esp + 18H], eax
mov dword ptr[esp + 1CH], edx
mov ecx, 1
mov edx, esp
mov eax, esp
call _vli_lshift
mov esi, eax
mov ecx, esp
mov edx, ebx
mov eax, ebx
call _vli_add
add esi, eax
mov eax, dword ptr[edi + 30H]
mov ecx, dword ptr[edi + 34H]
mov dword ptr[esp + 8H], 0
mov dword ptr[esp + 0CH], eax
mov edx, dword ptr[edi + 38H]
mov eax, dword ptr[edi + 3CH]
mov dword ptr[esp + 10H], ecx
mov dword ptr[esp + 14H], edx
mov dword ptr[esp + 18H], eax
mov dword ptr[esp + 1CH], 0
mov ecx, 1
mov edx, esp
mov eax, esp
call _vli_lshift
add esi, eax
mov ecx, esp
mov edx, ebx
mov eax, ebx
call _vli_add
add esi, eax
mov eax, dword ptr[edi + 20H]
mov edx, dword ptr[edi + 24H]
mov dword ptr[esp], eax
mov dword ptr[esp + 4H], edx
mov eax, dword ptr[edi + 28H]
mov dword ptr[esp + 8H], eax
mov dword ptr[esp + 0CH], 0
mov dword ptr[esp + 10H], 0
mov dword ptr[esp + 14H], 0
mov eax, dword ptr[edi + 38H]
mov edx, dword ptr[edi + 3CH]
mov dword ptr[esp + 18H], eax
mov dword ptr[esp + 1CH], edx
mov ecx, esp
mov edx, ebx
mov eax, ebx
call _vli_add
add esi, eax
mov ecx, dword ptr[edi + 24H]
mov edx, dword ptr[edi + 28H]
mov eax, dword ptr[edi + 2CH]
mov dword ptr[esp], ecx
mov dword ptr[esp + 4H], edx
mov ecx, dword ptr[edi + 34H]
mov dword ptr[esp + 8H], eax
mov dword ptr[esp + 0CH], ecx
mov eax, dword ptr[edi + 38H]
mov edx, dword ptr[edi + 3CH]
mov dword ptr[esp + 10H], eax
mov dword ptr[esp + 14H], edx
mov dword ptr[esp + 18H], ecx
mov eax, dword ptr[edi + 20H]
mov dword ptr[esp + 1CH], eax
mov ecx, esp
mov edx, ebx
mov eax, ebx
call _vli_add
add esi, eax
mov eax, dword ptr[edi + 28H]
mov ecx, dword ptr[edi + 30H]
mov edx, dword ptr[edi + 34H]
mov ebp, dword ptr[edi + 2CH]
mov dword ptr[esp], ebp
mov dword ptr[esp + 4H], ecx
mov dword ptr[esp + 8H], edx
mov dword ptr[esp + 0CH], 0
mov dword ptr[esp + 10H], 0
mov dword ptr[esp + 14H], 0
mov edx, dword ptr[edi + 20H]
mov dword ptr[esp + 18H], edx
mov dword ptr[esp + 1CH], eax
mov ecx, esp
mov edx, ebx
mov eax, ebx
call _vli_sub
sub esi, eax
mov eax, dword ptr[edi + 30H]
mov edx, dword ptr[edi + 34H]
mov dword ptr[esp], eax
mov dword ptr[esp + 4H], edx
mov eax, dword ptr[edi + 38H]
mov edx, dword ptr[edi + 3CH]
mov dword ptr[esp + 8H], eax
mov dword ptr[esp + 0CH], edx
mov dword ptr[esp + 10H], 0
mov dword ptr[esp + 14H], 0
mov edx, dword ptr[edi + 24H]
mov eax, dword ptr[edi + 2CH]
mov dword ptr[esp + 18H], edx
mov dword ptr[esp + 1CH], eax
mov ecx, esp
mov edx, ebx
mov eax, ebx
call _vli_sub
sub esi, eax
mov eax, dword ptr[edi + 30H]
mov ecx, dword ptr[edi + 34H]
mov edx, dword ptr[edi + 38H]
mov dword ptr[esp], ecx
mov dword ptr[esp + 4H], edx
mov edx, dword ptr[edi + 20H]
mov ecx, dword ptr[edi + 24H]
mov ebp, dword ptr[edi + 3CH]
mov dword ptr[esp + 8H], ebp
mov dword ptr[esp + 0CH], edx
mov edx, dword ptr[edi + 28H]
mov dword ptr[esp + 10H], ecx
mov dword ptr[esp + 14H], edx
mov dword ptr[esp + 18H], 0
mov dword ptr[esp + 1CH], eax
mov ecx, esp
mov edx, ebx
mov eax, ebx
call _vli_sub
sub esi, eax
mov eax, dword ptr[edi + 38H]
mov edx, dword ptr[edi + 3CH]
mov dword ptr[esp], eax
mov dword ptr[esp + 4H], edx
mov dword ptr[esp + 8H], 0
mov eax, dword ptr[edi + 24H]
mov dword ptr[esp + 0CH], eax
mov eax, dword ptr[edi + 28H]
mov edx, dword ptr[edi + 2CH]
mov dword ptr[esp + 10H], eax
mov dword ptr[esp + 14H], edx
mov dword ptr[esp + 18H], 0
mov eax, dword ptr[edi + 34H]
mov dword ptr[esp + 1CH], eax
mov ecx, esp
mov edx, ebx
mov eax, ebx
call _vli_sub
sub esi, eax
jns @055
@053: mov ecx, offset _curve_p
mov edx, ebx
mov eax, ebx
call _vli_add
add eax, esi
mov esi, eax
test eax, eax
js @053
jmp @056
@054: mov ecx, offset _curve_p
mov edx, ebx
mov eax, ebx
call _vli_sub
sub esi, eax
@055: test esi, esi
jnz @054
mov edx, ebx
mov eax, offset _curve_p
call _vli_cmp
cmp eax, 1
jnz @054
@056: add esp, 36
pop ebx
pop esi
pop edi
pop ebp
end;
procedure _vli_modMult_fast;
asm
push ebx
sub esp, 64
mov ebx, eax
mov eax, esp
call _vli_mult
mov edx, esp
mov eax, ebx
call _vli_mmod_fast
add esp, 64
pop ebx
end;
procedure _vli_modInv;
asm
push ebp
push edi
push esi
push ebx
sub esp, 132
mov esi, eax
mov edi, edx
mov ebx, ecx
mov eax, edx
call _vli_isZero
test eax, eax
jz @057
mov eax, esi
call _vli_clear
jmp @069
@057: mov edx, edi
lea eax, [esp + 60H]
call _vli_set
mov edx, ebx
lea eax, [esp + 40H]
call _vli_set
lea eax, [esp + 20H]
call _vli_clear
mov dword ptr[esp + 20H], 1
mov dword ptr[esp + 24H], 0
mov eax, esp
call _vli_clear
jmp @064
@058: test byte ptr[esp + 60H], 01H
jnz @059
lea eax, [esp + 60H]
call _vli_rshift1
test byte ptr[esp + 20H], 01H
je @065
mov ecx, ebx
lea edx, [esp + 20H]
mov eax, edx
call _vli_add
mov edi, eax
mov ebp, edx
lea eax, [esp + 20H]
call _vli_rshift1
or ebp, edi
je @064
or dword ptr[esp + 38H], 00H
or dword ptr[esp + 3CH], 80000000H
jmp @064
@059: test byte ptr[esp + 40H], 01H
jnz @060
lea eax, [esp + 40H]
call _vli_rshift1
test byte ptr[esp], 01H
je @066
mov ecx, ebx
mov edx, esp
mov eax, esp
call _vli_add
mov edi, eax
mov ebp, edx
mov eax, esp
call _vli_rshift1
or ebp, edi
je @064
or dword ptr[esp + 18H], 00H
or dword ptr[esp + 1CH], 80000000H
jmp @064
@060: test eax, eax
jle @062
lea ecx, [esp + 40H]
lea edx, [esp + 60H]
mov eax, edx
call _vli_sub
lea eax, [esp + 60H]
call _vli_rshift1
mov edx, esp
lea eax, [esp + 20H]
call _vli_cmp
test eax, eax
jns @061
mov ecx, ebx
lea edx, [esp + 20H]
mov eax, edx
call _vli_add
@061: mov ecx, esp
lea edx, [esp + 20H]
mov eax, edx
call _vli_sub
test byte ptr[esp + 20H], 01H
je @067
mov ecx, ebx
lea edx, [esp + 20H]
mov eax, edx
call _vli_add
mov edi, eax
mov ebp, edx
lea eax, [esp + 20H]
call _vli_rshift1
or ebp, edi
jz @064
or dword ptr[esp + 38H], 00H
or dword ptr[esp + 3CH], 80000000H
jmp @064
@062: lea ecx, [esp + 60H]
lea edx, [esp + 40H]
mov eax, edx
call _vli_sub
lea eax, [esp + 40H]
call _vli_rshift1
lea edx, [esp + 20H]
mov eax, esp
call _vli_cmp
test eax, eax
jns @063
mov ecx, ebx
mov edx, esp
mov eax, esp
call _vli_add
@063: lea ecx, [esp + 20H]
mov edx, esp
mov eax, esp
call _vli_sub
test byte ptr[esp], 01H
jz @068
mov ecx, ebx
mov edx, esp
mov eax, esp