fix clang-tidy warnings
This commit is contained in:
parent
dc7c5226ef
commit
e491b4db2d
@ -64,10 +64,12 @@ mp_err mp_reduce(mp_int *x, const mp_int *m, const mp_int *mu)
|
|||||||
/* If x < 0, add b**(k+1) to it */
|
/* If x < 0, add b**(k+1) to it */
|
||||||
if (mp_cmp_d(x, 0uL) == MP_LT) {
|
if (mp_cmp_d(x, 0uL) == MP_LT) {
|
||||||
mp_set(&q, 1uL);
|
mp_set(&q, 1uL);
|
||||||
if ((err = mp_lshd(&q, um + 1)) != MP_OKAY)
|
if ((err = mp_lshd(&q, um + 1)) != MP_OKAY) {
|
||||||
goto CLEANUP;
|
goto CLEANUP;
|
||||||
if ((err = mp_add(x, &q, x)) != MP_OKAY)
|
}
|
||||||
|
if ((err = mp_add(x, &q, x)) != MP_OKAY) {
|
||||||
goto CLEANUP;
|
goto CLEANUP;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Back off if it's too big */
|
/* Back off if it's too big */
|
||||||
|
@ -125,8 +125,9 @@ top:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* if not zero goto step 4 */
|
/* if not zero goto step 4 */
|
||||||
if (!MP_IS_ZERO(&u))
|
if (!MP_IS_ZERO(&u)) {
|
||||||
goto top;
|
goto top;
|
||||||
|
}
|
||||||
|
|
||||||
/* now a = C, b = D, gcd == g*v */
|
/* now a = C, b = D, gcd == g*v */
|
||||||
|
|
||||||
|
@ -45,22 +45,29 @@ mp_err s_mp_karatsuba_mul(const mp_int *a, const mp_int *b, mp_int *c)
|
|||||||
B = B >> 1;
|
B = B >> 1;
|
||||||
|
|
||||||
/* init copy all the temps */
|
/* init copy all the temps */
|
||||||
if (mp_init_size(&x0, B) != MP_OKAY)
|
if (mp_init_size(&x0, B) != MP_OKAY) {
|
||||||
goto LBL_ERR;
|
goto LBL_ERR;
|
||||||
if (mp_init_size(&x1, a->used - B) != MP_OKAY)
|
}
|
||||||
|
if (mp_init_size(&x1, a->used - B) != MP_OKAY) {
|
||||||
goto X0;
|
goto X0;
|
||||||
if (mp_init_size(&y0, B) != MP_OKAY)
|
}
|
||||||
|
if (mp_init_size(&y0, B) != MP_OKAY) {
|
||||||
goto X1;
|
goto X1;
|
||||||
if (mp_init_size(&y1, b->used - B) != MP_OKAY)
|
}
|
||||||
|
if (mp_init_size(&y1, b->used - B) != MP_OKAY) {
|
||||||
goto Y0;
|
goto Y0;
|
||||||
|
}
|
||||||
|
|
||||||
/* init temps */
|
/* init temps */
|
||||||
if (mp_init_size(&t1, B * 2) != MP_OKAY)
|
if (mp_init_size(&t1, B * 2) != MP_OKAY) {
|
||||||
goto Y1;
|
goto Y1;
|
||||||
if (mp_init_size(&x0y0, B * 2) != MP_OKAY)
|
}
|
||||||
|
if (mp_init_size(&x0y0, B * 2) != MP_OKAY) {
|
||||||
goto T1;
|
goto T1;
|
||||||
if (mp_init_size(&x1y1, B * 2) != MP_OKAY)
|
}
|
||||||
|
if (mp_init_size(&x1y1, B * 2) != MP_OKAY) {
|
||||||
goto X0Y0;
|
goto X0Y0;
|
||||||
|
}
|
||||||
|
|
||||||
/* now shift the digits */
|
/* now shift the digits */
|
||||||
x0.used = y0.used = B;
|
x0.used = y0.used = B;
|
||||||
@ -103,35 +110,46 @@ mp_err s_mp_karatsuba_mul(const mp_int *a, const mp_int *b, mp_int *c)
|
|||||||
|
|
||||||
/* now calc the products x0y0 and x1y1 */
|
/* now calc the products x0y0 and x1y1 */
|
||||||
/* after this x0 is no longer required, free temp [x0==t2]! */
|
/* after this x0 is no longer required, free temp [x0==t2]! */
|
||||||
if (mp_mul(&x0, &y0, &x0y0) != MP_OKAY)
|
if (mp_mul(&x0, &y0, &x0y0) != MP_OKAY) {
|
||||||
goto X1Y1; /* x0y0 = x0*y0 */
|
goto X1Y1; /* x0y0 = x0*y0 */
|
||||||
if (mp_mul(&x1, &y1, &x1y1) != MP_OKAY)
|
}
|
||||||
|
if (mp_mul(&x1, &y1, &x1y1) != MP_OKAY) {
|
||||||
goto X1Y1; /* x1y1 = x1*y1 */
|
goto X1Y1; /* x1y1 = x1*y1 */
|
||||||
|
}
|
||||||
|
|
||||||
/* now calc x1+x0 and y1+y0 */
|
/* now calc x1+x0 and y1+y0 */
|
||||||
if (s_mp_add(&x1, &x0, &t1) != MP_OKAY)
|
if (s_mp_add(&x1, &x0, &t1) != MP_OKAY) {
|
||||||
goto X1Y1; /* t1 = x1 - x0 */
|
goto X1Y1; /* t1 = x1 - x0 */
|
||||||
if (s_mp_add(&y1, &y0, &x0) != MP_OKAY)
|
}
|
||||||
|
if (s_mp_add(&y1, &y0, &x0) != MP_OKAY) {
|
||||||
goto X1Y1; /* t2 = y1 - y0 */
|
goto X1Y1; /* t2 = y1 - y0 */
|
||||||
if (mp_mul(&t1, &x0, &t1) != MP_OKAY)
|
}
|
||||||
|
if (mp_mul(&t1, &x0, &t1) != MP_OKAY) {
|
||||||
goto X1Y1; /* t1 = (x1 + x0) * (y1 + y0) */
|
goto X1Y1; /* t1 = (x1 + x0) * (y1 + y0) */
|
||||||
|
}
|
||||||
|
|
||||||
/* add x0y0 */
|
/* add x0y0 */
|
||||||
if (mp_add(&x0y0, &x1y1, &x0) != MP_OKAY)
|
if (mp_add(&x0y0, &x1y1, &x0) != MP_OKAY) {
|
||||||
goto X1Y1; /* t2 = x0y0 + x1y1 */
|
goto X1Y1; /* t2 = x0y0 + x1y1 */
|
||||||
if (s_mp_sub(&t1, &x0, &t1) != MP_OKAY)
|
}
|
||||||
|
if (s_mp_sub(&t1, &x0, &t1) != MP_OKAY) {
|
||||||
goto X1Y1; /* t1 = (x1+x0)*(y1+y0) - (x1y1 + x0y0) */
|
goto X1Y1; /* t1 = (x1+x0)*(y1+y0) - (x1y1 + x0y0) */
|
||||||
|
}
|
||||||
|
|
||||||
/* shift by B */
|
/* shift by B */
|
||||||
if (mp_lshd(&t1, B) != MP_OKAY)
|
if (mp_lshd(&t1, B) != MP_OKAY) {
|
||||||
goto X1Y1; /* t1 = (x0y0 + x1y1 - (x1-x0)*(y1-y0))<<B */
|
goto X1Y1; /* t1 = (x0y0 + x1y1 - (x1-x0)*(y1-y0))<<B */
|
||||||
if (mp_lshd(&x1y1, B * 2) != MP_OKAY)
|
}
|
||||||
|
if (mp_lshd(&x1y1, B * 2) != MP_OKAY) {
|
||||||
goto X1Y1; /* x1y1 = x1y1 << 2*B */
|
goto X1Y1; /* x1y1 = x1y1 << 2*B */
|
||||||
|
}
|
||||||
|
|
||||||
if (mp_add(&x0y0, &t1, &t1) != MP_OKAY)
|
if (mp_add(&x0y0, &t1, &t1) != MP_OKAY) {
|
||||||
goto X1Y1; /* t1 = x0y0 + t1 */
|
goto X1Y1; /* t1 = x0y0 + t1 */
|
||||||
if (mp_add(&t1, &x1y1, c) != MP_OKAY)
|
}
|
||||||
|
if (mp_add(&t1, &x1y1, c) != MP_OKAY) {
|
||||||
goto X1Y1; /* t1 = x0y0 + t1 + x1y1 */
|
goto X1Y1; /* t1 = x0y0 + t1 + x1y1 */
|
||||||
|
}
|
||||||
|
|
||||||
/* Algorithm succeeded set the return code to MP_OKAY */
|
/* Algorithm succeeded set the return code to MP_OKAY */
|
||||||
err = MP_OKAY;
|
err = MP_OKAY;
|
||||||
|
Loading…
Reference in New Issue
Block a user