Lines Matching +full:0 +full:- +full:7 +full:a +full:- +full:e

2 # Implement fast SHA-512 with AVX2 instructions. (x86_64)
12 # This software is available to you under a choice of one of two
22 # - Redistributions of source code must retain the above
26 # - Redistributions in binary form must reproduce the above
33 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
42 # This code is described in an Intel White-Paper:
43 # "Fast SHA-512 Implementations on Intel Architecture Processors"
49 # This code schedules 1 blocks at a time, with 4 lanes per block
82 e = %rdx define
87 a = %rax define
107 frame_XFER = 0
118 # Add reg to mem using reg-mem add and store
143 # Rotate symbols a..h right
148 f = e
149 e = d define
152 b = a
153 a = TMP_ define
159 vperm2f128 $0x3, \YSRC2, \YSRC1, \YDST # YDST = {YS1_LO, YS2_HI}
164 ################################### RND N + 0 #########################################
166 # Extract w[t-7]
167 MY_VPALIGNR YTMP0, Y_3, Y_2, 8 # YTMP0 = W[-7]
168 # Calculate w[t-16] + w[t-7]
169 vpaddq Y_0, YTMP0, YTMP0 # YTMP0 = W[-7] + W[-16]
170 # Extract w[t-15]
171 MY_VPALIGNR YTMP1, Y_1, Y_0, 8 # YTMP1 = W[-15]
175 # Calculate w[t-15] ror 1
177 vpsllq $(64-1), YTMP1, YTMP3
178 vpor YTMP2, YTMP3, YTMP3 # YTMP3 = W[-15] ror 1
179 # Calculate w[t-15] shr 7
180 vpsrlq $7, YTMP1, YTMP4 # YTMP4 = W[-15] >> 7
182 mov a, y3 # y3 = a # MAJA
183 rorx $41, e, y0 # y0 = e >> 41 # S1A
184 rorx $18, e, y1 # y1 = e >> 18 # S1B
185 add frame_XFER(%rsp),h # h = k + w + h # --
186 or c, y3 # y3 = a|c # MAJA
188 rorx $34, a, T1 # T1 = a >> 34 # S0B
190 xor y1, y0 # y0 = (e>>41) ^ (e>>18) # S1
192 rorx $14, e, y1 # y1 = (e >> 14) # S1
194 and e, y2 # y2 = (f^g)&e # CH
195 xor y1, y0 # y0 = (e>>41) ^ (e>>18) ^ (e>>14) # S1
196 rorx $39, a, y1 # y1 = a >> 39 # S0A
197 add h, d # d = k + w + h + d # --
199 and b, y3 # y3 = (a|c)&b # MAJA
200 xor T1, y1 # y1 = (a>>39) ^ (a>>34) # S0
201 rorx $28, a, T1 # T1 = (a >> 28) # S0
203 xor g, y2 # y2 = CH = ((f^g)&e)^g # CH
204 xor T1, y1 # y1 = (a>>39) ^ (a>>34) ^ (a>>28) # S0
205 mov a, T1 # T1 = a # MAJB
206 and c, T1 # T1 = a&c # MAJB
208 add y0, y2 # y2 = S1 + CH # --
209 or T1, y3 # y3 = MAJ = (a|c)&b)|(a&c) # MAJ
210 add y1, h # h = k + w + h + S0 # --
212 add y2, d # d = k + w + h + d + S1 + CH = d + t1 # --
214 add y2, h # h = k + w + h + S0 + S1 + CH = t1 + S0# --
215 add y3, h # h = t1 + S0 + MAJ # --
221 # Calculate w[t-15] ror 8
223 vpsllq $(64-8), YTMP1, YTMP1
224 vpor YTMP2, YTMP1, YTMP1 # YTMP1 = W[-15] ror 8
226 vpxor YTMP4, YTMP3, YTMP3 # YTMP3 = W[-15] ror 1 ^ W[-15] >> 7
230 # Add three components, w[t-16], w[t-7] and sigma0
231 vpaddq YTMP1, YTMP0, YTMP0 # YTMP0 = W[-16] + W[-7] + s0
233 vperm2f128 $0x0, YTMP0, YTMP0, Y_0 # Y_0 = W[-16] + W[-7] + s0 {BABA}
235 vpand MASK_YMM_LO(%rip), YTMP0, YTMP0 # YTMP0 = W[-16] + W[-7] + s0 {DC00}
240 vperm2f128 $0x11, Y_3, Y_3, YTMP2 # YTMP2 = W[-2] {BABA}
241 vpsrlq $6, YTMP2, YTMP4 # YTMP4 = W[-2] >> 6 {BABA}
244 mov a, y3 # y3 = a # MAJA
245 rorx $41, e, y0 # y0 = e >> 41 # S1A
246 rorx $18, e, y1 # y1 = e >> 18 # S1B
247 add 1*8+frame_XFER(%rsp), h # h = k + w + h # --
248 or c, y3 # y3 = a|c # MAJA
252 rorx $34, a, T1 # T1 = a >> 34 # S0B
253 xor y1, y0 # y0 = (e>>41) ^ (e>>18) # S1
257 rorx $14, e, y1 # y1 = (e >> 14) # S1
258 xor y1, y0 # y0 = (e>>41) ^ (e>>18) ^ (e>>14) # S1
259 rorx $39, a, y1 # y1 = a >> 39 # S0A
260 and e, y2 # y2 = (f^g)&e # CH
261 add h, d # d = k + w + h + d # --
263 and b, y3 # y3 = (a|c)&b # MAJA
264 xor T1, y1 # y1 = (a>>39) ^ (a>>34) # S0
266 rorx $28, a, T1 # T1 = (a >> 28) # S0
267 xor g, y2 # y2 = CH = ((f^g)&e)^g # CH
269 xor T1, y1 # y1 = (a>>39) ^ (a>>34) ^ (a>>28) # S0
270 mov a, T1 # T1 = a # MAJB
271 and c, T1 # T1 = a&c # MAJB
272 add y0, y2 # y2 = S1 + CH # --
274 or T1, y3 # y3 = MAJ = (a|c)&b)|(a&c) # MAJ
275 add y1, h # h = k + w + h + S0 # --
277 add y2, d # d = k + w + h + d + S1 + CH = d + t1 # --
278 add y2, h # h = k + w + h + S0 + S1 + CH = t1 + S0# --
279 add y3, h # h = t1 + S0 + MAJ # --
286 vpsrlq $19, YTMP2, YTMP3 # YTMP3 = W[-2] >> 19 {BABA}
287 vpsllq $(64-19), YTMP2, YTMP1 # YTMP1 = W[-2] << 19 {BABA}
288 vpor YTMP1, YTMP3, YTMP3 # YTMP3 = W[-2] ror 19 {BABA}
289 vpxor YTMP3, YTMP4, YTMP4 # YTMP4 = W[-2] ror 19 ^ W[-2] >> 6 {BABA}
290 vpsrlq $61, YTMP2, YTMP3 # YTMP3 = W[-2] >> 61 {BABA}
291 vpsllq $(64-61), YTMP2, YTMP1 # YTMP1 = W[-2] << 61 {BABA}
292 vpor YTMP1, YTMP3, YTMP3 # YTMP3 = W[-2] ror 61 {BABA}
293 vpxor YTMP3, YTMP4, YTMP4 # YTMP4 = s1 = (W[-2] ror 19) ^
294 # (W[-2] ror 61) ^ (W[-2] >> 6) {BABA}
297 vpaddq YTMP4, Y_0, Y_0 # Y_0 = {W[1], W[0], W[1], W[0]}
300 vpsrlq $6, Y_0, YTMP4 # YTMP4 = W[-2] >> 6 {DC--}
302 mov a, y3 # y3 = a # MAJA
303 rorx $41, e, y0 # y0 = e >> 41 # S1A
304 add 2*8+frame_XFER(%rsp), h # h = k + w + h # --
306 rorx $18, e, y1 # y1 = e >> 18 # S1B
307 or c, y3 # y3 = a|c # MAJA
311 rorx $34, a, T1 # T1 = a >> 34 # S0B
312 xor y1, y0 # y0 = (e>>41) ^ (e>>18) # S1
313 and e, y2 # y2 = (f^g)&e # CH
315 rorx $14, e, y1 # y1 = (e >> 14) # S1
316 add h, d # d = k + w + h + d # --
317 and b, y3 # y3 = (a|c)&b # MAJA
319 xor y1, y0 # y0 = (e>>41) ^ (e>>18) ^ (e>>14) # S1
320 rorx $39, a, y1 # y1 = a >> 39 # S0A
321 xor g, y2 # y2 = CH = ((f^g)&e)^g # CH
323 xor T1, y1 # y1 = (a>>39) ^ (a>>34) # S0
324 rorx $28, a, T1 # T1 = (a >> 28) # S0
326 xor T1, y1 # y1 = (a>>39) ^ (a>>34) ^ (a>>28) # S0
327 mov a, T1 # T1 = a # MAJB
328 and c, T1 # T1 = a&c # MAJB
329 add y0, y2 # y2 = S1 + CH # --
331 or T1, y3 # y3 = MAJ = (a|c)&b)|(a&c) # MAJ
332 add y1, h # h = k + w + h + S0 # --
333 add y2, d # d = k + w + h + d + S1 + CH = d + t1 # --
334 add y2, h # h = k + w + h + S0 + S1 + CH = t1 + S0# --
336 add y3, h # h = t1 + S0 + MAJ # --
342 vpsrlq $19, Y_0, YTMP3 # YTMP3 = W[-2] >> 19 {DC--}
343 vpsllq $(64-19), Y_0, YTMP1 # YTMP1 = W[-2] << 19 {DC--}
344 vpor YTMP1, YTMP3, YTMP3 # YTMP3 = W[-2] ror 19 {DC--}
345 vpxor YTMP3, YTMP4, YTMP4 # YTMP4 = W[-2] ror 19 ^ W[-2] >> 6 {DC--}
346 vpsrlq $61, Y_0, YTMP3 # YTMP3 = W[-2] >> 61 {DC--}
347 vpsllq $(64-61), Y_0, YTMP1 # YTMP1 = W[-2] << 61 {DC--}
348 vpor YTMP1, YTMP3, YTMP3 # YTMP3 = W[-2] ror 61 {DC--}
349 vpxor YTMP3, YTMP4, YTMP4 # YTMP4 = s1 = (W[-2] ror 19) ^
350 # (W[-2] ror 61) ^ (W[-2] >> 6) {DC--}
352 # Add the sigma0 + w[t-7] + w[t-16] for w[18] and w[19]
354 vpaddq YTMP4, YTMP0, YTMP2 # YTMP2 = {W[3], W[2], --, --}
357 vpblendd $0xF0, YTMP2, Y_0, Y_0 # Y_0 = {W[3], W[2], W[1], W[0]}
359 mov a, y3 # y3 = a # MAJA
360 rorx $41, e, y0 # y0 = e >> 41 # S1A
361 rorx $18, e, y1 # y1 = e >> 18 # S1B
362 add 3*8+frame_XFER(%rsp), h # h = k + w + h # --
363 or c, y3 # y3 = a|c # MAJA
367 rorx $34, a, T1 # T1 = a >> 34 # S0B
368 xor y1, y0 # y0 = (e>>41) ^ (e>>18) # S1
372 rorx $14, e, y1 # y1 = (e >> 14) # S1
373 and e, y2 # y2 = (f^g)&e # CH
374 add h, d # d = k + w + h + d # --
375 and b, y3 # y3 = (a|c)&b # MAJA
377 xor y1, y0 # y0 = (e>>41) ^ (e>>18) ^ (e>>14) # S1
378 xor g, y2 # y2 = CH = ((f^g)&e)^g # CH
380 rorx $39, a, y1 # y1 = a >> 39 # S0A
381 add y0, y2 # y2 = S1 + CH # --
383 xor T1, y1 # y1 = (a>>39) ^ (a>>34) # S0
384 add y2, d # d = k + w + h + d + S1 + CH = d + t1 # --
386 rorx $28, a, T1 # T1 = (a >> 28) # S0
388 xor T1, y1 # y1 = (a>>39) ^ (a>>34) ^ (a>>28) # S0
389 mov a, T1 # T1 = a # MAJB
390 and c, T1 # T1 = a&c # MAJB
391 or T1, y3 # y3 = MAJ = (a|c)&b)|(a&c) # MAJ
393 add y1, h # h = k + w + h + S0 # --
394 add y2, h # h = k + w + h + S0 + S1 + CH = t1 + S0# --
395 add y3, h # h = t1 + S0 + MAJ # --
404 ################################### RND N + 0 #########################################
407 rorx $41, e, y0 # y0 = e >> 41 # S1A
408 rorx $18, e, y1 # y1 = e >> 18 # S1B
411 xor y1, y0 # y0 = (e>>41) ^ (e>>18) # S1
412 rorx $14, e, y1 # y1 = (e >> 14) # S1
413 and e, y2 # y2 = (f^g)&e # CH
415 xor y1, y0 # y0 = (e>>41) ^ (e>>18) ^ (e>>14) # S1
416 rorx $34, a, T1 # T1 = a >> 34 # S0B
417 xor g, y2 # y2 = CH = ((f^g)&e)^g # CH
418 rorx $39, a, y1 # y1 = a >> 39 # S0A
419 mov a, y3 # y3 = a # MAJA
421 xor T1, y1 # y1 = (a>>39) ^ (a>>34) # S0
422 rorx $28, a, T1 # T1 = (a >> 28) # S0
423 add frame_XFER(%rsp), h # h = k + w + h # --
424 or c, y3 # y3 = a|c # MAJA
426 xor T1, y1 # y1 = (a>>39) ^ (a>>34) ^ (a>>28) # S0
427 mov a, T1 # T1 = a # MAJB
428 and b, y3 # y3 = (a|c)&b # MAJA
429 and c, T1 # T1 = a&c # MAJB
430 add y0, y2 # y2 = S1 + CH # --
432 add h, d # d = k + w + h + d # --
433 or T1, y3 # y3 = MAJ = (a|c)&b)|(a&c) # MAJ
434 add y1, h # h = k + w + h + S0 # --
436 add y2, d # d = k + w + h + d + S1 + CH = d + t1 # --
442 add y2, old_h # h = k + w + h + S0 + S1 + CH = t1 + S0# --
444 rorx $41, e, y0 # y0 = e >> 41 # S1A
445 rorx $18, e, y1 # y1 = e >> 18 # S1B
448 xor y1, y0 # y0 = (e>>41) ^ (e>>18) # S1
449 rorx $14, e, y1 # y1 = (e >> 14) # S1
450 and e, y2 # y2 = (f^g)&e # CH
451 add y3, old_h # h = t1 + S0 + MAJ # --
453 xor y1, y0 # y0 = (e>>41) ^ (e>>18) ^ (e>>14) # S1
454 rorx $34, a, T1 # T1 = a >> 34 # S0B
455 xor g, y2 # y2 = CH = ((f^g)&e)^g # CH
456 rorx $39, a, y1 # y1 = a >> 39 # S0A
457 mov a, y3 # y3 = a # MAJA
459 xor T1, y1 # y1 = (a>>39) ^ (a>>34) # S0
460 rorx $28, a, T1 # T1 = (a >> 28) # S0
461 add 8*1+frame_XFER(%rsp), h # h = k + w + h # --
462 or c, y3 # y3 = a|c # MAJA
464 xor T1, y1 # y1 = (a>>39) ^ (a>>34) ^ (a>>28) # S0
465 mov a, T1 # T1 = a # MAJB
466 and b, y3 # y3 = (a|c)&b # MAJA
467 and c, T1 # T1 = a&c # MAJB
468 add y0, y2 # y2 = S1 + CH # --
470 add h, d # d = k + w + h + d # --
471 or T1, y3 # y3 = MAJ = (a|c)&b)|(a&c) # MAJ
472 add y1, h # h = k + w + h + S0 # --
474 add y2, d # d = k + w + h + d + S1 + CH = d + t1 # --
480 add y2, old_h # h = k + w + h + S0 + S1 + CH = t1 + S0# --
482 rorx $41, e, y0 # y0 = e >> 41 # S1A
483 rorx $18, e, y1 # y1 = e >> 18 # S1B
486 xor y1, y0 # y0 = (e>>41) ^ (e>>18) # S1
487 rorx $14, e, y1 # y1 = (e >> 14) # S1
488 and e, y2 # y2 = (f^g)&e # CH
489 add y3, old_h # h = t1 + S0 + MAJ # --
491 xor y1, y0 # y0 = (e>>41) ^ (e>>18) ^ (e>>14) # S1
492 rorx $34, a, T1 # T1 = a >> 34 # S0B
493 xor g, y2 # y2 = CH = ((f^g)&e)^g # CH
494 rorx $39, a, y1 # y1 = a >> 39 # S0A
495 mov a, y3 # y3 = a # MAJA
497 xor T1, y1 # y1 = (a>>39) ^ (a>>34) # S0
498 rorx $28, a, T1 # T1 = (a >> 28) # S0
499 add 8*2+frame_XFER(%rsp), h # h = k + w + h # --
500 or c, y3 # y3 = a|c # MAJA
502 xor T1, y1 # y1 = (a>>39) ^ (a>>34) ^ (a>>28) # S0
503 mov a, T1 # T1 = a # MAJB
504 and b, y3 # y3 = (a|c)&b # MAJA
505 and c, T1 # T1 = a&c # MAJB
506 add y0, y2 # y2 = S1 + CH # --
508 add h, d # d = k + w + h + d # --
509 or T1, y3 # y3 = MAJ = (a|c)&b)|(a&c) # MAJ
510 add y1, h # h = k + w + h + S0 # --
512 add y2, d # d = k + w + h + d + S1 + CH = d + t1 # --
518 add y2, old_h # h = k + w + h + S0 + S1 + CH = t1 + S0# --
520 rorx $41, e, y0 # y0 = e >> 41 # S1A
521 rorx $18, e, y1 # y1 = e >> 18 # S1B
524 xor y1, y0 # y0 = (e>>41) ^ (e>>18) # S1
525 rorx $14, e, y1 # y1 = (e >> 14) # S1
526 and e, y2 # y2 = (f^g)&e # CH
527 add y3, old_h # h = t1 + S0 + MAJ # --
529 xor y1, y0 # y0 = (e>>41) ^ (e>>18) ^ (e>>14) # S1
530 rorx $34, a, T1 # T1 = a >> 34 # S0B
531 xor g, y2 # y2 = CH = ((f^g)&e)^g # CH
532 rorx $39, a, y1 # y1 = a >> 39 # S0A
533 mov a, y3 # y3 = a # MAJA
535 xor T1, y1 # y1 = (a>>39) ^ (a>>34) # S0
536 rorx $28, a, T1 # T1 = (a >> 28) # S0
537 add 8*3+frame_XFER(%rsp), h # h = k + w + h # --
538 or c, y3 # y3 = a|c # MAJA
540 xor T1, y1 # y1 = (a>>39) ^ (a>>34) ^ (a>>28) # S0
541 mov a, T1 # T1 = a # MAJB
542 and b, y3 # y3 = (a|c)&b # MAJA
543 and c, T1 # T1 = a&c # MAJB
544 add y0, y2 # y2 = S1 + CH # --
547 add h, d # d = k + w + h + d # --
548 or T1, y3 # y3 = MAJ = (a|c)&b)|(a&c) # MAJ
549 add y1, h # h = k + w + h + S0 # --
551 add y2, d # d = k + w + h + d + S1 + CH = d + t1 # --
553 add y2, h # h = k + w + h + S0 + S1 + CH = t1 + S0# --
555 add y3, h # h = t1 + S0 + MAJ # --
581 and $~(0x20 - 1), %rsp
583 shl $7, NUM_BLKS # convert to bytes
589 mov 8*0(CTX1), a
593 mov 8*4(CTX1), e
596 mov 8*7(CTX1), h
656 addm 8*0(CTX2), a
660 addm 8*4(CTX2), e
663 addm 8*7(CTX2), h
691 # Mergeable 640-byte rodata section. This allows linker to merge the table
692 # with other, exactly the same 640-byte fragment of another rodata section
698 .quad 0x428a2f98d728ae22,0x7137449123ef65cd
699 .quad 0xb5c0fbcfec4d3b2f,0xe9b5dba58189dbbc
700 .quad 0x3956c25bf348b538,0x59f111f1b605d019
701 .quad 0x923f82a4af194f9b,0xab1c5ed5da6d8118
702 .quad 0xd807aa98a3030242,0x12835b0145706fbe
703 .quad 0x243185be4ee4b28c,0x550c7dc3d5ffb4e2
704 .quad 0x72be5d74f27b896f,0x80deb1fe3b1696b1
705 .quad 0x9bdc06a725c71235,0xc19bf174cf692694
706 .quad 0xe49b69c19ef14ad2,0xefbe4786384f25e3
707 .quad 0x0fc19dc68b8cd5b5,0x240ca1cc77ac9c65
708 .quad 0x2de92c6f592b0275,0x4a7484aa6ea6e483
709 .quad 0x5cb0a9dcbd41fbd4,0x76f988da831153b5
710 .quad 0x983e5152ee66dfab,0xa831c66d2db43210
711 .quad 0xb00327c898fb213f,0xbf597fc7beef0ee4
712 .quad 0xc6e00bf33da88fc2,0xd5a79147930aa725
713 .quad 0x06ca6351e003826f,0x142929670a0e6e70
714 .quad 0x27b70a8546d22ffc,0x2e1b21385c26c926
715 .quad 0x4d2c6dfc5ac42aed,0x53380d139d95b3df
716 .quad 0x650a73548baf63de,0x766a0abb3c77b2a8
717 .quad 0x81c2c92e47edaee6,0x92722c851482353b
718 .quad 0xa2bfe8a14cf10364,0xa81a664bbc423001
719 .quad 0xc24b8b70d0f89791,0xc76c51a30654be30
720 .quad 0xd192e819d6ef5218,0xd69906245565a910
721 .quad 0xf40e35855771202a,0x106aa07032bbd1b8
722 .quad 0x19a4c116b8d2d0c8,0x1e376c085141ab53
723 .quad 0x2748774cdf8eeb99,0x34b0bcb5e19b48a8
724 .quad 0x391c0cb3c5c95a63,0x4ed8aa4ae3418acb
725 .quad 0x5b9cca4f7763e373,0x682e6ff3d6b2b8a3
726 .quad 0x748f82ee5defb2fc,0x78a5636f43172f60
727 .quad 0x84c87814a1f0ab72,0x8cc702081a6439ec
728 .quad 0x90befffa23631e28,0xa4506cebde82bde9
729 .quad 0xbef9a3f7b2c67915,0xc67178f2e372532b
730 .quad 0xca273eceea26619c,0xd186b8c721c0c207
731 .quad 0xeada7dd6cde0eb1e,0xf57d4f7fee6ed178
732 .quad 0x06f067aa72176fba,0x0a637dc5a2c898a6
733 .quad 0x113f9804bef90dae,0x1b710b35131c471b
734 .quad 0x28db77f523047d84,0x32caab7b40c72493
735 .quad 0x3c9ebe0a15c9bebc,0x431d67c49c100d4c
736 .quad 0x4cc5d4becb3e42b6,0x597f299cfc657e2a
737 .quad 0x5fcb6fab3ad6faec,0x6c44198c4a475817
741 # Mask for byte-swapping a couple of qwords in an XMM register using (v)pshufb.
743 .octa 0x08090a0b0c0d0e0f0001020304050607
744 .octa 0x18191a1b1c1d1e1f1011121314151617
749 .octa 0x00000000000000000000000000000000
750 .octa 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF