The unified diff between revisions [0dc5b2d6..] and [b14c94b9..] is displayed below. It can also be downloaded as a raw diff.
This diff has been restricted to the following files: 'bn_mp_exptmod_fast.c'
#
#
# patch "bn_mp_exptmod_fast.c"
# from [ec6cb8ea6c2dde8b87493bd481a51c9f8f946ede]
# to [0c597499c614a4fc38dbf06574749138133f69b2]
#
============================================================
--- bn_mp_exptmod_fast.c ec6cb8ea6c2dde8b87493bd481a51c9f8f946ede
+++ bn_mp_exptmod_fast.c 0c597499c614a4fc38dbf06574749138133f69b2
@@ -29,8 +29,7 @@
#define TAB_SIZE 256
#endif
-int
-mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode)
+int mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode)
{
mp_int M[TAB_SIZE], res;
mp_digit buf, mp;
@@ -88,11 +87,11 @@ mp_exptmod_fast (mp_int * G, mp_int * X,
#ifdef BN_MP_MONTGOMERY_SETUP_C
/* now setup montgomery */
if ((err = mp_montgomery_setup (P, &mp)) != MP_OKAY) {
- goto __M;
+ goto LBL_M;
}
#else
err = MP_VAL;
- goto __M;
+ goto LBL_M;
#endif
/* automatically pick the comba one if available (saves quite a few calls/ifs) */
@@ -108,7 +107,7 @@ mp_exptmod_fast (mp_int * G, mp_int * X,
redux = mp_montgomery_reduce;
#else
err = MP_VAL;
- goto __M;
+ goto LBL_M;
#endif
}
} else if (redmode == 1) {
@@ -118,24 +117,24 @@ mp_exptmod_fast (mp_int * G, mp_int * X,
redux = mp_dr_reduce;
#else
err = MP_VAL;
- goto __M;
+ goto LBL_M;
#endif
} else {
#if defined(BN_MP_REDUCE_2K_SETUP_C) && defined(BN_MP_REDUCE_2K_C)
/* setup DR reduction for moduli of the form 2**k - b */
if ((err = mp_reduce_2k_setup(P, &mp)) != MP_OKAY) {
- goto __M;
+ goto LBL_M;
}
redux = mp_reduce_2k;
#else
err = MP_VAL;
- goto __M;
+ goto LBL_M;
#endif
}
/* setup result */
if ((err = mp_init (&res)) != MP_OKAY) {
- goto __M;
+ goto LBL_M;
}
/* create M table
@@ -149,45 +148,45 @@ mp_exptmod_fast (mp_int * G, mp_int * X,
#ifdef BN_MP_MONTGOMERY_CALC_NORMALIZATION_C
/* now we need R mod m */
if ((err = mp_montgomery_calc_normalization (&res, P)) != MP_OKAY) {
- goto __RES;
+ goto LBL_RES;
}
#else
err = MP_VAL;
- goto __RES;
+ goto LBL_RES;
#endif
/* now set M[1] to G * R mod m */
if ((err = mp_mulmod (G, &res, P, &M[1])) != MP_OKAY) {
- goto __RES;
+ goto LBL_RES;
}
} else {
mp_set(&res, 1);
if ((err = mp_mod(G, P, &M[1])) != MP_OKAY) {
- goto __RES;
+ goto LBL_RES;
}
}
/* compute the value at M[1<<(winsize-1)] by squaring M[1] (winsize-1) times */
if ((err = mp_copy (&M[1], &M[1 << (winsize - 1)])) != MP_OKAY) {
- goto __RES;
+ goto LBL_RES;
}
for (x = 0; x < (winsize - 1); x++) {
if ((err = mp_sqr (&M[1 << (winsize - 1)], &M[1 << (winsize - 1)])) != MP_OKAY) {
- goto __RES;
+ goto LBL_RES;
}
if ((err = redux (&M[1 << (winsize - 1)], P, mp)) != MP_OKAY) {
- goto __RES;
+ goto LBL_RES;
}
}
/* create upper table */
for (x = (1 << (winsize - 1)) + 1; x < (1 << winsize); x++) {
if ((err = mp_mul (&M[x - 1], &M[1], &M[x])) != MP_OKAY) {
- goto __RES;
+ goto LBL_RES;
}
if ((err = redux (&M[x], P, mp)) != MP_OKAY) {
- goto __RES;
+ goto LBL_RES;
}
}
@@ -227,10 +226,10 @@ mp_exptmod_fast (mp_int * G, mp_int * X,
/* if the bit is zero and mode == 1 then we square */
if (mode == 1 && y == 0) {
if ((err = mp_sqr (&res, &res)) != MP_OKAY) {
- goto __RES;
+ goto LBL_RES;
}
if ((err = redux (&res, P, mp)) != MP_OKAY) {
- goto __RES;
+ goto LBL_RES;
}
continue;
}
@@ -244,19 +243,19 @@ mp_exptmod_fast (mp_int * G, mp_int * X,
/* square first */
for (x = 0; x < winsize; x++) {
if ((err = mp_sqr (&res, &res)) != MP_OKAY) {
- goto __RES;
+ goto LBL_RES;
}
if ((err = redux (&res, P, mp)) != MP_OKAY) {
- goto __RES;
+ goto LBL_RES;
}
}
/* then multiply */
if ((err = mp_mul (&res, &M[bitbuf], &res)) != MP_OKAY) {
- goto __RES;
+ goto LBL_RES;
}
if ((err = redux (&res, P, mp)) != MP_OKAY) {
- goto __RES;
+ goto LBL_RES;
}
/* empty window and reset */
@@ -271,10 +270,10 @@ mp_exptmod_fast (mp_int * G, mp_int * X,
/* square then multiply if the bit is set */
for (x = 0; x < bitcpy; x++) {
if ((err = mp_sqr (&res, &res)) != MP_OKAY) {
- goto __RES;
+ goto LBL_RES;
}
if ((err = redux (&res, P, mp)) != MP_OKAY) {
- goto __RES;
+ goto LBL_RES;
}
/* get next bit of the window */
@@ -282,10 +281,10 @@ mp_exptmod_fast (mp_int * G, mp_int * X,
if ((bitbuf & (1 << winsize)) != 0) {
/* then multiply */
if ((err = mp_mul (&res, &M[1], &res)) != MP_OKAY) {
- goto __RES;
+ goto LBL_RES;
}
if ((err = redux (&res, P, mp)) != MP_OKAY) {
- goto __RES;
+ goto LBL_RES;
}
}
}
@@ -299,15 +298,15 @@ mp_exptmod_fast (mp_int * G, mp_int * X,
* of R.
*/
if ((err = redux(&res, P, mp)) != MP_OKAY) {
- goto __RES;
+ goto LBL_RES;
}
}
/* swap res with Y */
mp_exch (&res, Y);
err = MP_OKAY;
-__RES:mp_clear (&res);
-__M:
+LBL_RES:mp_clear (&res);
+LBL_M:
mp_clear(&M[1]);
for (x = 1<<(winsize-1); x < (1 << winsize); x++) {
mp_clear (&M[x]);