1 /**********************************************************************
2 Copyright(c) 2019 Arm Corporation All rights reserved.
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions
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
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.
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 **********************************************************************/
38 .macro declare_var_vector_reg name:req,reg:req
46 .macro sha256_4_rounds_high msg:req,tmp0:req,tmp1:req
48 mov l0_tmp2_v.16b,l0_abcd_v.16b
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
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
69 declare_var_vector_reg key,31
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
82 declare_var_vector_reg l0_tmp0,2
83 declare_var_vector_reg l0_tmp1,3
84 declare_var_vector_reg l0_tmp2,4
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
96 void sha256_mb_ce_x1(SHA1_JOB * l0_job, int len);
105 .global sha256_mb_ce_x1
106 .type sha256_mb_ce_x1, %function
108 ldr l0_data, [l0_job]
109 ldr l0_abcd_q, [l0_job, 64]
110 ldr l0_efgh_q, [l0_job, 80]
117 ld1 {l0_msg0_v.4s-l0_msg3_v.4s},[l0_data]
120 //adjust loop parameter
121 add l0_data,l0_data,64
125 mov l0_abcd_saved_v.16b,l0_abcd_v.16b
126 mov l0_efgh_saved_v.16b,l0_efgh_v.16b
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
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
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
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
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
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
166 str l0_abcd_q, [l0_job, 64]
167 str l0_efgh_q, [l0_job, 80]
171 .size sha256_mb_ce_x1, .-sha256_mb_ce_x1
172 .section .rol0_data.cst16,"aM",@progbits,16