Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / nettle / x86_64 / sha256-compress.asm
blob385654c2d2725aec7ebc63cd8cf9b8bea2008829
1 C nettle, low-level cryptographics library
3 C Copyright (C) 2013 Niels Möller
5 C The nettle library is free software; you can redistribute it and/or modify
6 C it under the terms of the GNU Lesser General Public License as published by
7 C the Free Software Foundation; either version 2.1 of the License, or (at your
8 C option) any later version.
10 C The nettle library is distributed in the hope that it will be useful, but
11 C WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 C or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
13 C License for more details.
15 C You should have received a copy of the GNU Lesser General Public License
16 C along with the nettle library; see the file COPYING.LIB. If not, write to
17 C the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18 C MA 02111-1301, USA.
20 .file "sha256-compress.asm"
21 define(<STATE>, <%rdi>)
22 define(<INPUT>, <%rsi>)
23 define(<K>, <%rdx>)
24 define(<SA>, <%eax>)
25 define(<SB>, <%ebx>)
26 define(<SC>, <%ecx>)
27 define(<SD>, <%r8d>)
28 define(<SE>, <%r9d>)
29 define(<SF>, <%r10d>)
30 define(<SG>, <%r11d>)
31 define(<SH>, <%r12d>)
32 define(<T0>, <%r13d>)
33 define(<T1>, <%edi>) C Overlap STATE
34 define(<COUNT>, <%r14>)
35 define(<W>, <%r15d>)
37 define(<EXPN>, <
38 movl OFFSET($1)(%rsp), W
39 movl OFFSET(eval(($1 + 14) % 16))(%rsp), T0
40 movl T0, T1
41 shrl <$>10, T0
42 roll <$>13, T1
43 xorl T1, T0
44 roll <$>2, T1
45 xorl T1, T0
46 addl T0, W
47 movl OFFSET(eval(($1 + 1) % 16))(%rsp), T0
48 movl T0, T1
49 shrl <$>3, T0
50 roll <$>14, T1
51 xorl T1, T0
52 roll <$>11, T1
53 xorl T1, T0
54 addl T0, W
55 addl OFFSET(eval(($1 + 9) % 16))(%rsp), W
56 movl W, OFFSET($1)(%rsp)
59 C ROUND(A,B,C,D,E,F,G,H,K)
61 C H += S1(E) + Choice(E,F,G) + K + W
62 C D += H
63 C H += S0(A) + Majority(A,B,C)
65 C Where
67 C S1(E) = E<<<26 ^ E<<<21 ^ E<<<7
68 C S0(A) = A<<<30 ^ A<<<19 ^ A<<<10
69 C Choice (E, F, G) = G^(E&(F^G))
70 C Majority (A,B,C) = (A&B) + (C&(A^B))
72 define(<ROUND>, <
73 movl $5, T0
74 movl $5, T1
75 roll <$>7, T0
76 roll <$>21, T1
77 xorl T0, T1
78 roll <$>19, T0
79 xorl T0, T1
80 addl W, $8
81 addl T1, $8
82 movl $7, T0
83 xorl $6, T0
84 andl $5, T0
85 xorl $7, T0
86 addl OFFSET($9)(K,COUNT,4), $8
87 addl T0, $8
88 addl $8, $4
90 movl $1, T0
91 movl $1, T1
92 roll <$>10, T0
93 roll <$>19, T1
94 xorl T0, T1
95 roll <$>20, T0
96 xorl T0, T1
97 addl T1, $8
98 movl $1, T0
99 movl $1, T1
100 andl $2, T0
101 xorl $2, T1
102 addl T0, $8
103 andl $3, T1
104 addl T1, $8
107 define(<NOEXPN>, <
108 movl OFFSET($1)(INPUT, COUNT, 4), W
109 bswapl W
110 movl W, OFFSET($1)(%rsp, COUNT, 4)
113 C void
114 C _nettle_sha256_compress(uint32_t *state, const uint8_t *input, const uint32_t *k)
116 .text
117 ALIGN(16)
119 PROLOGUE(_nettle_sha256_compress)
120 W64_ENTRY(3, 0)
122 sub $120, %rsp
123 mov %rbx, 64(%rsp)
124 mov STATE, 72(%rsp) C Save state, to free a register
125 mov %rbp, 80(%rsp)
126 mov %r12, 88(%rsp)
127 mov %r13, 96(%rsp)
128 mov %r14, 104(%rsp)
129 mov %r15, 112(%rsp)
131 movl (STATE), SA
132 movl 4(STATE), SB
133 movl 8(STATE), SC
134 movl 12(STATE), SD
135 movl 16(STATE), SE
136 movl 20(STATE), SF
137 movl 24(STATE), SG
138 movl 28(STATE), SH
139 xor COUNT, COUNT
140 ALIGN(16)
142 .Loop1:
143 NOEXPN(0) ROUND(SA,SB,SC,SD,SE,SF,SG,SH,0)
144 NOEXPN(1) ROUND(SH,SA,SB,SC,SD,SE,SF,SG,1)
145 NOEXPN(2) ROUND(SG,SH,SA,SB,SC,SD,SE,SF,2)
146 NOEXPN(3) ROUND(SF,SG,SH,SA,SB,SC,SD,SE,3)
147 NOEXPN(4) ROUND(SE,SF,SG,SH,SA,SB,SC,SD,4)
148 NOEXPN(5) ROUND(SD,SE,SF,SG,SH,SA,SB,SC,5)
149 NOEXPN(6) ROUND(SC,SD,SE,SF,SG,SH,SA,SB,6)
150 NOEXPN(7) ROUND(SB,SC,SD,SE,SF,SG,SH,SA,7)
151 add $8, COUNT
152 cmp $16, COUNT
153 jne .Loop1
155 .Loop2:
156 EXPN( 0) ROUND(SA,SB,SC,SD,SE,SF,SG,SH,0)
157 EXPN( 1) ROUND(SH,SA,SB,SC,SD,SE,SF,SG,1)
158 EXPN( 2) ROUND(SG,SH,SA,SB,SC,SD,SE,SF,2)
159 EXPN( 3) ROUND(SF,SG,SH,SA,SB,SC,SD,SE,3)
160 EXPN( 4) ROUND(SE,SF,SG,SH,SA,SB,SC,SD,4)
161 EXPN( 5) ROUND(SD,SE,SF,SG,SH,SA,SB,SC,5)
162 EXPN( 6) ROUND(SC,SD,SE,SF,SG,SH,SA,SB,6)
163 EXPN( 7) ROUND(SB,SC,SD,SE,SF,SG,SH,SA,7)
164 EXPN( 8) ROUND(SA,SB,SC,SD,SE,SF,SG,SH,8)
165 EXPN( 9) ROUND(SH,SA,SB,SC,SD,SE,SF,SG,9)
166 EXPN(10) ROUND(SG,SH,SA,SB,SC,SD,SE,SF,10)
167 EXPN(11) ROUND(SF,SG,SH,SA,SB,SC,SD,SE,11)
168 EXPN(12) ROUND(SE,SF,SG,SH,SA,SB,SC,SD,12)
169 EXPN(13) ROUND(SD,SE,SF,SG,SH,SA,SB,SC,13)
170 EXPN(14) ROUND(SC,SD,SE,SF,SG,SH,SA,SB,14)
171 EXPN(15) ROUND(SB,SC,SD,SE,SF,SG,SH,SA,15)
172 add $16, COUNT
173 cmp $64, COUNT
174 jne .Loop2
176 mov 72(%rsp), STATE
178 addl SA, (STATE)
179 addl SB, 4(STATE)
180 addl SC, 8(STATE)
181 addl SD, 12(STATE)
182 addl SE, 16(STATE)
183 addl SF, 20(STATE)
184 addl SG, 24(STATE)
185 addl SH, 28(STATE)
187 mov 64(%rsp), %rbx
188 mov 80(%rsp), %rbp
189 mov 88(%rsp), %r12
190 mov 96(%rsp), %r13
191 mov 104(%rsp),%r14
192 mov 112(%rsp),%r15
194 add $120, %rsp
195 W64_EXIT(3, 0)
197 EPILOGUE(_nettle_sha256_compress)