line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
/********************************************************************\ |
2
|
|
|
|
|
|
|
* |
3
|
|
|
|
|
|
|
* FILE: rmd160.c |
4
|
|
|
|
|
|
|
* |
5
|
|
|
|
|
|
|
* CONTENTS: A sample C-implementation of the RIPEMD-160 |
6
|
|
|
|
|
|
|
* hash-function. |
7
|
|
|
|
|
|
|
* TARGET: any computer with an ANSI C compiler |
8
|
|
|
|
|
|
|
* |
9
|
|
|
|
|
|
|
* AUTHOR: Antoon Bosselaers, ESAT-COSIC |
10
|
|
|
|
|
|
|
* DATE: 1 March 1996 |
11
|
|
|
|
|
|
|
* VERSION: 1.0 |
12
|
|
|
|
|
|
|
* |
13
|
|
|
|
|
|
|
* Copyright (c) Katholieke Universiteit Leuven |
14
|
|
|
|
|
|
|
* 1996, All Rights Reserved |
15
|
|
|
|
|
|
|
* |
16
|
|
|
|
|
|
|
\********************************************************************/ |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
/* header files */ |
19
|
|
|
|
|
|
|
#include |
20
|
|
|
|
|
|
|
#include |
21
|
|
|
|
|
|
|
#include |
22
|
|
|
|
|
|
|
#include "rmd160.h" |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
/********************************************************************/ |
25
|
|
|
|
|
|
|
|
26
|
38
|
|
|
|
|
|
void MDinit(dword *MDbuf) |
27
|
|
|
|
|
|
|
{ |
28
|
38
|
|
|
|
|
|
MDbuf[0] = 0x67452301UL; |
29
|
38
|
|
|
|
|
|
MDbuf[1] = 0xefcdab89UL; |
30
|
38
|
|
|
|
|
|
MDbuf[2] = 0x98badcfeUL; |
31
|
38
|
|
|
|
|
|
MDbuf[3] = 0x10325476UL; |
32
|
38
|
|
|
|
|
|
MDbuf[4] = 0xc3d2e1f0UL; |
33
|
|
|
|
|
|
|
|
34
|
38
|
|
|
|
|
|
return; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
/********************************************************************/ |
38
|
|
|
|
|
|
|
|
39
|
16341
|
|
|
|
|
|
void rmd160_compress(dword *MDbuf, dword *X) |
40
|
|
|
|
|
|
|
{ |
41
|
16341
|
|
|
|
|
|
dword aa = MDbuf[0], bb = MDbuf[1], cc = MDbuf[2], |
42
|
16341
|
|
|
|
|
|
dd = MDbuf[3], ee = MDbuf[4]; |
43
|
16341
|
|
|
|
|
|
dword aaa = MDbuf[0], bbb = MDbuf[1], ccc = MDbuf[2], |
44
|
16341
|
|
|
|
|
|
ddd = MDbuf[3], eee = MDbuf[4]; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
/* round 1 */ |
47
|
16341
|
|
|
|
|
|
FF(aa, bb, cc, dd, ee, X[ 0], 11); |
48
|
16341
|
|
|
|
|
|
FF(ee, aa, bb, cc, dd, X[ 1], 14); |
49
|
16341
|
|
|
|
|
|
FF(dd, ee, aa, bb, cc, X[ 2], 15); |
50
|
16341
|
|
|
|
|
|
FF(cc, dd, ee, aa, bb, X[ 3], 12); |
51
|
16341
|
|
|
|
|
|
FF(bb, cc, dd, ee, aa, X[ 4], 5); |
52
|
16341
|
|
|
|
|
|
FF(aa, bb, cc, dd, ee, X[ 5], 8); |
53
|
16341
|
|
|
|
|
|
FF(ee, aa, bb, cc, dd, X[ 6], 7); |
54
|
16341
|
|
|
|
|
|
FF(dd, ee, aa, bb, cc, X[ 7], 9); |
55
|
16341
|
|
|
|
|
|
FF(cc, dd, ee, aa, bb, X[ 8], 11); |
56
|
16341
|
|
|
|
|
|
FF(bb, cc, dd, ee, aa, X[ 9], 13); |
57
|
16341
|
|
|
|
|
|
FF(aa, bb, cc, dd, ee, X[10], 14); |
58
|
16341
|
|
|
|
|
|
FF(ee, aa, bb, cc, dd, X[11], 15); |
59
|
16341
|
|
|
|
|
|
FF(dd, ee, aa, bb, cc, X[12], 6); |
60
|
16341
|
|
|
|
|
|
FF(cc, dd, ee, aa, bb, X[13], 7); |
61
|
16341
|
|
|
|
|
|
FF(bb, cc, dd, ee, aa, X[14], 9); |
62
|
16341
|
|
|
|
|
|
FF(aa, bb, cc, dd, ee, X[15], 8); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
/* round 2 */ |
65
|
16341
|
|
|
|
|
|
GG(ee, aa, bb, cc, dd, X[ 7], 7); |
66
|
16341
|
|
|
|
|
|
GG(dd, ee, aa, bb, cc, X[ 4], 6); |
67
|
16341
|
|
|
|
|
|
GG(cc, dd, ee, aa, bb, X[13], 8); |
68
|
16341
|
|
|
|
|
|
GG(bb, cc, dd, ee, aa, X[ 1], 13); |
69
|
16341
|
|
|
|
|
|
GG(aa, bb, cc, dd, ee, X[10], 11); |
70
|
16341
|
|
|
|
|
|
GG(ee, aa, bb, cc, dd, X[ 6], 9); |
71
|
16341
|
|
|
|
|
|
GG(dd, ee, aa, bb, cc, X[15], 7); |
72
|
16341
|
|
|
|
|
|
GG(cc, dd, ee, aa, bb, X[ 3], 15); |
73
|
16341
|
|
|
|
|
|
GG(bb, cc, dd, ee, aa, X[12], 7); |
74
|
16341
|
|
|
|
|
|
GG(aa, bb, cc, dd, ee, X[ 0], 12); |
75
|
16341
|
|
|
|
|
|
GG(ee, aa, bb, cc, dd, X[ 9], 15); |
76
|
16341
|
|
|
|
|
|
GG(dd, ee, aa, bb, cc, X[ 5], 9); |
77
|
16341
|
|
|
|
|
|
GG(cc, dd, ee, aa, bb, X[ 2], 11); |
78
|
16341
|
|
|
|
|
|
GG(bb, cc, dd, ee, aa, X[14], 7); |
79
|
16341
|
|
|
|
|
|
GG(aa, bb, cc, dd, ee, X[11], 13); |
80
|
16341
|
|
|
|
|
|
GG(ee, aa, bb, cc, dd, X[ 8], 12); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
/* round 3 */ |
83
|
16341
|
|
|
|
|
|
HH(dd, ee, aa, bb, cc, X[ 3], 11); |
84
|
16341
|
|
|
|
|
|
HH(cc, dd, ee, aa, bb, X[10], 13); |
85
|
16341
|
|
|
|
|
|
HH(bb, cc, dd, ee, aa, X[14], 6); |
86
|
16341
|
|
|
|
|
|
HH(aa, bb, cc, dd, ee, X[ 4], 7); |
87
|
16341
|
|
|
|
|
|
HH(ee, aa, bb, cc, dd, X[ 9], 14); |
88
|
16341
|
|
|
|
|
|
HH(dd, ee, aa, bb, cc, X[15], 9); |
89
|
16341
|
|
|
|
|
|
HH(cc, dd, ee, aa, bb, X[ 8], 13); |
90
|
16341
|
|
|
|
|
|
HH(bb, cc, dd, ee, aa, X[ 1], 15); |
91
|
16341
|
|
|
|
|
|
HH(aa, bb, cc, dd, ee, X[ 2], 14); |
92
|
16341
|
|
|
|
|
|
HH(ee, aa, bb, cc, dd, X[ 7], 8); |
93
|
16341
|
|
|
|
|
|
HH(dd, ee, aa, bb, cc, X[ 0], 13); |
94
|
16341
|
|
|
|
|
|
HH(cc, dd, ee, aa, bb, X[ 6], 6); |
95
|
16341
|
|
|
|
|
|
HH(bb, cc, dd, ee, aa, X[13], 5); |
96
|
16341
|
|
|
|
|
|
HH(aa, bb, cc, dd, ee, X[11], 12); |
97
|
16341
|
|
|
|
|
|
HH(ee, aa, bb, cc, dd, X[ 5], 7); |
98
|
16341
|
|
|
|
|
|
HH(dd, ee, aa, bb, cc, X[12], 5); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
/* round 4 */ |
101
|
16341
|
|
|
|
|
|
II(cc, dd, ee, aa, bb, X[ 1], 11); |
102
|
16341
|
|
|
|
|
|
II(bb, cc, dd, ee, aa, X[ 9], 12); |
103
|
16341
|
|
|
|
|
|
II(aa, bb, cc, dd, ee, X[11], 14); |
104
|
16341
|
|
|
|
|
|
II(ee, aa, bb, cc, dd, X[10], 15); |
105
|
16341
|
|
|
|
|
|
II(dd, ee, aa, bb, cc, X[ 0], 14); |
106
|
16341
|
|
|
|
|
|
II(cc, dd, ee, aa, bb, X[ 8], 15); |
107
|
16341
|
|
|
|
|
|
II(bb, cc, dd, ee, aa, X[12], 9); |
108
|
16341
|
|
|
|
|
|
II(aa, bb, cc, dd, ee, X[ 4], 8); |
109
|
16341
|
|
|
|
|
|
II(ee, aa, bb, cc, dd, X[13], 9); |
110
|
16341
|
|
|
|
|
|
II(dd, ee, aa, bb, cc, X[ 3], 14); |
111
|
16341
|
|
|
|
|
|
II(cc, dd, ee, aa, bb, X[ 7], 5); |
112
|
16341
|
|
|
|
|
|
II(bb, cc, dd, ee, aa, X[15], 6); |
113
|
16341
|
|
|
|
|
|
II(aa, bb, cc, dd, ee, X[14], 8); |
114
|
16341
|
|
|
|
|
|
II(ee, aa, bb, cc, dd, X[ 5], 6); |
115
|
16341
|
|
|
|
|
|
II(dd, ee, aa, bb, cc, X[ 6], 5); |
116
|
16341
|
|
|
|
|
|
II(cc, dd, ee, aa, bb, X[ 2], 12); |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
/* round 5 */ |
119
|
16341
|
|
|
|
|
|
JJ(bb, cc, dd, ee, aa, X[ 4], 9); |
120
|
16341
|
|
|
|
|
|
JJ(aa, bb, cc, dd, ee, X[ 0], 15); |
121
|
16341
|
|
|
|
|
|
JJ(ee, aa, bb, cc, dd, X[ 5], 5); |
122
|
16341
|
|
|
|
|
|
JJ(dd, ee, aa, bb, cc, X[ 9], 11); |
123
|
16341
|
|
|
|
|
|
JJ(cc, dd, ee, aa, bb, X[ 7], 6); |
124
|
16341
|
|
|
|
|
|
JJ(bb, cc, dd, ee, aa, X[12], 8); |
125
|
16341
|
|
|
|
|
|
JJ(aa, bb, cc, dd, ee, X[ 2], 13); |
126
|
16341
|
|
|
|
|
|
JJ(ee, aa, bb, cc, dd, X[10], 12); |
127
|
16341
|
|
|
|
|
|
JJ(dd, ee, aa, bb, cc, X[14], 5); |
128
|
16341
|
|
|
|
|
|
JJ(cc, dd, ee, aa, bb, X[ 1], 12); |
129
|
16341
|
|
|
|
|
|
JJ(bb, cc, dd, ee, aa, X[ 3], 13); |
130
|
16341
|
|
|
|
|
|
JJ(aa, bb, cc, dd, ee, X[ 8], 14); |
131
|
16341
|
|
|
|
|
|
JJ(ee, aa, bb, cc, dd, X[11], 11); |
132
|
16341
|
|
|
|
|
|
JJ(dd, ee, aa, bb, cc, X[ 6], 8); |
133
|
16341
|
|
|
|
|
|
JJ(cc, dd, ee, aa, bb, X[15], 5); |
134
|
16341
|
|
|
|
|
|
JJ(bb, cc, dd, ee, aa, X[13], 6); |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
/* parallel round 1 */ |
137
|
16341
|
|
|
|
|
|
JJJ(aaa, bbb, ccc, ddd, eee, X[ 5], 8); |
138
|
16341
|
|
|
|
|
|
JJJ(eee, aaa, bbb, ccc, ddd, X[14], 9); |
139
|
16341
|
|
|
|
|
|
JJJ(ddd, eee, aaa, bbb, ccc, X[ 7], 9); |
140
|
16341
|
|
|
|
|
|
JJJ(ccc, ddd, eee, aaa, bbb, X[ 0], 11); |
141
|
16341
|
|
|
|
|
|
JJJ(bbb, ccc, ddd, eee, aaa, X[ 9], 13); |
142
|
16341
|
|
|
|
|
|
JJJ(aaa, bbb, ccc, ddd, eee, X[ 2], 15); |
143
|
16341
|
|
|
|
|
|
JJJ(eee, aaa, bbb, ccc, ddd, X[11], 15); |
144
|
16341
|
|
|
|
|
|
JJJ(ddd, eee, aaa, bbb, ccc, X[ 4], 5); |
145
|
16341
|
|
|
|
|
|
JJJ(ccc, ddd, eee, aaa, bbb, X[13], 7); |
146
|
16341
|
|
|
|
|
|
JJJ(bbb, ccc, ddd, eee, aaa, X[ 6], 7); |
147
|
16341
|
|
|
|
|
|
JJJ(aaa, bbb, ccc, ddd, eee, X[15], 8); |
148
|
16341
|
|
|
|
|
|
JJJ(eee, aaa, bbb, ccc, ddd, X[ 8], 11); |
149
|
16341
|
|
|
|
|
|
JJJ(ddd, eee, aaa, bbb, ccc, X[ 1], 14); |
150
|
16341
|
|
|
|
|
|
JJJ(ccc, ddd, eee, aaa, bbb, X[10], 14); |
151
|
16341
|
|
|
|
|
|
JJJ(bbb, ccc, ddd, eee, aaa, X[ 3], 12); |
152
|
16341
|
|
|
|
|
|
JJJ(aaa, bbb, ccc, ddd, eee, X[12], 6); |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
/* parallel round 2 */ |
155
|
16341
|
|
|
|
|
|
III(eee, aaa, bbb, ccc, ddd, X[ 6], 9); |
156
|
16341
|
|
|
|
|
|
III(ddd, eee, aaa, bbb, ccc, X[11], 13); |
157
|
16341
|
|
|
|
|
|
III(ccc, ddd, eee, aaa, bbb, X[ 3], 15); |
158
|
16341
|
|
|
|
|
|
III(bbb, ccc, ddd, eee, aaa, X[ 7], 7); |
159
|
16341
|
|
|
|
|
|
III(aaa, bbb, ccc, ddd, eee, X[ 0], 12); |
160
|
16341
|
|
|
|
|
|
III(eee, aaa, bbb, ccc, ddd, X[13], 8); |
161
|
16341
|
|
|
|
|
|
III(ddd, eee, aaa, bbb, ccc, X[ 5], 9); |
162
|
16341
|
|
|
|
|
|
III(ccc, ddd, eee, aaa, bbb, X[10], 11); |
163
|
16341
|
|
|
|
|
|
III(bbb, ccc, ddd, eee, aaa, X[14], 7); |
164
|
16341
|
|
|
|
|
|
III(aaa, bbb, ccc, ddd, eee, X[15], 7); |
165
|
16341
|
|
|
|
|
|
III(eee, aaa, bbb, ccc, ddd, X[ 8], 12); |
166
|
16341
|
|
|
|
|
|
III(ddd, eee, aaa, bbb, ccc, X[12], 7); |
167
|
16341
|
|
|
|
|
|
III(ccc, ddd, eee, aaa, bbb, X[ 4], 6); |
168
|
16341
|
|
|
|
|
|
III(bbb, ccc, ddd, eee, aaa, X[ 9], 15); |
169
|
16341
|
|
|
|
|
|
III(aaa, bbb, ccc, ddd, eee, X[ 1], 13); |
170
|
16341
|
|
|
|
|
|
III(eee, aaa, bbb, ccc, ddd, X[ 2], 11); |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
/* parallel round 3 */ |
173
|
16341
|
|
|
|
|
|
HHH(ddd, eee, aaa, bbb, ccc, X[15], 9); |
174
|
16341
|
|
|
|
|
|
HHH(ccc, ddd, eee, aaa, bbb, X[ 5], 7); |
175
|
16341
|
|
|
|
|
|
HHH(bbb, ccc, ddd, eee, aaa, X[ 1], 15); |
176
|
16341
|
|
|
|
|
|
HHH(aaa, bbb, ccc, ddd, eee, X[ 3], 11); |
177
|
16341
|
|
|
|
|
|
HHH(eee, aaa, bbb, ccc, ddd, X[ 7], 8); |
178
|
16341
|
|
|
|
|
|
HHH(ddd, eee, aaa, bbb, ccc, X[14], 6); |
179
|
16341
|
|
|
|
|
|
HHH(ccc, ddd, eee, aaa, bbb, X[ 6], 6); |
180
|
16341
|
|
|
|
|
|
HHH(bbb, ccc, ddd, eee, aaa, X[ 9], 14); |
181
|
16341
|
|
|
|
|
|
HHH(aaa, bbb, ccc, ddd, eee, X[11], 12); |
182
|
16341
|
|
|
|
|
|
HHH(eee, aaa, bbb, ccc, ddd, X[ 8], 13); |
183
|
16341
|
|
|
|
|
|
HHH(ddd, eee, aaa, bbb, ccc, X[12], 5); |
184
|
16341
|
|
|
|
|
|
HHH(ccc, ddd, eee, aaa, bbb, X[ 2], 14); |
185
|
16341
|
|
|
|
|
|
HHH(bbb, ccc, ddd, eee, aaa, X[10], 13); |
186
|
16341
|
|
|
|
|
|
HHH(aaa, bbb, ccc, ddd, eee, X[ 0], 13); |
187
|
16341
|
|
|
|
|
|
HHH(eee, aaa, bbb, ccc, ddd, X[ 4], 7); |
188
|
16341
|
|
|
|
|
|
HHH(ddd, eee, aaa, bbb, ccc, X[13], 5); |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
/* parallel round 4 */ |
191
|
16341
|
|
|
|
|
|
GGG(ccc, ddd, eee, aaa, bbb, X[ 8], 15); |
192
|
16341
|
|
|
|
|
|
GGG(bbb, ccc, ddd, eee, aaa, X[ 6], 5); |
193
|
16341
|
|
|
|
|
|
GGG(aaa, bbb, ccc, ddd, eee, X[ 4], 8); |
194
|
16341
|
|
|
|
|
|
GGG(eee, aaa, bbb, ccc, ddd, X[ 1], 11); |
195
|
16341
|
|
|
|
|
|
GGG(ddd, eee, aaa, bbb, ccc, X[ 3], 14); |
196
|
16341
|
|
|
|
|
|
GGG(ccc, ddd, eee, aaa, bbb, X[11], 14); |
197
|
16341
|
|
|
|
|
|
GGG(bbb, ccc, ddd, eee, aaa, X[15], 6); |
198
|
16341
|
|
|
|
|
|
GGG(aaa, bbb, ccc, ddd, eee, X[ 0], 14); |
199
|
16341
|
|
|
|
|
|
GGG(eee, aaa, bbb, ccc, ddd, X[ 5], 6); |
200
|
16341
|
|
|
|
|
|
GGG(ddd, eee, aaa, bbb, ccc, X[12], 9); |
201
|
16341
|
|
|
|
|
|
GGG(ccc, ddd, eee, aaa, bbb, X[ 2], 12); |
202
|
16341
|
|
|
|
|
|
GGG(bbb, ccc, ddd, eee, aaa, X[13], 9); |
203
|
16341
|
|
|
|
|
|
GGG(aaa, bbb, ccc, ddd, eee, X[ 9], 12); |
204
|
16341
|
|
|
|
|
|
GGG(eee, aaa, bbb, ccc, ddd, X[ 7], 5); |
205
|
16341
|
|
|
|
|
|
GGG(ddd, eee, aaa, bbb, ccc, X[10], 15); |
206
|
16341
|
|
|
|
|
|
GGG(ccc, ddd, eee, aaa, bbb, X[14], 8); |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
/* parallel round 5 */ |
209
|
16341
|
|
|
|
|
|
FFF(bbb, ccc, ddd, eee, aaa, X[12] , 8); |
210
|
16341
|
|
|
|
|
|
FFF(aaa, bbb, ccc, ddd, eee, X[15] , 5); |
211
|
16341
|
|
|
|
|
|
FFF(eee, aaa, bbb, ccc, ddd, X[10] , 12); |
212
|
16341
|
|
|
|
|
|
FFF(ddd, eee, aaa, bbb, ccc, X[ 4] , 9); |
213
|
16341
|
|
|
|
|
|
FFF(ccc, ddd, eee, aaa, bbb, X[ 1] , 12); |
214
|
16341
|
|
|
|
|
|
FFF(bbb, ccc, ddd, eee, aaa, X[ 5] , 5); |
215
|
16341
|
|
|
|
|
|
FFF(aaa, bbb, ccc, ddd, eee, X[ 8] , 14); |
216
|
16341
|
|
|
|
|
|
FFF(eee, aaa, bbb, ccc, ddd, X[ 7] , 6); |
217
|
16341
|
|
|
|
|
|
FFF(ddd, eee, aaa, bbb, ccc, X[ 6] , 8); |
218
|
16341
|
|
|
|
|
|
FFF(ccc, ddd, eee, aaa, bbb, X[ 2] , 13); |
219
|
16341
|
|
|
|
|
|
FFF(bbb, ccc, ddd, eee, aaa, X[13] , 6); |
220
|
16341
|
|
|
|
|
|
FFF(aaa, bbb, ccc, ddd, eee, X[14] , 5); |
221
|
16341
|
|
|
|
|
|
FFF(eee, aaa, bbb, ccc, ddd, X[ 0] , 15); |
222
|
16341
|
|
|
|
|
|
FFF(ddd, eee, aaa, bbb, ccc, X[ 3] , 13); |
223
|
16341
|
|
|
|
|
|
FFF(ccc, ddd, eee, aaa, bbb, X[ 9] , 11); |
224
|
16341
|
|
|
|
|
|
FFF(bbb, ccc, ddd, eee, aaa, X[11] , 11); |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
/* combine results */ |
227
|
16341
|
|
|
|
|
|
ddd += cc + MDbuf[1]; /* final result for MDbuf[0] */ |
228
|
16341
|
|
|
|
|
|
MDbuf[1] = MDbuf[2] + dd + eee; |
229
|
16341
|
|
|
|
|
|
MDbuf[2] = MDbuf[3] + ee + aaa; |
230
|
16341
|
|
|
|
|
|
MDbuf[3] = MDbuf[4] + aa + bbb; |
231
|
16341
|
|
|
|
|
|
MDbuf[4] = MDbuf[0] + bb + ccc; |
232
|
16341
|
|
|
|
|
|
MDbuf[0] = ddd; |
233
|
|
|
|
|
|
|
|
234
|
16341
|
|
|
|
|
|
return; |
235
|
|
|
|
|
|
|
} |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
/********************************************************************/ |
238
|
|
|
|
|
|
|
|
239
|
36
|
|
|
|
|
|
void MDfinish(dword *MDbuf, byte *strptr, dword lswlen, dword mswlen) |
240
|
|
|
|
|
|
|
{ |
241
|
|
|
|
|
|
|
dword i; /* counter */ |
242
|
|
|
|
|
|
|
dword X[16]; /* message words */ |
243
|
|
|
|
|
|
|
|
244
|
36
|
|
|
|
|
|
memset(X, 0, 16*sizeof(dword)); |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
/* put bytes from strptr into X */ |
247
|
738
|
100
|
|
|
|
|
for (i=0; i<(lswlen&63); i++) { |
248
|
|
|
|
|
|
|
/* byte i goes into word X[i div 4] at pos. 8*(i mod 4) */ |
249
|
702
|
|
|
|
|
|
X[i>>2] ^= (dword) *strptr++ << (8 * (i&3)); |
250
|
|
|
|
|
|
|
} |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
/* append the bit m_n == 1 */ |
253
|
36
|
|
|
|
|
|
X[(lswlen>>2)&15] ^= (dword)1 << (8*(lswlen&3) + 7); |
254
|
|
|
|
|
|
|
|
255
|
36
|
100
|
|
|
|
|
if ((lswlen & 63) > 55) { |
256
|
|
|
|
|
|
|
/* length goes to next block */ |
257
|
2
|
|
|
|
|
|
rmd160_compress(MDbuf, X); |
258
|
2
|
|
|
|
|
|
memset(X, 0, 16*sizeof(dword)); |
259
|
|
|
|
|
|
|
} |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
/* append length in bits*/ |
262
|
36
|
|
|
|
|
|
X[14] = lswlen << 3; |
263
|
36
|
|
|
|
|
|
X[15] = (lswlen >> 29) | (mswlen << 3); |
264
|
36
|
|
|
|
|
|
rmd160_compress(MDbuf, X); |
265
|
|
|
|
|
|
|
|
266
|
36
|
|
|
|
|
|
return; |
267
|
|
|
|
|
|
|
} |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
/************************ end of file rmd160.c **********************/ |
270
|
|
|
|
|
|
|
|