1 /* TomsFastMath, a fast ISO C bignum library.
3 * This project is meant to fill in where LibTomMath
4 * falls short. That is speed ;-)
6 * This project is public domain and free for all purposes.
8 * Tom St Denis, tomstdenis@gmail.com
10 #include <tfm_private.h>
12 void fp_mul_2(fp_int * a, fp_int * b)
20 register fp_digit r, rr, *tmpa, *tmpb;
22 /* alias for source */
30 for (x = 0; x < a->used; x++) {
32 /* get what will be the *next* carry bit from the
33 * MSB of the current digit
35 rr = *tmpa >> ((fp_digit)(DIGIT_BIT - 1));
37 /* now shift up this digit, add in the carry [from the previous] */
38 *tmpb++ = ((*tmpa++ << ((fp_digit)1)) | r);
40 /* copy the carry that would be from the source
41 * digit into the next iteration
46 /* new leading digit? */
47 if (r != 0 && b->used != (FP_SIZE-1)) {
48 /* add a MSB which is always 1 at this point */
53 /* now zero any excess digits on the destination
54 * that we didn't write to
56 tmpb = b->dp + b->used;
57 for (x = b->used; x < oldused; x++) {