• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.text
2.code	32
3.type	K512,%object
4.align	5
5K512:
6.word	0x428a2f98,0xd728ae22, 0x71374491,0x23ef65cd
7.word	0xb5c0fbcf,0xec4d3b2f, 0xe9b5dba5,0x8189dbbc
8.word	0x3956c25b,0xf348b538, 0x59f111f1,0xb605d019
9.word	0x923f82a4,0xaf194f9b, 0xab1c5ed5,0xda6d8118
10.word	0xd807aa98,0xa3030242, 0x12835b01,0x45706fbe
11.word	0x243185be,0x4ee4b28c, 0x550c7dc3,0xd5ffb4e2
12.word	0x72be5d74,0xf27b896f, 0x80deb1fe,0x3b1696b1
13.word	0x9bdc06a7,0x25c71235, 0xc19bf174,0xcf692694
14.word	0xe49b69c1,0x9ef14ad2, 0xefbe4786,0x384f25e3
15.word	0x0fc19dc6,0x8b8cd5b5, 0x240ca1cc,0x77ac9c65
16.word	0x2de92c6f,0x592b0275, 0x4a7484aa,0x6ea6e483
17.word	0x5cb0a9dc,0xbd41fbd4, 0x76f988da,0x831153b5
18.word	0x983e5152,0xee66dfab, 0xa831c66d,0x2db43210
19.word	0xb00327c8,0x98fb213f, 0xbf597fc7,0xbeef0ee4
20.word	0xc6e00bf3,0x3da88fc2, 0xd5a79147,0x930aa725
21.word	0x06ca6351,0xe003826f, 0x14292967,0x0a0e6e70
22.word	0x27b70a85,0x46d22ffc, 0x2e1b2138,0x5c26c926
23.word	0x4d2c6dfc,0x5ac42aed, 0x53380d13,0x9d95b3df
24.word	0x650a7354,0x8baf63de, 0x766a0abb,0x3c77b2a8
25.word	0x81c2c92e,0x47edaee6, 0x92722c85,0x1482353b
26.word	0xa2bfe8a1,0x4cf10364, 0xa81a664b,0xbc423001
27.word	0xc24b8b70,0xd0f89791, 0xc76c51a3,0x0654be30
28.word	0xd192e819,0xd6ef5218, 0xd6990624,0x5565a910
29.word	0xf40e3585,0x5771202a, 0x106aa070,0x32bbd1b8
30.word	0x19a4c116,0xb8d2d0c8, 0x1e376c08,0x5141ab53
31.word	0x2748774c,0xdf8eeb99, 0x34b0bcb5,0xe19b48a8
32.word	0x391c0cb3,0xc5c95a63, 0x4ed8aa4a,0xe3418acb
33.word	0x5b9cca4f,0x7763e373, 0x682e6ff3,0xd6b2b8a3
34.word	0x748f82ee,0x5defb2fc, 0x78a5636f,0x43172f60
35.word	0x84c87814,0xa1f0ab72, 0x8cc70208,0x1a6439ec
36.word	0x90befffa,0x23631e28, 0xa4506ceb,0xde82bde9
37.word	0xbef9a3f7,0xb2c67915, 0xc67178f2,0xe372532b
38.word	0xca273ece,0xea26619c, 0xd186b8c7,0x21c0c207
39.word	0xeada7dd6,0xcde0eb1e, 0xf57d4f7f,0xee6ed178
40.word	0x06f067aa,0x72176fba, 0x0a637dc5,0xa2c898a6
41.word	0x113f9804,0xbef90dae, 0x1b710b35,0x131c471b
42.word	0x28db77f5,0x23047d84, 0x32caab7b,0x40c72493
43.word	0x3c9ebe0a,0x15c9bebc, 0x431d67c4,0x9c100d4c
44.word	0x4cc5d4be,0xcb3e42b6, 0x597f299c,0xfc657e2a
45.word	0x5fcb6fab,0x3ad6faec, 0x6c44198c,0x4a475817
46.size	K512,.-K512
47
48.global	sha512_block_data_order
49.type	sha512_block_data_order,%function
50sha512_block_data_order:
51	sub	r3,pc,#8		@ sha512_block_data_order
52	add	r2,r1,r2,lsl#7	@ len to point at the end of inp
53	stmdb	sp!,{r4-r12,lr}
54	sub	r14,r3,#640		@ K512
55	sub	sp,sp,#9*8
56
57	ldr	r7,[r0,#32+4]
58	ldr	r8,[r0,#32+0]
59	ldr	r9, [r0,#48+4]
60	ldr	r10, [r0,#48+0]
61	ldr	r11, [r0,#56+4]
62	ldr	r12, [r0,#56+0]
63.Loop:
64	str	r9, [sp,#48+0]
65	str	r10, [sp,#48+4]
66	str	r11, [sp,#56+0]
67	str	r12, [sp,#56+4]
68	ldr	r5,[r0,#0+4]
69	ldr	r6,[r0,#0+0]
70	ldr	r3,[r0,#8+4]
71	ldr	r4,[r0,#8+0]
72	ldr	r9, [r0,#16+4]
73	ldr	r10, [r0,#16+0]
74	ldr	r11, [r0,#24+4]
75	ldr	r12, [r0,#24+0]
76	str	r3,[sp,#8+0]
77	str	r4,[sp,#8+4]
78	str	r9, [sp,#16+0]
79	str	r10, [sp,#16+4]
80	str	r11, [sp,#24+0]
81	str	r12, [sp,#24+4]
82	ldr	r3,[r0,#40+4]
83	ldr	r4,[r0,#40+0]
84	str	r3,[sp,#40+0]
85	str	r4,[sp,#40+4]
86
87.L00_15:
88	ldrb	r3,[r1,#7]
89	ldrb	r9, [r1,#6]
90	ldrb	r10, [r1,#5]
91	ldrb	r11, [r1,#4]
92	ldrb	r4,[r1,#3]
93	ldrb	r12, [r1,#2]
94	orr	r3,r3,r9,lsl#8
95	ldrb	r9, [r1,#1]
96	orr	r3,r3,r10,lsl#16
97	ldrb	r10, [r1],#8
98	orr	r3,r3,r11,lsl#24
99	orr	r4,r4,r12,lsl#8
100	orr	r4,r4,r9,lsl#16
101	orr	r4,r4,r10,lsl#24
102	str	r3,[sp,#64+0]
103	str	r4,[sp,#64+4]
104	ldr	r11,[sp,#56+0]	@ h.lo
105	ldr	r12,[sp,#56+4]	@ h.hi
106	@ Sigma1(x)	(ROTR((x),14) ^ ROTR((x),18)  ^ ROTR((x),41))
107	@ LO		lo>>14^hi<<18 ^ lo>>18^hi<<14 ^ hi>>9^lo<<23
108	@ HI		hi>>14^lo<<18 ^ hi>>18^lo<<14 ^ lo>>9^hi<<23
109	mov	r9,r7,lsr#14
110	mov	r10,r8,lsr#14
111	eor	r9,r9,r8,lsl#18
112	eor	r10,r10,r7,lsl#18
113	eor	r9,r9,r7,lsr#18
114	eor	r10,r10,r8,lsr#18
115	eor	r9,r9,r8,lsl#14
116	eor	r10,r10,r7,lsl#14
117	eor	r9,r9,r8,lsr#9
118	eor	r10,r10,r7,lsr#9
119	eor	r9,r9,r7,lsl#23
120	eor	r10,r10,r8,lsl#23	@ Sigma1(e)
121	adds	r3,r3,r9
122	adc	r4,r4,r10		@ T += Sigma1(e)
123	adds	r3,r3,r11
124	adc	r4,r4,r12		@ T += h
125
126	ldr	r9,[sp,#40+0]	@ f.lo
127	ldr	r10,[sp,#40+4]	@ f.hi
128	ldr	r11,[sp,#48+0]	@ g.lo
129	ldr	r12,[sp,#48+4]	@ g.hi
130	str	r7,[sp,#32+0]
131	str	r8,[sp,#32+4]
132	str	r5,[sp,#0+0]
133	str	r6,[sp,#0+4]
134
135	eor	r9,r9,r11
136	eor	r10,r10,r12
137	and	r9,r9,r7
138	and	r10,r10,r8
139	eor	r9,r9,r11
140	eor	r10,r10,r12		@ Ch(e,f,g)
141
142	ldr	r11,[r14,#4]		@ K[i].lo
143	ldr	r12,[r14,#0]		@ K[i].hi
144	ldr	r7,[sp,#24+0]	@ d.lo
145	ldr	r8,[sp,#24+4]	@ d.hi
146
147	adds	r3,r3,r9
148	adc	r4,r4,r10		@ T += Ch(e,f,g)
149	adds	r3,r3,r11
150	adc	r4,r4,r12		@ T += K[i]
151	adds	r7,r7,r3
152	adc	r8,r8,r4		@ d += T
153
154	and	r9,r11,#0xff
155	teq	r9,#148
156	orreq	r14,r14,#1
157
158	ldr	r11,[sp,#8+0]	@ b.lo
159	ldr	r12,[sp,#16+0]	@ c.lo
160	@ Sigma0(x)	(ROTR((x),28) ^ ROTR((x),34) ^ ROTR((x),39))
161	@ LO		lo>>28^hi<<4  ^ hi>>2^lo<<30 ^ hi>>7^lo<<25
162	@ HI		hi>>28^lo<<4  ^ lo>>2^hi<<30 ^ lo>>7^hi<<25
163	mov	r9,r5,lsr#28
164	mov	r10,r6,lsr#28
165	eor	r9,r9,r6,lsl#4
166	eor	r10,r10,r5,lsl#4
167	eor	r9,r9,r6,lsr#2
168	eor	r10,r10,r5,lsr#2
169	eor	r9,r9,r5,lsl#30
170	eor	r10,r10,r6,lsl#30
171	eor	r9,r9,r6,lsr#7
172	eor	r10,r10,r5,lsr#7
173	eor	r9,r9,r5,lsl#25
174	eor	r10,r10,r6,lsl#25	@ Sigma0(a)
175	adds	r3,r3,r9
176	adc	r4,r4,r10		@ T += Sigma0(a)
177
178	and	r9,r5,r11
179	orr	r5,r5,r11
180	ldr	r10,[sp,#8+4]	@ b.hi
181	ldr	r11,[sp,#16+4]	@ c.hi
182	and	r5,r5,r12
183	orr	r5,r5,r9		@ Maj(a,b,c).lo
184	and	r12,r6,r10
185	orr	r6,r6,r10
186	and	r6,r6,r11
187	orr	r6,r6,r12		@ Maj(a,b,c).hi
188	adds	r5,r5,r3
189	adc	r6,r6,r4		@ h += T
190
191	sub	sp,sp,#8
192	add	r14,r14,#8
193	tst	r14,#1
194	beq	.L00_15
195	bic	r14,r14,#1
196
197.L16_79:
198	ldr	r9,[sp,#184+0]
199	ldr	r10,[sp,#184+4]
200	ldr	r11,[sp,#80+0]
201	ldr	r12,[sp,#80+4]
202
203	@ sigma0(x)	(ROTR((x),1)  ^ ROTR((x),8)  ^ ((x)>>7))
204	@ LO		lo>>1^hi<<31  ^ lo>>8^hi<<24 ^ lo>>7^hi<<25
205	@ HI		hi>>1^lo<<31  ^ hi>>8^lo<<24 ^ hi>>7
206	mov	r3,r9,lsr#1
207	mov	r4,r10,lsr#1
208	eor	r3,r3,r10,lsl#31
209	eor	r4,r4,r9,lsl#31
210	eor	r3,r3,r9,lsr#8
211	eor	r4,r4,r10,lsr#8
212	eor	r3,r3,r10,lsl#24
213	eor	r4,r4,r9,lsl#24
214	eor	r3,r3,r9,lsr#7
215	eor	r4,r4,r10,lsr#7
216	eor	r3,r3,r10,lsl#25
217
218	@ sigma1(x)	(ROTR((x),19) ^ ROTR((x),61) ^ ((x)>>6))
219	@ LO		lo>>19^hi<<13 ^ hi>>29^lo<<3 ^ lo>>6^hi<<26
220	@ HI		hi>>19^lo<<13 ^ lo>>29^hi<<3 ^ hi>>6
221	mov	r9,r11,lsr#19
222	mov	r10,r12,lsr#19
223	eor	r9,r9,r12,lsl#13
224	eor	r10,r10,r11,lsl#13
225	eor	r9,r9,r12,lsr#29
226	eor	r10,r10,r11,lsr#29
227	eor	r9,r9,r11,lsl#3
228	eor	r10,r10,r12,lsl#3
229	eor	r9,r9,r11,lsr#6
230	eor	r10,r10,r12,lsr#6
231	eor	r9,r9,r12,lsl#26
232
233	ldr	r11,[sp,#120+0]
234	ldr	r12,[sp,#120+4]
235	adds	r3,r3,r9
236	adc	r4,r4,r10
237
238	ldr	r9,[sp,#192+0]
239	ldr	r10,[sp,#192+4]
240	adds	r3,r3,r11
241	adc	r4,r4,r12
242	adds	r3,r3,r9
243	adc	r4,r4,r10
244	str	r3,[sp,#64+0]
245	str	r4,[sp,#64+4]
246	ldr	r11,[sp,#56+0]	@ h.lo
247	ldr	r12,[sp,#56+4]	@ h.hi
248	@ Sigma1(x)	(ROTR((x),14) ^ ROTR((x),18)  ^ ROTR((x),41))
249	@ LO		lo>>14^hi<<18 ^ lo>>18^hi<<14 ^ hi>>9^lo<<23
250	@ HI		hi>>14^lo<<18 ^ hi>>18^lo<<14 ^ lo>>9^hi<<23
251	mov	r9,r7,lsr#14
252	mov	r10,r8,lsr#14
253	eor	r9,r9,r8,lsl#18
254	eor	r10,r10,r7,lsl#18
255	eor	r9,r9,r7,lsr#18
256	eor	r10,r10,r8,lsr#18
257	eor	r9,r9,r8,lsl#14
258	eor	r10,r10,r7,lsl#14
259	eor	r9,r9,r8,lsr#9
260	eor	r10,r10,r7,lsr#9
261	eor	r9,r9,r7,lsl#23
262	eor	r10,r10,r8,lsl#23	@ Sigma1(e)
263	adds	r3,r3,r9
264	adc	r4,r4,r10		@ T += Sigma1(e)
265	adds	r3,r3,r11
266	adc	r4,r4,r12		@ T += h
267
268	ldr	r9,[sp,#40+0]	@ f.lo
269	ldr	r10,[sp,#40+4]	@ f.hi
270	ldr	r11,[sp,#48+0]	@ g.lo
271	ldr	r12,[sp,#48+4]	@ g.hi
272	str	r7,[sp,#32+0]
273	str	r8,[sp,#32+4]
274	str	r5,[sp,#0+0]
275	str	r6,[sp,#0+4]
276
277	eor	r9,r9,r11
278	eor	r10,r10,r12
279	and	r9,r9,r7
280	and	r10,r10,r8
281	eor	r9,r9,r11
282	eor	r10,r10,r12		@ Ch(e,f,g)
283
284	ldr	r11,[r14,#4]		@ K[i].lo
285	ldr	r12,[r14,#0]		@ K[i].hi
286	ldr	r7,[sp,#24+0]	@ d.lo
287	ldr	r8,[sp,#24+4]	@ d.hi
288
289	adds	r3,r3,r9
290	adc	r4,r4,r10		@ T += Ch(e,f,g)
291	adds	r3,r3,r11
292	adc	r4,r4,r12		@ T += K[i]
293	adds	r7,r7,r3
294	adc	r8,r8,r4		@ d += T
295
296	and	r9,r11,#0xff
297	teq	r9,#23
298	orreq	r14,r14,#1
299
300	ldr	r11,[sp,#8+0]	@ b.lo
301	ldr	r12,[sp,#16+0]	@ c.lo
302	@ Sigma0(x)	(ROTR((x),28) ^ ROTR((x),34) ^ ROTR((x),39))
303	@ LO		lo>>28^hi<<4  ^ hi>>2^lo<<30 ^ hi>>7^lo<<25
304	@ HI		hi>>28^lo<<4  ^ lo>>2^hi<<30 ^ lo>>7^hi<<25
305	mov	r9,r5,lsr#28
306	mov	r10,r6,lsr#28
307	eor	r9,r9,r6,lsl#4
308	eor	r10,r10,r5,lsl#4
309	eor	r9,r9,r6,lsr#2
310	eor	r10,r10,r5,lsr#2
311	eor	r9,r9,r5,lsl#30
312	eor	r10,r10,r6,lsl#30
313	eor	r9,r9,r6,lsr#7
314	eor	r10,r10,r5,lsr#7
315	eor	r9,r9,r5,lsl#25
316	eor	r10,r10,r6,lsl#25	@ Sigma0(a)
317	adds	r3,r3,r9
318	adc	r4,r4,r10		@ T += Sigma0(a)
319
320	and	r9,r5,r11
321	orr	r5,r5,r11
322	ldr	r10,[sp,#8+4]	@ b.hi
323	ldr	r11,[sp,#16+4]	@ c.hi
324	and	r5,r5,r12
325	orr	r5,r5,r9		@ Maj(a,b,c).lo
326	and	r12,r6,r10
327	orr	r6,r6,r10
328	and	r6,r6,r11
329	orr	r6,r6,r12		@ Maj(a,b,c).hi
330	adds	r5,r5,r3
331	adc	r6,r6,r4		@ h += T
332
333	sub	sp,sp,#8
334	add	r14,r14,#8
335	tst	r14,#1
336	beq	.L16_79
337	bic	r14,r14,#1
338
339	ldr	r3,[sp,#8+0]
340	ldr	r4,[sp,#8+4]
341	ldr	r9, [r0,#0+4]
342	ldr	r10, [r0,#0+0]
343	ldr	r11, [r0,#8+4]
344	ldr	r12, [r0,#8+0]
345	adds	r9,r5,r9
346	adc	r10,r6,r10
347	adds	r11,r3,r11
348	adc	r12,r4,r12
349	str	r9, [r0,#0+4]
350	str	r10, [r0,#0+0]
351	str	r11, [r0,#8+4]
352	str	r12, [r0,#8+0]
353
354	ldr	r5,[sp,#16+0]
355	ldr	r6,[sp,#16+4]
356	ldr	r3,[sp,#24+0]
357	ldr	r4,[sp,#24+4]
358	ldr	r9, [r0,#16+4]
359	ldr	r10, [r0,#16+0]
360	ldr	r11, [r0,#24+4]
361	ldr	r12, [r0,#24+0]
362	adds	r9,r5,r9
363	adc	r10,r6,r10
364	adds	r11,r3,r11
365	adc	r12,r4,r12
366	str	r9, [r0,#16+4]
367	str	r10, [r0,#16+0]
368	str	r11, [r0,#24+4]
369	str	r12, [r0,#24+0]
370
371	ldr	r3,[sp,#40+0]
372	ldr	r4,[sp,#40+4]
373	ldr	r9, [r0,#32+4]
374	ldr	r10, [r0,#32+0]
375	ldr	r11, [r0,#40+4]
376	ldr	r12, [r0,#40+0]
377	adds	r7,r7,r9
378	adc	r8,r8,r10
379	adds	r11,r3,r11
380	adc	r12,r4,r12
381	str	r7,[r0,#32+4]
382	str	r8,[r0,#32+0]
383	str	r11, [r0,#40+4]
384	str	r12, [r0,#40+0]
385
386	ldr	r5,[sp,#48+0]
387	ldr	r6,[sp,#48+4]
388	ldr	r3,[sp,#56+0]
389	ldr	r4,[sp,#56+4]
390	ldr	r9, [r0,#48+4]
391	ldr	r10, [r0,#48+0]
392	ldr	r11, [r0,#56+4]
393	ldr	r12, [r0,#56+0]
394	adds	r9,r5,r9
395	adc	r10,r6,r10
396	adds	r11,r3,r11
397	adc	r12,r4,r12
398	str	r9, [r0,#48+4]
399	str	r10, [r0,#48+0]
400	str	r11, [r0,#56+4]
401	str	r12, [r0,#56+0]
402
403	add	sp,sp,#640
404	sub	r14,r14,#640
405
406	teq	r1,r2
407	bne	.Loop
408
409	add	sp,sp,#8*9		@ destroy frame
410	ldmia	sp!,{r4-r12,lr}
411	tst	lr,#1
412	moveq	pc,lr			@ be binary compatible with V4, yet
413	.word	0xe12fff1e			@ interoperable with Thumb ISA:-)
414.size   sha512_block_data_order,.-sha512_block_data_order
415.asciz  "SHA512 block transform for ARMv4, CRYPTOGAMS by <appro@openssl.org>"
416