📄 panama_8cpp-source.html
字号:
<a name="l00141"></a>00141 AS2( movdqu [WORD_REG(di)+16], xmm6)<a name="l00142"></a>00142 AS2( <span class="keyword">add</span> WORD_REG(di), 32)<a name="l00143"></a>00143 ASL(0)<a name="l00144"></a>00144 <a name="l00145"></a>00145 <span class="comment">// buffer update</span><a name="l00146"></a>00146 AS2( lea WORD_REG(cx), [WORD_REG(bx) + 32])<a name="l00147"></a>00147 AS2( and WORD_REG(cx), 31*32)<a name="l00148"></a>00148 AS2( lea WORD_REG(bp), [WORD_REG(bx) + (32-24)*32])<a name="l00149"></a>00149 AS2( and WORD_REG(bp), 31*32)<a name="l00150"></a>00150 <a name="l00151"></a>00151 AS2( movdqa xmm0, [WORD_REG(si)+20*4+WORD_REG(cx)+0*8])<a name="l00152"></a>00152 AS2( pxor xmm3, xmm0)<a name="l00153"></a>00153 ASS( pshufd xmm0, xmm0, 2, 3, 0, 1)<a name="l00154"></a>00154 AS2( movdqa [WORD_REG(si)+20*4+WORD_REG(cx)+0*8], xmm3)<a name="l00155"></a>00155 AS2( pxor xmm0, [WORD_REG(si)+20*4+WORD_REG(bp)+2*8])<a name="l00156"></a>00156 AS2( movdqa [WORD_REG(si)+20*4+WORD_REG(bp)+2*8], xmm0)<a name="l00157"></a>00157 <a name="l00158"></a>00158 AS2( movdqa xmm4, [WORD_REG(si)+20*4+WORD_REG(cx)+2*8])<a name="l00159"></a>00159 AS2( pxor xmm1, xmm4)<a name="l00160"></a>00160 AS2( movdqa [WORD_REG(si)+20*4+WORD_REG(cx)+2*8], xmm1)<a name="l00161"></a>00161 AS2( pxor xmm4, [WORD_REG(si)+20*4+WORD_REG(bp)+0*8])<a name="l00162"></a>00162 AS2( movdqa [WORD_REG(si)+20*4+WORD_REG(bp)+0*8], xmm4)<a name="l00163"></a>00163 <a name="l00164"></a>00164 <span class="comment">// theta</span><a name="l00165"></a>00165 AS2( movdqa xmm3, [WORD_REG(si)+3*16])<a name="l00166"></a>00166 AS2( movdqa xmm2, [WORD_REG(si)+2*16])<a name="l00167"></a>00167 AS2( movdqa xmm1, [WORD_REG(si)+1*16])<a name="l00168"></a>00168 AS2( movdqa xmm0, [WORD_REG(si)+0*16])<a name="l00169"></a>00169 <a name="l00170"></a>00170 #<span class="keywordflow">if</span> CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE<a name="l00171"></a>00171 AS2( test WORD_REG(bx), 1)<a name="l00172"></a>00172 ASJ( jnz, 8, f)<a name="l00173"></a>00173 #endif<a name="l00174"></a>00174 AS2( movd xmm6, eax)<a name="l00175"></a>00175 AS2( movdqa xmm7, xmm3)<a name="l00176"></a>00176 AS2( movss xmm7, xmm6)<a name="l00177"></a>00177 AS2( movdqa xmm6, xmm2)<a name="l00178"></a>00178 AS2( movss xmm6, xmm3)<a name="l00179"></a>00179 AS2( movdqa xmm5, xmm1)<a name="l00180"></a>00180 AS2( movss xmm5, xmm2)<a name="l00181"></a>00181 AS2( movdqa xmm4, xmm0)<a name="l00182"></a>00182 AS2( movss xmm4, xmm1)<a name="l00183"></a>00183 ASS( pshufd xmm7, xmm7, 0, 3, 2, 1)<a name="l00184"></a>00184 ASS( pshufd xmm6, xmm6, 0, 3, 2, 1)<a name="l00185"></a>00185 ASS( pshufd xmm5, xmm5, 0, 3, 2, 1)<a name="l00186"></a>00186 ASS( pshufd xmm4, xmm4, 0, 3, 2, 1)<a name="l00187"></a>00187 #<span class="keywordflow">if</span> CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE<a name="l00188"></a>00188 ASJ( jmp, 9, f)<a name="l00189"></a>00189 ASL(8)<a name="l00190"></a>00190 AS2( movd xmm7, eax)<a name="l00191"></a>00191 AS3( palignr xmm7, xmm3, 4)<a name="l00192"></a>00192 AS2( movq xmm6, xmm3)<a name="l00193"></a>00193 AS3( palignr xmm6, xmm2, 4)<a name="l00194"></a>00194 AS2( movq xmm5, xmm2)<a name="l00195"></a>00195 AS3( palignr xmm5, xmm1, 4)<a name="l00196"></a>00196 AS2( movq xmm4, xmm1)<a name="l00197"></a>00197 AS3( palignr xmm4, xmm0, 4)<a name="l00198"></a>00198 ASL(9)<a name="l00199"></a>00199 #endif<a name="l00200"></a>00200 <a name="l00201"></a>00201 AS2( xor eax, 1)<a name="l00202"></a>00202 AS2( movd ecx, xmm0)<a name="l00203"></a>00203 AS2( xor eax, ecx)<a name="l00204"></a>00204 AS2( movd ecx, xmm3)<a name="l00205"></a>00205 AS2( xor eax, ecx)<a name="l00206"></a>00206 <a name="l00207"></a>00207 AS2( pxor xmm3, xmm2)<a name="l00208"></a>00208 AS2( pxor xmm2, xmm1)<a name="l00209"></a>00209 AS2( pxor xmm1, xmm0)<a name="l00210"></a>00210 AS2( pxor xmm0, xmm7)<a name="l00211"></a>00211 AS2( pxor xmm3, xmm7)<a name="l00212"></a>00212 AS2( pxor xmm2, xmm6)<a name="l00213"></a>00213 AS2( pxor xmm1, xmm5)<a name="l00214"></a>00214 AS2( pxor xmm0, xmm4)<a name="l00215"></a>00215 <a name="l00216"></a>00216 <span class="comment">// sigma</span><a name="l00217"></a>00217 AS2( lea WORD_REG(cx), [WORD_REG(bx) + (32-4)*32])<a name="l00218"></a>00218 AS2( and WORD_REG(cx), 31*32)<a name="l00219"></a>00219 AS2( lea WORD_REG(bp), [WORD_REG(bx) + 16*32])<a name="l00220"></a>00220 AS2( and WORD_REG(bp), 31*32)<a name="l00221"></a>00221 <a name="l00222"></a>00222 AS2( movdqa xmm4, [WORD_REG(si)+20*4+WORD_REG(cx)+0*16])<a name="l00223"></a>00223 AS2( movdqa xmm5, [WORD_REG(si)+20*4+WORD_REG(bp)+0*16])<a name="l00224"></a>00224 AS2( movdqa xmm6, xmm4)<a name="l00225"></a>00225 AS2( punpcklqdq xmm4, xmm5)<a name="l00226"></a>00226 AS2( punpckhqdq xmm6, xmm5)<a name="l00227"></a>00227 AS2( pxor xmm3, xmm4)<a name="l00228"></a>00228 AS2( pxor xmm2, xmm6)<a name="l00229"></a>00229 <a name="l00230"></a>00230 AS2( movdqa xmm4, [WORD_REG(si)+20*4+WORD_REG(cx)+1*16])<a name="l00231"></a>00231 AS2( movdqa xmm5, [WORD_REG(si)+20*4+WORD_REG(bp)+1*16])<a name="l00232"></a>00232 AS2( movdqa xmm6, xmm4)<a name="l00233"></a>00233 AS2( punpcklqdq xmm4, xmm5)<a name="l00234"></a>00234 AS2( punpckhqdq xmm6, xmm5)<a name="l00235"></a>00235 AS2( pxor xmm1, xmm4)<a name="l00236"></a>00236 AS2( pxor xmm0, xmm6)<a name="l00237"></a>00237 <a name="l00238"></a>00238 <span class="comment">// loop</span><a name="l00239"></a>00239 AS2( <span class="keyword">add</span> WORD_REG(bx), 32)<a name="l00240"></a>00240 AS2( cmp WORD_REG(bx), [WORD_REG(sp)])<a name="l00241"></a>00241 ASJ( jne, 4, b)<a name="l00242"></a>00242 <a name="l00243"></a>00243 <span class="comment">// save state</span><a name="l00244"></a>00244 AS2( <span class="keyword">add</span> WORD_REG(sp), WORD_SZ)<a name="l00245"></a>00245 AS_POP( bp)<a name="l00246"></a>00246 AS2( mov [WORD_REG(si)+4*16], eax)<a name="l00247"></a>00247 AS2( movdqa [WORD_REG(si)+3*16], xmm3)<a name="l00248"></a>00248 AS2( movdqa [WORD_REG(si)+2*16], xmm2)<a name="l00249"></a>00249 AS2( movdqa [WORD_REG(si)+1*16], xmm1)<a name="l00250"></a>00250 AS2( movdqa [WORD_REG(si)+0*16], xmm0)<a name="l00251"></a>00251 ASL(5)<a name="l00252"></a>00252 <a name="l00253"></a>00253 #ifdef __GNUC__<a name="l00254"></a>00254 AS_POP( bx)<a name="l00255"></a>00255 <span class="stringliteral">".att_syntax prefix;"</span><a name="l00256"></a>00256 :<a name="l00257"></a>00257 : <span class="stringliteral">"c"</span> (count), <span class="stringliteral">"S"</span> (state), <span class="stringliteral">"D"</span> (z), <span class="stringliteral">"d"</span> (y)<a name="l00258"></a>00258 : <span class="stringliteral">"%eax"</span>, <span class="stringliteral">"memory"</span>, <span class="stringliteral">"cc"</span><a name="l00259"></a>00259 );<a name="l00260"></a>00260 <span class="preprocessor">#endif</span><a name="l00261"></a>00261 <span class="preprocessor"></span>}<a name="l00262"></a>00262 <a name="l00263"></a>00263 <span class="preprocessor">#endif</span><a name="l00264"></a>00264 <span class="preprocessor"></span><a name="l00265"></a>00265 <span class="keyword">template</span> <<span class="keyword">class</span> B><a name="l00266"></a><a class="code" href="class_panama.html#b576dd602b018f3572e54ea9d043961a">00266</a> <span class="keywordtype">void</span> <a class="code" href="class_panama.html#b576dd602b018f3572e54ea9d043961a">Panama<B>::Iterate</a>(<span class="keywordtype">size_t</span> count, <span class="keyword">const</span> word32 *p, word32 *z, <span class="keyword">const</span> word32 *y)<a name="l00267"></a>00267 {<a name="l00268"></a>00268 word32 bstart = <a class="code" href="class_panama.html#a24602ddf6d8b7da9c5e77609af9e3ce">m_state</a>[17];<a name="l00269"></a>00269 word32 *<span class="keyword">const</span> aPtr = <a class="code" href="class_panama.html#a24602ddf6d8b7da9c5e77609af9e3ce">m_state</a>;<a name="l00270"></a>00270 word32 cPtr[17];<a name="l00271"></a>00271 <a name="l00272"></a>00272 <span class="preprocessor">#define bPtr ((byte *)(aPtr+20))</span><a name="l00273"></a>00273 <span class="preprocessor"></span><a name="l00274"></a>00274 <span class="comment">// reorder the state for SSE2</span><a name="l00275"></a>00275 <span class="comment">// a and c: 4 8 12 16 | 3 7 11 15 | 2 6 10 14 | 1 5 9 13 | 0</span><a name="l00276"></a>00276 <span class="comment">// xmm0 xmm1 xmm2 xmm3 eax</span><a name="l00277"></a>00277 <span class="preprocessor">#define a(i) aPtr[((i)*13+16) % 17] // 13 is inverse of 4 mod 17</span><a name="l00278"></a>00278 <span class="preprocessor"></span><span class="preprocessor">#define c(i) cPtr[((i)*13+16) % 17]</span><a name="l00279"></a>00279 <span class="preprocessor"></span><span class="comment">// b: 0 4 | 1 5 | 2 6 | 3 7</span><a name="l00280"></a>00280 <span class="preprocessor">#define b(i, j) b##i[(j)*2%8 + (j)/4]</span><a name="l00281"></a>00281 <span class="preprocessor"></span><a name="l00282"></a>00282 <span class="comment">// output</span><a name="l00283"></a>00283 <span class="preprocessor">#define OA(i) z[i] = ConditionalByteReverse(B::ToEnum(), a(i+9))</span><a name="l00284"></a>00284 <span class="preprocessor"></span><span class="preprocessor">#define OX(i) z[i] = y[i] ^ ConditionalByteReverse(B::ToEnum(), a(i+9))</span><a name="l00285"></a>00285 <span class="preprocessor"></span><span class="comment">// buffer update</span><a name="l00286"></a>00286 <span class="preprocessor">#define US(i) {word32 t=b(0,i); b(0,i)=ConditionalByteReverse(B::ToEnum(), p[i])^t; b(25,(i+6)%8)^=t;}</span><a name="l00287"></a>00287 <span class="preprocessor"></span><span class="preprocessor">#define UL(i) {word32 t=b(0,i); b(0,i)=a(i+1)^t; b(25,(i+6)%8)^=t;}</span><a name="l00288"></a>00288 <span class="preprocessor"></span><span class="comment">// gamma and pi</span><a name="l00289"></a>00289 <span class="preprocessor">#define GP(i) c(5*i%17) = rotlFixed(a(i) ^ (a((i+1)%17) | ~a((i+2)%17)), ((5*i%17)*((5*i%17)+1)/2)%32)</span><a name="l00290"></a>00290 <span class="preprocessor"></span><span class="comment">// theta and sigma</span><a name="l00291"></a>00291 <span class="preprocessor">#define T(i,x) a(i) = c(i) ^ c((i+1)%17) ^ c((i+4)%17) ^ x</span><a name="l00292"></a>00292 <span class="preprocessor"></span><span class="preprocessor">#define TS1S(i) T(i+1, ConditionalByteReverse(B::ToEnum(), p[i]))</span><a name="l00293"></a>00293 <span class="preprocessor"></span><span class="preprocessor">#define TS1L(i) T(i+1, b(4,i))</span><a name="l00294"></a>00294 <span class="preprocessor"></span><span class="preprocessor">#define TS2(i) T(i+9, b(16,i))</span><a name="l00295"></a>00295 <span class="preprocessor"></span><a name="l00296"></a>00296 <span class="keywordflow">while</span> (count--)<a name="l00297"></a>00297 {<a name="l00298"></a>00298 <span class="keywordflow">if</span> (z)<a name="l00299"></a>00299 {<a name="l00300"></a>00300 <span class="keywordflow">if</span> (y)<a name="l00301"></a>00301 {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -