]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Source/CyaSSL/ctaocrypt/src/fp_mul_comba_6.i
e691e98134a1c4dfa17221f15b24adcf906e4aa7
[freertos] / FreeRTOS-Plus / Source / CyaSSL / ctaocrypt / src / fp_mul_comba_6.i
1 /* fp_mul_comba_6.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_MUL6
24 void fp_mul_comba6(fp_int *A, fp_int *B, fp_int *C)
25 {
26    fp_digit c0, c1, c2, at[12];
27
28    memcpy(at, A->dp, 6 * sizeof(fp_digit));
29    memcpy(at+6, B->dp, 6 * sizeof(fp_digit));
30    COMBA_START;
31
32    COMBA_CLEAR;
33    /* 0 */
34    MULADD(at[0], at[6]); 
35    COMBA_STORE(C->dp[0]);
36    /* 1 */
37    COMBA_FORWARD;
38    MULADD(at[0], at[7]);    MULADD(at[1], at[6]); 
39    COMBA_STORE(C->dp[1]);
40    /* 2 */
41    COMBA_FORWARD;
42    MULADD(at[0], at[8]);    MULADD(at[1], at[7]);    MULADD(at[2], at[6]); 
43    COMBA_STORE(C->dp[2]);
44    /* 3 */
45    COMBA_FORWARD;
46    MULADD(at[0], at[9]);    MULADD(at[1], at[8]);    MULADD(at[2], at[7]);    MULADD(at[3], at[6]); 
47    COMBA_STORE(C->dp[3]);
48    /* 4 */
49    COMBA_FORWARD;
50    MULADD(at[0], at[10]);    MULADD(at[1], at[9]);    MULADD(at[2], at[8]);    MULADD(at[3], at[7]);    MULADD(at[4], at[6]); 
51    COMBA_STORE(C->dp[4]);
52    /* 5 */
53    COMBA_FORWARD;
54    MULADD(at[0], at[11]);    MULADD(at[1], at[10]);    MULADD(at[2], at[9]);    MULADD(at[3], at[8]);    MULADD(at[4], at[7]);    MULADD(at[5], at[6]); 
55    COMBA_STORE(C->dp[5]);
56    /* 6 */
57    COMBA_FORWARD;
58    MULADD(at[1], at[11]);    MULADD(at[2], at[10]);    MULADD(at[3], at[9]);    MULADD(at[4], at[8]);    MULADD(at[5], at[7]); 
59    COMBA_STORE(C->dp[6]);
60    /* 7 */
61    COMBA_FORWARD;
62    MULADD(at[2], at[11]);    MULADD(at[3], at[10]);    MULADD(at[4], at[9]);    MULADD(at[5], at[8]); 
63    COMBA_STORE(C->dp[7]);
64    /* 8 */
65    COMBA_FORWARD;
66    MULADD(at[3], at[11]);    MULADD(at[4], at[10]);    MULADD(at[5], at[9]); 
67    COMBA_STORE(C->dp[8]);
68    /* 9 */
69    COMBA_FORWARD;
70    MULADD(at[4], at[11]);    MULADD(at[5], at[10]); 
71    COMBA_STORE(C->dp[9]);
72    /* 10 */
73    COMBA_FORWARD;
74    MULADD(at[5], at[11]); 
75    COMBA_STORE(C->dp[10]);
76    COMBA_STORE2(C->dp[11]);
77    C->used = 12;
78    C->sign = A->sign ^ B->sign;
79    fp_clamp(C);
80    COMBA_FINI;
81 }
82 #endif