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>
13 void fp_mul_2d(fp_int *a, int b, fp_int *c)
15 fp_digit carry, carrytmp, shift;
21 /* handle whole digits */
23 fp_lshd(c, b/DIGIT_BIT);
27 /* shift the digits */
30 shift = DIGIT_BIT - b;
31 for (x = 0; x < c->used; x++) {
32 carrytmp = c->dp[x] >> shift;
33 c->dp[x] = (c->dp[x] << b) + carry;
36 /* store last carry if room */
37 if (carry && x < FP_SIZE) {
38 c->dp[c->used++] = carry;