etc/services - sync with NetBSD-8
[minix.git] / crypto / external / bsd / openssl / lib / libcrypto / arch / arm / ghashv8-armx.S
blob65dc52bec1491e7e6cdeeac7f978bc50c8b42a8f
1 #include "arm_arch.h"
2 #include "arm_asm.h"
4 .text
5 .fpu    neon
6 .code   32
7 .global gcm_init_v8
8 .type   gcm_init_v8,%function
9 .align  4
10 gcm_init_v8:
11         vld1.64         {q9},[r1]               @ load H
12         vmov.i8         q8,#0xe1
13         vext.8          q3,q9,q9,#8
14         vshl.i64        q8,q8,#57
15         vshr.u64        q10,q8,#63
16         vext.8          q8,q10,q8,#8            @ t0=0xc2....01
17         vdup.32 q9,d18[1]
18         vshr.u64        q11,q3,#63
19         vshr.s32        q9,q9,#31               @ broadcast carry bit
20         vand            q11,q11,q8
21         vshl.i64        q3,q3,#1
22         vext.8          q11,q11,q11,#8
23         vand            q8,q8,q9
24         vorr            q3,q3,q11               @ H<<<=1
25         veor            q3,q3,q8                @ twisted H
26         vst1.64         {q3},[r0]
28         RET
29 .size   gcm_init_v8,.-gcm_init_v8
31 .global gcm_gmult_v8
32 .type   gcm_gmult_v8,%function
33 .align  4
34 gcm_gmult_v8:
35         vld1.64         {q9},[r0]               @ load Xi
36         vmov.i8         q11,#0xe1
37         vld1.64         {q12},[r1]              @ load twisted H
38         vshl.u64        q11,q11,#57
39 #ifndef __ARMEB__
40         vrev64.8        q9,q9
41 #endif
42         vext.8          q13,q12,q12,#8
43         mov             r3,#0
44         vext.8          q3,q9,q9,#8
45         mov             r12,#0
46         veor            q13,q13,q12             @ Karatsuba pre-processing
47         mov             r2,r0
48         b               .Lgmult_v8
49 .size   gcm_gmult_v8,.-gcm_gmult_v8
51 .global gcm_ghash_v8
52 .type   gcm_ghash_v8,%function
53 .align  4
54 gcm_ghash_v8:
55         vld1.64         {q0},[r0]               @ load [rotated] Xi
56         subs            r3,r3,#16
57         vmov.i8         q11,#0xe1
58         mov             r12,#16
59         vld1.64         {q12},[r1]              @ load twisted H
60         moveq   r12,#0
61         vext.8          q0,q0,q0,#8
62         vshl.u64        q11,q11,#57
63         vld1.64         {q9},[r2],r12   @ load [rotated] inp
64         vext.8          q13,q12,q12,#8
65 #ifndef __ARMEB__
66         vrev64.8        q0,q0
67         vrev64.8        q9,q9
68 #endif
69         veor            q13,q13,q12             @ Karatsuba pre-processing
70         vext.8          q3,q9,q9,#8
71         b               .Loop_v8
73 .align  4
74 .Loop_v8:
75         vext.8          q10,q0,q0,#8
76         veor            q3,q3,q0                @ inp^=Xi
77         veor            q9,q9,q10               @ q9 is rotated inp^Xi
79 .Lgmult_v8:
80         .inst   0xf2a80e86      @ pmull q0,q12,q3               @ H.lo·Xi.lo
81         veor            q9,q9,q3                @ Karatsuba pre-processing
82         .inst   0xf2a94e87      @ pmull2 q2,q12,q3              @ H.hi·Xi.hi
83         subs            r3,r3,#16
84         .inst   0xf2aa2ea2      @ pmull q1,q13,q9               @ (H.lo+H.hi)·(Xi.lo+Xi.hi)
85         moveq   r12,#0
87         vext.8          q9,q0,q2,#8             @ Karatsuba post-processing
88         veor            q10,q0,q2
89         veor            q1,q1,q9
90          vld1.64        {q9},[r2],r12   @ load [rotated] inp
91         veor            q1,q1,q10
92         .inst   0xf2e04e26      @ pmull q10,q0,q11              @ 1st phase
94         vmov            d4,d3           @ Xh|Xm - 256-bit result
95         vmov            d3,d0           @ Xm is rotated Xl
96 #ifndef __ARMEB__
97          vrev64.8       q9,q9
98 #endif
99         veor            q0,q1,q10
100          vext.8         q3,q9,q9,#8
102         vext.8          q10,q0,q0,#8            @ 2nd phase
103         .inst   0xf2a00e26      @ pmull q0,q0,q11
104         veor            q10,q10,q2
105         veor            q0,q0,q10
106         bhs             .Loop_v8
108 #ifndef __ARMEB__
109         vrev64.8        q0,q0
110 #endif
111         vext.8          q0,q0,q0,#8
112         vst1.64         {q0},[r0]               @ write out Xi
114         RET
115 .size   gcm_ghash_v8,.-gcm_ghash_v8
116 .asciz  "GHASH for ARMv8, CRYPTOGAMS by <appro@openssl.org>"
117 .align  2