commit
5bb73c6f74
@ -28,6 +28,10 @@ int fast_mp_montgomery_reduce(mp_int *x, const mp_int *n, mp_digit rho)
|
|||||||
int ix, res, olduse;
|
int ix, res, olduse;
|
||||||
mp_word W[MP_WARRAY];
|
mp_word W[MP_WARRAY];
|
||||||
|
|
||||||
|
if (x->used > MP_WARRAY) {
|
||||||
|
return MP_VAL;
|
||||||
|
}
|
||||||
|
|
||||||
/* get old used count */
|
/* get old used count */
|
||||||
olduse = x->used;
|
olduse = x->used;
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ int fast_s_mp_mul_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs)
|
|||||||
{
|
{
|
||||||
mp_digit *tmpc;
|
mp_digit *tmpc;
|
||||||
tmpc = c->dp;
|
tmpc = c->dp;
|
||||||
for (ix = 0; ix < (pa + 1); ix++) {
|
for (ix = 0; ix < pa; ix++) {
|
||||||
/* now extract the previous digit [below the carry] */
|
/* now extract the previous digit [below the carry] */
|
||||||
*tmpc++ = W[ix];
|
*tmpc++ = W[ix];
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,10 @@ int mp_lshd(mp_int *a, int b)
|
|||||||
if (b <= 0) {
|
if (b <= 0) {
|
||||||
return MP_OKAY;
|
return MP_OKAY;
|
||||||
}
|
}
|
||||||
|
/* no need to shift 0 around */
|
||||||
|
if (mp_iszero(a) == MP_YES) {
|
||||||
|
return MP_OKAY;
|
||||||
|
}
|
||||||
|
|
||||||
/* grow to fit the new digits */
|
/* grow to fit the new digits */
|
||||||
if (a->alloc < (a->used + b)) {
|
if (a->alloc < (a->used + b)) {
|
||||||
|
@ -29,6 +29,7 @@ int mp_montgomery_reduce(mp_int *x, const mp_int *n, mp_digit rho)
|
|||||||
*/
|
*/
|
||||||
digs = (n->used * 2) + 1;
|
digs = (n->used * 2) + 1;
|
||||||
if ((digs < MP_WARRAY) &&
|
if ((digs < MP_WARRAY) &&
|
||||||
|
(x->used <= MP_WARRAY) &&
|
||||||
(n->used <
|
(n->used <
|
||||||
(1 << ((CHAR_BIT * sizeof(mp_word)) - (2 * DIGIT_BIT))))) {
|
(1 << ((CHAR_BIT * sizeof(mp_word)) - (2 * DIGIT_BIT))))) {
|
||||||
return fast_mp_montgomery_reduce(x, n, rho);
|
return fast_mp_montgomery_reduce(x, n, rho);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user