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
|
dnl sha1opt.i586.m4
dnl
dnl Copyright (c) 2003 Bob Deblier
dnl
dnl Author: Bob Deblier <bob.deblier@pandora.be>
dnl
dnl This library is free software; you can redistribute it and/or
dnl modify it under the terms of the GNU Lesser General Public
dnl License as published by the Free Software Foundation; either
dnl version 2.1 of the License, or (at your option) any later version.
dnl
dnl This library is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
dnl Lesser General Public License for more details.
dnl
dnl You should have received a copy of the GNU Lesser General Public
dnl License along with this library; if not, write to the Free Software
dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
include(config.m4)
include(ASM_SRCDIR/x86.m4)
.equ K00, 0x5a827999
.equ K20, 0x6ed9eba1
.equ K40, 0x8f1bbcdc
.equ K60, 0xca62c1d6
.equ PARAM_H, 0
.equ PARAM_DATA, 20
define(`subround1',`
movl $2,%ecx
movl $1,%ebx
movl $3,%edx
roll `$'5,%eax
xorl %edx,%ecx
addl $4,%eax
andl %ebx,%ecx
addl `$'K00,%eax
rorl `$'2,%ebx
addl $5(%esi,%edi),%eax
xorl %edx,%ecx
movl %ebx,$1
addl %ecx,%eax
movl %eax,$4
')
define(`subround2',`
movl $2,%ecx
movl $1,%ebx
roll `$'5,%eax
xorl %ebx,%ecx
addl $4,%eax
xorl $3,%ecx
addl `$'K20,%eax
rorl `$'2,%ebx
addl $5(%esi,%edi),%eax
movl %ebx,$1
addl %ecx,%eax
movl %eax,$4
')
define(`subround3',`
movl $2,%ecx
roll `$'5,%eax
movl $1,%ebx
movl %ecx,%edx
addl $4,%eax
orl %ebx,%ecx
andl %ebx,%edx
andl $3,%ecx
addl `$'K40,%eax
orl %edx,%ecx
addl $5(%esi,%edi),%eax
rorl `$'2,%ebx
addl %ecx,%eax
movl %ebx,$1
movl %eax,$4
')
define(`subround4',`
movl $2,%ecx
movl $1,%ebx
roll `$'5,%eax
xorl %ebx,%ecx
addl $4,%eax
xorl $3,%ecx
addl `$'K60,%eax
rorl `$'2,%ebx
addl $5(%esi,%edi),%eax
movl %ebx,$1
addl %ecx,%eax
movl %eax,$4
')
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
LOCAL(0):
movl (%esi,%ecx,4),%edx
movl %edx,(%ebp,%ecx,4)
decl %ecx
jns LOCAL(0)
movl `$'15,%ecx
.align 4
LOCAL(1):
movl (%edi,%ecx,4),%edx
ifdef(`USE_BSWAP',`
bswap %edx
',`
movl %edx,%eax
andl `$'0xff00ff,%edx
rol `$'8,%eax
andl `$'0xff00ff,%eax
ror `$'8,%edx
or %eax,%edx
')
mov %edx,(%edi,%ecx,4)
decl %ecx
jns LOCAL(1)
leal PARAM_DATA(%esi),%edi
movl `$'16,%ecx
xorl %eax,%eax
.align 4
LOCAL(2):
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 LOCAL(2)
movl `$'PARAM_DATA,%edi
movl (%ebp),%eax
LOCAL(01_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
LOCAL(21_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
LOCAL(41_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
LOCAL(61_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)
movl `$'4,%ecx
.align 4
LOCAL(3):
movl (%ebp,%ecx,4),%eax
addl %eax,(%esi,%ecx,4)
decl %ecx
jns LOCAL(3)
addl `$'20,%esp
popl %ebp
popl %ebx
popl %esi
popl %edi
ret
C_FUNCTION_END(sha1Process)
|