summaryrefslogtreecommitdiffstats
path: root/libtommath/logs/mult.log
blob: 864de46310de7b77983db5a7554b3b64f128e52f (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
271       580
390       861
511      1177
630      1598
749      2115
871      2670
991      3276
1111      3987
1231      4722
1351      5474
1471      6281
1589      7126
1710      8114
1831      8988
1946     10038
2071     10995
2188     12286
2310     13152
2430     14480
2549     15521
2671     17171
2790     18081
2911     19754
3031     20809
3150     22849
3269     23757
3391     25772
3508     26832
3631     29304
3750     30149
3865     32581
3988     33644
4111     36565
4231     37309
4351     40152
4471     41188
4590     44658
4710     45256
4827     48538
4951     49490
5070     53472
5190     53902
5308     57619
5431     58509
5550     63044
5664     63333
5791     67542
5911     68279
6028     73477
6150     73475
6271     78189
6390     78842
6510     84691
6631     84444
6751     89721
6871     90186
6991     96665
7111     96119
7231    101937
7350    102212
7471    109439
7591    108491
7709    114965
7829    115025
7951    123002
8071    121630
8190    128725
8311    128536
8430    137298
8550    135568
8671    143265
8791    142793
8911    152432
9030    150202
9151    158616
9271    157848
9391    168374
9511    165651
9627    174775
9750    173375
9871    185067
9985    181845
10111    191708
10229    190239
10351    202585
10467    198704
10591    209193
10711    207322
10831    220842
10950    215882
11071    227761
11191    225501
11311    239669
11430    234809
11550    243511
11671    255947
11791    255243
11906    267828
12029    263437
12149    276571
12270    275579
12390    288963
12510    284001
12631    298196
12751    297018
12869    310848
12990    305369
13111    319086
13230    318940
13349    333685
13471    327495
13588    343678
13711    341817
13831    357181
13948    350440
14071    367526
14189    365330
14311    381551
14429    374149
14549    392203
14670    389764
14791    406761
14910    398652
15026    417718
15150    414733
15269    432759
15390   1037071
15511   1053454
15631   1069198
15748   1086164
15871   1112820
15991   1129676
16111   1145924
16230   1163016
16345   1179911
16471   1197048
16586   1214352
16711   1232095
16829   1249338
16947   1266987
17071   1284181
17188   1302521
17311   1320539
((res = mp_grow (x, digs)) != MP_OKAY) { return res; } } x->used = digs; for (ix = 0; ix < n->used; ix++) { /* mu = ai * rho mod b * * The value of rho must be precalculated via * montgomery_setup() such that * it equals -1/n0 mod b this allows the * following inner loop to reduce the * input one digit at a time */ mu = (mp_digit) (((mp_word)x->dp[ix]) * ((mp_word)rho) & MP_MASK); /* a = a + mu * m * b**i */ { register int iy; register mp_digit *tmpn, *tmpx, u; register mp_word r; /* alias for digits of the modulus */ tmpn = n->dp; /* alias for the digits of x [the input] */ tmpx = x->dp + ix; /* set the carry to zero */ u = 0; /* Multiply and add in place */ for (iy = 0; iy < n->used; iy++) { /* compute product and sum */ r = ((mp_word)mu) * ((mp_word)*tmpn++) + ((mp_word) u) + ((mp_word) * tmpx); /* get carry */ u = (mp_digit)(r >> ((mp_word) DIGIT_BIT)); /* fix digit */ *tmpx++ = (mp_digit)(r & ((mp_word) MP_MASK)); } /* At this point the ix'th digit of x should be zero */ /* propagate carries upwards as required*/ while (u) { *tmpx += u; u = *tmpx >> DIGIT_BIT; *tmpx++ &= MP_MASK; } } } /* at this point the n.used'th least * significant digits of x are all zero * which means we can shift x to the * right by n.used digits and the * residue is unchanged. */ /* x = x/b**n.used */ mp_clamp(x); mp_rshd (x, n->used); /* if x >= n then x = x - n */ if (mp_cmp_mag (x, n) != MP_LT) { return s_mp_sub (x, n, x); } return MP_OKAY; } #endif