2 # SPDX-License-Identifier: GPL-1.0+ OR BSD-3-Clause
4 # ====================================================================
5 # Written by Andy Polyakov, @dot-asm, initially for the OpenSSL
7 # ====================================================================
9 # This module implements Poly1305 hash for ARMv8.
13 # Numbers are cycles per processed byte with poly1305_blocks alone.
17 # Apple A7 1.86/+5% 0.72
18 # Cortex-A53 2.69/+58% 1.47
19 # Cortex-A57 2.70/+7% 1.14
20 # Denver 1.64/+50% 1.18(*)
21 # X-Gene 2.13/+68% 2.27
22 # Mongoose 1.77/+75% 1.12
24 # ThunderX2 1.17/+95% 1.36
26 # (*) estimate based on resources availability is less than 1.0,
27 # i.e. measured result is worse than expected, presumably binary
28 # translator is not almighty;
33 if ($flavour && $flavour ne "void") {
34 $0 =~ m/(.*[\/\\])[^\
/\\]+$/; $dir=$1;
35 ( $xlate="${dir}arm-xlate.pl" and -f
$xlate ) or
36 ( $xlate="${dir}../../perlasm/arm-xlate.pl" and -f
$xlate) or
37 die "can't locate arm-xlate.pl";
39 open STDOUT
,"| \"$^X\" $xlate $flavour $output";
41 open STDOUT
,">$output";
44 my ($ctx,$inp,$len,$padbit) = map("x$_",(0..3));
45 my ($mac,$nonce)=($inp,$len);
47 my ($h0,$h1,$h2,$r0,$r1,$s1,$t0,$t1,$d0,$d1,$d2) = map("x$_",(4..14));
51 # include "arm_arch.h"
52 .extern OPENSSL_armcap_P
57 // forward
"declarations" are required
for Apple
58 .globl poly1305_blocks
62 .type poly1305_init
,%function
66 stp xzr
,xzr
,[$ctx] // zero hash value
67 stp xzr
,xzr
,[$ctx,#16] // [along with is_base2_26]
73 adrp x17
,OPENSSL_armcap_P
74 ldr w17
,[x17
,#:lo12:OPENSSL_armcap_P]
77 ldp
$r0,$r1,[$inp] // load key
78 mov
$s1,#0xfffffffc0fffffff
79 movk
$s1,#0x0fff,lsl#48
81 rev
$r0,$r0 // flip bytes
84 and $r0,$r0,$s1 // &=0ffffffc0fffffff
86 and $r1,$r1,$s1 // &=0ffffffc0ffffffc
88 stp
$r0,$r1,[$ctx,#32] // save key value
89 str w
#$s1,[$ctx,#48] // impossible key power value
94 adr
$d0,.Lpoly1305_blocks
95 adr
$r0,.Lpoly1305_blocks_neon
96 adr
$d1,.Lpoly1305_emit
101 stp w
#$d0,w#$d1,[$len]
109 .size poly1305_init
,.-poly1305_init
111 .type poly1305_blocks
,%function
118 ldp
$h0,$h1,[$ctx] // load hash value
119 ldp
$h2,x17
,[$ctx,#16] // [along with is_base2_26]
120 ldp
$r0,$r1,[$ctx,#32] // load key value
136 add
$d0,$d0,$d1,lsl
#26 // base 2^26 -> base 2^64
138 adds
$d0,$d0,$d2,lsl
#52
139 add
$d1,$d1,x15
,lsl
#14
142 adds
$d1,$d1,x16
,lsl
#40
145 cmp x17
,#0 // is_base2_26?
146 add
$s1,$r1,$r1,lsr
#2 // s1 = r1 + (r1 >> 2)
147 csel
$h0,$h0,$d0,eq // choose between radixes
152 ldp
$t0,$t1,[$inp],#16 // load input
158 adds
$h0,$h0,$t0 // accumulate input
161 mul
$d0,$h0,$r0 // h0
*r0
165 mul
$t0,$h1,$s1 // h1
*5*r1
169 mul
$t0,$h0,$r1 // h0
*r1
174 mul
$t0,$h1,$r0 // h1
*r0
179 mul
$t0,$h2,$s1 // h2
*5*r1
181 mul
$t1,$h2,$r0 // h2
*r0
186 and $t0,$d2,#-4 // final reduction
188 add
$t0,$t0,$d2,lsr
#2
195 stp
$h0,$h1,[$ctx] // store hash value
196 stp
$h2,xzr
,[$ctx,#16] // [and clear is_base2_26]
200 .size poly1305_blocks
,.-poly1305_blocks
202 .type poly1305_emit
,%function
206 ldp
$h0,$h1,[$ctx] // load hash base
2^64
207 ldp
$h2,$r0,[$ctx,#16] // [along with is_base2_26]
208 ldp
$t0,$t1,[$nonce] // load nonce
224 add
$d0,$d0,$d1,lsl
#26 // base 2^26 -> base 2^64
226 adds
$d0,$d0,$d2,lsl
#52
227 add
$d1,$d1,x15
,lsl
#14
230 adds
$d1,$d1,x16
,lsl
#40
233 cmp $r0,#0 // is_base2_26?
234 csel
$h0,$h0,$d0,eq // choose between radixes
238 adds
$d0,$h0,#5 // compare to modulus
242 tst
$d2,#-4 // see if it's carried/borrowed
248 ror
$t0,$t0,#32 // flip nonce words
251 adds
$h0,$h0,$t0 // accumulate nonce
254 rev
$h0,$h0 // flip output bytes
257 stp
$h0,$h1,[$mac] // write result
260 .size poly1305_emit
,.-poly1305_emit
262 my ($R0,$R1,$S1,$R2,$S2,$R3,$S3,$R4,$S4) = map("v$_.4s",(0..8));
263 my ($IN01_0,$IN01_1,$IN01_2,$IN01_3,$IN01_4) = map("v$_.2s",(9..13));
264 my ($IN23_0,$IN23_1,$IN23_2,$IN23_3,$IN23_4) = map("v$_.2s",(14..18));
265 my ($ACC0,$ACC1,$ACC2,$ACC3,$ACC4) = map("v$_.2d",(19..23));
266 my ($H0,$H1,$H2,$H3,$H4) = map("v$_.2s",(24..28));
267 my ($T0,$T1,$MASK) = map("v$_",(29..31));
269 my ($in2,$zeros)=("x16","x17");
270 my $is_base2_26 = $zeros; # borrow
273 .type poly1305_mult
,%function
276 mul
$d0,$h0,$r0 // h0
*r0
279 mul
$t0,$h1,$s1 // h1
*5*r1
283 mul
$t0,$h0,$r1 // h0
*r1
288 mul
$t0,$h1,$r0 // h1
*r0
293 mul
$t0,$h2,$s1 // h2
*5*r1
295 mul
$t1,$h2,$r0 // h2
*r0
300 and $t0,$d2,#-4 // final reduction
302 add
$t0,$t0,$d2,lsr
#2
308 .size poly1305_mult
,.-poly1305_mult
310 .type poly1305_splat
,%function
313 and x12
,$h0,#0x03ffffff // base 2^64 -> base 2^26
316 and x14
,x14
,#0x03ffffff
320 str w12
,[$ctx,#16*0] // r0
321 add w12
,w13
,w13
,lsl
#2 // r1*5
322 str w13
,[$ctx,#16*1] // r1
323 add w13
,w14
,w14
,lsl
#2 // r2*5
324 str w12
,[$ctx,#16*2] // s1
325 str w14
,[$ctx,#16*3] // r2
326 add w14
,w15
,w15
,lsl
#2 // r3*5
327 str w13
,[$ctx,#16*4] // s2
328 str w15
,[$ctx,#16*5] // r3
329 add w15
,w16
,w16
,lsl
#2 // r4*5
330 str w14
,[$ctx,#16*6] // s3
331 str w16
,[$ctx,#16*7] // r4
332 str w15
,[$ctx,#16*8] // s4
335 .size poly1305_splat
,.-poly1305_splat
338 .globl poly1305_blocks_neon
340 .type poly1305_blocks_neon
,%function
342 poly1305_blocks_neon
:
343 .Lpoly1305_blocks_neon
:
344 ldr
$is_base2_26,[$ctx,#24]
346 b
.lo
.Lpoly1305_blocks
348 .inst
0xd503233f // paciasp
349 stp x29
,x30
,[sp
,#-80]!
352 stp d8
,d9
,[sp
,#16] // meet ABI requirements
357 cbz
$is_base2_26,.Lbase2_64_neon
359 ldp w10
,w11
,[$ctx] // load hash value base
2^26
360 ldp w12
,w13
,[$ctx,#8]
366 ldp
$r0,$r1,[$ctx,#32] // load key value
368 add
$h0,x10
,x11
,lsl
#26 // base 2^26 -> base 2^64
370 adds
$h0,$h0,x12
,lsl
#52
371 add
$h1,$h1,x13
,lsl
#14
374 adds
$h1,$h1,x14
,lsl
#40
375 adc
$d2,$h2,xzr
// can be partially reduced
...
377 ldp
$d0,$d1,[$inp],#16 // load input
379 add
$s1,$r1,$r1,lsr
#2 // s1 = r1 + (r1 >> 2)
385 adds
$h0,$h0,$d0 // accumulate input
391 and x10
,$h0,#0x03ffffff // base 2^64 -> base 2^26
394 and x12
,x12
,#0x03ffffff
402 ldp
$r0,$r1,[$ctx,#32] // load key value
404 ldp
$h0,$h1,[$ctx] // load hash value base
2^64
410 ldp
$d0,$d1,[$inp],#16 // load input
412 add
$s1,$r1,$r1,lsr
#2 // s1 = r1 + (r1 >> 2)
417 adds
$h0,$h0,$d0 // accumulate input
424 ldr w17
,[$ctx,#48] // first table element
425 and x10
,$h0,#0x03ffffff // base 2^64 -> base 2^26
428 and x12
,x12
,#0x03ffffff
432 cmp w17
,#-1 // is value impossible?
441 ////////////////////////////////// initialize r
^n table
443 add
$s1,$r1,$r1,lsr
#2 // s1 = r1 + (r1 >> 2)
449 bl poly1305_mult
// r
^2
453 bl poly1305_mult
// r
^3
457 bl poly1305_mult
// r
^4
460 sub $ctx,$ctx,#48 // restore original $ctx
472 ldp x8
,x12
,[$inp,#32] // inp[2:3]
474 ldp x9
,x13
,[$inp,#48]
478 lsl
$padbit,$padbit,#24
487 and x4
,x8
,#0x03ffffff // base 2^64 -> base 2^26
488 and x5
,x9
,#0x03ffffff
491 add x4
,x4
,x5
,lsl
#32 // bfi x4,x5,#32,#32
494 add x6
,x6
,x7
,lsl
#32 // bfi x6,x7,#32,#32
496 and x8
,x8
,#0x03ffffff
497 and x9
,x9
,#0x03ffffff
500 add x12
,$padbit,x12
,lsr
#40
501 add x13
,$padbit,x13
,lsr
#40
502 add x8
,x8
,x9
,lsl
#32 // bfi x8,x9,#32,#32
504 add x10
,x10
,x11
,lsl
#32 // bfi x10,x11,#32,#32
505 add x12
,x12
,x13
,lsl
#32 // bfi x12,x13,#32,#32
510 ldp x8
,x12
,[$inp],#16 // inp[0:1]
511 ldp x9
,x13
,[$inp],#48
513 ld1
{$R0,$R1,$S1,$R2},[x15
],#64
514 ld1
{$S2,$R3,$S3,$R4},[x15
],#64
523 and x4
,x8
,#0x03ffffff // base 2^64 -> base 2^26
524 and x5
,x9
,#0x03ffffff
527 add x4
,x4
,x5
,lsl
#32 // bfi x4,x5,#32,#32
530 add x6
,x6
,x7
,lsl
#32 // bfi x6,x7,#32,#32
532 and x8
,x8
,#0x03ffffff
533 and x9
,x9
,#0x03ffffff
536 add x12
,$padbit,x12
,lsr
#40
537 add x13
,$padbit,x13
,lsr
#40
538 add x8
,x8
,x9
,lsl
#32 // bfi x8,x9,#32,#32
540 add x10
,x10
,x11
,lsl
#32 // bfi x10,x11,#32,#32
541 add x12
,x12
,x13
,lsl
#32 // bfi x12,x13,#32,#32
546 ushr
$MASK.2d
,$MASK.2d
,#38
552 ////////////////////////////////////////////////////////////////
553 // ((inp
[0]*r
^4+inp
[2]*r
^2+inp
[4])*r
^4+inp
[6]*r
^2
554 // ((inp
[1]*r
^4+inp
[3]*r
^2+inp
[5])*r
^3+inp
[7]*r
555 // \___________________
/
556 // ((inp
[0]*r
^4+inp
[2]*r
^2+inp
[4])*r
^4+inp
[6]*r
^2+inp
[8])*r
^2
557 // ((inp
[1]*r
^4+inp
[3]*r
^2+inp
[5])*r
^4+inp
[7]*r
^2+inp
[9])*r
558 // \___________________
/ \____________________/
560 // Note that we start with inp
[2:3]*r
^2. This is because it
561 // doesn
't depend on reduction in previous iteration.
562 ////////////////////////////////////////////////////////////////
563 // d4 = h0*r4 + h1*r3 + h2*r2 + h3*r1 + h4*r0
564 // d3 = h0*r3 + h1*r2 + h2*r1 + h3*r0 + h4*5*r4
565 // d2 = h0*r2 + h1*r1 + h2*r0 + h3*5*r4 + h4*5*r3
566 // d1 = h0*r1 + h1*r0 + h2*5*r4 + h3*5*r3 + h4*5*r2
567 // d0 = h0*r0 + h1*5*r4 + h2*5*r3 + h3*5*r2 + h4*5*r1
570 umull $ACC4,$IN23_0,${R4}[2]
571 csel $in2,$zeros,$in2,lo
572 umull $ACC3,$IN23_0,${R3}[2]
573 umull $ACC2,$IN23_0,${R2}[2]
574 ldp x8,x12,[$in2],#16 // inp[2:3] (or zero)
575 umull $ACC1,$IN23_0,${R1}[2]
576 ldp x9,x13,[$in2],#48
577 umull $ACC0,$IN23_0,${R0}[2]
585 umlal $ACC4,$IN23_1,${R3}[2]
586 and x4,x8,#0x03ffffff // base 2^64 -> base 2^26
587 umlal $ACC3,$IN23_1,${R2}[2]
588 and x5,x9,#0x03ffffff
589 umlal $ACC2,$IN23_1,${R1}[2]
591 umlal $ACC1,$IN23_1,${R0}[2]
593 umlal $ACC0,$IN23_1,${S4}[2]
594 add x4,x4,x5,lsl#32 // bfi x4,x5,#32,#32
596 umlal $ACC4,$IN23_2,${R2}[2]
598 umlal $ACC3,$IN23_2,${R1}[2]
600 umlal $ACC2,$IN23_2,${R0}[2]
601 add x6,x6,x7,lsl#32 // bfi x6,x7,#32,#32
602 umlal $ACC1,$IN23_2,${S4}[2]
604 umlal $ACC0,$IN23_2,${S3}[2]
605 and x8,x8,#0x03ffffff
607 umlal $ACC4,$IN23_3,${R1}[2]
608 and x9,x9,#0x03ffffff
609 umlal $ACC3,$IN23_3,${R0}[2]
611 umlal $ACC2,$IN23_3,${S4}[2]
613 umlal $ACC1,$IN23_3,${S3}[2]
614 add x8,x8,x9,lsl#32 // bfi x8,x9,#32,#32
615 umlal $ACC0,$IN23_3,${S2}[2]
618 add $IN01_2,$IN01_2,$H2
619 add x12,$padbit,x12,lsr#40
620 umlal $ACC4,$IN23_4,${R0}[2]
621 add x13,$padbit,x13,lsr#40
622 umlal $ACC3,$IN23_4,${S4}[2]
623 add x10,x10,x11,lsl#32 // bfi x10,x11,#32,#32
624 umlal $ACC2,$IN23_4,${S3}[2]
625 add x12,x12,x13,lsl#32 // bfi x12,x13,#32,#32
626 umlal $ACC1,$IN23_4,${S2}[2]
628 umlal $ACC0,$IN23_4,${S1}[2]
631 ////////////////////////////////////////////////////////////////
632 // (hash+inp[0:1])*r^4 and accumulate
634 add $IN01_0,$IN01_0,$H0
636 umlal $ACC3,$IN01_2,${R1}[0]
637 ldp x8,x12,[$inp],#16 // inp[0:1]
638 umlal $ACC0,$IN01_2,${S3}[0]
639 ldp x9,x13,[$inp],#48
640 umlal $ACC4,$IN01_2,${R2}[0]
641 umlal $ACC1,$IN01_2,${S4}[0]
642 umlal $ACC2,$IN01_2,${R0}[0]
650 add $IN01_1,$IN01_1,$H1
651 umlal $ACC3,$IN01_0,${R3}[0]
652 umlal $ACC4,$IN01_0,${R4}[0]
653 and x4,x8,#0x03ffffff // base 2^64 -> base 2^26
654 umlal $ACC2,$IN01_0,${R2}[0]
655 and x5,x9,#0x03ffffff
656 umlal $ACC0,$IN01_0,${R0}[0]
658 umlal $ACC1,$IN01_0,${R1}[0]
661 add $IN01_3,$IN01_3,$H3
662 add x4,x4,x5,lsl#32 // bfi x4,x5,#32,#32
663 umlal $ACC3,$IN01_1,${R2}[0]
665 umlal $ACC4,$IN01_1,${R3}[0]
667 umlal $ACC0,$IN01_1,${S4}[0]
668 add x6,x6,x7,lsl#32 // bfi x6,x7,#32,#32
669 umlal $ACC2,$IN01_1,${R1}[0]
671 umlal $ACC1,$IN01_1,${R0}[0]
672 and x8,x8,#0x03ffffff
674 add $IN01_4,$IN01_4,$H4
675 and x9,x9,#0x03ffffff
676 umlal $ACC3,$IN01_3,${R0}[0]
678 umlal $ACC0,$IN01_3,${S2}[0]
680 umlal $ACC4,$IN01_3,${R1}[0]
681 add x8,x8,x9,lsl#32 // bfi x8,x9,#32,#32
682 umlal $ACC1,$IN01_3,${S3}[0]
684 umlal $ACC2,$IN01_3,${S4}[0]
685 add x12,$padbit,x12,lsr#40
687 umlal $ACC3,$IN01_4,${S4}[0]
688 add x13,$padbit,x13,lsr#40
689 umlal $ACC0,$IN01_4,${S1}[0]
690 add x10,x10,x11,lsl#32 // bfi x10,x11,#32,#32
691 umlal $ACC4,$IN01_4,${R0}[0]
692 add x12,x12,x13,lsl#32 // bfi x12,x13,#32,#32
693 umlal $ACC1,$IN01_4,${S2}[0]
695 umlal $ACC2,$IN01_4,${S3}[0]
699 /////////////////////////////////////////////////////////////////
700 // lazy reduction as discussed in "NEON crypto" by D.J. Bernstein
703 // [see discussion in poly1305-armv4 module]
705 ushr $T0.2d,$ACC3,#26
707 ushr $T1.2d,$ACC0,#26
708 and $ACC0,$ACC0,$MASK.2d
709 add $ACC4,$ACC4,$T0.2d // h3 -> h4
710 bic $H3,#0xfc,lsl#24 // &=0x03ffffff
711 add $ACC1,$ACC1,$T1.2d // h0 -> h1
713 ushr $T0.2d,$ACC4,#26
715 ushr $T1.2d,$ACC1,#26
718 add $ACC2,$ACC2,$T1.2d // h1 -> h2
720 add $ACC0,$ACC0,$T0.2d
722 shrn $T1.2s,$ACC2,#26
724 add $ACC0,$ACC0,$T0.2d // h4 -> h0
726 add $H3,$H3,$T1.2s // h2 -> h3
729 shrn $T0.2s,$ACC0,#26
734 add $H1,$H1,$T0.2s // h0 -> h1
735 add $H4,$H4,$T1.2s // h3 -> h4
740 dup $IN23_2,${IN23_2}[0]
741 add $IN01_2,$IN01_2,$H2
743 ////////////////////////////////////////////////////////////////
744 // multiply (inp[0:1]+hash) or inp[2:3] by r^2:r^1
749 dup $IN23_2,${IN01_2}[0]
750 add $IN23_0,$IN01_0,$H0
751 add $IN23_3,$IN01_3,$H3
752 add $IN23_1,$IN01_1,$H1
753 add $IN23_4,$IN01_4,$H4
756 dup $IN23_0,${IN23_0}[0]
757 umull2 $ACC0,$IN23_2,${S3}
758 umull2 $ACC3,$IN23_2,${R1}
759 umull2 $ACC4,$IN23_2,${R2}
760 umull2 $ACC2,$IN23_2,${R0}
761 umull2 $ACC1,$IN23_2,${S4}
763 dup $IN23_1,${IN23_1}[0]
764 umlal2 $ACC0,$IN23_0,${R0}
765 umlal2 $ACC2,$IN23_0,${R2}
766 umlal2 $ACC3,$IN23_0,${R3}
767 umlal2 $ACC4,$IN23_0,${R4}
768 umlal2 $ACC1,$IN23_0,${R1}
770 dup $IN23_3,${IN23_3}[0]
771 umlal2 $ACC0,$IN23_1,${S4}
772 umlal2 $ACC3,$IN23_1,${R2}
773 umlal2 $ACC2,$IN23_1,${R1}
774 umlal2 $ACC4,$IN23_1,${R3}
775 umlal2 $ACC1,$IN23_1,${R0}
777 dup $IN23_4,${IN23_4}[0]
778 umlal2 $ACC3,$IN23_3,${R0}
779 umlal2 $ACC4,$IN23_3,${R1}
780 umlal2 $ACC0,$IN23_3,${S2}
781 umlal2 $ACC1,$IN23_3,${S3}
782 umlal2 $ACC2,$IN23_3,${S4}
784 umlal2 $ACC3,$IN23_4,${S4}
785 umlal2 $ACC0,$IN23_4,${S1}
786 umlal2 $ACC4,$IN23_4,${R0}
787 umlal2 $ACC1,$IN23_4,${S2}
788 umlal2 $ACC2,$IN23_4,${S3}
792 ////////////////////////////////////////////////////////////////
793 // (hash+inp[0:1])*r^4:r^3 and accumulate
795 add $IN01_0,$IN01_0,$H0
796 umlal $ACC3,$IN01_2,${R1}
797 umlal $ACC0,$IN01_2,${S3}
798 umlal $ACC4,$IN01_2,${R2}
799 umlal $ACC1,$IN01_2,${S4}
800 umlal $ACC2,$IN01_2,${R0}
802 add $IN01_1,$IN01_1,$H1
803 umlal $ACC3,$IN01_0,${R3}
804 umlal $ACC0,$IN01_0,${R0}
805 umlal $ACC4,$IN01_0,${R4}
806 umlal $ACC1,$IN01_0,${R1}
807 umlal $ACC2,$IN01_0,${R2}
809 add $IN01_3,$IN01_3,$H3
810 umlal $ACC3,$IN01_1,${R2}
811 umlal $ACC0,$IN01_1,${S4}
812 umlal $ACC4,$IN01_1,${R3}
813 umlal $ACC1,$IN01_1,${R0}
814 umlal $ACC2,$IN01_1,${R1}
816 add $IN01_4,$IN01_4,$H4
817 umlal $ACC3,$IN01_3,${R0}
818 umlal $ACC0,$IN01_3,${S2}
819 umlal $ACC4,$IN01_3,${R1}
820 umlal $ACC1,$IN01_3,${S3}
821 umlal $ACC2,$IN01_3,${S4}
823 umlal $ACC3,$IN01_4,${S4}
824 umlal $ACC0,$IN01_4,${S1}
825 umlal $ACC4,$IN01_4,${R0}
826 umlal $ACC1,$IN01_4,${S2}
827 umlal $ACC2,$IN01_4,${S3}
830 ////////////////////////////////////////////////////////////////
833 addp $ACC3,$ACC3,$ACC3
834 ldp d8,d9,[sp,#16] // meet ABI requirements
835 addp $ACC0,$ACC0,$ACC0
837 addp $ACC4,$ACC4,$ACC4
839 addp $ACC1,$ACC1,$ACC1
841 addp $ACC2,$ACC2,$ACC2
843 .inst 0xd50323bf // autiasp
845 ////////////////////////////////////////////////////////////////
846 // lazy reduction, but without narrowing
848 ushr $T0.2d,$ACC3,#26
849 and $ACC3,$ACC3,$MASK.2d
850 ushr $T1.2d,$ACC0,#26
851 and $ACC0,$ACC0,$MASK.2d
853 add $ACC4,$ACC4,$T0.2d // h3 -> h4
854 add $ACC1,$ACC1,$T1.2d // h0 -> h1
856 ushr $T0.2d,$ACC4,#26
857 and $ACC4,$ACC4,$MASK.2d
858 ushr $T1.2d,$ACC1,#26
859 and $ACC1,$ACC1,$MASK.2d
860 add $ACC2,$ACC2,$T1.2d // h1 -> h2
862 add $ACC0,$ACC0,$T0.2d
864 ushr $T1.2d,$ACC2,#26
865 and $ACC2,$ACC2,$MASK.2d
866 add $ACC0,$ACC0,$T0.2d // h4 -> h0
867 add $ACC3,$ACC3,$T1.2d // h2 -> h3
869 ushr $T0.2d,$ACC0,#26
870 and $ACC0,$ACC0,$MASK.2d
871 ushr $T1.2d,$ACC3,#26
872 and $ACC3,$ACC3,$MASK.2d
873 add $ACC1,$ACC1,$T0.2d // h0 -> h1
874 add $ACC4,$ACC4,$T1.2d // h3 -> h4
876 ////////////////////////////////////////////////////////////////
877 // write the result, can be partially reduced
879 st4 {$ACC0,$ACC1,$ACC2,$ACC3}[0],[$ctx],#16
881 st1 {$ACC4}[0],[$ctx]
882 str x4,[$ctx,#8] // set is_base2_26
886 .size poly1305_blocks_neon,.-poly1305_blocks_neon
890 .long 0,0,0,0,0,0,0,0
891 .asciz "Poly1305 for ARMv8, CRYPTOGAMS by \@dot-asm"
893 #if !defined(__KERNEL__) && !defined(_WIN64)
894 .comm OPENSSL_armcap_P,4,4
895 .hidden OPENSSL_armcap_P
899 foreach (split("\n",$code)) {
900 s/\b(shrn\s+v[0-9]+)\.[24]d/$1.2s/ or
901 s/\b(fmov\s+)v([0-9]+)[^,]*,\s*x([0-9]+)/$1d$2,x$3/ or
902 (m/\bdup\b/ and (s/\.[24]s/.2d/g or 1)) or
903 (m/\b(eor|and)/ and (s/\.[248][sdh]/.16b/g or 1)) or
904 (m/\bum(ul|la)l\b/ and (s/\.4s/.2s/g or 1)) or
905 (m/\bum(ul|la)l2\b/ and (s/\.2s/.4s/g or 1)) or
906 (m/\bst[1-4]\s+{[^}]+}\[/ and (s/\.[24]d/.s/g or 1));
908 s/\.[124]([sd])\[/.$1\[/;