wnum.neg = 0;
wnum.d = &(snum->d[loop]);
wnum.top = div_n;
-#ifdef BN_DEBUG_RAND
/* only needed when BN_ucmp messes up the values between top and max */
wnum.dmax = snum->dmax - loop; /* so we don't step out of bounds */
-#endif
/* Get the top 2 words of sdiv */
/* div_n=sdiv->top; */
if (BN_ucmp(&wnum,sdiv) >= 0)
{
-#ifdef BN_DEBUG_RAND
/* If BN_DEBUG_RAND is defined BN_ucmp changes (via
* bn_pollute) the const bignum arguments =>
* clean the values between top and max again */
bn_clear_top2max(&wnum);
-#endif
bn_sub_words(wnum.d, wnum.d, sdiv->d, div_n);
*resp=1;
}
/* store part of the result */
*resp = q;
}
+ bn_correct_top(snum);
if (rm != NULL)
{
/* Keep a copy of the neg flag in num because if rm==num
* BN_rshift() will overwrite it.
*/
int neg = num->neg;
- bn_correct_top(snum);
BN_rshift(rm,snum,norm_shift);
if (!BN_is_zero(rm))
rm->neg = neg;
#define Lw(t) (((BN_ULONG)(t))&BN_MASK2)
#define Hw(t) (((BN_ULONG)((t)>>BN_BITS2))&BN_MASK2)
-
+#ifdef BN_DEBUG_RAND
#define bn_clear_top2max(a) \
{ \
int ind = (a)->dmax - (a)->top; \
for (; ind != 0; ind--) \
*(++ftl) = 0x0; \
}
+#else
+#define bn_clear_top2max(a)
+#endif
#ifdef BN_LLONG
#define mul_add(r,a,w,c) { \
--carry;
}
r->top = BN_NIST_192_TOP;
-
-#if 1
- bn_clear_top2max(r);
-#endif
bn_correct_top(r);
-
if (BN_ucmp(r, field) >= 0)
{
bn_sub_words(r_d, r_d, _nist_p_192, BN_NIST_192_TOP);
}
r->top = BN_NIST_224_TOP;
-#if 1
- bn_clear_top2max(r);
-#endif
bn_correct_top(r);
-
if (BN_ucmp(r, field) >= 0)
{
bn_sub_words(r_d, r_d, _nist_p_224, BN_NIST_224_TOP);
}
r->top = BN_NIST_256_TOP;
-#if 1
- bn_clear_top2max(r);
-#endif
bn_correct_top(r);
-
if (BN_ucmp(r, field) >= 0)
{
bn_sub_words(r_d, r_d, _nist_p_256, BN_NIST_256_TOP);
}
r->top = BN_NIST_384_TOP;
-#if 1
- bn_clear_top2max(r);
-#endif
bn_correct_top(r);
-
if (BN_ucmp(r, field) >= 0)
{
bn_sub_words(r_d, r_d, _nist_p_384, BN_NIST_384_TOP);