1 #include "tommath_private.h"
3 /* LibTomMath, multiple-precision integer library -- Tom St Denis */
4 /* SPDX-License-Identifier: Unlicense */
7 mp_err
mp_sqr(const mp_int
*a
, mp_int
*b
)
10 if (MP_HAS(S_MP_TOOM_SQR
) && /* use Toom-Cook? */
11 (a
->used
>= MP_TOOM_SQR_CUTOFF
)) {
12 err
= s_mp_toom_sqr(a
, b
);
13 } else if (MP_HAS(S_MP_KARATSUBA_SQR
) && /* Karatsuba? */
14 (a
->used
>= MP_KARATSUBA_SQR_CUTOFF
)) {
15 err
= s_mp_karatsuba_sqr(a
, b
);
16 } else if (MP_HAS(S_MP_SQR_FAST
) && /* can we use the fast comba multiplier? */
17 (((a
->used
* 2) + 1) < MP_WARRAY
) &&
18 (a
->used
< (MP_MAXFAST
/ 2))) {
19 err
= s_mp_sqr_fast(a
, b
);
20 } else if (MP_HAS(S_MP_SQR
)) {