Lines Matching +full:in +full:-
1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * RIPEMD-320 - 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 rmd320_transform(u32 *state, const __le32 *in) in rmd320_transform() argument
68 ROUND(aa, bb, cc, dd, ee, F1, K1, in[0], 11); in rmd320_transform()
69 ROUND(ee, aa, bb, cc, dd, F1, K1, in[1], 14); in rmd320_transform()
70 ROUND(dd, ee, aa, bb, cc, F1, K1, in[2], 15); in rmd320_transform()
71 ROUND(cc, dd, ee, aa, bb, F1, K1, in[3], 12); in rmd320_transform()
72 ROUND(bb, cc, dd, ee, aa, F1, K1, in[4], 5); in rmd320_transform()
73 ROUND(aa, bb, cc, dd, ee, F1, K1, in[5], 8); in rmd320_transform()
74 ROUND(ee, aa, bb, cc, dd, F1, K1, in[6], 7); in rmd320_transform()
75 ROUND(dd, ee, aa, bb, cc, F1, K1, in[7], 9); in rmd320_transform()
76 ROUND(cc, dd, ee, aa, bb, F1, K1, in[8], 11); in rmd320_transform()
77 ROUND(bb, cc, dd, ee, aa, F1, K1, in[9], 13); in rmd320_transform()
78 ROUND(aa, bb, cc, dd, ee, F1, K1, in[10], 14); in rmd320_transform()
79 ROUND(ee, aa, bb, cc, dd, F1, K1, in[11], 15); in rmd320_transform()
80 ROUND(dd, ee, aa, bb, cc, F1, K1, in[12], 6); in rmd320_transform()
81 ROUND(cc, dd, ee, aa, bb, F1, K1, in[13], 7); in rmd320_transform()
82 ROUND(bb, cc, dd, ee, aa, F1, K1, in[14], 9); in rmd320_transform()
83 ROUND(aa, bb, cc, dd, ee, F1, K1, in[15], 8); in rmd320_transform()
86 ROUND(aaa, bbb, ccc, ddd, eee, F5, KK1, in[5], 8); in rmd320_transform()
87 ROUND(eee, aaa, bbb, ccc, ddd, F5, KK1, in[14], 9); in rmd320_transform()
88 ROUND(ddd, eee, aaa, bbb, ccc, F5, KK1, in[7], 9); in rmd320_transform()
89 ROUND(ccc, ddd, eee, aaa, bbb, F5, KK1, in[0], 11); in rmd320_transform()
90 ROUND(bbb, ccc, ddd, eee, aaa, F5, KK1, in[9], 13); in rmd320_transform()
91 ROUND(aaa, bbb, ccc, ddd, eee, F5, KK1, in[2], 15); in rmd320_transform()
92 ROUND(eee, aaa, bbb, ccc, ddd, F5, KK1, in[11], 15); in rmd320_transform()
93 ROUND(ddd, eee, aaa, bbb, ccc, F5, KK1, in[4], 5); in rmd320_transform()
94 ROUND(ccc, ddd, eee, aaa, bbb, F5, KK1, in[13], 7); in rmd320_transform()
95 ROUND(bbb, ccc, ddd, eee, aaa, F5, KK1, in[6], 7); in rmd320_transform()
96 ROUND(aaa, bbb, ccc, ddd, eee, F5, KK1, in[15], 8); in rmd320_transform()
97 ROUND(eee, aaa, bbb, ccc, ddd, F5, KK1, in[8], 11); in rmd320_transform()
98 ROUND(ddd, eee, aaa, bbb, ccc, F5, KK1, in[1], 14); in rmd320_transform()
99 ROUND(ccc, ddd, eee, aaa, bbb, F5, KK1, in[10], 14); in rmd320_transform()
100 ROUND(bbb, ccc, ddd, eee, aaa, F5, KK1, in[3], 12); in rmd320_transform()
101 ROUND(aaa, bbb, ccc, ddd, eee, F5, KK1, in[12], 6); in rmd320_transform()
107 ROUND(ee, aa, bb, cc, dd, F2, K2, in[7], 7); in rmd320_transform()
108 ROUND(dd, ee, aa, bb, cc, F2, K2, in[4], 6); in rmd320_transform()
109 ROUND(cc, dd, ee, aa, bb, F2, K2, in[13], 8); in rmd320_transform()
110 ROUND(bb, cc, dd, ee, aa, F2, K2, in[1], 13); in rmd320_transform()
111 ROUND(aa, bb, cc, dd, ee, F2, K2, in[10], 11); in rmd320_transform()
112 ROUND(ee, aa, bb, cc, dd, F2, K2, in[6], 9); in rmd320_transform()
113 ROUND(dd, ee, aa, bb, cc, F2, K2, in[15], 7); in rmd320_transform()
114 ROUND(cc, dd, ee, aa, bb, F2, K2, in[3], 15); in rmd320_transform()
115 ROUND(bb, cc, dd, ee, aa, F2, K2, in[12], 7); in rmd320_transform()
116 ROUND(aa, bb, cc, dd, ee, F2, K2, in[0], 12); in rmd320_transform()
117 ROUND(ee, aa, bb, cc, dd, F2, K2, in[9], 15); in rmd320_transform()
118 ROUND(dd, ee, aa, bb, cc, F2, K2, in[5], 9); in rmd320_transform()
119 ROUND(cc, dd, ee, aa, bb, F2, K2, in[2], 11); in rmd320_transform()
120 ROUND(bb, cc, dd, ee, aa, F2, K2, in[14], 7); in rmd320_transform()
121 ROUND(aa, bb, cc, dd, ee, F2, K2, in[11], 13); in rmd320_transform()
122 ROUND(ee, aa, bb, cc, dd, F2, K2, in[8], 12); in rmd320_transform()
125 ROUND(eee, aaa, bbb, ccc, ddd, F4, KK2, in[6], 9); in rmd320_transform()
126 ROUND(ddd, eee, aaa, bbb, ccc, F4, KK2, in[11], 13); in rmd320_transform()
127 ROUND(ccc, ddd, eee, aaa, bbb, F4, KK2, in[3], 15); in rmd320_transform()
128 ROUND(bbb, ccc, ddd, eee, aaa, F4, KK2, in[7], 7); in rmd320_transform()
129 ROUND(aaa, bbb, ccc, ddd, eee, F4, KK2, in[0], 12); in rmd320_transform()
130 ROUND(eee, aaa, bbb, ccc, ddd, F4, KK2, in[13], 8); in rmd320_transform()
131 ROUND(ddd, eee, aaa, bbb, ccc, F4, KK2, in[5], 9); in rmd320_transform()
132 ROUND(ccc, ddd, eee, aaa, bbb, F4, KK2, in[10], 11); in rmd320_transform()
133 ROUND(bbb, ccc, ddd, eee, aaa, F4, KK2, in[14], 7); in rmd320_transform()
134 ROUND(aaa, bbb, ccc, ddd, eee, F4, KK2, in[15], 7); in rmd320_transform()
135 ROUND(eee, aaa, bbb, ccc, ddd, F4, KK2, in[8], 12); in rmd320_transform()
136 ROUND(ddd, eee, aaa, bbb, ccc, F4, KK2, in[12], 7); in rmd320_transform()
137 ROUND(ccc, ddd, eee, aaa, bbb, F4, KK2, in[4], 6); in rmd320_transform()
138 ROUND(bbb, ccc, ddd, eee, aaa, F4, KK2, in[9], 15); in rmd320_transform()
139 ROUND(aaa, bbb, ccc, ddd, eee, F4, KK2, in[1], 13); in rmd320_transform()
140 ROUND(eee, aaa, bbb, ccc, ddd, F4, KK2, in[2], 11); in rmd320_transform()
146 ROUND(dd, ee, aa, bb, cc, F3, K3, in[3], 11); in rmd320_transform()
147 ROUND(cc, dd, ee, aa, bb, F3, K3, in[10], 13); in rmd320_transform()
148 ROUND(bb, cc, dd, ee, aa, F3, K3, in[14], 6); in rmd320_transform()
149 ROUND(aa, bb, cc, dd, ee, F3, K3, in[4], 7); in rmd320_transform()
150 ROUND(ee, aa, bb, cc, dd, F3, K3, in[9], 14); in rmd320_transform()
151 ROUND(dd, ee, aa, bb, cc, F3, K3, in[15], 9); in rmd320_transform()
152 ROUND(cc, dd, ee, aa, bb, F3, K3, in[8], 13); in rmd320_transform()
153 ROUND(bb, cc, dd, ee, aa, F3, K3, in[1], 15); in rmd320_transform()
154 ROUND(aa, bb, cc, dd, ee, F3, K3, in[2], 14); in rmd320_transform()
155 ROUND(ee, aa, bb, cc, dd, F3, K3, in[7], 8); in rmd320_transform()
156 ROUND(dd, ee, aa, bb, cc, F3, K3, in[0], 13); in rmd320_transform()
157 ROUND(cc, dd, ee, aa, bb, F3, K3, in[6], 6); in rmd320_transform()
158 ROUND(bb, cc, dd, ee, aa, F3, K3, in[13], 5); in rmd320_transform()
159 ROUND(aa, bb, cc, dd, ee, F3, K3, in[11], 12); in rmd320_transform()
160 ROUND(ee, aa, bb, cc, dd, F3, K3, in[5], 7); in rmd320_transform()
161 ROUND(dd, ee, aa, bb, cc, F3, K3, in[12], 5); in rmd320_transform()
164 ROUND(ddd, eee, aaa, bbb, ccc, F3, KK3, in[15], 9); in rmd320_transform()
165 ROUND(ccc, ddd, eee, aaa, bbb, F3, KK3, in[5], 7); in rmd320_transform()
166 ROUND(bbb, ccc, ddd, eee, aaa, F3, KK3, in[1], 15); in rmd320_transform()
167 ROUND(aaa, bbb, ccc, ddd, eee, F3, KK3, in[3], 11); in rmd320_transform()
168 ROUND(eee, aaa, bbb, ccc, ddd, F3, KK3, in[7], 8); in rmd320_transform()
169 ROUND(ddd, eee, aaa, bbb, ccc, F3, KK3, in[14], 6); in rmd320_transform()
170 ROUND(ccc, ddd, eee, aaa, bbb, F3, KK3, in[6], 6); in rmd320_transform()
171 ROUND(bbb, ccc, ddd, eee, aaa, F3, KK3, in[9], 14); in rmd320_transform()
172 ROUND(aaa, bbb, ccc, ddd, eee, F3, KK3, in[11], 12); in rmd320_transform()
173 ROUND(eee, aaa, bbb, ccc, ddd, F3, KK3, in[8], 13); in rmd320_transform()
174 ROUND(ddd, eee, aaa, bbb, ccc, F3, KK3, in[12], 5); in rmd320_transform()
175 ROUND(ccc, ddd, eee, aaa, bbb, F3, KK3, in[2], 14); in rmd320_transform()
176 ROUND(bbb, ccc, ddd, eee, aaa, F3, KK3, in[10], 13); in rmd320_transform()
177 ROUND(aaa, bbb, ccc, ddd, eee, F3, KK3, in[0], 13); in rmd320_transform()
178 ROUND(eee, aaa, bbb, ccc, ddd, F3, KK3, in[4], 7); in rmd320_transform()
179 ROUND(ddd, eee, aaa, bbb, ccc, F3, KK3, in[13], 5); in rmd320_transform()
185 ROUND(cc, dd, ee, aa, bb, F4, K4, in[1], 11); in rmd320_transform()
186 ROUND(bb, cc, dd, ee, aa, F4, K4, in[9], 12); in rmd320_transform()
187 ROUND(aa, bb, cc, dd, ee, F4, K4, in[11], 14); in rmd320_transform()
188 ROUND(ee, aa, bb, cc, dd, F4, K4, in[10], 15); in rmd320_transform()
189 ROUND(dd, ee, aa, bb, cc, F4, K4, in[0], 14); in rmd320_transform()
190 ROUND(cc, dd, ee, aa, bb, F4, K4, in[8], 15); in rmd320_transform()
191 ROUND(bb, cc, dd, ee, aa, F4, K4, in[12], 9); in rmd320_transform()
192 ROUND(aa, bb, cc, dd, ee, F4, K4, in[4], 8); in rmd320_transform()
193 ROUND(ee, aa, bb, cc, dd, F4, K4, in[13], 9); in rmd320_transform()
194 ROUND(dd, ee, aa, bb, cc, F4, K4, in[3], 14); in rmd320_transform()
195 ROUND(cc, dd, ee, aa, bb, F4, K4, in[7], 5); in rmd320_transform()
196 ROUND(bb, cc, dd, ee, aa, F4, K4, in[15], 6); in rmd320_transform()
197 ROUND(aa, bb, cc, dd, ee, F4, K4, in[14], 8); in rmd320_transform()
198 ROUND(ee, aa, bb, cc, dd, F4, K4, in[5], 6); in rmd320_transform()
199 ROUND(dd, ee, aa, bb, cc, F4, K4, in[6], 5); in rmd320_transform()
200 ROUND(cc, dd, ee, aa, bb, F4, K4, in[2], 12); in rmd320_transform()
203 ROUND(ccc, ddd, eee, aaa, bbb, F2, KK4, in[8], 15); in rmd320_transform()
204 ROUND(bbb, ccc, ddd, eee, aaa, F2, KK4, in[6], 5); in rmd320_transform()
205 ROUND(aaa, bbb, ccc, ddd, eee, F2, KK4, in[4], 8); in rmd320_transform()
206 ROUND(eee, aaa, bbb, ccc, ddd, F2, KK4, in[1], 11); in rmd320_transform()
207 ROUND(ddd, eee, aaa, bbb, ccc, F2, KK4, in[3], 14); in rmd320_transform()
208 ROUND(ccc, ddd, eee, aaa, bbb, F2, KK4, in[11], 14); in rmd320_transform()
209 ROUND(bbb, ccc, ddd, eee, aaa, F2, KK4, in[15], 6); in rmd320_transform()
210 ROUND(aaa, bbb, ccc, ddd, eee, F2, KK4, in[0], 14); in rmd320_transform()
211 ROUND(eee, aaa, bbb, ccc, ddd, F2, KK4, in[5], 6); in rmd320_transform()
212 ROUND(ddd, eee, aaa, bbb, ccc, F2, KK4, in[12], 9); in rmd320_transform()
213 ROUND(ccc, ddd, eee, aaa, bbb, F2, KK4, in[2], 12); in rmd320_transform()
214 ROUND(bbb, ccc, ddd, eee, aaa, F2, KK4, in[13], 9); in rmd320_transform()
215 ROUND(aaa, bbb, ccc, ddd, eee, F2, KK4, in[9], 12); in rmd320_transform()
216 ROUND(eee, aaa, bbb, ccc, ddd, F2, KK4, in[7], 5); in rmd320_transform()
217 ROUND(ddd, eee, aaa, bbb, ccc, F2, KK4, in[10], 15); in rmd320_transform()
218 ROUND(ccc, ddd, eee, aaa, bbb, F2, KK4, in[14], 8); in rmd320_transform()
224 ROUND(bb, cc, dd, ee, aa, F5, K5, in[4], 9); in rmd320_transform()
225 ROUND(aa, bb, cc, dd, ee, F5, K5, in[0], 15); in rmd320_transform()
226 ROUND(ee, aa, bb, cc, dd, F5, K5, in[5], 5); in rmd320_transform()
227 ROUND(dd, ee, aa, bb, cc, F5, K5, in[9], 11); in rmd320_transform()
228 ROUND(cc, dd, ee, aa, bb, F5, K5, in[7], 6); in rmd320_transform()
229 ROUND(bb, cc, dd, ee, aa, F5, K5, in[12], 8); in rmd320_transform()
230 ROUND(aa, bb, cc, dd, ee, F5, K5, in[2], 13); in rmd320_transform()
231 ROUND(ee, aa, bb, cc, dd, F5, K5, in[10], 12); in rmd320_transform()
232 ROUND(dd, ee, aa, bb, cc, F5, K5, in[14], 5); in rmd320_transform()
233 ROUND(cc, dd, ee, aa, bb, F5, K5, in[1], 12); in rmd320_transform()
234 ROUND(bb, cc, dd, ee, aa, F5, K5, in[3], 13); in rmd320_transform()
235 ROUND(aa, bb, cc, dd, ee, F5, K5, in[8], 14); in rmd320_transform()
236 ROUND(ee, aa, bb, cc, dd, F5, K5, in[11], 11); in rmd320_transform()
237 ROUND(dd, ee, aa, bb, cc, F5, K5, in[6], 8); in rmd320_transform()
238 ROUND(cc, dd, ee, aa, bb, F5, K5, in[15], 5); in rmd320_transform()
239 ROUND(bb, cc, dd, ee, aa, F5, K5, in[13], 6); in rmd320_transform()
242 ROUND(bbb, ccc, ddd, eee, aaa, F1, KK5, in[12], 8); in rmd320_transform()
243 ROUND(aaa, bbb, ccc, ddd, eee, F1, KK5, in[15], 5); in rmd320_transform()
244 ROUND(eee, aaa, bbb, ccc, ddd, F1, KK5, in[10], 12); in rmd320_transform()
245 ROUND(ddd, eee, aaa, bbb, ccc, F1, KK5, in[4], 9); in rmd320_transform()
246 ROUND(ccc, ddd, eee, aaa, bbb, F1, KK5, in[1], 12); in rmd320_transform()
247 ROUND(bbb, ccc, ddd, eee, aaa, F1, KK5, in[5], 5); in rmd320_transform()
248 ROUND(aaa, bbb, ccc, ddd, eee, F1, KK5, in[8], 14); in rmd320_transform()
249 ROUND(eee, aaa, bbb, ccc, ddd, F1, KK5, in[7], 6); in rmd320_transform()
250 ROUND(ddd, eee, aaa, bbb, ccc, F1, KK5, in[6], 8); in rmd320_transform()
251 ROUND(ccc, ddd, eee, aaa, bbb, F1, KK5, in[2], 13); in rmd320_transform()
252 ROUND(bbb, ccc, ddd, eee, aaa, F1, KK5, in[13], 6); in rmd320_transform()
253 ROUND(aaa, bbb, ccc, ddd, eee, F1, KK5, in[14], 5); in rmd320_transform()
254 ROUND(eee, aaa, bbb, ccc, ddd, F1, KK5, in[0], 15); in rmd320_transform()
255 ROUND(ddd, eee, aaa, bbb, ccc, F1, KK5, in[3], 13); in rmd320_transform()
256 ROUND(ccc, ddd, eee, aaa, bbb, F1, KK5, in[9], 11); in rmd320_transform()
257 ROUND(bbb, ccc, ddd, eee, aaa, F1, KK5, in[11], 11); in rmd320_transform()
279 rctx->byte_count = 0; in rmd320_init()
281 rctx->state[0] = RMD_H0; in rmd320_init()
282 rctx->state[1] = RMD_H1; in rmd320_init()
283 rctx->state[2] = RMD_H2; in rmd320_init()
284 rctx->state[3] = RMD_H3; in rmd320_init()
285 rctx->state[4] = RMD_H4; in rmd320_init()
286 rctx->state[5] = RMD_H5; in rmd320_init()
287 rctx->state[6] = RMD_H6; in rmd320_init()
288 rctx->state[7] = RMD_H7; in rmd320_init()
289 rctx->state[8] = RMD_H8; in rmd320_init()
290 rctx->state[9] = RMD_H9; in rmd320_init()
292 memset(rctx->buffer, 0, sizeof(rctx->buffer)); in rmd320_init()
301 const u32 avail = sizeof(rctx->buffer) - (rctx->byte_count & 0x3f); in rmd320_update()
303 rctx->byte_count += len; in rmd320_update()
305 /* Enough space in buffer? If so copy and we're done */ in rmd320_update()
307 memcpy((char *)rctx->buffer + (sizeof(rctx->buffer) - avail), in rmd320_update()
312 memcpy((char *)rctx->buffer + (sizeof(rctx->buffer) - avail), in rmd320_update()
315 rmd320_transform(rctx->state, rctx->buffer); in rmd320_update()
317 len -= avail; in rmd320_update()
319 while (len >= sizeof(rctx->buffer)) { in rmd320_update()
320 memcpy(rctx->buffer, data, sizeof(rctx->buffer)); in rmd320_update()
321 rmd320_transform(rctx->state, rctx->buffer); in rmd320_update()
322 data += sizeof(rctx->buffer); in rmd320_update()
323 len -= sizeof(rctx->buffer); in rmd320_update()
326 memcpy(rctx->buffer, data, len); in rmd320_update()
341 bits = cpu_to_le64(rctx->byte_count << 3); in rmd320_final()
344 index = rctx->byte_count & 0x3f; in rmd320_final()
345 padlen = (index < 56) ? (56 - index) : ((64+56) - index); in rmd320_final()
351 /* Store state in digest */ in rmd320_final()
353 dst[i] = cpu_to_le32p(&rctx->state[i]); in rmd320_final()
369 .cra_driver_name = "rmd320-generic",
389 MODULE_AUTHOR("Adrian-Ken Rueegsegger <ken@codelabs.ch>");
390 MODULE_DESCRIPTION("RIPEMD-320 Message Digest");