Commit 572a0c62 authored by Davide Galassi's avatar Davide Galassi

MPI square check for zero input

parent c4bc9cc1
Pipeline #137640727 passed with stages
in 7 minutes and 26 seconds
......@@ -7,11 +7,6 @@
int cry_mpi_mul_abs(cry_mpi *r, const cry_mpi *a, const cry_mpi *b)
{
if (cry_mpi_is_zero(a)) {
cry_mpi_zero(r);
return 0;
}
#ifdef CRY_MPI_MUL_TOOM3
if (CRY_MIN(a->used, b->used) > TOOM3_CUTOFF)
return cry_mpi_mul_toom3(r, a, b);
......
......@@ -6,11 +6,6 @@
int cry_mpi_sqr(cry_mpi *r, const cry_mpi *a)
{
if (cry_mpi_is_zero(a)) {
cry_mpi_zero(r);
return 0;
}
#ifdef CRY_MPI_MUL_KARATSUBA
if (a->used > KARATSUBA_CUTOFF)
return cry_mpi_sqr_karatsuba(r, a);
......
......@@ -8,6 +8,11 @@ int cry_mpi_sqr_baseline(cry_mpi *r, const cry_mpi *a)
cry_mpi_dword dd, c, ch;
cry_mpi_digit tmpx, *tmpt;
if (cry_mpi_is_zero(a)) {
cry_mpi_zero(r);
return 0;
}
pa = a->used;
if ((res = cry_mpi_init_size(&t, 2*pa + 1)) != 0)
return res;
......
......@@ -9,6 +9,11 @@ int cry_mpi_sqr_comba(cry_mpi *r, const cry_mpi *a)
cry_mpi tmp, *dst;
cry_mpi_dword cc;
if (cry_mpi_is_zero(a)) {
cry_mpi_zero(r);
return 0;
}
pa = a->used + a->used;
if (r == a) {
if ((res = cry_mpi_init_size(&tmp, pa)) != 0)
......
......@@ -6,6 +6,11 @@ int cry_mpi_sqr_karatsuba(cry_mpi *r, const cry_mpi *a)
size_t B, hB;
cry_mpi x0, x1, z0, z1, z2;
if (cry_mpi_is_zero(a)) {
cry_mpi_zero(r);
return 0;
}
/* Number of digits */
B = a->used;
/* Divide by two */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment