1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
|
/*
* fips180opt.i586.S
*
* Assembler optimized SHA-1 routines for Intel Pentium processors
*
* Compile target is GNU Assembler
*
* Copyright (c) 2000 Virtual Unlimited B.V.
*
* Author: Bob Deblier <bob@virtualunlimited.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "config.gas.h"
.file "fips180opt.i586.S"
.text
.equ K00, 0x5a827999
.equ K20, 0x6ed9eba1
.equ K40, 0x8f1bbcdc
.equ K60, 0xca62c1d6
.equ PARAM_H, 0
.equ PARAM_DATA, 20
.macro subround1 b c d e w
movl \c,%ecx
movl \b,%ebx
movl \d,%edx
roll $5,%eax
xorl %edx,%ecx
addl \e,%eax
andl %ebx,%ecx
addl $K00,%eax
rorl $2,%ebx
addl \w(%esi,%edi),%eax
xorl %edx,%ecx
movl %ebx,\b
addl %ecx,%eax
movl %eax,\e
.endm
.macro subround2 b c d e w
movl \c,%ecx
movl \b,%ebx
roll $5,%eax
xorl %ebx,%ecx
addl \e,%eax
xorl \d,%ecx
addl $K20,%eax
rorl $2,%ebx
addl \w(%esi,%edi),%eax
movl %ebx,\b
addl %ecx,%eax
movl %eax,\e
.endm
.macro subround3 b c d e w
movl \c,%ecx
roll $5,%eax
movl \b,%ebx
movl %ecx,%edx
addl \e,%eax
orl %ebx,%ecx
andl %ebx,%edx
andl \d,%ecx
addl $K40,%eax
orl %edx,%ecx
addl \w(%esi,%edi),%eax
rorl $2,%ebx
addl %ecx,%eax
movl %ebx,\b
movl %eax,\e
.endm
.macro subround4 b c d e w
movl \c,%ecx
movl \b,%ebx
roll $5,%eax
xorl %ebx,%ecx
addl \e,%eax
xorl \d,%ecx
addl $K60,%eax
rorl $2,%ebx
addl \w(%esi,%edi),%eax
movl %ebx,\b
addl %ecx,%eax
movl %eax,\e
.endm
C_FUNCTION_BEGIN(sha1Process)
pushl %edi
pushl %esi
pushl %ebx
pushl %ebp
movl 20(%esp),%esi
subl $20,%esp
leal PARAM_DATA(%esi),%edi
movl %esp,%ebp
movl $4,%ecx
.L0:
movl (%esi,%ecx,4),%edx
movl %edx,(%ebp,%ecx,4)
decl %ecx
jns .L0
movl $15,%ecx
xorl %eax,%eax
.p2align 2
.L1:
movl (%edi,%ecx,4),%edx
bswap %edx
mov %edx,(%edi,%ecx,4)
decl %ecx
jns .L1
leal PARAM_DATA(%esi),%edi
movl $16,%ecx
.p2align 2
.L2:
movl 52(%edi),%eax
movl 56(%edi),%ebx
xorl 32(%edi),%eax
xorl 36(%edi),%ebx
xorl 8(%edi),%eax
xorl 12(%edi),%ebx
xorl (%edi),%eax
xorl 4(%edi),%ebx
roll $1,%eax
roll $1,%ebx
movl %eax,64(%edi)
movl %ebx,68(%edi)
movl 60(%edi),%eax
movl 64(%edi),%ebx
xorl 40(%edi),%eax
xorl 44(%edi),%ebx
xorl 16(%edi),%eax
xorl 20(%edi),%ebx
xorl 8(%edi),%eax
xorl 12(%edi),%ebx
roll $1,%eax
roll $1,%ebx
movl %eax,72(%edi)
movl %ebx,76(%edi)
addl $16,%edi
decl %ecx
jnz .L2
movl $PARAM_DATA,%edi
movl (%ebp),%eax
.L01_20:
subround1 4(%ebp), 8(%ebp), 12(%ebp), 16(%ebp), 0
subround1 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4
subround1 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8
subround1 12(%ebp), %ebx , (%ebp), 4(%ebp), 12
subround1 8(%ebp), %ebx , 16(%ebp), (%ebp), 16
addl $20,%edi
subround1 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0
subround1 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4
subround1 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8
subround1 12(%ebp), %ebx , (%ebp), 4(%ebp), 12
subround1 8(%ebp), %ebx , 16(%ebp), (%ebp), 16
addl $20,%edi
subround1 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0
subround1 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4
subround1 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8
subround1 12(%ebp), %ebx , (%ebp), 4(%ebp), 12
subround1 8(%ebp), %ebx , 16(%ebp), (%ebp), 16
addl $20,%edi
subround1 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0
subround1 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4
subround1 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8
subround1 12(%ebp), %ebx , (%ebp), 4(%ebp), 12
subround1 8(%ebp), %ebx , 16(%ebp), (%ebp), 16
addl $20,%edi
.L21_40:
subround2 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0
subround2 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4
subround2 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8
subround2 12(%ebp), %ebx , (%ebp), 4(%ebp), 12
subround2 8(%ebp), %ebx , 16(%ebp), (%ebp), 16
addl $20,%edi
subround2 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0
subround2 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4
subround2 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8
subround2 12(%ebp), %ebx , (%ebp), 4(%ebp), 12
subround2 8(%ebp), %ebx , 16(%ebp), (%ebp), 16
addl $20,%edi
subround2 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0
subround2 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4
subround2 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8
subround2 12(%ebp), %ebx , (%ebp), 4(%ebp), 12
subround2 8(%ebp), %ebx , 16(%ebp), (%ebp), 16
addl $20,%edi
subround2 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0
subround2 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4
subround2 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8
subround2 12(%ebp), %ebx , (%ebp), 4(%ebp), 12
subround2 8(%ebp), %ebx , 16(%ebp), (%ebp), 16
addl $20,%edi
.L41_60:
subround3 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0
subround3 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4
subround3 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8
subround3 12(%ebp), %ebx , (%ebp), 4(%ebp), 12
subround3 8(%ebp), %ebx , 16(%ebp), (%ebp), 16
addl $20,%edi
subround3 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0
subround3 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4
subround3 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8
subround3 12(%ebp), %ebx , (%ebp), 4(%ebp), 12
subround3 8(%ebp), %ebx , 16(%ebp), (%ebp), 16
addl $20,%edi
subround3 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0
subround3 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4
subround3 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8
subround3 12(%ebp), %ebx , (%ebp), 4(%ebp), 12
subround3 8(%ebp), %ebx , 16(%ebp), (%ebp), 16
addl $20,%edi
subround3 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0
subround3 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4
subround3 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8
subround3 12(%ebp), %ebx , (%ebp), 4(%ebp), 12
subround3 8(%ebp), %ebx , 16(%ebp), (%ebp), 16
addl $20,%edi
.L61_80:
subround4 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0
subround4 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4
subround4 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8
subround4 12(%ebp), %ebx , (%ebp), 4(%ebp), 12
subround4 8(%ebp), %ebx , 16(%ebp), (%ebp), 16
addl $20,%edi
subround4 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0
subround4 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4
subround4 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8
subround4 12(%ebp), %ebx , (%ebp), 4(%ebp), 12
subround4 8(%ebp), %ebx , 16(%ebp), (%ebp), 16
addl $20,%edi
subround4 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0
subround4 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4
subround4 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8
subround4 12(%ebp), %ebx , (%ebp), 4(%ebp), 12
subround4 8(%ebp), %ebx , 16(%ebp), (%ebp), 16
addl $20,%edi
subround4 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0
subround4 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4
subround4 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8
subround4 12(%ebp), %ebx , (%ebp), 4(%ebp), 12
subround4 8(%ebp), %ebx , 16(%ebp), (%ebp), 16
/* addl $20,%edi */
movl $4,%ecx
.p2align 2
.L3:
movl (%ebp,%ecx,4),%eax
addl %eax,(%esi,%ecx,4)
decl %ecx
jns .L3
addl $20,%esp
popl %ebp
popl %ebx
popl %esi
popl %edi
ret
C_FUNCTION_END(sha1Process, .Lsha1Process_size)
|