summaryrefslogtreecommitdiff
path: root/mpi
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2011-02-04 20:21:45 +0100
committerWerner Koch <wk@gnupg.org>2011-02-04 20:21:45 +0100
commit4f048514ecae879fa4bb7b8522baf801229be522 (patch)
treed798c8527b68e83e4419c14d7c6dd47f2abdfd9e /mpi
parent9d00b28e0d04361fe9ccf02983bea781b5701c1d (diff)
downloadlibgcrypt-4f048514ecae879fa4bb7b8522baf801229be522.tar.gz
Nuked almost all trailing whitespace.post-nuke-of-trailing-ws
Check and install the standard git pre-commit hook.
Diffstat (limited to 'mpi')
-rw-r--r--mpi/ChangeLog10
-rw-r--r--mpi/Makefile.am18
-rw-r--r--mpi/config.links3
-rw-r--r--mpi/ec.c83
-rw-r--r--mpi/mpi-add.c1
-rw-r--r--mpi/mpi-bit.c13
-rw-r--r--mpi/mpi-div.c3
-rw-r--r--mpi/mpi-gcd.c3
-rw-r--r--mpi/mpi-inline.c1
-rw-r--r--mpi/mpi-internal.h1
-rw-r--r--mpi/mpi-mod.c15
-rw-r--r--mpi/mpi-mpow.c1
-rw-r--r--mpi/mpi-mul.c3
-rw-r--r--mpi/mpi-pow.c51
-rw-r--r--mpi/mpi-scan.c2
-rw-r--r--mpi/mpicoder.c67
-rw-r--r--mpi/mpih-div.c2
-rw-r--r--mpi/mpih-mul.c2
-rw-r--r--mpi/mpiutil.c19
19 files changed, 137 insertions, 161 deletions
diff --git a/mpi/ChangeLog b/mpi/ChangeLog
index 2bf3f2bf..227f4515 100644
--- a/mpi/ChangeLog
+++ b/mpi/ChangeLog
@@ -74,7 +74,7 @@
2007-10-29 Werner Koch <wk@g10code.com>
* config.links: No Candadian Cross here, thus use $host instead of
- $target.
+ $target.
2007-10-26 Werner Koch <wk@g10code.com>
@@ -95,7 +95,7 @@
2007-05-04 Werner Koch <wk@g10code.com>
- * config.links (path): Allowthe sue of colons as delimiters.
+ * config.links (path): Allowthe sue of colons as delimiters.
2007-05-03 Werner Koch <wk@g10code.com>
@@ -449,7 +449,7 @@
with _gcry_ or gcry_. Renamed also all mpihelp_ to just mpih_ so
that functions names are not getting to long an unreadable and for
better matching with the filenames.
-
+
2001-05-28 Werner Koch <wk@gnupg.org>
* mpicoder.c (mpi_fromstr): Made static and assume that all input
@@ -479,14 +479,14 @@
Major change:
Removed all GnuPG stuff and renamed this piece of software
- to gcrypt.
+ to gcrypt.
2000-11-14 Werner Koch <wk@gnupg.org>
* mpi-internal.h, mpi.h: Changed the way they are called and
introduced DID_MPI_LIMP_TYPEDEF hack. Very ugly, should all be
revamped.
-
+
* Makefile.am (OMIT_DEPENDENCIES): Hack to work around dependency
problems.
diff --git a/mpi/Makefile.am b/mpi/Makefile.am
index edfc5dfd..e900539a 100644
--- a/mpi/Makefile.am
+++ b/mpi/Makefile.am
@@ -65,7 +65,7 @@ else
if MPI_MOD_C_MPIH_ADD1
mpih_add1 = mpih-add1.c
else
-mpih_add1 =
+mpih_add1 =
endif
endif
@@ -75,7 +75,7 @@ else
if MPI_MOD_C_MPIH_SUB1
mpih_sub1 = mpih-sub1.c
else
-mpih_sub1 =
+mpih_sub1 =
endif
endif
@@ -85,7 +85,7 @@ else
if MPI_MOD_C_MPIH_MUL1
mpih_mul1 = mpih-mul1.c
else
-mpih_mul1 =
+mpih_mul1 =
endif
endif
@@ -95,7 +95,7 @@ else
if MPI_MOD_C_MPIH_MUL2
mpih_mul2 = mpih-mul2.c
else
-mpih_mul2 =
+mpih_mul2 =
endif
endif
@@ -105,7 +105,7 @@ else
if MPI_MOD_C_MPIH_MUL3
mpih_mul3 = mpih-mul3.c
else
-mpih_mul3 =
+mpih_mul3 =
endif
endif
@@ -115,7 +115,7 @@ else
if MPI_MOD_C_MPIH_LSHIFT
mpih_lshift = mpih-lshift.c
else
-mpih_lshift =
+mpih_lshift =
endif
endif
@@ -125,7 +125,7 @@ else
if MPI_MOD_C_MPIH_RSHIFT
mpih_rshift = mpih-rshift.c
else
-mpih_rshift =
+mpih_rshift =
endif
endif
@@ -135,7 +135,7 @@ else
if MPI_MOD_C_UDIV
udiv = udiv.c
else
-udiv =
+udiv =
endif
endif
@@ -145,7 +145,7 @@ else
if MPI_MOD_C_UDIV_QRNND
udiv_qrnnd = udiv-qrnnd.c
else
-udiv_qrnnd =
+udiv_qrnnd =
endif
endif
diff --git a/mpi/config.links b/mpi/config.links
index 79506379..7e910ee3 100644
--- a/mpi/config.links
+++ b/mpi/config.links
@@ -310,7 +310,7 @@ fi
mpi_required_modules=$mpi_standard_modules
if test "$mpi_extra_modules" != ""; then
for fn in $mpi_extra_modules; do
- for i in $mpi_optional_modules; do
+ for i in $mpi_optional_modules; do
if test "$fn" = "$i" ; then
mpi_required_modules="$mpi_required_modules $fn"
fi
@@ -358,4 +358,3 @@ for dir in $path ; do
break;
fi
done
-
diff --git a/mpi/ec.c b/mpi/ec.c
index 4a3a5f8c..e3253580 100644
--- a/mpi/ec.c
+++ b/mpi/ec.c
@@ -2,17 +2,17 @@
Copyright (C) 2007 Free Software Foundation, Inc.
This file is part of Libgcrypt.
-
+
Libgcrypt is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of
the License, or (at your option) any later version.
-
+
Libgcrypt is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
@@ -54,7 +54,7 @@ struct mpi_ec_ctx_s
/* Scratch variables. */
gcry_mpi_t scratch[11];
-
+
/* Helper for fast reduction. */
/* int nist_nbits; /\* If this is a NIST curve, the number of bits. *\/ */
/* gcry_mpi_t s[10]; */
@@ -177,7 +177,7 @@ ec_mulm (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, mpi_ec_t ctx)
i = 0; } while (0)
#define X(a) do { sp[i++] = wp[(a)];} while (0)
#define X0(a) do { sp[i++] = 0; } while (0)
- NEXT(0);
+ NEXT(0);
X(0);X(1);X(2);X(3);X(4);X(5);X(6);X(7);X(8);X(9);X(10);X(11);
NEXT(1);
X0();X0();X0();X0();X(21);X(22);X(23);X0();X0();X0();X0();X0();
@@ -239,10 +239,10 @@ ec_invm (gcry_mpi_t x, gcry_mpi_t a, mpi_ec_t ctx)
/* This function returns a new context for elliptic curve based on the
field GF(p). P is the prime specifying thuis field, A is the first
- coefficient.
+ coefficient.
This context needs to be released using _gcry_mpi_ec_free. */
-mpi_ec_t
+mpi_ec_t
_gcry_mpi_ec_init (gcry_mpi_t p, gcry_mpi_t a)
{
int i;
@@ -392,7 +392,7 @@ _gcry_mpi_ec_dup_point (mpi_point_t *result, mpi_point_t *point, mpi_ec_t ctx)
#define l3 (ctx->scratch[5])
if (!mpi_cmp_ui (point->y, 0) || !mpi_cmp_ui (point->z, 0))
- {
+ {
/* P_y == 0 || P_z == 0 => [1:1:0] */
mpi_set_ui (x3, 1);
mpi_set_ui (y3, 1);
@@ -401,29 +401,29 @@ _gcry_mpi_ec_dup_point (mpi_point_t *result, mpi_point_t *point, mpi_ec_t ctx)
else
{
if (ctx->a_is_pminus3) /* Use the faster case. */
- {
+ {
/* L1 = 3(X - Z^2)(X + Z^2) */
/* T1: used for Z^2. */
/* T2: used for the right term. */
- ec_powm (t1, point->z, ctx->two, ctx);
- ec_subm (l1, point->x, t1, ctx);
+ ec_powm (t1, point->z, ctx->two, ctx);
+ ec_subm (l1, point->x, t1, ctx);
ec_mulm (l1, l1, ctx->three, ctx);
- ec_addm (t2, point->x, t1, ctx);
- ec_mulm (l1, l1, t2, ctx);
+ ec_addm (t2, point->x, t1, ctx);
+ ec_mulm (l1, l1, t2, ctx);
}
else /* Standard case. */
{
/* L1 = 3X^2 + aZ^4 */
/* T1: used for aZ^4. */
- ec_powm (l1, point->x, ctx->two, ctx);
- ec_mulm (l1, l1, ctx->three, ctx);
- ec_powm (t1, point->z, ctx->four, ctx);
- ec_mulm (t1, t1, ctx->a, ctx);
- ec_addm (l1, l1, t1, ctx);
+ ec_powm (l1, point->x, ctx->two, ctx);
+ ec_mulm (l1, l1, ctx->three, ctx);
+ ec_powm (t1, point->z, ctx->four, ctx);
+ ec_mulm (t1, t1, ctx->a, ctx);
+ ec_addm (l1, l1, t1, ctx);
}
/* Z3 = 2YZ */
ec_mulm (z3, point->y, point->z, ctx);
- ec_mulm (z3, z3, ctx->two, ctx);
+ ec_mulm (z3, z3, ctx->two, ctx);
/* L2 = 4XY^2 */
/* T2: used for Y2; required later. */
@@ -436,10 +436,10 @@ _gcry_mpi_ec_dup_point (mpi_point_t *result, mpi_point_t *point, mpi_ec_t ctx)
ec_powm (x3, l1, ctx->two, ctx);
ec_mulm (t1, l2, ctx->two, ctx);
ec_subm (x3, x3, t1, ctx);
-
+
/* L3 = 8Y^4 */
/* T2: taken from above. */
- ec_powm (t2, t2, ctx->two, ctx);
+ ec_powm (t2, t2, ctx->two, ctx);
ec_mulm (l3, t2, ctx->eight, ctx);
/* Y3 = L1(L2 - X3) - L3 */
@@ -463,8 +463,8 @@ _gcry_mpi_ec_dup_point (mpi_point_t *result, mpi_point_t *point, mpi_ec_t ctx)
/* RESULT = P1 + P2 */
void
-_gcry_mpi_ec_add_points (mpi_point_t *result,
- mpi_point_t *p1, mpi_point_t *p2,
+_gcry_mpi_ec_add_points (mpi_point_t *result,
+ mpi_point_t *p1, mpi_point_t *p2,
mpi_ec_t ctx)
{
#define x1 (p1->x )
@@ -518,14 +518,14 @@ _gcry_mpi_ec_add_points (mpi_point_t *result,
mpi_set (l1, x1);
else
{
- ec_powm (l1, z2, ctx->two, ctx);
+ ec_powm (l1, z2, ctx->two, ctx);
ec_mulm (l1, l1, x1, ctx);
}
if (z1_is_one)
mpi_set (l2, x1);
else
{
- ec_powm (l2, z1, ctx->two, ctx);
+ ec_powm (l2, z1, ctx->two, ctx);
ec_mulm (l2, l2, x2, ctx);
}
/* l3 = l1 - l2 */
@@ -620,16 +620,16 @@ _gcry_mpi_ec_mul_point (mpi_point_t *result,
nbits = mpi_get_nbits (scalar);
mpi_set_ui (result->x, 1);
mpi_set_ui (result->y, 1);
- mpi_set_ui (result->z, 0);
+ mpi_set_ui (result->z, 0);
for (i=nbits-1; i >= 0; i--)
{
_gcry_mpi_ec_dup_point (result, result, ctx);
if (mpi_test_bit (scalar, i) == 1)
- _gcry_mpi_ec_add_points (result, result, point, ctx);
+ _gcry_mpi_ec_add_points (result, result, point, ctx);
}
-#else
+#else
gcry_mpi_t x1, y1, z1, k, h, yy;
unsigned int i, loops;
mpi_point_t p1, p2, p1inv;
@@ -638,16 +638,16 @@ _gcry_mpi_ec_mul_point (mpi_point_t *result,
y1 = mpi_alloc_like (ctx->p);
h = mpi_alloc_like (ctx->p);
k = mpi_copy (scalar);
- yy = mpi_copy (point->y);
+ yy = mpi_copy (point->y);
if ( mpi_is_neg (k) )
- {
+ {
k->sign = 0;
ec_invm (yy, yy, ctx);
}
if (!mpi_cmp_ui (point->z, 1))
- {
+ {
mpi_set (x1, point->x);
mpi_set (y1, yy);
}
@@ -657,12 +657,12 @@ _gcry_mpi_ec_mul_point (mpi_point_t *result,
z2 = mpi_alloc_like (ctx->p);
z3 = mpi_alloc_like (ctx->p);
- ec_mulm (z2, point->z, point->z, ctx);
- ec_mulm (z3, point->z, z2, ctx);
- ec_invm (z2, z2, ctx);
+ ec_mulm (z2, point->z, point->z, ctx);
+ ec_mulm (z3, point->z, z2, ctx);
+ ec_invm (z2, z2, ctx);
ec_mulm (x1, point->x, z2, ctx);
- ec_invm (z3, z3, ctx);
- ec_mulm (y1, yy, z3, ctx);
+ ec_invm (z3, z3, ctx);
+ ec_mulm (y1, yy, z3, ctx);
mpi_free (z2);
mpi_free (z3);
}
@@ -673,7 +673,7 @@ _gcry_mpi_ec_mul_point (mpi_point_t *result,
mpi_set (result->x, point->x);
mpi_set (result->y, yy); mpi_free (yy); yy = NULL;
- mpi_set (result->z, point->z);
+ mpi_set (result->z, point->z);
p1.x = x1; x1 = NULL;
p1.y = y1; y1 = NULL;
@@ -682,12 +682,12 @@ _gcry_mpi_ec_mul_point (mpi_point_t *result,
point_init (&p1inv);
for (i=loops-2; i > 0; i--)
- {
+ {
_gcry_mpi_ec_dup_point (result, result, ctx);
if (mpi_test_bit (h, i) == 1 && mpi_test_bit (k, i) == 0)
- {
+ {
point_set (&p2, result);
- _gcry_mpi_ec_add_points (result, &p2, &p1, ctx);
+ _gcry_mpi_ec_add_points (result, &p2, &p1, ctx);
}
if (mpi_test_bit (h, i) == 0 && mpi_test_bit (k, i) == 1)
{
@@ -695,7 +695,7 @@ _gcry_mpi_ec_mul_point (mpi_point_t *result,
/* Invert point: y = p - y mod p */
point_set (&p1inv, &p1);
ec_subm (p1inv.y, ctx->p, p1inv.y, ctx);
- _gcry_mpi_ec_add_points (result, &p2, &p1inv, ctx);
+ _gcry_mpi_ec_add_points (result, &p2, &p1inv, ctx);
}
}
@@ -706,4 +706,3 @@ _gcry_mpi_ec_mul_point (mpi_point_t *result,
mpi_free (k);
#endif
}
-
diff --git a/mpi/mpi-add.c b/mpi/mpi-add.c
index ada257ae..98abc565 100644
--- a/mpi/mpi-add.c
+++ b/mpi/mpi-add.c
@@ -233,4 +233,3 @@ gcry_mpi_subm( gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m)
gcry_mpi_sub(w, u, v);
_gcry_mpi_fdiv_r( w, w, m );
}
-
diff --git a/mpi/mpi-bit.c b/mpi/mpi-bit.c
index dbfdfcfa..cdc6b0b3 100644
--- a/mpi/mpi-bit.c
+++ b/mpi/mpi-bit.c
@@ -120,7 +120,7 @@ gcry_mpi_set_bit( gcry_mpi_t a, unsigned int n )
limbno = n / BITS_PER_MPI_LIMB;
bitno = n % BITS_PER_MPI_LIMB;
- if ( limbno >= a->nlimbs )
+ if ( limbno >= a->nlimbs )
{
mpi_resize (a, limbno+1 );
a->nlimbs = limbno+1;
@@ -135,12 +135,12 @@ void
gcry_mpi_set_highbit( gcry_mpi_t a, unsigned int n )
{
unsigned int limbno, bitno;
-
+
limbno = n / BITS_PER_MPI_LIMB;
bitno = n % BITS_PER_MPI_LIMB;
-
- if ( limbno >= a->nlimbs )
- {
+
+ if ( limbno >= a->nlimbs )
+ {
mpi_resize (a, limbno+1 );
a->nlimbs = limbno+1;
}
@@ -276,7 +276,7 @@ gcry_mpi_rshift ( gcry_mpi_t x, gcry_mpi_t a, unsigned int n )
x->sign = a->sign;
RESIZE_IF_NEEDED (x, xsize);
x->nlimbs = xsize;
-
+
if ( xsize )
{
if (nbits )
@@ -362,4 +362,3 @@ gcry_mpi_lshift ( gcry_mpi_t x, gcry_mpi_t a, unsigned int n )
MPN_NORMALIZE (x->d, x->nlimbs);
}
-
diff --git a/mpi/mpi-div.c b/mpi/mpi-div.c
index 0d8a2d16..a6ee3006 100644
--- a/mpi/mpi-div.c
+++ b/mpi/mpi-div.c
@@ -353,6 +353,3 @@ gcry_mpi_div (gcry_mpi_t quot, gcry_mpi_t rem, gcry_mpi_t dividend, gcry_mpi_t d
else
log_bug ("mpi rounding to ceiling not yet implemented\n");
}
-
-
-
diff --git a/mpi/mpi-gcd.c b/mpi/mpi-gcd.c
index 51841e78..5cbefa12 100644
--- a/mpi/mpi-gcd.c
+++ b/mpi/mpi-gcd.c
@@ -49,6 +49,3 @@ gcry_mpi_gcd( gcry_mpi_t g, gcry_mpi_t xa, gcry_mpi_t xb )
mpi_free(b);
return !gcry_mpi_cmp_ui( g, 1);
}
-
-
-
diff --git a/mpi/mpi-inline.c b/mpi/mpi-inline.c
index fdccb8f1..39e22224 100644
--- a/mpi/mpi-inline.c
+++ b/mpi/mpi-inline.c
@@ -33,4 +33,3 @@
* of the macro allows us to do so
*/
#include "mpi-inline.h"
-
diff --git a/mpi/mpi-internal.h b/mpi/mpi-internal.h
index f9c1f9d4..e75b7c6d 100644
--- a/mpi/mpi-internal.h
+++ b/mpi/mpi-internal.h
@@ -275,4 +275,3 @@ mpi_limb_t _gcry_mpih_rshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize,
#endif
#endif /*G10_MPI_INTERNAL_H*/
-
diff --git a/mpi/mpi-mod.c b/mpi/mpi-mod.c
index 948bf231..7ebfe6dc 100644
--- a/mpi/mpi-mod.c
+++ b/mpi/mpi-mod.c
@@ -3,17 +3,17 @@
2007 Free Software Foundation, Inc.
This file is part of Libgcrypt.
-
+
Libgcrypt is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of
the License, or (at your option) any later version.
-
+
Libgcrypt is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
@@ -35,7 +35,7 @@ struct barrett_ctx_s
gcry_mpi_t m; /* The modulus - may not be modified. */
int m_copied; /* If true, M needs to be released. */
int k;
- gcry_mpi_t y;
+ gcry_mpi_t y;
gcry_mpi_t r1; /* Helper MPI. */
gcry_mpi_t r2; /* Helper MPI. */
gcry_mpi_t r3; /* Helper MPI allocated on demand. */
@@ -56,7 +56,7 @@ _gcry_mpi_mod (gcry_mpi_t rem, gcry_mpi_t dividend, gcry_mpi_t divisor)
_gcry_mpi_barrett_free. If COPY is true M will be transferred to
the context and the user may change M. If COPY is false, M may not
be changed until gcry_mpi_barrett_free has been called. */
-mpi_barrett_t
+mpi_barrett_t
_gcry_mpi_barrett_init (gcry_mpi_t m, int copy)
{
mpi_barrett_t ctx;
@@ -137,7 +137,7 @@ _gcry_mpi_mod_barrett (gcry_mpi_t r, gcry_mpi_t x, mpi_barrett_t ctx)
/* 1. q1 = floor( x / b^k-1)
* q2 = q1 * y
* q3 = floor( q2 / b^k+1 )
- * Actually, we don't need qx, we can work direct on r2
+ * Actually, we don't need qx, we can work direct on r2
*/
mpi_set ( r2, x );
mpi_rshift_limbs ( r2, k-1 );
@@ -167,7 +167,7 @@ _gcry_mpi_mod_barrett (gcry_mpi_t r, gcry_mpi_t x, mpi_barrett_t ctx)
}
mpi_add ( r, r, ctx->r3 );
}
-
+
/* 4. while r >= m do r = r - m */
while ( mpi_cmp( r, m ) >= 0 )
mpi_sub ( r, r, m );
@@ -182,4 +182,3 @@ _gcry_mpi_mul_barrett (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v,
gcry_mpi_mul (w, u, v);
mpi_mod_barrett (w, w, ctx);
}
-
diff --git a/mpi/mpi-mpow.c b/mpi/mpi-mpow.c
index 131c5b67..ca5b3f18 100644
--- a/mpi/mpi-mpow.c
+++ b/mpi/mpi-mpow.c
@@ -221,4 +221,3 @@ calc_barrett( gcry_mpi_t r, gcry_mpi_t x, gcry_mpi_t m, gcry_mpi_t y, int k, gcr
return 0;
}
#endif /* USE_BARRETT */
-
diff --git a/mpi/mpi-mul.c b/mpi/mpi-mul.c
index 25aeaa0a..9aefd217 100644
--- a/mpi/mpi-mul.c
+++ b/mpi/mpi-mul.c
@@ -144,7 +144,7 @@ gcry_mpi_mul( gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v)
wsize = usize + vsize;
if ( !mpi_is_secure (w) && (mpi_is_secure (u) || mpi_is_secure (v)) ) {
/* w is not allocated in secure space but u or v is. To make sure
- * that no temporray results are stored in w, we temporary use
+ * that no temporray results are stored in w, we temporary use
* a newly allocated limb space for w */
wp = mpi_alloc_limb_space( wsize, 1 );
assign_wp = 2; /* mark it as 2 so that we can later copy it back to
@@ -210,4 +210,3 @@ gcry_mpi_mulm( gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m)
gcry_mpi_mul(w, u, v);
_gcry_mpi_fdiv_r( w, w, m );
}
-
diff --git a/mpi/mpi-pow.c b/mpi/mpi-pow.c
index ca7ead02..fbdb7ce5 100644
--- a/mpi/mpi-pow.c
+++ b/mpi/mpi-pow.c
@@ -37,7 +37,7 @@
* RES = BASE ^ EXPO mod MOD
*/
void
-gcry_mpi_powm (gcry_mpi_t res,
+gcry_mpi_powm (gcry_mpi_t res,
gcry_mpi_t base, gcry_mpi_t expo, gcry_mpi_t mod)
{
/* Pointer to the limbs of the arguments, their size and signs. */
@@ -45,7 +45,7 @@ gcry_mpi_powm (gcry_mpi_t res,
mpi_size_t esize, msize, bsize, rsize;
int msign, bsign, rsign;
/* Flags telling the secure allocation status of the arguments. */
- int esec, msec, bsec, rsec;
+ int esec, msec, bsec, rsec;
/* Size of the result including space for temporary values. */
mpi_size_t size;
/* Helper. */
@@ -60,14 +60,14 @@ gcry_mpi_powm (gcry_mpi_t res,
unsigned int ep_nlimbs = 0;
unsigned int xp_nlimbs = 0;
mpi_ptr_t tspace = NULL;
- mpi_size_t tsize = 0;
+ mpi_size_t tsize = 0;
esize = expo->nlimbs;
msize = mod->nlimbs;
size = 2 * msize;
msign = mod->sign;
-
+
esec = mpi_is_secure(expo);
msec = mpi_is_secure(mod);
bsec = mpi_is_secure(base);
@@ -79,7 +79,7 @@ gcry_mpi_powm (gcry_mpi_t res,
if (!msize)
msize = 1 / msize; /* Provoke a signal. */
- if (!esize)
+ if (!esize)
{
/* Exponent is zero, result is 1 mod MOD, i.e., 1 or 0 depending
on if MOD equals 1. */
@@ -103,7 +103,7 @@ gcry_mpi_powm (gcry_mpi_t res,
bsize = base->nlimbs;
bsign = base->sign;
- if (bsize > msize)
+ if (bsize > msize)
{
/* The base is larger than the module. Reduce it.
@@ -147,7 +147,7 @@ gcry_mpi_powm (gcry_mpi_t res,
ep = ep_marker = mpi_alloc_limb_space( esize, esec );
MPN_COPY(ep, rp, esize);
}
- if ( rp == mp )
+ if ( rp == mp )
{
/* RES and MOD are identical. Allocate temporary space for MOD.*/
gcry_assert (!mp_marker);
@@ -165,7 +165,7 @@ gcry_mpi_powm (gcry_mpi_t res,
MPN_COPY ( rp, bp, bsize );
rsize = bsize;
rsign = bsign;
-
+
/* Main processing. */
{
mpi_size_t i;
@@ -174,13 +174,13 @@ gcry_mpi_powm (gcry_mpi_t res,
mpi_limb_t e;
mpi_limb_t carry_limb;
struct karatsuba_ctx karactx;
-
+
xp_nlimbs = msec? (2 * (msize + 1)):0;
xp = xp_marker = mpi_alloc_limb_space( 2 * (msize + 1), msec );
-
+
memset( &karactx, 0, sizeof karactx );
negative_result = (ep[0] & 1) && base->sign;
-
+
i = esize - 1;
e = ep[i];
count_leading_zeros (c, e);
@@ -188,7 +188,7 @@ gcry_mpi_powm (gcry_mpi_t res,
c = BITS_PER_MPI_LIMB - 1 - c;
/* Main loop.
-
+
Make the result be pointed to alternately by XP and RP. This
helps us avoid block copying, which would otherwise be
necessary with the overlap restrictions of
@@ -197,17 +197,17 @@ gcry_mpi_powm (gcry_mpi_t res,
and with 50% probability in the area originally pointed to by XP. */
for (;;)
{
- while (c)
+ while (c)
{
mpi_ptr_t tp;
mpi_size_t xsize;
-
+
/*mpih_mul_n(xp, rp, rp, rsize);*/
if ( rsize < KARATSUBA_THRESHOLD )
_gcry_mpih_sqr_n_basecase( xp, rp, rsize );
- else
+ else
{
- if ( !tspace )
+ if ( !tspace )
{
tsize = 2 * rsize;
tspace = mpi_alloc_limb_space( tsize, 0 );
@@ -234,19 +234,19 @@ gcry_mpi_powm (gcry_mpi_t res,
if ( (mpi_limb_signed_t)e < 0 )
{
/*mpih_mul( xp, rp, rsize, bp, bsize );*/
- if( bsize < KARATSUBA_THRESHOLD )
+ if( bsize < KARATSUBA_THRESHOLD )
_gcry_mpih_mul ( xp, rp, rsize, bp, bsize );
- else
+ else
_gcry_mpih_mul_karatsuba_case (xp, rp, rsize, bp, bsize,
&karactx);
-
+
xsize = rsize + bsize;
- if ( xsize > msize )
+ if ( xsize > msize )
{
_gcry_mpih_divrem(xp + msize, 0, xp, xsize, mp, msize);
xsize = msize;
}
-
+
tp = rp; rp = xp; xp = tp;
rsize = xsize;
}
@@ -267,7 +267,7 @@ gcry_mpi_powm (gcry_mpi_t res,
Also make sure the result is put in RES->d (where it already
might be, see above). */
- if ( mod_shift_cnt )
+ if ( mod_shift_cnt )
{
carry_limb = _gcry_mpih_lshift( res->d, rp, rsize, mod_shift_cnt);
rp = res->d;
@@ -283,7 +283,7 @@ gcry_mpi_powm (gcry_mpi_t res,
rp = res->d;
}
- if ( rsize >= msize )
+ if ( rsize >= msize )
{
_gcry_mpih_divrem(rp + msize, 0, rp, rsize, mp, msize);
rsize = msize;
@@ -293,7 +293,7 @@ gcry_mpi_powm (gcry_mpi_t res,
if ( mod_shift_cnt )
_gcry_mpih_rshift( rp, rp, rsize, mod_shift_cnt);
MPN_NORMALIZE (rp, rsize);
-
+
_gcry_mpih_release_karatsuba_ctx (&karactx );
}
@@ -310,7 +310,7 @@ gcry_mpi_powm (gcry_mpi_t res,
gcry_assert (res->d == rp);
res->nlimbs = rsize;
res->sign = rsign;
-
+
leave:
if (mp_marker)
_gcry_mpi_free_limb_space( mp_marker, mp_nlimbs );
@@ -323,4 +323,3 @@ gcry_mpi_powm (gcry_mpi_t res,
if (tspace)
_gcry_mpi_free_limb_space( tspace, 0 );
}
-
diff --git a/mpi/mpi-scan.c b/mpi/mpi-scan.c
index 90699cdd..2473cd9b 100644
--- a/mpi/mpi-scan.c
+++ b/mpi/mpi-scan.c
@@ -128,5 +128,3 @@ _gcry_mpi_trailing_zeros( gcry_mpi_t a )
return count;
}
-
-
diff --git a/mpi/mpicoder.c b/mpi/mpicoder.c
index d73b5624..f499796d 100644
--- a/mpi/mpicoder.c
+++ b/mpi/mpicoder.c
@@ -37,7 +37,7 @@ mpi_read_from_buffer (const unsigned char *buffer, unsigned *ret_nread,
unsigned int nbits, nbytes, nlimbs, nread=0;
mpi_limb_t a;
gcry_mpi_t val = MPI_NULL;
-
+
if ( *ret_nread < 2 )
goto leave;
nbits = buffer[0] << 8 | buffer[1];
@@ -59,7 +59,7 @@ mpi_read_from_buffer (const unsigned char *buffer, unsigned *ret_nread,
for ( ; j > 0; j-- )
{
a = 0;
- for (; i < BYTES_PER_MPI_LIMB; i++ )
+ for (; i < BYTES_PER_MPI_LIMB; i++ )
{
if ( ++nread > *ret_nread )
{
@@ -74,7 +74,7 @@ mpi_read_from_buffer (const unsigned char *buffer, unsigned *ret_nread,
i = 0;
val->d[j-1] = a;
}
-
+
leave:
*ret_nread = nread;
return val;
@@ -159,7 +159,7 @@ mpi_fromstr (gcry_mpi_t val, const char *str)
c |= c2 - 'a' + 10;
else if( c2 >= 'A' && c2 <= 'F' )
c |= c2 - 'A' + 10;
- else
+ else
{
mpi_clear(val);
return 1; /* Error. */
@@ -170,7 +170,7 @@ mpi_fromstr (gcry_mpi_t val, const char *str)
i = 0;
val->d[j-1] = a;
}
-
+
return 0; /* Okay. */
}
@@ -179,7 +179,7 @@ mpi_fromstr (gcry_mpi_t val, const char *str)
Libgcrypt's logging stream. Note that one leading space but no
trailing space or linefeed will be printed. It is okay to pass
NULL for A. */
-void
+void
gcry_mpi_dump (const gcry_mpi_t a)
{
int i;
@@ -187,7 +187,7 @@ gcry_mpi_dump (const gcry_mpi_t a)
log_printf (" ");
if (!a)
log_printf ("[MPI_NULL]");
- else
+ else
{
if (a->sign)
log_printf ( "-");
@@ -235,7 +235,7 @@ do_get_buffer (gcry_mpi_t a, unsigned int *nbytes, int *sign, int force_secure)
mpi_limb_t alimb;
int i;
size_t n;
-
+
if (sign)
*sign = a->sign;
@@ -304,12 +304,12 @@ _gcry_mpi_set_buffer (gcry_mpi_t a, const void *buffer_arg,
mpi_limb_t alimb;
int nlimbs;
int i;
-
+
nlimbs = (nbytes + BYTES_PER_MPI_LIMB - 1) / BYTES_PER_MPI_LIMB;
RESIZE_IF_NEEDED(a, nlimbs);
a->sign = sign;
-
- for (i=0, p = buffer+nbytes-1; p >= buffer+BYTES_PER_MPI_LIMB; )
+
+ for (i=0, p = buffer+nbytes-1; p >= buffer+BYTES_PER_MPI_LIMB; )
{
#if BYTES_PER_MPI_LIMB == 4
alimb = *p-- ;
@@ -383,7 +383,7 @@ gcry_mpi_scan (struct gcry_mpi **ret_mpi, enum gcry_mpi_format format,
len = 0;
else
len = buflen;
-
+
if (format == GCRYMPI_FMT_STD)
{
const unsigned char *s = buffer;
@@ -392,7 +392,7 @@ gcry_mpi_scan (struct gcry_mpi **ret_mpi, enum gcry_mpi_format format,
/BYTES_PER_MPI_LIMB)
: mpi_alloc ((len+BYTES_PER_MPI_LIMB-1)/BYTES_PER_MPI_LIMB);
if (len)
- {
+ {
a->sign = !!(*s & 0x80);
if (a->sign)
{
@@ -450,7 +450,7 @@ gcry_mpi_scan (struct gcry_mpi **ret_mpi, enum gcry_mpi_format format,
{
const unsigned char *s = buffer;
size_t n;
-
+
/* This test is not strictly necessary and an assert (!len)
would be sufficient. We keep this test in case we later
allow the BUFLEN argument to act as a sanitiy check. Same
@@ -459,7 +459,7 @@ gcry_mpi_scan (struct gcry_mpi **ret_mpi, enum gcry_mpi_format format,
return gcry_error (GPG_ERR_TOO_SHORT);
n = (s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]);
- s += 4;
+ s += 4;
if (len)
len -= 4;
if (len && n > len)
@@ -495,7 +495,7 @@ gcry_mpi_scan (struct gcry_mpi **ret_mpi, enum gcry_mpi_format format,
{
/* We can only handle C strings for now. */
if (buflen)
- return gcry_error (GPG_ERR_INV_ARG);
+ return gcry_error (GPG_ERR_INV_ARG);
a = secure? mpi_alloc_secure (0) : mpi_alloc(0);
if (mpi_fromstr (a, (const char *)buffer))
@@ -503,7 +503,7 @@ gcry_mpi_scan (struct gcry_mpi **ret_mpi, enum gcry_mpi_format format,
mpi_free (a);
return gcry_error (GPG_ERR_INV_OBJ);
}
- if (ret_mpi)
+ if (ret_mpi)
{
mpi_normalize ( a );
*ret_mpi = a;
@@ -531,18 +531,18 @@ gcry_mpi_print (enum gcry_mpi_format format,
unsigned int nbits = mpi_get_nbits (a);
size_t len;
size_t dummy_nwritten;
-
+
if (!nwritten)
nwritten = &dummy_nwritten;
len = buflen;
*nwritten = 0;
- if (format == GCRYMPI_FMT_STD)
+ if (format == GCRYMPI_FMT_STD)
{
unsigned char *tmp;
int extra = 0;
unsigned int n;
-
+
if (a->sign)
return gcry_error (GPG_ERR_INTERNAL); /* Can't handle it yet. */
@@ -554,12 +554,12 @@ gcry_mpi_print (enum gcry_mpi_format format,
n++;
extra=1;
}
-
+
if (buffer && n > len)
{
/* The provided buffer is too short. */
gcry_free (tmp);
- return gcry_error (GPG_ERR_TOO_SHORT);
+ return gcry_error (GPG_ERR_TOO_SHORT);
}
if (buffer)
{
@@ -598,10 +598,10 @@ gcry_mpi_print (enum gcry_mpi_format format,
else if (format == GCRYMPI_FMT_PGP)
{
unsigned int n = (nbits + 7)/8;
-
+
/* The PGP format can only handle unsigned integers. */
if( a->sign )
- return gcry_error (GPG_ERR_INV_ARG);
+ return gcry_error (GPG_ERR_INV_ARG);
if (buffer && n+2 > len)
return gcry_error (GPG_ERR_TOO_SHORT);
@@ -613,7 +613,7 @@ gcry_mpi_print (enum gcry_mpi_format format,
s[0] = nbits >> 8;
s[1] = nbits;
-
+
tmp = _gcry_mpi_get_buffer (a, &n, NULL);
if (!tmp)
return gpg_error_from_syserror ();
@@ -628,10 +628,10 @@ gcry_mpi_print (enum gcry_mpi_format format,
unsigned char *tmp;
int extra = 0;
unsigned int n;
-
+
if (a->sign)
return gcry_error (GPG_ERR_INTERNAL); /* Can't handle it yet. */
-
+
tmp = _gcry_mpi_get_buffer (a, &n, NULL);
if (!tmp)
return gpg_error_from_syserror ();
@@ -650,14 +650,14 @@ gcry_mpi_print (enum gcry_mpi_format format,
if (buffer)
{
unsigned char *s = buffer;
-
+
*s++ = n >> 24;
*s++ = n >> 16;
*s++ = n >> 8;
*s++ = n;
if (extra)
*s++ = 0;
-
+
memcpy (s, tmp, n-extra);
}
gcry_free (tmp);
@@ -670,7 +670,7 @@ gcry_mpi_print (enum gcry_mpi_format format,
int i;
int extra = 0;
unsigned int n = 0;
-
+
tmp = _gcry_mpi_get_buffer (a, &n, NULL);
if (!tmp)
return gpg_error_from_syserror ();
@@ -693,7 +693,7 @@ gcry_mpi_print (enum gcry_mpi_format format,
*s++ = '0';
*s++ = '0';
}
-
+
for (i=0; i < n; i++)
{
unsigned int c = tmp[i];
@@ -705,7 +705,7 @@ gcry_mpi_print (enum gcry_mpi_format format,
*s++ = 0;
*nwritten = s - buffer;
}
- else
+ else
{
*nwritten = 2*n + extra + !!a->sign + 1;
}
@@ -729,7 +729,7 @@ gcry_mpi_aprint (enum gcry_mpi_format format,
{
size_t n;
gcry_error_t rc;
-
+
*buffer = NULL;
rc = gcry_mpi_print (format, NULL, 0, &n, a);
if (rc)
@@ -748,4 +748,3 @@ gcry_mpi_aprint (enum gcry_mpi_format format,
*nwritten = n;
return rc;
}
-
diff --git a/mpi/mpih-div.c b/mpi/mpih-div.c
index e41e205e..224b8108 100644
--- a/mpi/mpih-div.c
+++ b/mpi/mpih-div.c
@@ -531,5 +531,3 @@ _gcry_mpih_divmod_1( mpi_ptr_t quot_ptr,
return r;
}
}
-
-
diff --git a/mpi/mpih-mul.c b/mpi/mpih-mul.c
index e1f6f58e..b8e05617 100644
--- a/mpi/mpih-mul.c
+++ b/mpi/mpih-mul.c
@@ -526,5 +526,3 @@ _gcry_mpih_mul( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t usize,
_gcry_mpih_release_karatsuba_ctx( &ctx );
return *prod_endp;
}
-
-
diff --git a/mpi/mpiutil.c b/mpi/mpiutil.c
index 950e4ea5..76630a62 100644
--- a/mpi/mpiutil.c
+++ b/mpi/mpiutil.c
@@ -100,7 +100,7 @@ _gcry_mpi_free_limb_space( mpi_ptr_t a, unsigned int nlimbs)
if (a)
{
size_t len = nlimbs * sizeof(mpi_limb_t);
-
+
/* If we have information on the number of allocated limbs, we
better wipe that space out. This is a failsafe feature if
secure memory has been disabled or was not properly
@@ -137,7 +137,7 @@ _gcry_mpi_resize (gcry_mpi_t a, unsigned nlimbs)
limb space is already of the correct size. */
for (i=a->nlimbs; i < a->alloced; i++)
a->d[i] = 0;
- return;
+ return;
}
/* Actually resize the limb space. */
@@ -207,12 +207,12 @@ mpi_set_secure( gcry_mpi_t a )
gcry_mpi_t
gcry_mpi_set_opaque( gcry_mpi_t a, void *p, unsigned int nbits )
{
- if (!a)
+ if (!a)
a = mpi_alloc(0);
-
+
if( a->flags & 4 )
gcry_free( a->d );
- else
+ else
_gcry_mpi_free_limb_space (a->d, a->alloced);
a->d = p;
@@ -302,7 +302,7 @@ gcry_mpi_set( gcry_mpi_t w, gcry_mpi_t u)
mpi_ptr_t wp, up;
mpi_size_t usize = u->nlimbs;
int usign = u->sign;
-
+
if (!w)
w = _gcry_mpi_alloc( mpi_get_nlimbs(u) );
RESIZE_IF_NEEDED(w, usize);
@@ -346,7 +346,7 @@ _gcry_mpi_get_ui (gcry_mpi_t w, unsigned long *u)
if (! err)
*u = x;
-
+
return err;
}
@@ -356,7 +356,7 @@ gcry_mpi_get_ui (gcry_mpi_t w, unsigned long *u)
gcry_err_code_t err = GPG_ERR_NO_ERROR;
err = _gcry_mpi_get_ui (w, u);
-
+
return gcry_error (err);
}
@@ -406,7 +406,7 @@ gcry_mpi_randomize( gcry_mpi_t w,
{
unsigned char *p;
size_t nbytes = (nbits+7)/8;
-
+
if (level == GCRY_WEAK_RANDOM)
{
p = mpi_is_secure(w) ? gcry_xmalloc_secure (nbytes)
@@ -458,4 +458,3 @@ gcry_mpi_get_flag( gcry_mpi_t a, enum gcry_mpi_flag flag )
/*NOTREACHED*/
return 0;
}
-