]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Source/WolfSSL/ctaocrypt/src/fp_sqr_comba_4.i
Rename the CyaSSL directory to WolfSSL
[freertos] / FreeRTOS-Plus / Source / WolfSSL / ctaocrypt / src / fp_sqr_comba_4.i
1 /* fp_sqr_comba_4.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_SQR4
24 void fp_sqr_comba4(fp_int *A, fp_int *B)
25 {
26    fp_digit *a, b[8], c0, c1, c2;
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[1], a[3]); SQRADD(a[2], a[2]); 
59    COMBA_STORE(b[4]);
60
61    /* output 5 */
62    CARRY_FORWARD;
63    SQRADD2(a[2], a[3]); 
64    COMBA_STORE(b[5]);
65
66    /* output 6 */
67    CARRY_FORWARD;
68    SQRADD(a[3], a[3]); 
69    COMBA_STORE(b[6]);
70    COMBA_STORE2(b[7]);
71    COMBA_FINI;
72
73    B->used = 8;
74    B->sign = FP_ZPOS;
75    memcpy(B->dp, b, 8 * sizeof(fp_digit));
76    fp_clamp(B);
77 }
78 #endif
79
80