1 | /* |
2 | Copyright (C) 1999-2007 The Botan Project. All rights reserved. |
3 | |
4 | Redistribution and use in source and binary forms, for any use, with or without |
5 | modification, is permitted provided that the following conditions are met: |
6 | |
7 | 1. Redistributions of source code must retain the above copyright notice, this |
8 | list of conditions, and the following disclaimer. |
9 | |
10 | 2. Redistributions in binary form must reproduce the above copyright notice, |
11 | this list of conditions, and the following disclaimer in the documentation |
12 | and/or other materials provided with the distribution. |
13 | |
14 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) "AS IS" AND ANY EXPRESS OR IMPLIED |
15 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
16 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED. |
17 | |
18 | IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTOR(S) BE LIABLE FOR ANY DIRECT, |
19 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
20 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
21 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
22 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
23 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
24 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 | */ |
26 | // LICENSEHEADER_END |
27 | namespace QCA { // WRAPNS_LINE |
28 | /************************************************* |
29 | * Comba Multiplication and Squaring Source File * |
30 | * (C) 1999-2007 The Botan Project * |
31 | *************************************************/ |
32 | |
33 | } // WRAPNS_LINE |
34 | #include <botan/mp_core.h> |
35 | namespace QCA { // WRAPNS_LINE |
36 | } // WRAPNS_LINE |
37 | #include <botan/mp_asmi.h> |
38 | namespace QCA { // WRAPNS_LINE |
39 | |
40 | namespace Botan { |
41 | |
42 | extern "C" { |
43 | |
44 | /************************************************* |
45 | * Comba 4x4 Multiplication * |
46 | *************************************************/ |
47 | void bigint_comba_mul4(word z[8], const word x[4], const word y[4]) |
48 | { |
49 | word w2 = 0, w1 = 0, w0 = 0; |
50 | |
51 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: y[0]); |
52 | z[0] = w0; |
53 | w0 = w1; |
54 | w1 = w2; |
55 | w2 = 0; |
56 | |
57 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: y[1]); |
58 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: y[0]); |
59 | z[1] = w0; |
60 | w0 = w1; |
61 | w1 = w2; |
62 | w2 = 0; |
63 | |
64 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: y[2]); |
65 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: y[1]); |
66 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[2], b: y[0]); |
67 | z[2] = w0; |
68 | w0 = w1; |
69 | w1 = w2; |
70 | w2 = 0; |
71 | |
72 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: y[3]); |
73 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: y[2]); |
74 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[2], b: y[1]); |
75 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[3], b: y[0]); |
76 | z[3] = w0; |
77 | w0 = w1; |
78 | w1 = w2; |
79 | w2 = 0; |
80 | |
81 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: y[3]); |
82 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[2], b: y[2]); |
83 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[3], b: y[1]); |
84 | z[4] = w0; |
85 | w0 = w1; |
86 | w1 = w2; |
87 | w2 = 0; |
88 | |
89 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[2], b: y[3]); |
90 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[3], b: y[2]); |
91 | z[5] = w0; |
92 | w0 = w1; |
93 | w1 = w2; |
94 | w2 = 0; |
95 | |
96 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[3], b: y[3]); |
97 | z[6] = w0; |
98 | z[7] = w1; |
99 | } |
100 | |
101 | /************************************************* |
102 | * Comba 6x6 Multiplication * |
103 | *************************************************/ |
104 | void bigint_comba_mul6(word z[12], const word x[6], const word y[6]) |
105 | { |
106 | word w2 = 0, w1 = 0, w0 = 0; |
107 | |
108 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: y[0]); |
109 | z[0] = w0; |
110 | w0 = w1; |
111 | w1 = w2; |
112 | w2 = 0; |
113 | |
114 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: y[1]); |
115 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: y[0]); |
116 | z[1] = w0; |
117 | w0 = w1; |
118 | w1 = w2; |
119 | w2 = 0; |
120 | |
121 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: y[2]); |
122 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: y[1]); |
123 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[2], b: y[0]); |
124 | z[2] = w0; |
125 | w0 = w1; |
126 | w1 = w2; |
127 | w2 = 0; |
128 | |
129 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: y[3]); |
130 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: y[2]); |
131 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[2], b: y[1]); |
132 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[3], b: y[0]); |
133 | z[3] = w0; |
134 | w0 = w1; |
135 | w1 = w2; |
136 | w2 = 0; |
137 | |
138 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: y[4]); |
139 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: y[3]); |
140 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[2], b: y[2]); |
141 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[3], b: y[1]); |
142 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[4], b: y[0]); |
143 | z[4] = w0; |
144 | w0 = w1; |
145 | w1 = w2; |
146 | w2 = 0; |
147 | |
148 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: y[5]); |
149 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: y[4]); |
150 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[2], b: y[3]); |
151 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[3], b: y[2]); |
152 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[4], b: y[1]); |
153 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[5], b: y[0]); |
154 | z[5] = w0; |
155 | w0 = w1; |
156 | w1 = w2; |
157 | w2 = 0; |
158 | |
159 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: y[5]); |
160 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[2], b: y[4]); |
161 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[3], b: y[3]); |
162 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[4], b: y[2]); |
163 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[5], b: y[1]); |
164 | z[6] = w0; |
165 | w0 = w1; |
166 | w1 = w2; |
167 | w2 = 0; |
168 | |
169 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[2], b: y[5]); |
170 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[3], b: y[4]); |
171 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[4], b: y[3]); |
172 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[5], b: y[2]); |
173 | z[7] = w0; |
174 | w0 = w1; |
175 | w1 = w2; |
176 | w2 = 0; |
177 | |
178 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[3], b: y[5]); |
179 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[4], b: y[4]); |
180 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[5], b: y[3]); |
181 | z[8] = w0; |
182 | w0 = w1; |
183 | w1 = w2; |
184 | w2 = 0; |
185 | |
186 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[4], b: y[5]); |
187 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[5], b: y[4]); |
188 | z[9] = w0; |
189 | w0 = w1; |
190 | w1 = w2; |
191 | w2 = 0; |
192 | |
193 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[5], b: y[5]); |
194 | z[10] = w0; |
195 | z[11] = w1; |
196 | } |
197 | |
198 | /************************************************* |
199 | * Comba 8x8 Multiplication * |
200 | *************************************************/ |
201 | void bigint_comba_mul8(word z[16], const word x[8], const word y[8]) |
202 | { |
203 | word w2 = 0, w1 = 0, w0 = 0; |
204 | |
205 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: y[0]); |
206 | z[0] = w0; |
207 | w0 = w1; |
208 | w1 = w2; |
209 | w2 = 0; |
210 | |
211 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: y[1]); |
212 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: y[0]); |
213 | z[1] = w0; |
214 | w0 = w1; |
215 | w1 = w2; |
216 | w2 = 0; |
217 | |
218 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: y[2]); |
219 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: y[1]); |
220 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[2], b: y[0]); |
221 | z[2] = w0; |
222 | w0 = w1; |
223 | w1 = w2; |
224 | w2 = 0; |
225 | |
226 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: y[3]); |
227 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: y[2]); |
228 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[2], b: y[1]); |
229 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[3], b: y[0]); |
230 | z[3] = w0; |
231 | w0 = w1; |
232 | w1 = w2; |
233 | w2 = 0; |
234 | |
235 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: y[4]); |
236 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: y[3]); |
237 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[2], b: y[2]); |
238 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[3], b: y[1]); |
239 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[4], b: y[0]); |
240 | z[4] = w0; |
241 | w0 = w1; |
242 | w1 = w2; |
243 | w2 = 0; |
244 | |
245 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: y[5]); |
246 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: y[4]); |
247 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[2], b: y[3]); |
248 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[3], b: y[2]); |
249 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[4], b: y[1]); |
250 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[5], b: y[0]); |
251 | z[5] = w0; |
252 | w0 = w1; |
253 | w1 = w2; |
254 | w2 = 0; |
255 | |
256 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: y[6]); |
257 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: y[5]); |
258 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[2], b: y[4]); |
259 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[3], b: y[3]); |
260 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[4], b: y[2]); |
261 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[5], b: y[1]); |
262 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[6], b: y[0]); |
263 | z[6] = w0; |
264 | w0 = w1; |
265 | w1 = w2; |
266 | w2 = 0; |
267 | |
268 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: y[7]); |
269 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: y[6]); |
270 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[2], b: y[5]); |
271 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[3], b: y[4]); |
272 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[4], b: y[3]); |
273 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[5], b: y[2]); |
274 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[6], b: y[1]); |
275 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[7], b: y[0]); |
276 | z[7] = w0; |
277 | w0 = w1; |
278 | w1 = w2; |
279 | w2 = 0; |
280 | |
281 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: y[7]); |
282 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[2], b: y[6]); |
283 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[3], b: y[5]); |
284 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[4], b: y[4]); |
285 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[5], b: y[3]); |
286 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[6], b: y[2]); |
287 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[7], b: y[1]); |
288 | z[8] = w0; |
289 | w0 = w1; |
290 | w1 = w2; |
291 | w2 = 0; |
292 | |
293 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[2], b: y[7]); |
294 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[3], b: y[6]); |
295 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[4], b: y[5]); |
296 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[5], b: y[4]); |
297 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[6], b: y[3]); |
298 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[7], b: y[2]); |
299 | z[9] = w0; |
300 | w0 = w1; |
301 | w1 = w2; |
302 | w2 = 0; |
303 | |
304 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[3], b: y[7]); |
305 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[4], b: y[6]); |
306 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[5], b: y[5]); |
307 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[6], b: y[4]); |
308 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[7], b: y[3]); |
309 | z[10] = w0; |
310 | w0 = w1; |
311 | w1 = w2; |
312 | w2 = 0; |
313 | |
314 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[4], b: y[7]); |
315 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[5], b: y[6]); |
316 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[6], b: y[5]); |
317 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[7], b: y[4]); |
318 | z[11] = w0; |
319 | w0 = w1; |
320 | w1 = w2; |
321 | w2 = 0; |
322 | |
323 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[5], b: y[7]); |
324 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[6], b: y[6]); |
325 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[7], b: y[5]); |
326 | z[12] = w0; |
327 | w0 = w1; |
328 | w1 = w2; |
329 | w2 = 0; |
330 | |
331 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[6], b: y[7]); |
332 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[7], b: y[6]); |
333 | z[13] = w0; |
334 | w0 = w1; |
335 | w1 = w2; |
336 | w2 = 0; |
337 | |
338 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[7], b: y[7]); |
339 | z[14] = w0; |
340 | z[15] = w1; |
341 | } |
342 | |
343 | /************************************************* |
344 | * Comba 4x4 Squaring * |
345 | *************************************************/ |
346 | void bigint_comba_sqr4(word z[8], const word x[4]) |
347 | { |
348 | word w2 = 0, w1 = 0, w0 = 0; |
349 | |
350 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: x[0]); |
351 | z[0] = w0; |
352 | w0 = w1; |
353 | w1 = w2; |
354 | w2 = 0; |
355 | |
356 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: x[1]); |
357 | z[1] = w0; |
358 | w0 = w1; |
359 | w1 = w2; |
360 | w2 = 0; |
361 | |
362 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: x[2]); |
363 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: x[1]); |
364 | z[2] = w0; |
365 | w0 = w1; |
366 | w1 = w2; |
367 | w2 = 0; |
368 | |
369 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: x[3]); |
370 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: x[2]); |
371 | z[3] = w0; |
372 | w0 = w1; |
373 | w1 = w2; |
374 | w2 = 0; |
375 | |
376 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: x[3]); |
377 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[2], b: x[2]); |
378 | z[4] = w0; |
379 | w0 = w1; |
380 | w1 = w2; |
381 | w2 = 0; |
382 | |
383 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[2], b: x[3]); |
384 | z[5] = w0; |
385 | w0 = w1; |
386 | w1 = w2; |
387 | w2 = 0; |
388 | |
389 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[3], b: x[3]); |
390 | z[6] = w0; |
391 | z[7] = w1; |
392 | } |
393 | |
394 | /************************************************* |
395 | * Comba 6x6 Squaring * |
396 | *************************************************/ |
397 | void bigint_comba_sqr6(word z[12], const word x[6]) |
398 | { |
399 | word w2 = 0, w1 = 0, w0 = 0; |
400 | |
401 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: x[0]); |
402 | z[0] = w0; |
403 | w0 = w1; |
404 | w1 = w2; |
405 | w2 = 0; |
406 | |
407 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: x[1]); |
408 | z[1] = w0; |
409 | w0 = w1; |
410 | w1 = w2; |
411 | w2 = 0; |
412 | |
413 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: x[2]); |
414 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: x[1]); |
415 | z[2] = w0; |
416 | w0 = w1; |
417 | w1 = w2; |
418 | w2 = 0; |
419 | |
420 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: x[3]); |
421 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: x[2]); |
422 | z[3] = w0; |
423 | w0 = w1; |
424 | w1 = w2; |
425 | w2 = 0; |
426 | |
427 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: x[4]); |
428 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: x[3]); |
429 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[2], b: x[2]); |
430 | z[4] = w0; |
431 | w0 = w1; |
432 | w1 = w2; |
433 | w2 = 0; |
434 | |
435 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: x[5]); |
436 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: x[4]); |
437 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[2], b: x[3]); |
438 | z[5] = w0; |
439 | w0 = w1; |
440 | w1 = w2; |
441 | w2 = 0; |
442 | |
443 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: x[5]); |
444 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[2], b: x[4]); |
445 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[3], b: x[3]); |
446 | z[6] = w0; |
447 | w0 = w1; |
448 | w1 = w2; |
449 | w2 = 0; |
450 | |
451 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[2], b: x[5]); |
452 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[3], b: x[4]); |
453 | z[7] = w0; |
454 | w0 = w1; |
455 | w1 = w2; |
456 | w2 = 0; |
457 | |
458 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[3], b: x[5]); |
459 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[4], b: x[4]); |
460 | z[8] = w0; |
461 | w0 = w1; |
462 | w1 = w2; |
463 | w2 = 0; |
464 | |
465 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[4], b: x[5]); |
466 | z[9] = w0; |
467 | w0 = w1; |
468 | w1 = w2; |
469 | w2 = 0; |
470 | |
471 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[5], b: x[5]); |
472 | z[10] = w0; |
473 | z[11] = w1; |
474 | } |
475 | |
476 | /************************************************* |
477 | * Comba 8x8 Squaring * |
478 | *************************************************/ |
479 | void bigint_comba_sqr8(word z[16], const word x[8]) |
480 | { |
481 | word w2 = 0, w1 = 0, w0 = 0; |
482 | |
483 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: x[0]); |
484 | z[0] = w0; |
485 | w0 = w1; |
486 | w1 = w2; |
487 | w2 = 0; |
488 | |
489 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: x[1]); |
490 | z[1] = w0; |
491 | w0 = w1; |
492 | w1 = w2; |
493 | w2 = 0; |
494 | |
495 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: x[2]); |
496 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: x[1]); |
497 | z[2] = w0; |
498 | w0 = w1; |
499 | w1 = w2; |
500 | w2 = 0; |
501 | |
502 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: x[3]); |
503 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: x[2]); |
504 | z[3] = w0; |
505 | w0 = w1; |
506 | w1 = w2; |
507 | w2 = 0; |
508 | |
509 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: x[4]); |
510 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: x[3]); |
511 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[2], b: x[2]); |
512 | z[4] = w0; |
513 | w0 = w1; |
514 | w1 = w2; |
515 | w2 = 0; |
516 | |
517 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: x[5]); |
518 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: x[4]); |
519 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[2], b: x[3]); |
520 | z[5] = w0; |
521 | w0 = w1; |
522 | w1 = w2; |
523 | w2 = 0; |
524 | |
525 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: x[6]); |
526 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: x[5]); |
527 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[2], b: x[4]); |
528 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[3], b: x[3]); |
529 | z[6] = w0; |
530 | w0 = w1; |
531 | w1 = w2; |
532 | w2 = 0; |
533 | |
534 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[0], b: x[7]); |
535 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: x[6]); |
536 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[2], b: x[5]); |
537 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[3], b: x[4]); |
538 | z[7] = w0; |
539 | w0 = w1; |
540 | w1 = w2; |
541 | w2 = 0; |
542 | |
543 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[1], b: x[7]); |
544 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[2], b: x[6]); |
545 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[3], b: x[5]); |
546 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[4], b: x[4]); |
547 | z[8] = w0; |
548 | w0 = w1; |
549 | w1 = w2; |
550 | w2 = 0; |
551 | |
552 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[2], b: x[7]); |
553 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[3], b: x[6]); |
554 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[4], b: x[5]); |
555 | z[9] = w0; |
556 | w0 = w1; |
557 | w1 = w2; |
558 | w2 = 0; |
559 | |
560 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[3], b: x[7]); |
561 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[4], b: x[6]); |
562 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[5], b: x[5]); |
563 | z[10] = w0; |
564 | w0 = w1; |
565 | w1 = w2; |
566 | w2 = 0; |
567 | |
568 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[4], b: x[7]); |
569 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[5], b: x[6]); |
570 | z[11] = w0; |
571 | w0 = w1; |
572 | w1 = w2; |
573 | w2 = 0; |
574 | |
575 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[5], b: x[7]); |
576 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[6], b: x[6]); |
577 | z[12] = w0; |
578 | w0 = w1; |
579 | w1 = w2; |
580 | w2 = 0; |
581 | |
582 | word3_muladd_2(w2: &w2, w1: &w1, w0: &w0, a: x[6], b: x[7]); |
583 | z[13] = w0; |
584 | w0 = w1; |
585 | w1 = w2; |
586 | w2 = 0; |
587 | |
588 | word3_muladd(w2: &w2, w1: &w1, w0: &w0, a: x[7], b: x[7]); |
589 | z[14] = w0; |
590 | z[15] = w1; |
591 | } |
592 | } |
593 | |
594 | } |
595 | } // WRAPNS_LINE |
596 | |