]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Source/CyaSSL/ctaocrypt/src/fp_sqr_comba_6.i
Final commit before tagging - cosmetic changes only.
[freertos] / FreeRTOS-Plus / Source / CyaSSL / ctaocrypt / src / fp_sqr_comba_6.i
1 /* fp_sqr_comba_6.i
2  *
3  * Copyright (C) 2006-2014 wolfSSL Inc.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21
22
23 #ifdef TFM_SQR6
24 void fp_sqr_comba6(fp_int *A, fp_int *B)
25 {
26    fp_digit *a, b[12], c0, c1, c2, sc0, sc1, sc2;
27 #ifdef TFM_ISO
28    fp_word tt;
29 #endif
30
31    a = A->dp;
32    COMBA_START; 
33
34    /* clear carries */
35    CLEAR_CARRY;
36
37    /* output 0 */
38    SQRADD(a[0],a[0]);
39    COMBA_STORE(b[0]);
40
41    /* output 1 */
42    CARRY_FORWARD;
43    SQRADD2(a[0], a[1]); 
44    COMBA_STORE(b[1]);
45
46    /* output 2 */
47    CARRY_FORWARD;
48    SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); 
49    COMBA_STORE(b[2]);
50
51    /* output 3 */
52    CARRY_FORWARD;
53    SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); 
54    COMBA_STORE(b[3]);
55
56    /* output 4 */
57    CARRY_FORWARD;
58    SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); 
59    COMBA_STORE(b[4]);
60
61    /* output 5 */
62    CARRY_FORWARD;
63    SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; 
64    COMBA_STORE(b[5]);
65
66    /* output 6 */
67    CARRY_FORWARD;
68    SQRADD2(a[1], a[5]); SQRADD2(a[2], a[4]); SQRADD(a[3], a[3]); 
69    COMBA_STORE(b[6]);
70
71    /* output 7 */
72    CARRY_FORWARD;
73    SQRADD2(a[2], a[5]); SQRADD2(a[3], a[4]); 
74    COMBA_STORE(b[7]);
75
76    /* output 8 */
77    CARRY_FORWARD;
78    SQRADD2(a[3], a[5]); SQRADD(a[4], a[4]); 
79    COMBA_STORE(b[8]);
80
81    /* output 9 */
82    CARRY_FORWARD;
83    SQRADD2(a[4], a[5]); 
84    COMBA_STORE(b[9]);
85
86    /* output 10 */
87    CARRY_FORWARD;
88    SQRADD(a[5], a[5]); 
89    COMBA_STORE(b[10]);
90    COMBA_STORE2(b[11]);
91    COMBA_FINI;
92
93    B->used = 12;
94    B->sign = FP_ZPOS;
95    memcpy(B->dp, b, 12 * sizeof(fp_digit));
96    fp_clamp(B);
97 }
98 #endif
99
100