summaryrefslogtreecommitdiffstats
path: root/libtommath/bn_fast_s_mp_mul_digs.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-09-18 08:31:55 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-09-18 08:31:55 (GMT)
commita187f65cfd5964971d7ed52f09e18fdbb4bf51cc (patch)
tree6b7bbde03122d1571d4543d10eccfe88610bd680 /libtommath/bn_fast_s_mp_mul_digs.c
parent0faaca01de4e9fa2039c7fdd34f60b138f665249 (diff)
parent30f7e69b182d1267056ee2628a860891f6555aa3 (diff)
downloadtcl-a187f65cfd5964971d7ed52f09e18fdbb4bf51cc.zip
tcl-a187f65cfd5964971d7ed52f09e18fdbb4bf51cc.tar.gz
tcl-a187f65cfd5964971d7ed52f09e18fdbb4bf51cc.tar.bz2
Merge libtommath upstream changes (astyle formatting only). No functional changes. All Tcl-specific modifications are kept.
Diffstat (limited to 'libtommath/bn_fast_s_mp_mul_digs.c')
-rw-r--r--libtommath/bn_fast_s_mp_mul_digs.c80
1 files changed, 40 insertions, 40 deletions
diff --git a/libtommath/bn_fast_s_mp_mul_digs.c b/libtommath/bn_fast_s_mp_mul_digs.c
index 641b574..558d151 100644
--- a/libtommath/bn_fast_s_mp_mul_digs.c
+++ b/libtommath/bn_fast_s_mp_mul_digs.c
@@ -17,39 +17,39 @@
/* Fast (comba) multiplier
*
- * This is the fast column-array [comba] multiplier. It is
- * designed to compute the columns of the product first
- * then handle the carries afterwards. This has the effect
+ * This is the fast column-array [comba] multiplier. It is
+ * designed to compute the columns of the product first
+ * then handle the carries afterwards. This has the effect
* of making the nested loops that compute the columns very
* simple and schedulable on super-scalar processors.
*
- * This has been modified to produce a variable number of
- * digits of output so if say only a half-product is required
- * you don't have to compute the upper half (a feature
+ * This has been modified to produce a variable number of
+ * digits of output so if say only a half-product is required
+ * you don't have to compute the upper half (a feature
* required for fast Barrett reduction).
*
* Based on Algorithm 14.12 on pp.595 of HAC.
*
*/
-int fast_s_mp_mul_digs (const mp_int * a, const mp_int * b, mp_int * c, int digs)
+int fast_s_mp_mul_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs)
{
- int olduse, res, pa, ix, iz;
- mp_digit W[MP_WARRAY];
- mp_word _W;
+ int olduse, res, pa, ix, iz;
+ mp_digit W[MP_WARRAY];
+ mp_word _W;
- /* grow the destination as required */
- if (c->alloc < digs) {
- if ((res = mp_grow (c, digs)) != MP_OKAY) {
- return res;
- }
- }
+ /* grow the destination as required */
+ if (c->alloc < digs) {
+ if ((res = mp_grow(c, digs)) != MP_OKAY) {
+ return res;
+ }
+ }
- /* number of output digits to produce */
- pa = MIN(digs, a->used + b->used);
+ /* number of output digits to produce */
+ pa = MIN(digs, a->used + b->used);
- /* clear the carry */
- _W = 0;
- for (ix = 0; ix < pa; ix++) {
+ /* clear the carry */
+ _W = 0;
+ for (ix = 0; ix < pa; ix++) {
int tx, ty;
int iy;
mp_digit *tmpx, *tmpy;
@@ -62,7 +62,7 @@ int fast_s_mp_mul_digs (const mp_int * a, const mp_int * b, mp_int * c, int digs
tmpx = a->dp + tx;
tmpy = b->dp + ty;
- /* this is the number of times the loop will iterrate, essentially
+ /* this is the number of times the loop will iterrate, essentially
while (tx++ < a->used && ty-- >= 0) { ... }
*/
iy = MIN(a->used-tx, ty+1);
@@ -78,27 +78,27 @@ int fast_s_mp_mul_digs (const mp_int * a, const mp_int * b, mp_int * c, int digs
/* make next carry */
_W = _W >> ((mp_word)DIGIT_BIT);
- }
+ }
- /* setup dest */
- olduse = c->used;
- c->used = pa;
+ /* setup dest */
+ olduse = c->used;
+ c->used = pa;
- {
- mp_digit *tmpc;
- tmpc = c->dp;
- for (ix = 0; ix < (pa + 1); ix++) {
- /* now extract the previous digit [below the carry] */
- *tmpc++ = W[ix];
- }
+ {
+ mp_digit *tmpc;
+ tmpc = c->dp;
+ for (ix = 0; ix < (pa + 1); ix++) {
+ /* now extract the previous digit [below the carry] */
+ *tmpc++ = W[ix];
+ }
- /* clear unused digits [that existed in the old copy of c] */
- for (; ix < olduse; ix++) {
- *tmpc++ = 0;
- }
- }
- mp_clamp (c);
- return MP_OKAY;
+ /* clear unused digits [that existed in the old copy of c] */
+ for (; ix < olduse; ix++) {
+ *tmpc++ = 0;
+ }
+ }
+ mp_clamp(c);
+ return MP_OKAY;
}
#endif