comparison tomsfastmath/src/sqr/fp_sqr.c @ 643:a362b62d38b2 dropbear-tfm

Add tomsfastmath from git rev bfa4582842bc3bab42e4be4aed5703437049502a with Makefile.in renamed
author Matt Johnston <matt@ucc.asn.au>
date Wed, 23 Nov 2011 18:10:20 +0700
parents
children
comparison
equal deleted inserted replaced
642:33fd2f3499d2 643:a362b62d38b2
1 /* TomsFastMath, a fast ISO C bignum library.
2 *
3 * This project is meant to fill in where LibTomMath
4 * falls short. That is speed ;-)
5 *
6 * This project is public domain and free for all purposes.
7 *
8 * Tom St Denis, [email protected]
9 */
10 #include <tfm.h>
11
12 /* b = a*a */
13 void fp_sqr(fp_int *A, fp_int *B)
14 {
15 int y;
16
17 /* call generic if we're out of range */
18 if (A->used + A->used > FP_SIZE) {
19 fp_sqr_comba(A, B);
20 return ;
21 }
22
23 y = A->used;
24 #if defined(TFM_SQR3)
25 if (y <= 3) {
26 fp_sqr_comba3(A,B);
27 return;
28 }
29 #endif
30 #if defined(TFM_SQR4)
31 if (y == 4) {
32 fp_sqr_comba4(A,B);
33 return;
34 }
35 #endif
36 #if defined(TFM_SQR6)
37 if (y <= 6) {
38 fp_sqr_comba6(A,B);
39 return;
40 }
41 #endif
42 #if defined(TFM_SQR7)
43 if (y == 7) {
44 fp_sqr_comba7(A,B);
45 return;
46 }
47 #endif
48 #if defined(TFM_SQR8)
49 if (y == 8) {
50 fp_sqr_comba8(A,B);
51 return;
52 }
53 #endif
54 #if defined(TFM_SQR9)
55 if (y == 9) {
56 fp_sqr_comba9(A,B);
57 return;
58 }
59 #endif
60 #if defined(TFM_SQR12)
61 if (y <= 12) {
62 fp_sqr_comba12(A,B);
63 return;
64 }
65 #endif
66 #if defined(TFM_SQR17)
67 if (y <= 17) {
68 fp_sqr_comba17(A,B);
69 return;
70 }
71 #endif
72 #if defined(TFM_SMALL_SET)
73 if (y <= 16) {
74 fp_sqr_comba_small(A,B);
75 return;
76 }
77 #endif
78 #if defined(TFM_SQR20)
79 if (y <= 20) {
80 fp_sqr_comba20(A,B);
81 return;
82 }
83 #endif
84 #if defined(TFM_SQR24)
85 if (y <= 24) {
86 fp_sqr_comba24(A,B);
87 return;
88 }
89 #endif
90 #if defined(TFM_SQR28)
91 if (y <= 28) {
92 fp_sqr_comba28(A,B);
93 return;
94 }
95 #endif
96 #if defined(TFM_SQR32)
97 if (y <= 32) {
98 fp_sqr_comba32(A,B);
99 return;
100 }
101 #endif
102 #if defined(TFM_SQR48)
103 if (y <= 48) {
104 fp_sqr_comba48(A,B);
105 return;
106 }
107 #endif
108 #if defined(TFM_SQR64)
109 if (y <= 64) {
110 fp_sqr_comba64(A,B);
111 return;
112 }
113 #endif
114 fp_sqr_comba(A, B);
115 }
116
117
118 /* $Source$ */
119 /* $Revision$ */
120 /* $Date$ */