Don't cast the potential problems away, handle them appropriately
This commit is contained in:
parent
5bed36d997
commit
1c1baaa755
@ -270,7 +270,9 @@ int mp_div (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (d != NULL) {
|
if (d != NULL) {
|
||||||
(void)mp_div_2d (&x, norm, &x, NULL);
|
if ((res = mp_div_2d (&x, norm, &x, NULL)) != MP_OKAY) {
|
||||||
|
goto LBL_Y;
|
||||||
|
}
|
||||||
mp_exch (&x, d);
|
mp_exch (&x, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,9 @@ top:
|
|||||||
* Each successive "recursion" makes the input smaller and smaller.
|
* Each successive "recursion" makes the input smaller and smaller.
|
||||||
*/
|
*/
|
||||||
if (mp_cmp_mag (x, n) != MP_LT) {
|
if (mp_cmp_mag (x, n) != MP_LT) {
|
||||||
(void)s_mp_sub(x, n, x);
|
if ((err = s_mp_sub(x, n, x)) != MP_OKAY) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
goto top;
|
goto top;
|
||||||
}
|
}
|
||||||
return MP_OKAY;
|
return MP_OKAY;
|
||||||
|
@ -61,9 +61,9 @@ int mp_exteuclid(mp_int *a, mp_int *b, mp_int *U1, mp_int *U2, mp_int *U3)
|
|||||||
|
|
||||||
/* make sure U3 >= 0 */
|
/* make sure U3 >= 0 */
|
||||||
if (u3.sign == MP_NEG) {
|
if (u3.sign == MP_NEG) {
|
||||||
(void)mp_neg(&u1, &u1);
|
if ((err = mp_neg(&u1, &u1)) != MP_OKAY) { goto _ERR; }
|
||||||
(void)mp_neg(&u2, &u2);
|
if ((err = mp_neg(&u2, &u2)) != MP_OKAY) { goto _ERR; }
|
||||||
(void)mp_neg(&u3, &u3);
|
if ((err = mp_neg(&u3, &u3)) != MP_OKAY) { goto _ERR; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy result out */
|
/* copy result out */
|
||||||
|
@ -45,7 +45,9 @@ top:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mp_cmp_mag(a, n) != MP_LT) {
|
if (mp_cmp_mag(a, n) != MP_LT) {
|
||||||
(void)s_mp_sub(a, n, a);
|
if ((res = s_mp_sub(a, n, a)) != MP_OKAY) {
|
||||||
|
goto ERR;
|
||||||
|
}
|
||||||
goto top;
|
goto top;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,9 @@ top:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mp_cmp_mag(a, n) != MP_LT) {
|
if (mp_cmp_mag(a, n) != MP_LT) {
|
||||||
(void)s_mp_sub(a, n, a);
|
if ((res = s_mp_sub(a, n, a)) != MP_OKAY) {
|
||||||
|
goto ERR;
|
||||||
|
}
|
||||||
goto top;
|
goto top;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,9 @@ int mp_toom_mul(mp_int *a, mp_int *b, mp_int *c)
|
|||||||
goto ERR;
|
goto ERR;
|
||||||
}
|
}
|
||||||
mp_rshd(&a1, B);
|
mp_rshd(&a1, B);
|
||||||
(void)mp_mod_2d(&a1, DIGIT_BIT * B, &a1);
|
if ((res = mp_mod_2d(&a1, DIGIT_BIT * B, &a1)) != MP_OKAY) {
|
||||||
|
goto ERR;
|
||||||
|
}
|
||||||
|
|
||||||
if ((res = mp_copy(a, &a2)) != MP_OKAY) {
|
if ((res = mp_copy(a, &a2)) != MP_OKAY) {
|
||||||
goto ERR;
|
goto ERR;
|
||||||
|
@ -39,7 +39,9 @@ mp_toom_sqr(mp_int *a, mp_int *b)
|
|||||||
goto ERR;
|
goto ERR;
|
||||||
}
|
}
|
||||||
mp_rshd(&a1, B);
|
mp_rshd(&a1, B);
|
||||||
(void)mp_mod_2d(&a1, DIGIT_BIT * B, &a1);
|
if ((res = mp_mod_2d(&a1, DIGIT_BIT * B, &a1)) != MP_OKAY) {
|
||||||
|
goto ERR;
|
||||||
|
}
|
||||||
|
|
||||||
if ((res = mp_copy(a, &a2)) != MP_OKAY) {
|
if ((res = mp_copy(a, &a2)) != MP_OKAY) {
|
||||||
goto ERR;
|
goto ERR;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user