]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Source/CyaSSL/ctaocrypt/src/fp_sqr_comba_7.i
Add FreeRTOS-Plus directory with new directory structure so it matches the FreeRTOS...
[freertos] / FreeRTOS-Plus / Source / CyaSSL / ctaocrypt / src / fp_sqr_comba_7.i
1 /* fp_sqr_comba_7.i
2  *
3  * Copyright (C) 2006-2011 Sawtooth Consulting Ltd.
4  *
5  * This file is part of CyaSSL.
6  *
7  * CyaSSL is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * CyaSSL is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
20  */
21
22
23 #ifdef TFM_SQR7
24 void fp_sqr_comba7(fp_int *A, fp_int *B)
25 {
26    fp_digit *a, b[14], c0, c1, c2, sc0, sc1, sc2;
27
28    a = A->dp;
29    COMBA_START; 
30
31    /* clear carries */
32    CLEAR_CARRY;
33
34    /* output 0 */
35    SQRADD(a[0],a[0]);
36    COMBA_STORE(b[0]);
37
38    /* output 1 */
39    CARRY_FORWARD;
40    SQRADD2(a[0], a[1]); 
41    COMBA_STORE(b[1]);
42
43    /* output 2 */
44    CARRY_FORWARD;
45    SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); 
46    COMBA_STORE(b[2]);
47
48    /* output 3 */
49    CARRY_FORWARD;
50    SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); 
51    COMBA_STORE(b[3]);
52
53    /* output 4 */
54    CARRY_FORWARD;
55    SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); 
56    COMBA_STORE(b[4]);
57
58    /* output 5 */
59    CARRY_FORWARD;
60    SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; 
61    COMBA_STORE(b[5]);
62
63    /* output 6 */
64    CARRY_FORWARD;
65    SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); 
66    COMBA_STORE(b[6]);
67
68    /* output 7 */
69    CARRY_FORWARD;
70    SQRADDSC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; 
71    COMBA_STORE(b[7]);
72
73    /* output 8 */
74    CARRY_FORWARD;
75    SQRADD2(a[2], a[6]); SQRADD2(a[3], a[5]); SQRADD(a[4], a[4]); 
76    COMBA_STORE(b[8]);
77
78    /* output 9 */
79    CARRY_FORWARD;
80    SQRADD2(a[3], a[6]); SQRADD2(a[4], a[5]); 
81    COMBA_STORE(b[9]);
82
83    /* output 10 */
84    CARRY_FORWARD;
85    SQRADD2(a[4], a[6]); SQRADD(a[5], a[5]); 
86    COMBA_STORE(b[10]);
87
88    /* output 11 */
89    CARRY_FORWARD;
90    SQRADD2(a[5], a[6]); 
91    COMBA_STORE(b[11]);
92
93    /* output 12 */
94    CARRY_FORWARD;
95    SQRADD(a[6], a[6]); 
96    COMBA_STORE(b[12]);
97    COMBA_STORE2(b[13]);
98    COMBA_FINI;
99
100    B->used = 14;
101    B->sign = FP_ZPOS;
102    memcpy(B->dp, b, 14 * sizeof(fp_digit));
103    fp_clamp(B);
104 }
105 #endif
106
107