1
/* LibTomMath, multiple-precision integer library -- Tom St Denis
3
* LibTomMath is a library that provides multiple-precision
4
* integer arithmetic as well as number theoretic functionality.
6
* The library was designed directly after the MPI library by
7
* Michael Fromberger but has been written from scratch with
8
* additional optimizations in place.
10
* The library is free for all purposes without any express
13
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
17
/* computes b = a*a */
19
mp_sqr (mp_int * a, mp_int * b)
24
if (a->used >= TOOM_SQR_CUTOFF) {
25
res = mp_toom_sqr(a, b);
28
#ifndef NO_LTM_KARATSUBA
30
if (a->used >= KARATSUBA_SQR_CUTOFF) {
31
res = mp_karatsuba_sqr (a, b);
35
/* can we use the fast comba multiplier? */
36
if ((a->used * 2 + 1) < MP_WARRAY &&
38
(1 << (sizeof(mp_word) * CHAR_BIT - 2*DIGIT_BIT - 1))) {
39
res = fast_s_mp_sqr (a, b);
41
res = s_mp_sqr (a, b);