Lines Matching +full:in +full:-

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * RIPEMD-256 - 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>
45 static void rmd256_transform(u32 *state, const __le32 *in) in rmd256_transform() argument
62 ROUND(aa, bb, cc, dd, F1, K1, in[0], 11); in rmd256_transform()
63 ROUND(dd, aa, bb, cc, F1, K1, in[1], 14); in rmd256_transform()
64 ROUND(cc, dd, aa, bb, F1, K1, in[2], 15); in rmd256_transform()
65 ROUND(bb, cc, dd, aa, F1, K1, in[3], 12); in rmd256_transform()
66 ROUND(aa, bb, cc, dd, F1, K1, in[4], 5); in rmd256_transform()
67 ROUND(dd, aa, bb, cc, F1, K1, in[5], 8); in rmd256_transform()
68 ROUND(cc, dd, aa, bb, F1, K1, in[6], 7); in rmd256_transform()
69 ROUND(bb, cc, dd, aa, F1, K1, in[7], 9); in rmd256_transform()
70 ROUND(aa, bb, cc, dd, F1, K1, in[8], 11); in rmd256_transform()
71 ROUND(dd, aa, bb, cc, F1, K1, in[9], 13); in rmd256_transform()
72 ROUND(cc, dd, aa, bb, F1, K1, in[10], 14); in rmd256_transform()
73 ROUND(bb, cc, dd, aa, F1, K1, in[11], 15); in rmd256_transform()
74 ROUND(aa, bb, cc, dd, F1, K1, in[12], 6); in rmd256_transform()
75 ROUND(dd, aa, bb, cc, F1, K1, in[13], 7); in rmd256_transform()
76 ROUND(cc, dd, aa, bb, F1, K1, in[14], 9); in rmd256_transform()
77 ROUND(bb, cc, dd, aa, F1, K1, in[15], 8); in rmd256_transform()
80 ROUND(aaa, bbb, ccc, ddd, F4, KK1, in[5], 8); in rmd256_transform()
81 ROUND(ddd, aaa, bbb, ccc, F4, KK1, in[14], 9); in rmd256_transform()
82 ROUND(ccc, ddd, aaa, bbb, F4, KK1, in[7], 9); in rmd256_transform()
83 ROUND(bbb, ccc, ddd, aaa, F4, KK1, in[0], 11); in rmd256_transform()
84 ROUND(aaa, bbb, ccc, ddd, F4, KK1, in[9], 13); in rmd256_transform()
85 ROUND(ddd, aaa, bbb, ccc, F4, KK1, in[2], 15); in rmd256_transform()
86 ROUND(ccc, ddd, aaa, bbb, F4, KK1, in[11], 15); in rmd256_transform()
87 ROUND(bbb, ccc, ddd, aaa, F4, KK1, in[4], 5); in rmd256_transform()
88 ROUND(aaa, bbb, ccc, ddd, F4, KK1, in[13], 7); in rmd256_transform()
89 ROUND(ddd, aaa, bbb, ccc, F4, KK1, in[6], 7); in rmd256_transform()
90 ROUND(ccc, ddd, aaa, bbb, F4, KK1, in[15], 8); in rmd256_transform()
91 ROUND(bbb, ccc, ddd, aaa, F4, KK1, in[8], 11); in rmd256_transform()
92 ROUND(aaa, bbb, ccc, ddd, F4, KK1, in[1], 14); in rmd256_transform()
93 ROUND(ddd, aaa, bbb, ccc, F4, KK1, in[10], 14); in rmd256_transform()
94 ROUND(ccc, ddd, aaa, bbb, F4, KK1, in[3], 12); in rmd256_transform()
95 ROUND(bbb, ccc, ddd, aaa, F4, KK1, in[12], 6); in rmd256_transform()
101 ROUND(aa, bb, cc, dd, F2, K2, in[7], 7); in rmd256_transform()
102 ROUND(dd, aa, bb, cc, F2, K2, in[4], 6); in rmd256_transform()
103 ROUND(cc, dd, aa, bb, F2, K2, in[13], 8); in rmd256_transform()
104 ROUND(bb, cc, dd, aa, F2, K2, in[1], 13); in rmd256_transform()
105 ROUND(aa, bb, cc, dd, F2, K2, in[10], 11); in rmd256_transform()
106 ROUND(dd, aa, bb, cc, F2, K2, in[6], 9); in rmd256_transform()
107 ROUND(cc, dd, aa, bb, F2, K2, in[15], 7); in rmd256_transform()
108 ROUND(bb, cc, dd, aa, F2, K2, in[3], 15); in rmd256_transform()
109 ROUND(aa, bb, cc, dd, F2, K2, in[12], 7); in rmd256_transform()
110 ROUND(dd, aa, bb, cc, F2, K2, in[0], 12); in rmd256_transform()
111 ROUND(cc, dd, aa, bb, F2, K2, in[9], 15); in rmd256_transform()
112 ROUND(bb, cc, dd, aa, F2, K2, in[5], 9); in rmd256_transform()
113 ROUND(aa, bb, cc, dd, F2, K2, in[2], 11); in rmd256_transform()
114 ROUND(dd, aa, bb, cc, F2, K2, in[14], 7); in rmd256_transform()
115 ROUND(cc, dd, aa, bb, F2, K2, in[11], 13); in rmd256_transform()
116 ROUND(bb, cc, dd, aa, F2, K2, in[8], 12); in rmd256_transform()
119 ROUND(aaa, bbb, ccc, ddd, F3, KK2, in[6], 9); in rmd256_transform()
120 ROUND(ddd, aaa, bbb, ccc, F3, KK2, in[11], 13); in rmd256_transform()
121 ROUND(ccc, ddd, aaa, bbb, F3, KK2, in[3], 15); in rmd256_transform()
122 ROUND(bbb, ccc, ddd, aaa, F3, KK2, in[7], 7); in rmd256_transform()
123 ROUND(aaa, bbb, ccc, ddd, F3, KK2, in[0], 12); in rmd256_transform()
124 ROUND(ddd, aaa, bbb, ccc, F3, KK2, in[13], 8); in rmd256_transform()
125 ROUND(ccc, ddd, aaa, bbb, F3, KK2, in[5], 9); in rmd256_transform()
126 ROUND(bbb, ccc, ddd, aaa, F3, KK2, in[10], 11); in rmd256_transform()
127 ROUND(aaa, bbb, ccc, ddd, F3, KK2, in[14], 7); in rmd256_transform()
128 ROUND(ddd, aaa, bbb, ccc, F3, KK2, in[15], 7); in rmd256_transform()
129 ROUND(ccc, ddd, aaa, bbb, F3, KK2, in[8], 12); in rmd256_transform()
130 ROUND(bbb, ccc, ddd, aaa, F3, KK2, in[12], 7); in rmd256_transform()
131 ROUND(aaa, bbb, ccc, ddd, F3, KK2, in[4], 6); in rmd256_transform()
132 ROUND(ddd, aaa, bbb, ccc, F3, KK2, in[9], 15); in rmd256_transform()
133 ROUND(ccc, ddd, aaa, bbb, F3, KK2, in[1], 13); in rmd256_transform()
134 ROUND(bbb, ccc, ddd, aaa, F3, KK2, in[2], 11); in rmd256_transform()
140 ROUND(aa, bb, cc, dd, F3, K3, in[3], 11); in rmd256_transform()
141 ROUND(dd, aa, bb, cc, F3, K3, in[10], 13); in rmd256_transform()
142 ROUND(cc, dd, aa, bb, F3, K3, in[14], 6); in rmd256_transform()
143 ROUND(bb, cc, dd, aa, F3, K3, in[4], 7); in rmd256_transform()
144 ROUND(aa, bb, cc, dd, F3, K3, in[9], 14); in rmd256_transform()
145 ROUND(dd, aa, bb, cc, F3, K3, in[15], 9); in rmd256_transform()
146 ROUND(cc, dd, aa, bb, F3, K3, in[8], 13); in rmd256_transform()
147 ROUND(bb, cc, dd, aa, F3, K3, in[1], 15); in rmd256_transform()
148 ROUND(aa, bb, cc, dd, F3, K3, in[2], 14); in rmd256_transform()
149 ROUND(dd, aa, bb, cc, F3, K3, in[7], 8); in rmd256_transform()
150 ROUND(cc, dd, aa, bb, F3, K3, in[0], 13); in rmd256_transform()
151 ROUND(bb, cc, dd, aa, F3, K3, in[6], 6); in rmd256_transform()
152 ROUND(aa, bb, cc, dd, F3, K3, in[13], 5); in rmd256_transform()
153 ROUND(dd, aa, bb, cc, F3, K3, in[11], 12); in rmd256_transform()
154 ROUND(cc, dd, aa, bb, F3, K3, in[5], 7); in rmd256_transform()
155 ROUND(bb, cc, dd, aa, F3, K3, in[12], 5); in rmd256_transform()
158 ROUND(aaa, bbb, ccc, ddd, F2, KK3, in[15], 9); in rmd256_transform()
159 ROUND(ddd, aaa, bbb, ccc, F2, KK3, in[5], 7); in rmd256_transform()
160 ROUND(ccc, ddd, aaa, bbb, F2, KK3, in[1], 15); in rmd256_transform()
161 ROUND(bbb, ccc, ddd, aaa, F2, KK3, in[3], 11); in rmd256_transform()
162 ROUND(aaa, bbb, ccc, ddd, F2, KK3, in[7], 8); in rmd256_transform()
163 ROUND(ddd, aaa, bbb, ccc, F2, KK3, in[14], 6); in rmd256_transform()
164 ROUND(ccc, ddd, aaa, bbb, F2, KK3, in[6], 6); in rmd256_transform()
165 ROUND(bbb, ccc, ddd, aaa, F2, KK3, in[9], 14); in rmd256_transform()
166 ROUND(aaa, bbb, ccc, ddd, F2, KK3, in[11], 12); in rmd256_transform()
167 ROUND(ddd, aaa, bbb, ccc, F2, KK3, in[8], 13); in rmd256_transform()
168 ROUND(ccc, ddd, aaa, bbb, F2, KK3, in[12], 5); in rmd256_transform()
169 ROUND(bbb, ccc, ddd, aaa, F2, KK3, in[2], 14); in rmd256_transform()
170 ROUND(aaa, bbb, ccc, ddd, F2, KK3, in[10], 13); in rmd256_transform()
171 ROUND(ddd, aaa, bbb, ccc, F2, KK3, in[0], 13); in rmd256_transform()
172 ROUND(ccc, ddd, aaa, bbb, F2, KK3, in[4], 7); in rmd256_transform()
173 ROUND(bbb, ccc, ddd, aaa, F2, KK3, in[13], 5); in rmd256_transform()
179 ROUND(aa, bb, cc, dd, F4, K4, in[1], 11); in rmd256_transform()
180 ROUND(dd, aa, bb, cc, F4, K4, in[9], 12); in rmd256_transform()
181 ROUND(cc, dd, aa, bb, F4, K4, in[11], 14); in rmd256_transform()
182 ROUND(bb, cc, dd, aa, F4, K4, in[10], 15); in rmd256_transform()
183 ROUND(aa, bb, cc, dd, F4, K4, in[0], 14); in rmd256_transform()
184 ROUND(dd, aa, bb, cc, F4, K4, in[8], 15); in rmd256_transform()
185 ROUND(cc, dd, aa, bb, F4, K4, in[12], 9); in rmd256_transform()
186 ROUND(bb, cc, dd, aa, F4, K4, in[4], 8); in rmd256_transform()
187 ROUND(aa, bb, cc, dd, F4, K4, in[13], 9); in rmd256_transform()
188 ROUND(dd, aa, bb, cc, F4, K4, in[3], 14); in rmd256_transform()
189 ROUND(cc, dd, aa, bb, F4, K4, in[7], 5); in rmd256_transform()
190 ROUND(bb, cc, dd, aa, F4, K4, in[15], 6); in rmd256_transform()
191 ROUND(aa, bb, cc, dd, F4, K4, in[14], 8); in rmd256_transform()
192 ROUND(dd, aa, bb, cc, F4, K4, in[5], 6); in rmd256_transform()
193 ROUND(cc, dd, aa, bb, F4, K4, in[6], 5); in rmd256_transform()
194 ROUND(bb, cc, dd, aa, F4, K4, in[2], 12); in rmd256_transform()
197 ROUND(aaa, bbb, ccc, ddd, F1, KK4, in[8], 15); in rmd256_transform()
198 ROUND(ddd, aaa, bbb, ccc, F1, KK4, in[6], 5); in rmd256_transform()
199 ROUND(ccc, ddd, aaa, bbb, F1, KK4, in[4], 8); in rmd256_transform()
200 ROUND(bbb, ccc, ddd, aaa, F1, KK4, in[1], 11); in rmd256_transform()
201 ROUND(aaa, bbb, ccc, ddd, F1, KK4, in[3], 14); in rmd256_transform()
202 ROUND(ddd, aaa, bbb, ccc, F1, KK4, in[11], 14); in rmd256_transform()
203 ROUND(ccc, ddd, aaa, bbb, F1, KK4, in[15], 6); in rmd256_transform()
204 ROUND(bbb, ccc, ddd, aaa, F1, KK4, in[0], 14); in rmd256_transform()
205 ROUND(aaa, bbb, ccc, ddd, F1, KK4, in[5], 6); in rmd256_transform()
206 ROUND(ddd, aaa, bbb, ccc, F1, KK4, in[12], 9); in rmd256_transform()
207 ROUND(ccc, ddd, aaa, bbb, F1, KK4, in[2], 12); in rmd256_transform()
208 ROUND(bbb, ccc, ddd, aaa, F1, KK4, in[13], 9); in rmd256_transform()
209 ROUND(aaa, bbb, ccc, ddd, F1, KK4, in[9], 12); in rmd256_transform()
210 ROUND(ddd, aaa, bbb, ccc, F1, KK4, in[7], 5); in rmd256_transform()
211 ROUND(ccc, ddd, aaa, bbb, F1, KK4, in[10], 15); in rmd256_transform()
212 ROUND(bbb, ccc, ddd, aaa, F1, KK4, in[14], 8); in rmd256_transform()
232 rctx->byte_count = 0; in rmd256_init()
234 rctx->state[0] = RMD_H0; in rmd256_init()
235 rctx->state[1] = RMD_H1; in rmd256_init()
236 rctx->state[2] = RMD_H2; in rmd256_init()
237 rctx->state[3] = RMD_H3; in rmd256_init()
238 rctx->state[4] = RMD_H5; in rmd256_init()
239 rctx->state[5] = RMD_H6; in rmd256_init()
240 rctx->state[6] = RMD_H7; in rmd256_init()
241 rctx->state[7] = RMD_H8; in rmd256_init()
243 memset(rctx->buffer, 0, sizeof(rctx->buffer)); in rmd256_init()
252 const u32 avail = sizeof(rctx->buffer) - (rctx->byte_count & 0x3f); in rmd256_update()
254 rctx->byte_count += len; in rmd256_update()
256 /* Enough space in buffer? If so copy and we're done */ in rmd256_update()
258 memcpy((char *)rctx->buffer + (sizeof(rctx->buffer) - avail), in rmd256_update()
263 memcpy((char *)rctx->buffer + (sizeof(rctx->buffer) - avail), in rmd256_update()
266 rmd256_transform(rctx->state, rctx->buffer); in rmd256_update()
268 len -= avail; in rmd256_update()
270 while (len >= sizeof(rctx->buffer)) { in rmd256_update()
271 memcpy(rctx->buffer, data, sizeof(rctx->buffer)); in rmd256_update()
272 rmd256_transform(rctx->state, rctx->buffer); in rmd256_update()
273 data += sizeof(rctx->buffer); in rmd256_update()
274 len -= sizeof(rctx->buffer); in rmd256_update()
277 memcpy(rctx->buffer, data, len); in rmd256_update()
292 bits = cpu_to_le64(rctx->byte_count << 3); in rmd256_final()
295 index = rctx->byte_count & 0x3f; in rmd256_final()
296 padlen = (index < 56) ? (56 - index) : ((64+56) - index); in rmd256_final()
302 /* Store state in digest */ in rmd256_final()
304 dst[i] = cpu_to_le32p(&rctx->state[i]); in rmd256_final()
320 .cra_driver_name = "rmd256-generic",
340 MODULE_AUTHOR("Adrian-Ken Rueegsegger <ken@codelabs.ch>");
341 MODULE_DESCRIPTION("RIPEMD-256 Message Digest");