1 /* $NetBSD: bn_mp_sqr.c,v 1.1.1.2 2014/04/24 12:45:31 pettai Exp $ */
5 /* LibTomMath, multiple-precision integer library -- Tom St Denis
7 * LibTomMath is a library that provides multiple-precision
8 * integer arithmetic as well as number theoretic functionality.
10 * The library was designed directly after the MPI library by
11 * Michael Fromberger but has been written from scratch with
12 * additional optimizations in place.
14 * The library is free for all purposes without any express
17 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
20 /* computes b = a*a */
22 mp_sqr (mp_int
* a
, mp_int
* b
)
26 #ifdef BN_MP_TOOM_SQR_C
28 if (a
->used
>= TOOM_SQR_CUTOFF
) {
29 res
= mp_toom_sqr(a
, b
);
33 #ifdef BN_MP_KARATSUBA_SQR_C
34 if (a
->used
>= KARATSUBA_SQR_CUTOFF
) {
35 res
= mp_karatsuba_sqr (a
, b
);
39 #ifdef BN_FAST_S_MP_SQR_C
40 /* can we use the fast comba multiplier? */
41 if ((a
->used
* 2 + 1) < MP_WARRAY
&&
43 (1 << (sizeof(mp_word
) * CHAR_BIT
- 2*DIGIT_BIT
- 1))) {
44 res
= fast_s_mp_sqr (a
, b
);
48 res
= s_mp_sqr (a
, b
);
58 /* Source: /cvs/libtom/libtommath/bn_mp_sqr.c,v */
60 /* Date: 2006/12/28 01:25:13 */