The unified diff between revisions [0578ae2c..] and [adf974cb..] is displayed below. It can also be downloaded as a raw diff.
#
#
# patch "dbutil.c"
# from [8b79072ae93e76c7e59fa171a92875efe2713abe]
# to [46f91aa47ad63006772ef99b27898bcf0ac5b6f1]
#
# patch "libtommath/bn_mp_exptmod.c"
# from [5834ec7efb5ce20b64f84e8015eaa59bfd93f090]
# to [367cb261dd16705dbc90fb13dc687b7c47810c9b]
#
# patch "libtommath/bn_mp_exptmod_fast.c"
# from [0c597499c614a4fc38dbf06574749138133f69b2]
# to [6180b2ea74c26856dd590bbcdbf2ec47dbda7ca0]
#
============================================================
--- dbutil.c 8b79072ae93e76c7e59fa171a92875efe2713abe
+++ dbutil.c 46f91aa47ad63006772ef99b27898bcf0ac5b6f1
@@ -482,10 +482,6 @@ void printhex(const char * label, const
int i;
- if (!debug_trace) {
- return;
- }
-
fprintf(stderr, "%s\n", label);
for (i = 0; i < len; i++) {
fprintf(stderr, "%02x", buf[i]);
@@ -504,10 +500,6 @@ void print_mp_int(const char * label, mp
int size;
char * buf = NULL;
- if (!debug_trace) {
- return;
- }
-
fprintf(stderr, "mp_int %s: ", label);
ret = mp_radix_size(mp, 10, &size);
dropbear_assert(ret == MP_OKAY);
============================================================
--- libtommath/bn_mp_exptmod.c 5834ec7efb5ce20b64f84e8015eaa59bfd93f090
+++ libtommath/bn_mp_exptmod.c 367cb261dd16705dbc90fb13dc687b7c47810c9b
@@ -1,3 +1,4 @@
+#include "../dbutil.h"
#include <tommath.h>
#ifdef BN_MP_EXPTMOD_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
============================================================
--- libtommath/bn_mp_exptmod_fast.c 0c597499c614a4fc38dbf06574749138133f69b2
+++ libtommath/bn_mp_exptmod_fast.c 6180b2ea74c26856dd590bbcdbf2ec47dbda7ca0
@@ -1,3 +1,4 @@
+#include "../dbutil.h"
#include <tommath.h>
#ifdef BN_MP_EXPTMOD_FAST_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
@@ -65,6 +66,8 @@ int mp_exptmod_fast (mp_int * G, mp_int
}
#endif
+ dropbear_trace("mp_exptmod_fast x bits %d redmode %d", x, redmode);
+
/* init M array */
/* init first cell */
if ((err = mp_init(&M[1])) != MP_OKAY) {
@@ -210,6 +213,8 @@ int mp_exptmod_fast (mp_int * G, mp_int
bitcnt = (int)DIGIT_BIT;
}
+ dropbear_trace("mp_exptmod_fast digidx %d buf %u", digidx+1, buf);
+
/* grab the next msb from the exponent */
y = (mp_digit)(buf >> (DIGIT_BIT - 1)) & 1;
buf <<= (mp_digit)1;
@@ -231,6 +236,7 @@ int mp_exptmod_fast (mp_int * G, mp_int
if ((err = redux (&res, P, mp)) != MP_OKAY) {
goto LBL_RES;
}
+ print_mp_int("mp_exptmod_fast bit=0 mode=1 sq", &res);
continue;
}
@@ -263,6 +269,7 @@ int mp_exptmod_fast (mp_int * G, mp_int
bitbuf = 0;
mode = 1;
}
+ print_mp_int("mp_exptmod_fast other way", &res);
}
/* if bits remain then square/multiply */
@@ -289,6 +296,7 @@ int mp_exptmod_fast (mp_int * G, mp_int
}
}
}
+ print_mp_int("mp_exptmod_fast remaining bits", &res);
if (redmode == 0) {
/* fixup result if Montgomery reduction is used
@@ -300,6 +308,7 @@ int mp_exptmod_fast (mp_int * G, mp_int
if ((err = redux(&res, P, mp)) != MP_OKAY) {
goto LBL_RES;
}
+ print_mp_int("mp_exptmod_fast fixup", &res);
}
/* swap res with Y */