FS#8961 - Anti-Aliased Fonts.
[kugel-rb.git] / utils / zenutils / libraries / beecrypt-4.1.2 / beecrypt / mp.h
blob57a3e6c502e06806d85166d72a2b0513925eb8a8
1 /*
2 * Copyright (c) 2002, 2003 Bob Deblier
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 /*!\file mp.h
21 * \brief Multi-precision integer routines.
23 * The routines declared here are all low-level operations, most of them
24 * suitable to be implemented in assembler. Prime candidates are in order
25 * of importance (according to gprof):
26 * <ul>
27 * <li>mpaddmul
28 * <li>mpsetmul
29 * <li>mpaddsqrtrc
30 * <li>mpsub
31 * <li>mpadd
32 * </ul>
34 * With some smart use of available assembler instructions, it's possible
35 * to speed these routines up by a factor of 2 to 4.
37 * \author Bob Deblier <bob.deblier@pandora.be>
38 * \ingroup MP_m
41 #ifndef _MP_H
42 #define _MP_H
44 #include "beecrypt/api.h"
45 #include "beecrypt/mpopt.h"
47 #define MP_HWBITS (MP_WBITS >> 1)
48 #define MP_WBYTES (MP_WBITS >> 3)
49 #define MP_WNIBBLES (MP_WBITS >> 2)
51 #if (MP_WBITS == 64)
52 # define MP_WORDS_TO_BITS(x) ((x) << 6)
53 # define MP_WORDS_TO_NIBBLES(x) ((x) << 4)
54 # define MP_WORDS_TO_BYTES(x) ((x) << 3)
55 # define MP_BITS_TO_WORDS(x) ((x) >> 6)
56 # define MP_NIBBLES_TO_WORDS(x) ((x) >> 4)
57 # define MP_BYTES_TO_WORDS(x) ((x) >> 3)
58 #elif (MP_WBITS == 32)
59 # define MP_WORDS_TO_BITS(x) ((x) << 5)
60 # define MP_WORDS_TO_NIBBLES(x) ((x) << 3)
61 # define MP_WORDS_TO_BYTES(x) ((x) << 2)
62 # define MP_BITS_TO_WORDS(x) ((x) >> 5)
63 # define MP_NIBBLES_TO_WORDS(x) ((x) >> 3)
64 # define MP_BYTES_TO_WORDS(x) ((x) >> 2)
65 #else
66 # error
67 #endif
69 #define MP_MSBMASK (((mpw) 0x1) << (MP_WBITS-1))
70 #define MP_LSBMASK ((mpw) 0x1)
71 #define MP_ALLMASK ~((mpw) 0x0)
73 #ifdef __cplusplus
74 extern "C" {
75 #endif
77 #ifndef ASM_MPCOPY
78 # define mpcopy(size, dst, src) memcpy(dst, src, MP_WORDS_TO_BYTES(size))
79 #else
80 BEECRYPTAPI
81 void mpcopy(size_t size, mpw* dest, const mpw* src);
82 #endif
84 #ifndef ASM_MPMOVE
85 # define mpmove(size, dst, src) memmove(dst, src, MP_WORDS_TO_BYTES(size))
86 #else
87 BEECRYPTAPI
88 void mpmove(size_t size, mpw* dest, const mpw* src);
89 #endif
91 /*!\fn void mpzero(size_t size, mpw* data)
92 * \brief This function zeroes a multi-precision integer of a given size.
93 * \param size The size of the multi-precision integer.
94 * \param data The multi-precision integer data.
96 BEECRYPTAPI
97 void mpzero(size_t size, mpw* data);
99 /*!\fn void mpfill(size_t size, mpw* data, mpw fill)
100 * \brief This function fills each word of a multi-precision integer with a
101 * given value.
102 * \param size The size of the multi-precision integer.
103 * \param data The multi-precision integer data.
104 * \param fill The value fill the data with.
106 BEECRYPTAPI
107 void mpfill(size_t size, mpw* data, mpw fill);
109 /*!\fn int mpodd(size_t size, const mpw* data)
110 * \brief This functions tests if a multi-precision integer is odd.
111 * \param size The size of the multi-precision integer.
112 * \param data The multi-precision integer data.
113 * \retval 1 if odd
114 * \retval 0 if even
116 BEECRYPTAPI
117 int mpodd (size_t size, const mpw* data);
119 /*!\fn int mpeven(size_t size, const mpw* data)
120 * \brief This function tests if a multi-precision integer is even.
121 * \param size The size of the multi-precision integer.
122 * \param data The multi-precision integer data.
123 * \retval 1 if even
124 * \retval 0 if odd
126 BEECRYPTAPI
127 int mpeven(size_t size, const mpw* data);
129 /*!\fn int mpz(size_t size, const mpw* data)
130 * \brief This function tests if a multi-precision integer is zero.
131 * \param size The size of the multi-precision integer.
132 * \param data The multi-precision integer data.
133 * \retval 1 if zero
134 * \retval 0 if not zero
136 BEECRYPTAPI
137 int mpz (size_t size, const mpw* data);
139 /*!\fn int mpnz(size_t size, const mpw* data)
140 * \brief This function tests if a multi-precision integer is not zero.
141 * \param size The size of the multi-precision integer.
142 * \param data The multi-precision integer data.
143 * \retval 1 if not zero
144 * \retval 0 if zero
146 BEECRYPTAPI
147 int mpnz (size_t size, const mpw* data);
149 /*!\fn int mpeq(size_t size, const mpw* xdata, const mpw* ydata)
150 * \brief This function tests if two multi-precision integers of the same size
151 * are equal.
152 * \param size The size of the multi-precision integers.
153 * \param xdata The first multi-precision integer.
154 * \param ydata The second multi-precision integer.
155 * \retval 1 if equal
156 * \retval 0 if not equal
158 BEECRYPTAPI
159 int mpeq (size_t size, const mpw* xdata, const mpw* ydata);
161 /*!\fn int mpne(size_t size, const mpw* xdata, const mpw* ydata)
162 * \brief This function tests if two multi-precision integers of the same size
163 * differ.
164 * \param size The size of the multi-precision integers.
165 * \param xdata The first multi-precision integer.
166 * \param ydata The second multi-precision integer.
167 * \retval 1 if not equal
168 * \retval 0 if equal
170 BEECRYPTAPI
171 int mpne (size_t size, const mpw* xdata, const mpw* ydata);
173 /*!\fn int mpgt(size_t size, const mpw* xdata, const mpw* ydata)
174 * \brief This function tests if the first of two multi-precision integers
175 * of the same size is greater than the second.
176 * \note The comparison treats the arguments as unsigned.
177 * \param size The size of the multi-precision integers.
178 * \param xdata The first multi-precision integer.
179 * \param ydata The second multi-precision integer.
180 * \retval 1 if greater
181 * \retval 0 if less or equal
183 BEECRYPTAPI
184 int mpgt (size_t size, const mpw* xdata, const mpw* ydata);
186 /*!\fn int mplt(size_t size, const mpw* xdata, const mpw* ydata)
187 * \brief This function tests if the first of two multi-precision integers
188 * of the same size is less than the second.
189 * \note The comparison treats the arguments as unsigned.
190 * \param size The size of the multi-precision integers.
191 * \param xdata The first multi-precision integer.
192 * \param ydata The second multi-precision integer.
193 * \retval 1 if less
194 * \retval 0 if greater or equal
196 BEECRYPTAPI
197 int mplt (size_t size, const mpw* xdata, const mpw* ydata);
199 /*!\fn int mpge(size_t size, const mpw* xdata, const mpw* ydata)
200 * \brief This function tests if the first of two multi-precision integers
201 * of the same size is greater than or equal to the second.
202 * \note The comparison treats the arguments as unsigned.
203 * \param size The size of the multi-precision integers.
204 * \param xdata The first multi-precision integer.
205 * \param ydata The second multi-precision integer.
206 * \retval 1 if greater or equal
207 * \retval 0 if less
209 BEECRYPTAPI
210 int mpge (size_t size, const mpw* xdata, const mpw* ydata);
212 /*!\fn int mple(size_t size, const mpw* xdata, const mpw* ydata)
213 * \brief This function tests if the first of two multi-precision integers
214 * of the same size is less than or equal to the second.
215 * \note The comparison treats the arguments as unsigned.
216 * \param size The size of the multi-precision integers.
217 * \param xdata The first multi-precision integer.
218 * \param ydata The second multi-precision integer.
219 * \retval 1 if less or equal
220 * \retval 0 if greater
222 BEECRYPTAPI
223 int mple (size_t size, const mpw* xdata, const mpw* ydata);
225 /*!\fn int mpeqx(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata)
226 * \brief This function tests if two multi-precision integers of different
227 * size are equal.
228 * \param xsize The size of the first multi-precision integer.
229 * \param xdata The first multi-precision integer.
230 * \param ysize The size of the first multi-precision integer.
231 * \param ydata The second multi-precision integer.
232 * \retval 1 if equal
233 * \retval 0 if not equal
235 BEECRYPTAPI
236 int mpeqx(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata);
238 /*!\fn int mpnex(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata)
239 * \brief This function tests if two multi-precision integers of different
240 * size are equal.
241 * \param xsize The size of the first multi-precision integer.
242 * \param xdata The first multi-precision integer.
243 * \param ysize The size of the first multi-precision integer.
244 * \param ydata The second multi-precision integer.
245 * \retval 1 if equal
246 * \retval 0 if not equal
248 BEECRYPTAPI
249 int mpnex(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata);
251 /*!\fn int mpgtx(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata)
252 * \brief This function tests if the first of two multi-precision integers
253 * of different size is greater than the second.
254 * \note The comparison treats the arguments as unsigned.
255 * \param xsize The size of the first multi-precision integer.
256 * \param xdata The first multi-precision integer.
257 * \param ysize The size of the second multi-precision integer.
258 * \param ydata The second multi-precision integer.
259 * \retval 1 if greater
260 * \retval 0 if less or equal
262 BEECRYPTAPI
263 int mpgtx(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata);
265 /*!\fn int mpltx(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata)
266 * \brief This function tests if the first of two multi-precision integers
267 * of different size is less than the second.
268 * \note The comparison treats the arguments as unsigned.
269 * \param xsize The size of the first multi-precision integer.
270 * \param xdata The first multi-precision integer.
271 * \param ysize The size of the second multi-precision integer.
272 * \param ydata The second multi-precision integer.
273 * \retval 1 if less
274 * \retval 0 if greater or equal
276 BEECRYPTAPI
277 int mpltx(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata);
279 /*!\fn int mpgex(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata)
280 * \brief This function tests if the first of two multi-precision integers
281 * of different size is greater than or equal to the second.
282 * \note The comparison treats the arguments as unsigned.
283 * \param xsize The size of the first multi-precision integer.
284 * \param xdata The first multi-precision integer.
285 * \param ysize The size of the second multi-precision integer.
286 * \param ydata The second multi-precision integer.
287 * \retval 1 if greater or equal
288 * \retval 0 if less
290 BEECRYPTAPI
291 int mpgex(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata);
293 /*!\fn int mplex(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata)
294 * \brief This function tests if the first of two multi-precision integers
295 * of different size is less than or equal to the second.
296 * \note The comparison treats the arguments as unsigned.
297 * \param xsize The size of the first multi-precision integer.
298 * \param xdata The first multi-precision integer.
299 * \param ysize The size of the second multi-precision integer.
300 * \param ydata The second multi-precision integer.
301 * \retval 1 if less or equal
302 * \retval 0 if greater
304 BEECRYPTAPI
305 int mplex(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata);
307 /*!\fn int mpisone(size_t size, const mpw* data)
308 * \brief This functions tests if the value of a multi-precision integer is
309 * equal to one.
310 * \param size The size of the multi-precision integer.
311 * \param data The multi-precision integer data.
312 * \retval 1 if one
313 * \retval 0 if not one
315 BEECRYPTAPI
316 int mpisone(size_t size, const mpw* data);
318 /*!\fn int mpistwo(size_t size, const mpw* data)
319 * \brief This function tests if the value of a multi-precision integer is
320 * equal to two.
321 * \param size The size of the multi-precision integer.
322 * \param data The multi-precision integer data.
323 * \retval 1 if two
324 * \retval 0 if not two
326 BEECRYPTAPI
327 int mpistwo(size_t size, const mpw* data);
329 /*!\fn int mpleone(size_t size, const mpw* data);
330 * \brief This function tests if the value of a multi-precision integer is
331 * less than or equal to one.
332 * \param size The size of the multi-precision integer.
333 * \param data The multi-precision integer data.
334 * \retval 1 if less than or equal to one.
335 * \retval 0 if greater than one.
337 BEECRYPTAPI
338 int mpleone(size_t size, const mpw* data);
340 /*!\fn int mpeqmone(size_t size, const mpw* xdata, const mpw* ydata);
341 * \brief This function tests if multi-precision integer x is equal to y
342 * minus one.
343 * \param size The size of the multi-precision integers.
344 * \param xdata The first multi-precision integer.
345 * \param ydata The second multi-precision integer.
346 * \retval 1 if less than or equal to one.
347 * \retval 0 if greater than one.
349 BEECRYPTAPI
350 int mpeqmone(size_t size, const mpw* xdata, const mpw* ydata);
352 /*!\fn int mpmsbset(size_t size, const mpw* data)
353 * \brief This function tests if the most significant bit of a multi-precision
354 * integer is set.
355 * \param size The size of the multi-precision integer.
356 * \param data The multi-precision integer data.
357 * \retval 1 if set
358 * \retval 0 if not set
360 BEECRYPTAPI
361 int mpmsbset(size_t size, const mpw* data);
363 /*!\fn int mplsbset(size_t size, const mpw* data)
364 * \brief This function tests if the leiast significant bit of a multi-precision
365 * integer is set.
366 * \param size The size of the multi-precision integer.
367 * \param data The multi-precision integer data.
368 * \retval 1 if set
369 * \retval 0 if not set
371 BEECRYPTAPI
372 int mplsbset(size_t size, const mpw* data);
374 /*!\fn void mpsetmsb(size_t size, mpw* data)
375 * \brief This function sets the most significant bit of a multi-precision
376 * integer.
377 * \param size The size of the multi-precision integer.
378 * \param data The multi-precision integer data.
380 BEECRYPTAPI
381 void mpsetmsb(size_t size, mpw* data);
383 /*!\fn void mpsetlsb(size_t size, mpw* data)
384 * \brief This function sets the least significant bit of a multi-precision
385 * integer.
386 * \param size The size of the multi-precision integer.
387 * \param data The multi-precision integer data.
389 BEECRYPTAPI
390 void mpsetlsb(size_t size, mpw* data);
392 /*!\fn void mpclrmsb(size_t size, mpw* data)
393 * \brief This function clears the most significant bit of a multi-precision
394 * integer.
395 * \param size The size of the multi-precision integer.
396 * \param data The multi-precision integer data.
398 BEECRYPTAPI
399 void mpclrmsb(size_t size, mpw* data);
401 /*!\fn void mpclrlsb(size_t size, mpw* data)
402 * \brief This function clears the least significant bit of a multi-precision
403 * integer.
404 * \param size The size of the multi-precision integer.
405 * \param data The multi-precision integer data.
407 BEECRYPTAPI
408 void mpclrlsb(size_t size, mpw* data);
410 /*!\fn mpand(size_t size, mpw* xdata, const mpw* ydata)
411 * \brief This function computes the bit-wise AND of two multi-precision
412 * integers. Modifies xdata.
413 * \param size The size of the multi-precision integers.
414 * \param xdata The multi-precision integer data.
415 * \param ydata The multi-precision integer data.
417 BEECRYPTAPI
418 void mpand(size_t size, mpw* xdata, const mpw* ydata);
420 /*!\fn void mpor(size_t size, mpw* xdata, const mpw* ydata)
421 * \brief This function computes the bit-wise OR of two multi-precision
422 * integers. Modifies xdata.
423 * \param size The size of the multi-precision integer.
424 * \param xdata The multi-precision integer data.
425 * \param ydata The multi-precision integer data.
427 BEECRYPTAPI
428 void mpor(size_t size, mpw* xdata, const mpw* ydata);
430 /*!\fn void mpxor(size_t size, mpw* xdata, const mpw* ydata)
431 * \brief This function computes the bit-wise XOR of two multi-precision
432 * integers. Modifies xdata.
433 * \param size The size of the multi-precision integer.
434 * \param xdata The multi-precision integer data.
435 * \param ydata The multi-precision integer data.
437 BEECRYPTAPI
438 void mpxor(size_t size, mpw* xdata, const mpw* ydata);
440 /*!\fn mpnot(size_t size, mpw* data)
441 * \brief This function flips all bits of a multi-precision integer.
442 * \param size The size of the multi-precision integer.
443 * \param data The multi-precision integer data.
445 BEECRYPTAPI
446 void mpnot(size_t size, mpw* data);
448 /*!\fn void mpsetw(size_t size, mpw* xdata, mpw y)
449 * \brief This function sets the value of a multi-precision integer to the
450 * given word. The given value is copied into the least significant word,
451 * while the most significant words are zeroed.
452 * \param size The size of the multi-precision integer.
453 * \param xdata The first multi-precision integer.
454 * \param y The multi-precision word.
456 BEECRYPTAPI
457 void mpsetw(size_t size, mpw* xdata, mpw y);
459 /*!\fn void mpsetx(size_t xsize, mpw* xdata, size_t ysize, const mpw* ydata)
460 * \brief This function set the value of the first multi-precision integer
461 * to the second, truncating the most significant words if ysize > xsize, or
462 * zeroing the most significant words if ysize < xsize.
463 * \param xsize The size of the first multi-precision integer.
464 * \param xdata The first multi-precision integer.
465 * \param ysize The size of the second multi-precision integer.
466 * \param ydata The second multi-precision integer.
468 void mpsetx(size_t xsize, mpw* xdata, size_t ysize, const mpw* ydata);
470 /*!\fn int mpaddw(size_t size, mpw* xdata, mpw y)
471 * \brief This function adds one word to a multi-precision integer.
472 * The performed operation is in pseudocode: x += y.
473 * \param size The size of the multi-precision integer.
474 * \param xdata The first multi-precision integer.
475 * \param y The multi-precision word.
476 * \return The carry-over value of the operation; this value is either 0 or 1.
478 BEECRYPTAPI
479 int mpaddw(size_t size, mpw* xdata, mpw y);
481 /*!\fn int mpadd(size_t size, mpw* xdata, const mpw* ydata)
482 * \brief This function adds two multi-precision integers of equal size.
483 * The performed operation is in pseudocode: x += y.
484 * \param size The size of the multi-precision integers.
485 * \param xdata The first multi-precision integer.
486 * \param ydata The second multi-precision integer.
487 * \return The carry-over value of the operation; this value is either 0 or 1.
489 BEECRYPTAPI
490 int mpadd (size_t size, mpw* xdata, const mpw* ydata);
492 /*!\fn int mpaddx(size_t xsize, mpw* xdata, size_t ysize, const mpw* ydata)
493 * \brief This function adds two multi-precision integers of different size.
494 * The performed operation in pseudocode: x += y.
495 * \param xsize The size of the first multi-precision integer.
496 * \param xdata The first multi-precision integer.
497 * \param ysize The size of the second multi-precision integer.
498 * \param ydata The second multi-precision integer.
499 * \return The carry-over value of the operation; this value is either 0 or 1.
501 BEECRYPTAPI
502 int mpaddx(size_t xsize, mpw* xdata, size_t ysize, const mpw* ydata);
504 /*!\fn int mpsubw(size_t size, mpw* xdata, mpw y)
505 * \brief This function subtracts one word to a multi-precision integer.
506 * The performed operation in pseudocode: x -= y
507 * \param size The size of the multi-precision integers.
508 * \param xdata The first multi-precision integer.
509 * \param y The multi-precision word.
510 * \return The carry-over value of the operation; this value is either 0 or 1.
512 BEECRYPTAPI
513 int mpsubw(size_t size, mpw* xdata, mpw y);
515 /*!\fn int mpsub(size_t size, mpw* xdata, const mpw* ydata)
516 * \brief This function subtracts two multi-precision integers of equal size.
517 * The performed operation in pseudocode: x -= y
518 * \param size The size of the multi-precision integers.
519 * \param xdata The first multi-precision integer.
520 * \param ydata The second multi-precision integer.
521 * \return The carry-over value of the operation; this value is either 0 or 1.
523 BEECRYPTAPI
524 int mpsub (size_t size, mpw* xdata, const mpw* ydata);
526 /*!\fn int mpsubx(size_t xsize, mpw* xdata, size_t ysize, const mpw* ydata)
527 * \brief This function subtracts two multi-precision integers of different
528 * size. The performed operation in pseudocode: x -= y.
529 * \param xsize The size of the first multi-precision integer.
530 * \param xdata The first multi-precision integer.
531 * \param ysize The size of the second multi-precision integer.
532 * \param ydata The second multi-precision integer.
533 * \return The carry-over value of the operation; this value is either 0 or 1.
535 BEECRYPTAPI
536 int mpsubx(size_t xsize, mpw* xdata, size_t ysize, const mpw* ydata);
538 BEECRYPTAPI
539 int mpmultwo(size_t size, mpw* data);
541 /*!\fn void mpneg(size_t size, mpw* data)
542 * \brief This function negates a multi-precision integer.
543 * \param size The size of the multi-precision integer.
544 * \param data The multi-precision integer data.
546 BEECRYPTAPI
547 void mpneg(size_t size, mpw* data);
549 /*!\fn size_t mpsize(size_t size, const mpw* data)
550 * \brief This function returns the true size of a multi-precision
551 * integer, after stripping leading zero words.
552 * \param size The size of the multi-precision integer.
553 * \param data The multi-precision integer data.
555 BEECRYPTAPI
556 size_t mpsize(size_t size, const mpw* data);
558 /*!\fn size_t mpbits(size_t size, const mpw* data)
559 * \brief This function returns the number of significant bits
560 * in a multi-precision integer.
561 * \param size The size of the multi-precision integer.
562 * \param data The multi-precision integer data.
564 BEECRYPTAPI
565 size_t mpbits(size_t size, const mpw* data);
567 BEECRYPTAPI
568 size_t mpmszcnt(size_t size, const mpw* data);
570 BEECRYPTAPI
571 size_t mplszcnt(size_t size, const mpw* data);
573 BEECRYPTAPI
574 void mplshift(size_t size, mpw* data, size_t count);
576 BEECRYPTAPI
577 void mprshift(size_t size, mpw* data, size_t count);
579 BEECRYPTAPI
580 size_t mprshiftlsz(size_t size, mpw* data);
582 BEECRYPTAPI
583 size_t mpnorm(size_t size, mpw* data);
585 BEECRYPTAPI
586 void mpdivtwo (size_t size, mpw* data);
588 BEECRYPTAPI
589 void mpsdivtwo(size_t size, mpw* data);
591 /*!\fn mpw mpsetmul(size_t size, mpw* result, const mpw* data, mpw y)
592 * \brief This function performs a multi-precision multiply-setup.
594 * This function is used in the computation of a full multi-precision
595 * multiplication. By using it we can shave off a few cycles; otherwise we'd
596 * have to zero the least significant half of the result first and use
597 * another call to the slightly slower mpaddmul function.
599 * \param size The size of multi-precision integer multiplier.
600 * \param result The place where result will be accumulated.
601 * \param data The multi-precision integer multiplier.
602 * \param y The multiplicand.
603 * \return The carry-over multi-precision word.
605 BEECRYPTAPI
606 mpw mpsetmul (size_t size, mpw* result, const mpw* data, mpw y);
608 /*!\fn mpw mpaddmul(size_t size, mpw* result, const mpw* data, mpw y)
609 * \brief This function performs a mult-precision multiply-accumulate.
611 * This function is used in the computation of a full multi-precision
612 * multiplication. It computes the product-by-one-word and accumulates it with
613 * the previous result.
615 * \param size The size of multi-precision integer multiplier.
616 * \param result The place where result will be accumulated.
617 * \param data The multi-precision integer multiplier.
618 * \param y The multiplicand.
619 * \retval The carry-over multi-precision word.
621 BEECRYPTAPI
622 mpw mpaddmul (size_t size, mpw* result, const mpw* data, mpw y);
624 /*!\fn void mpaddsqrtrc(size_t size, mpw* result, const mpw* data)
625 * \brief This function is used in the calculation of a multi-precision
626 * squaring.
628 BEECRYPTAPI
629 void mpaddsqrtrc(size_t size, mpw* result, const mpw* data);
631 /*!\fn void mpmul(mpw* result, size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata)
632 * \brief This function computes a full multi-precision product.
634 BEECRYPTAPI
635 void mpmul(mpw* result, size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata);
637 /*!\fn void mpsqr(mpw* result, size_t size, const mpw* data)
638 * \brief This function computes a full multi-precision square.
640 BEECRYPTAPI
641 void mpsqr(mpw* result, size_t size, const mpw* data);
643 BEECRYPTAPI
644 void mpgcd_w(size_t size, const mpw* xdata, const mpw* ydata, mpw* result, mpw* wksp);
646 BEECRYPTAPI
647 int mpextgcd_w(size_t size, const mpw* xdata, const mpw* ydata, mpw* result, mpw* wksp);
649 BEECRYPTAPI
650 mpw mppndiv(mpw xhi, mpw xlo, mpw y);
652 BEECRYPTAPI
653 void mpmod (mpw* result, size_t xsize, const mpw* xdata, size_t ysize, const mpw*ydata, mpw* wksp);
655 BEECRYPTAPI
656 void mpndivmod(mpw* result, size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata, mpw* wksp);
659 * Output Routines
662 BEECRYPTAPI
663 void mpprint(size_t size, const mpw* data);
665 BEECRYPTAPI
666 void mpprintln(size_t size, const mpw* data);
668 BEECRYPTAPI
669 void mpfprint(FILE* f, size_t size, const mpw* data);
671 BEECRYPTAPI
672 void mpfprintln(FILE* f, size_t size, const mpw* data);
675 * Conversion Routines
678 BEECRYPTAPI
679 int os2ip(mpw* idata, size_t isize, const byte* osdata, size_t ossize);
681 BEECRYPTAPI
682 int i2osp(byte* osdata, size_t ossize, const mpw* idata, size_t isize);
684 BEECRYPTAPI
685 int hs2ip(mpw* idata, size_t isize, const char* hsdata, size_t hssize);
687 #ifdef __cplusplus
689 #endif
691 #endif