Lines Matching +full:in +full:-

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * RIPEMD-160 - RACE Integrity Primitives Evaluation Message Digest.
7 * Based on the reference implementation by Antoon Bosselaers, ESAT-COSIC
9 * Copyright (c) 2008 Adrian-Ken Rueegsegger <ken@codelabs.ch>
49 static void rmd160_transform(u32 *state, const __le32 *in) in rmd160_transform() argument
68 ROUND(aa, bb, cc, dd, ee, F1, K1, in[0], 11); in rmd160_transform()
69 ROUND(ee, aa, bb, cc, dd, F1, K1, in[1], 14); in rmd160_transform()
70 ROUND(dd, ee, aa, bb, cc, F1, K1, in[2], 15); in rmd160_transform()
71 ROUND(cc, dd, ee, aa, bb, F1, K1, in[3], 12); in rmd160_transform()
72 ROUND(bb, cc, dd, ee, aa, F1, K1, in[4], 5); in rmd160_transform()
73 ROUND(aa, bb, cc, dd, ee, F1, K1, in[5], 8); in rmd160_transform()
74 ROUND(ee, aa, bb, cc, dd, F1, K1, in[6], 7); in rmd160_transform()
75 ROUND(dd, ee, aa, bb, cc, F1, K1, in[7], 9); in rmd160_transform()
76 ROUND(cc, dd, ee, aa, bb, F1, K1, in[8], 11); in rmd160_transform()
77 ROUND(bb, cc, dd, ee, aa, F1, K1, in[9], 13); in rmd160_transform()
78 ROUND(aa, bb, cc, dd, ee, F1, K1, in[10], 14); in rmd160_transform()
79 ROUND(ee, aa, bb, cc, dd, F1, K1, in[11], 15); in rmd160_transform()
80 ROUND(dd, ee, aa, bb, cc, F1, K1, in[12], 6); in rmd160_transform()
81 ROUND(cc, dd, ee, aa, bb, F1, K1, in[13], 7); in rmd160_transform()
82 ROUND(bb, cc, dd, ee, aa, F1, K1, in[14], 9); in rmd160_transform()
83 ROUND(aa, bb, cc, dd, ee, F1, K1, in[15], 8); in rmd160_transform()
86 ROUND(ee, aa, bb, cc, dd, F2, K2, in[7], 7); in rmd160_transform()
87 ROUND(dd, ee, aa, bb, cc, F2, K2, in[4], 6); in rmd160_transform()
88 ROUND(cc, dd, ee, aa, bb, F2, K2, in[13], 8); in rmd160_transform()
89 ROUND(bb, cc, dd, ee, aa, F2, K2, in[1], 13); in rmd160_transform()
90 ROUND(aa, bb, cc, dd, ee, F2, K2, in[10], 11); in rmd160_transform()
91 ROUND(ee, aa, bb, cc, dd, F2, K2, in[6], 9); in rmd160_transform()
92 ROUND(dd, ee, aa, bb, cc, F2, K2, in[15], 7); in rmd160_transform()
93 ROUND(cc, dd, ee, aa, bb, F2, K2, in[3], 15); in rmd160_transform()
94 ROUND(bb, cc, dd, ee, aa, F2, K2, in[12], 7); in rmd160_transform()
95 ROUND(aa, bb, cc, dd, ee, F2, K2, in[0], 12); in rmd160_transform()
96 ROUND(ee, aa, bb, cc, dd, F2, K2, in[9], 15); in rmd160_transform()
97 ROUND(dd, ee, aa, bb, cc, F2, K2, in[5], 9); in rmd160_transform()
98 ROUND(cc, dd, ee, aa, bb, F2, K2, in[2], 11); in rmd160_transform()
99 ROUND(bb, cc, dd, ee, aa, F2, K2, in[14], 7); in rmd160_transform()
100 ROUND(aa, bb, cc, dd, ee, F2, K2, in[11], 13); in rmd160_transform()
101 ROUND(ee, aa, bb, cc, dd, F2, K2, in[8], 12); in rmd160_transform()
104 ROUND(dd, ee, aa, bb, cc, F3, K3, in[3], 11); in rmd160_transform()
105 ROUND(cc, dd, ee, aa, bb, F3, K3, in[10], 13); in rmd160_transform()
106 ROUND(bb, cc, dd, ee, aa, F3, K3, in[14], 6); in rmd160_transform()
107 ROUND(aa, bb, cc, dd, ee, F3, K3, in[4], 7); in rmd160_transform()
108 ROUND(ee, aa, bb, cc, dd, F3, K3, in[9], 14); in rmd160_transform()
109 ROUND(dd, ee, aa, bb, cc, F3, K3, in[15], 9); in rmd160_transform()
110 ROUND(cc, dd, ee, aa, bb, F3, K3, in[8], 13); in rmd160_transform()
111 ROUND(bb, cc, dd, ee, aa, F3, K3, in[1], 15); in rmd160_transform()
112 ROUND(aa, bb, cc, dd, ee, F3, K3, in[2], 14); in rmd160_transform()
113 ROUND(ee, aa, bb, cc, dd, F3, K3, in[7], 8); in rmd160_transform()
114 ROUND(dd, ee, aa, bb, cc, F3, K3, in[0], 13); in rmd160_transform()
115 ROUND(cc, dd, ee, aa, bb, F3, K3, in[6], 6); in rmd160_transform()
116 ROUND(bb, cc, dd, ee, aa, F3, K3, in[13], 5); in rmd160_transform()
117 ROUND(aa, bb, cc, dd, ee, F3, K3, in[11], 12); in rmd160_transform()
118 ROUND(ee, aa, bb, cc, dd, F3, K3, in[5], 7); in rmd160_transform()
119 ROUND(dd, ee, aa, bb, cc, F3, K3, in[12], 5); in rmd160_transform()
122 ROUND(cc, dd, ee, aa, bb, F4, K4, in[1], 11); in rmd160_transform()
123 ROUND(bb, cc, dd, ee, aa, F4, K4, in[9], 12); in rmd160_transform()
124 ROUND(aa, bb, cc, dd, ee, F4, K4, in[11], 14); in rmd160_transform()
125 ROUND(ee, aa, bb, cc, dd, F4, K4, in[10], 15); in rmd160_transform()
126 ROUND(dd, ee, aa, bb, cc, F4, K4, in[0], 14); in rmd160_transform()
127 ROUND(cc, dd, ee, aa, bb, F4, K4, in[8], 15); in rmd160_transform()
128 ROUND(bb, cc, dd, ee, aa, F4, K4, in[12], 9); in rmd160_transform()
129 ROUND(aa, bb, cc, dd, ee, F4, K4, in[4], 8); in rmd160_transform()
130 ROUND(ee, aa, bb, cc, dd, F4, K4, in[13], 9); in rmd160_transform()
131 ROUND(dd, ee, aa, bb, cc, F4, K4, in[3], 14); in rmd160_transform()
132 ROUND(cc, dd, ee, aa, bb, F4, K4, in[7], 5); in rmd160_transform()
133 ROUND(bb, cc, dd, ee, aa, F4, K4, in[15], 6); in rmd160_transform()
134 ROUND(aa, bb, cc, dd, ee, F4, K4, in[14], 8); in rmd160_transform()
135 ROUND(ee, aa, bb, cc, dd, F4, K4, in[5], 6); in rmd160_transform()
136 ROUND(dd, ee, aa, bb, cc, F4, K4, in[6], 5); in rmd160_transform()
137 ROUND(cc, dd, ee, aa, bb, F4, K4, in[2], 12); in rmd160_transform()
140 ROUND(bb, cc, dd, ee, aa, F5, K5, in[4], 9); in rmd160_transform()
141 ROUND(aa, bb, cc, dd, ee, F5, K5, in[0], 15); in rmd160_transform()
142 ROUND(ee, aa, bb, cc, dd, F5, K5, in[5], 5); in rmd160_transform()
143 ROUND(dd, ee, aa, bb, cc, F5, K5, in[9], 11); in rmd160_transform()
144 ROUND(cc, dd, ee, aa, bb, F5, K5, in[7], 6); in rmd160_transform()
145 ROUND(bb, cc, dd, ee, aa, F5, K5, in[12], 8); in rmd160_transform()
146 ROUND(aa, bb, cc, dd, ee, F5, K5, in[2], 13); in rmd160_transform()
147 ROUND(ee, aa, bb, cc, dd, F5, K5, in[10], 12); in rmd160_transform()
148 ROUND(dd, ee, aa, bb, cc, F5, K5, in[14], 5); in rmd160_transform()
149 ROUND(cc, dd, ee, aa, bb, F5, K5, in[1], 12); in rmd160_transform()
150 ROUND(bb, cc, dd, ee, aa, F5, K5, in[3], 13); in rmd160_transform()
151 ROUND(aa, bb, cc, dd, ee, F5, K5, in[8], 14); in rmd160_transform()
152 ROUND(ee, aa, bb, cc, dd, F5, K5, in[11], 11); in rmd160_transform()
153 ROUND(dd, ee, aa, bb, cc, F5, K5, in[6], 8); in rmd160_transform()
154 ROUND(cc, dd, ee, aa, bb, F5, K5, in[15], 5); in rmd160_transform()
155 ROUND(bb, cc, dd, ee, aa, F5, K5, in[13], 6); in rmd160_transform()
158 ROUND(aaa, bbb, ccc, ddd, eee, F5, KK1, in[5], 8); in rmd160_transform()
159 ROUND(eee, aaa, bbb, ccc, ddd, F5, KK1, in[14], 9); in rmd160_transform()
160 ROUND(ddd, eee, aaa, bbb, ccc, F5, KK1, in[7], 9); in rmd160_transform()
161 ROUND(ccc, ddd, eee, aaa, bbb, F5, KK1, in[0], 11); in rmd160_transform()
162 ROUND(bbb, ccc, ddd, eee, aaa, F5, KK1, in[9], 13); in rmd160_transform()
163 ROUND(aaa, bbb, ccc, ddd, eee, F5, KK1, in[2], 15); in rmd160_transform()
164 ROUND(eee, aaa, bbb, ccc, ddd, F5, KK1, in[11], 15); in rmd160_transform()
165 ROUND(ddd, eee, aaa, bbb, ccc, F5, KK1, in[4], 5); in rmd160_transform()
166 ROUND(ccc, ddd, eee, aaa, bbb, F5, KK1, in[13], 7); in rmd160_transform()
167 ROUND(bbb, ccc, ddd, eee, aaa, F5, KK1, in[6], 7); in rmd160_transform()
168 ROUND(aaa, bbb, ccc, ddd, eee, F5, KK1, in[15], 8); in rmd160_transform()
169 ROUND(eee, aaa, bbb, ccc, ddd, F5, KK1, in[8], 11); in rmd160_transform()
170 ROUND(ddd, eee, aaa, bbb, ccc, F5, KK1, in[1], 14); in rmd160_transform()
171 ROUND(ccc, ddd, eee, aaa, bbb, F5, KK1, in[10], 14); in rmd160_transform()
172 ROUND(bbb, ccc, ddd, eee, aaa, F5, KK1, in[3], 12); in rmd160_transform()
173 ROUND(aaa, bbb, ccc, ddd, eee, F5, KK1, in[12], 6); in rmd160_transform()
176 ROUND(eee, aaa, bbb, ccc, ddd, F4, KK2, in[6], 9); in rmd160_transform()
177 ROUND(ddd, eee, aaa, bbb, ccc, F4, KK2, in[11], 13); in rmd160_transform()
178 ROUND(ccc, ddd, eee, aaa, bbb, F4, KK2, in[3], 15); in rmd160_transform()
179 ROUND(bbb, ccc, ddd, eee, aaa, F4, KK2, in[7], 7); in rmd160_transform()
180 ROUND(aaa, bbb, ccc, ddd, eee, F4, KK2, in[0], 12); in rmd160_transform()
181 ROUND(eee, aaa, bbb, ccc, ddd, F4, KK2, in[13], 8); in rmd160_transform()
182 ROUND(ddd, eee, aaa, bbb, ccc, F4, KK2, in[5], 9); in rmd160_transform()
183 ROUND(ccc, ddd, eee, aaa, bbb, F4, KK2, in[10], 11); in rmd160_transform()
184 ROUND(bbb, ccc, ddd, eee, aaa, F4, KK2, in[14], 7); in rmd160_transform()
185 ROUND(aaa, bbb, ccc, ddd, eee, F4, KK2, in[15], 7); in rmd160_transform()
186 ROUND(eee, aaa, bbb, ccc, ddd, F4, KK2, in[8], 12); in rmd160_transform()
187 ROUND(ddd, eee, aaa, bbb, ccc, F4, KK2, in[12], 7); in rmd160_transform()
188 ROUND(ccc, ddd, eee, aaa, bbb, F4, KK2, in[4], 6); in rmd160_transform()
189 ROUND(bbb, ccc, ddd, eee, aaa, F4, KK2, in[9], 15); in rmd160_transform()
190 ROUND(aaa, bbb, ccc, ddd, eee, F4, KK2, in[1], 13); in rmd160_transform()
191 ROUND(eee, aaa, bbb, ccc, ddd, F4, KK2, in[2], 11); in rmd160_transform()
194 ROUND(ddd, eee, aaa, bbb, ccc, F3, KK3, in[15], 9); in rmd160_transform()
195 ROUND(ccc, ddd, eee, aaa, bbb, F3, KK3, in[5], 7); in rmd160_transform()
196 ROUND(bbb, ccc, ddd, eee, aaa, F3, KK3, in[1], 15); in rmd160_transform()
197 ROUND(aaa, bbb, ccc, ddd, eee, F3, KK3, in[3], 11); in rmd160_transform()
198 ROUND(eee, aaa, bbb, ccc, ddd, F3, KK3, in[7], 8); in rmd160_transform()
199 ROUND(ddd, eee, aaa, bbb, ccc, F3, KK3, in[14], 6); in rmd160_transform()
200 ROUND(ccc, ddd, eee, aaa, bbb, F3, KK3, in[6], 6); in rmd160_transform()
201 ROUND(bbb, ccc, ddd, eee, aaa, F3, KK3, in[9], 14); in rmd160_transform()
202 ROUND(aaa, bbb, ccc, ddd, eee, F3, KK3, in[11], 12); in rmd160_transform()
203 ROUND(eee, aaa, bbb, ccc, ddd, F3, KK3, in[8], 13); in rmd160_transform()
204 ROUND(ddd, eee, aaa, bbb, ccc, F3, KK3, in[12], 5); in rmd160_transform()
205 ROUND(ccc, ddd, eee, aaa, bbb, F3, KK3, in[2], 14); in rmd160_transform()
206 ROUND(bbb, ccc, ddd, eee, aaa, F3, KK3, in[10], 13); in rmd160_transform()
207 ROUND(aaa, bbb, ccc, ddd, eee, F3, KK3, in[0], 13); in rmd160_transform()
208 ROUND(eee, aaa, bbb, ccc, ddd, F3, KK3, in[4], 7); in rmd160_transform()
209 ROUND(ddd, eee, aaa, bbb, ccc, F3, KK3, in[13], 5); in rmd160_transform()
212 ROUND(ccc, ddd, eee, aaa, bbb, F2, KK4, in[8], 15); in rmd160_transform()
213 ROUND(bbb, ccc, ddd, eee, aaa, F2, KK4, in[6], 5); in rmd160_transform()
214 ROUND(aaa, bbb, ccc, ddd, eee, F2, KK4, in[4], 8); in rmd160_transform()
215 ROUND(eee, aaa, bbb, ccc, ddd, F2, KK4, in[1], 11); in rmd160_transform()
216 ROUND(ddd, eee, aaa, bbb, ccc, F2, KK4, in[3], 14); in rmd160_transform()
217 ROUND(ccc, ddd, eee, aaa, bbb, F2, KK4, in[11], 14); in rmd160_transform()
218 ROUND(bbb, ccc, ddd, eee, aaa, F2, KK4, in[15], 6); in rmd160_transform()
219 ROUND(aaa, bbb, ccc, ddd, eee, F2, KK4, in[0], 14); in rmd160_transform()
220 ROUND(eee, aaa, bbb, ccc, ddd, F2, KK4, in[5], 6); in rmd160_transform()
221 ROUND(ddd, eee, aaa, bbb, ccc, F2, KK4, in[12], 9); in rmd160_transform()
222 ROUND(ccc, ddd, eee, aaa, bbb, F2, KK4, in[2], 12); in rmd160_transform()
223 ROUND(bbb, ccc, ddd, eee, aaa, F2, KK4, in[13], 9); in rmd160_transform()
224 ROUND(aaa, bbb, ccc, ddd, eee, F2, KK4, in[9], 12); in rmd160_transform()
225 ROUND(eee, aaa, bbb, ccc, ddd, F2, KK4, in[7], 5); in rmd160_transform()
226 ROUND(ddd, eee, aaa, bbb, ccc, F2, KK4, in[10], 15); in rmd160_transform()
227 ROUND(ccc, ddd, eee, aaa, bbb, F2, KK4, in[14], 8); in rmd160_transform()
230 ROUND(bbb, ccc, ddd, eee, aaa, F1, KK5, in[12], 8); in rmd160_transform()
231 ROUND(aaa, bbb, ccc, ddd, eee, F1, KK5, in[15], 5); in rmd160_transform()
232 ROUND(eee, aaa, bbb, ccc, ddd, F1, KK5, in[10], 12); in rmd160_transform()
233 ROUND(ddd, eee, aaa, bbb, ccc, F1, KK5, in[4], 9); in rmd160_transform()
234 ROUND(ccc, ddd, eee, aaa, bbb, F1, KK5, in[1], 12); in rmd160_transform()
235 ROUND(bbb, ccc, ddd, eee, aaa, F1, KK5, in[5], 5); in rmd160_transform()
236 ROUND(aaa, bbb, ccc, ddd, eee, F1, KK5, in[8], 14); in rmd160_transform()
237 ROUND(eee, aaa, bbb, ccc, ddd, F1, KK5, in[7], 6); in rmd160_transform()
238 ROUND(ddd, eee, aaa, bbb, ccc, F1, KK5, in[6], 8); in rmd160_transform()
239 ROUND(ccc, ddd, eee, aaa, bbb, F1, KK5, in[2], 13); in rmd160_transform()
240 ROUND(bbb, ccc, ddd, eee, aaa, F1, KK5, in[13], 6); in rmd160_transform()
241 ROUND(aaa, bbb, ccc, ddd, eee, F1, KK5, in[14], 5); in rmd160_transform()
242 ROUND(eee, aaa, bbb, ccc, ddd, F1, KK5, in[0], 15); in rmd160_transform()
243 ROUND(ddd, eee, aaa, bbb, ccc, F1, KK5, in[3], 13); in rmd160_transform()
244 ROUND(ccc, ddd, eee, aaa, bbb, F1, KK5, in[9], 11); in rmd160_transform()
245 ROUND(bbb, ccc, ddd, eee, aaa, F1, KK5, in[11], 11); in rmd160_transform()
260 rctx->byte_count = 0; in rmd160_init()
262 rctx->state[0] = RMD_H0; in rmd160_init()
263 rctx->state[1] = RMD_H1; in rmd160_init()
264 rctx->state[2] = RMD_H2; in rmd160_init()
265 rctx->state[3] = RMD_H3; in rmd160_init()
266 rctx->state[4] = RMD_H4; in rmd160_init()
268 memset(rctx->buffer, 0, sizeof(rctx->buffer)); in rmd160_init()
277 const u32 avail = sizeof(rctx->buffer) - (rctx->byte_count & 0x3f); in rmd160_update()
279 rctx->byte_count += len; in rmd160_update()
281 /* Enough space in buffer? If so copy and we're done */ in rmd160_update()
283 memcpy((char *)rctx->buffer + (sizeof(rctx->buffer) - avail), in rmd160_update()
288 memcpy((char *)rctx->buffer + (sizeof(rctx->buffer) - avail), in rmd160_update()
291 rmd160_transform(rctx->state, rctx->buffer); in rmd160_update()
293 len -= avail; in rmd160_update()
295 while (len >= sizeof(rctx->buffer)) { in rmd160_update()
296 memcpy(rctx->buffer, data, sizeof(rctx->buffer)); in rmd160_update()
297 rmd160_transform(rctx->state, rctx->buffer); in rmd160_update()
298 data += sizeof(rctx->buffer); in rmd160_update()
299 len -= sizeof(rctx->buffer); in rmd160_update()
302 memcpy(rctx->buffer, data, len); in rmd160_update()
317 bits = cpu_to_le64(rctx->byte_count << 3); in rmd160_final()
320 index = rctx->byte_count & 0x3f; in rmd160_final()
321 padlen = (index < 56) ? (56 - index) : ((64+56) - index); in rmd160_final()
327 /* Store state in digest */ in rmd160_final()
329 dst[i] = cpu_to_le32p(&rctx->state[i]); in rmd160_final()
345 .cra_driver_name = "rmd160-generic",
365 MODULE_AUTHOR("Adrian-Ken Rueegsegger <ken@codelabs.ch>");
366 MODULE_DESCRIPTION("RIPEMD-160 Message Digest");