]> git.proxmox.com Git - ceph.git/blob - ceph/src/crypto/isa-l/isa-l_crypto/sha256_mb/aarch64/sha256_mb_x1_ce.S
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / crypto / isa-l / isa-l_crypto / sha256_mb / aarch64 / sha256_mb_x1_ce.S
1 /**********************************************************************
2 Copyright(c) 2019 Arm Corporation All rights reserved.
3
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions
6 are met:
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in
11 the documentation and/or other materials provided with the
12 distribution.
13 * Neither the name of Arm Corporation nor the names of its
14 contributors may be used to endorse or promote products derived
15 from this software without specific prior written permission.
16
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 **********************************************************************/
29 .arch armv8-a+crypto
30 .text
31 .align 2
32 .p2align 3,,7
33
34 /*
35 Macros
36 */
37
38 .macro declare_var_vector_reg name:req,reg:req
39 \name\()_q .req q\reg
40 \name\()_v .req v\reg
41 \name\()_s .req s\reg
42 .endm
43 /**
44 maros for round 48-63
45 */
46 .macro sha256_4_rounds_high msg:req,tmp0:req,tmp1:req
47 ldr key_q , [tmp]
48 mov l0_tmp2_v.16b,l0_abcd_v.16b
49 add tmp,tmp,16
50 add l0_\tmp1\()_v.4s,l0_\msg\()_v.4s,key_v.4s
51 sha256h l0_abcd_q,l0_efgh_q,l0_\tmp0\()_v.4s
52 sha256h2 l0_efgh_q,l0_tmp2_q,l0_\tmp0\()_v.4s
53
54 .endm
55 /**
56 maros for round 0-47
57 */
58 .macro sha256_4_rounds_low msg0:req,msg1:req,msg2:req,msg3:req,tmp0:req,tmp1:req
59 sha256su0 l0_\msg0\()_v.4s,l0_\msg1\()_v.4s
60 sha256_4_rounds_high \msg1,\tmp0,\tmp1
61 sha256su1 l0_\msg0\()_v.4s,l0_\msg2\()_v.4s,l0_\msg3\()_v.4s
62 .endm
63
64
65 /*
66 Variable list
67 */
68
69 declare_var_vector_reg key,31
70
71
72 /*
73 digest variables
74 */
75 declare_var_vector_reg l0_abcd,0
76 declare_var_vector_reg l0_efgh,1
77 declare_var_vector_reg l0_abcd_saved,5
78 declare_var_vector_reg l0_efgh_saved,6
79 /*
80 Temporay variables
81 */
82 declare_var_vector_reg l0_tmp0,2
83 declare_var_vector_reg l0_tmp1,3
84 declare_var_vector_reg l0_tmp2,4
85 /*
86 Message variables
87 */
88 declare_var_vector_reg l0_msg0,16
89 declare_var_vector_reg l0_msg1,17
90 declare_var_vector_reg l0_msg2,18
91 declare_var_vector_reg l0_msg3,19
92
93
94
95 /*
96 void sha256_mb_ce_x1(SHA1_JOB * l0_job, int len);
97 */
98 /*
99 Arguements list
100 */
101 l0_job .req x0
102 len .req w1
103 l0_data .req x2
104 tmp .req x3
105 .global sha256_mb_ce_x1
106 .type sha256_mb_ce_x1, %function
107 sha256_mb_ce_x1:
108 ldr l0_data, [l0_job]
109 ldr l0_abcd_q, [l0_job, 64]
110 ldr l0_efgh_q, [l0_job, 80]
111
112
113
114 start_loop:
115 adr tmp, KEY
116 //load msgs
117 ld1 {l0_msg0_v.4s-l0_msg3_v.4s},[l0_data]
118 ldr key_q,[tmp]
119 add tmp,tmp,16
120 //adjust loop parameter
121 add l0_data,l0_data,64
122 sub len, len, #1
123 cmp len, 0
124 //backup digest
125 mov l0_abcd_saved_v.16b,l0_abcd_v.16b
126 mov l0_efgh_saved_v.16b,l0_efgh_v.16b
127
128 rev32 l0_msg0_v.16b,l0_msg0_v.16b
129 rev32 l0_msg1_v.16b,l0_msg1_v.16b
130 add l0_tmp0_v.4s,l0_msg0_v.4s,key_v.4s
131 rev32 l0_msg2_v.16b,l0_msg2_v.16b
132 rev32 l0_msg3_v.16b,l0_msg3_v.16b
133
134
135
136 sha256_4_rounds_low msg0,msg1,msg2,msg3,tmp0,tmp1 /* rounds 0-3 */
137 sha256_4_rounds_low msg1,msg2,msg3,msg0,tmp1,tmp0
138 sha256_4_rounds_low msg2,msg3,msg0,msg1,tmp0,tmp1
139 sha256_4_rounds_low msg3,msg0,msg1,msg2,tmp1,tmp0
140
141 sha256_4_rounds_low msg0,msg1,msg2,msg3,tmp0,tmp1 /* rounds 16-19 */
142 sha256_4_rounds_low msg1,msg2,msg3,msg0,tmp1,tmp0
143 sha256_4_rounds_low msg2,msg3,msg0,msg1,tmp0,tmp1
144 sha256_4_rounds_low msg3,msg0,msg1,msg2,tmp1,tmp0
145 sha256_4_rounds_low msg0,msg1,msg2,msg3,tmp0,tmp1 /* rounds 32-35 */
146 sha256_4_rounds_low msg1,msg2,msg3,msg0,tmp1,tmp0
147 sha256_4_rounds_low msg2,msg3,msg0,msg1,tmp0,tmp1
148 sha256_4_rounds_low msg3,msg0,msg1,msg2,tmp1,tmp0
149
150 sha256_4_rounds_high msg1,tmp0,tmp1 /* rounds 48-51 */
151 sha256_4_rounds_high msg2,tmp1,tmp0
152 sha256_4_rounds_high msg3,tmp0,tmp1
153
154 /* rounds 60-63 */
155 mov l0_tmp2_v.16b,l0_abcd_v.16b
156 sha256h l0_abcd_q,l0_efgh_q,l0_tmp1_v.4s
157 sha256h2 l0_efgh_q,l0_tmp2_q,l0_tmp1_v.4s
158
159
160
161 add l0_abcd_v.4s,l0_abcd_v.4s,l0_abcd_saved_v.4s
162 add l0_efgh_v.4s,l0_efgh_v.4s,l0_efgh_saved_v.4s
163
164
165 bgt start_loop
166 str l0_abcd_q, [l0_job, 64]
167 str l0_efgh_q, [l0_job, 80]
168
169 ret
170
171 .size sha256_mb_ce_x1, .-sha256_mb_ce_x1
172 .section .rol0_data.cst16,"aM",@progbits,16
173 .align 4
174 KEY:
175 .word 0x428A2F98
176 .word 0x71374491
177 .word 0xB5C0FBCF
178 .word 0xE9B5DBA5
179 .word 0x3956C25B
180 .word 0x59F111F1
181 .word 0x923F82A4
182 .word 0xAB1C5ED5
183 .word 0xD807AA98
184 .word 0x12835B01
185 .word 0x243185BE
186 .word 0x550C7DC3
187 .word 0x72BE5D74
188 .word 0x80DEB1FE
189 .word 0x9BDC06A7
190 .word 0xC19BF174
191 .word 0xE49B69C1
192 .word 0xEFBE4786
193 .word 0x0FC19DC6
194 .word 0x240CA1CC
195 .word 0x2DE92C6F
196 .word 0x4A7484AA
197 .word 0x5CB0A9DC
198 .word 0x76F988DA
199 .word 0x983E5152
200 .word 0xA831C66D
201 .word 0xB00327C8
202 .word 0xBF597FC7
203 .word 0xC6E00BF3
204 .word 0xD5A79147
205 .word 0x06CA6351
206 .word 0x14292967
207 .word 0x27B70A85
208 .word 0x2E1B2138
209 .word 0x4D2C6DFC
210 .word 0x53380D13
211 .word 0x650A7354
212 .word 0x766A0ABB
213 .word 0x81C2C92E
214 .word 0x92722C85
215 .word 0xA2BFE8A1
216 .word 0xA81A664B
217 .word 0xC24B8B70
218 .word 0xC76C51A3
219 .word 0xD192E819
220 .word 0xD6990624
221 .word 0xF40E3585
222 .word 0x106AA070
223 .word 0x19A4C116
224 .word 0x1E376C08
225 .word 0x2748774C
226 .word 0x34B0BCB5
227 .word 0x391C0CB3
228 .word 0x4ED8AA4A
229 .word 0x5B9CCA4F
230 .word 0x682E6FF3
231 .word 0x748F82EE
232 .word 0x78A5636F
233 .word 0x84C87814
234 .word 0x8CC70208
235 .word 0x90BEFFFA
236 .word 0xA4506CEB
237 .word 0xBEF9A3F7
238 .word 0xC67178F2