Lines Matching +full:in +full:-

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * RIPEMD-128 - 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 rmd128_transform(u32 *state, const __le32 *in) in rmd128_transform() argument
62 ROUND(aa, bb, cc, dd, F1, K1, in[0], 11); in rmd128_transform()
63 ROUND(dd, aa, bb, cc, F1, K1, in[1], 14); in rmd128_transform()
64 ROUND(cc, dd, aa, bb, F1, K1, in[2], 15); in rmd128_transform()
65 ROUND(bb, cc, dd, aa, F1, K1, in[3], 12); in rmd128_transform()
66 ROUND(aa, bb, cc, dd, F1, K1, in[4], 5); in rmd128_transform()
67 ROUND(dd, aa, bb, cc, F1, K1, in[5], 8); in rmd128_transform()
68 ROUND(cc, dd, aa, bb, F1, K1, in[6], 7); in rmd128_transform()
69 ROUND(bb, cc, dd, aa, F1, K1, in[7], 9); in rmd128_transform()
70 ROUND(aa, bb, cc, dd, F1, K1, in[8], 11); in rmd128_transform()
71 ROUND(dd, aa, bb, cc, F1, K1, in[9], 13); in rmd128_transform()
72 ROUND(cc, dd, aa, bb, F1, K1, in[10], 14); in rmd128_transform()
73 ROUND(bb, cc, dd, aa, F1, K1, in[11], 15); in rmd128_transform()
74 ROUND(aa, bb, cc, dd, F1, K1, in[12], 6); in rmd128_transform()
75 ROUND(dd, aa, bb, cc, F1, K1, in[13], 7); in rmd128_transform()
76 ROUND(cc, dd, aa, bb, F1, K1, in[14], 9); in rmd128_transform()
77 ROUND(bb, cc, dd, aa, F1, K1, in[15], 8); in rmd128_transform()
80 ROUND(aa, bb, cc, dd, F2, K2, in[7], 7); in rmd128_transform()
81 ROUND(dd, aa, bb, cc, F2, K2, in[4], 6); in rmd128_transform()
82 ROUND(cc, dd, aa, bb, F2, K2, in[13], 8); in rmd128_transform()
83 ROUND(bb, cc, dd, aa, F2, K2, in[1], 13); in rmd128_transform()
84 ROUND(aa, bb, cc, dd, F2, K2, in[10], 11); in rmd128_transform()
85 ROUND(dd, aa, bb, cc, F2, K2, in[6], 9); in rmd128_transform()
86 ROUND(cc, dd, aa, bb, F2, K2, in[15], 7); in rmd128_transform()
87 ROUND(bb, cc, dd, aa, F2, K2, in[3], 15); in rmd128_transform()
88 ROUND(aa, bb, cc, dd, F2, K2, in[12], 7); in rmd128_transform()
89 ROUND(dd, aa, bb, cc, F2, K2, in[0], 12); in rmd128_transform()
90 ROUND(cc, dd, aa, bb, F2, K2, in[9], 15); in rmd128_transform()
91 ROUND(bb, cc, dd, aa, F2, K2, in[5], 9); in rmd128_transform()
92 ROUND(aa, bb, cc, dd, F2, K2, in[2], 11); in rmd128_transform()
93 ROUND(dd, aa, bb, cc, F2, K2, in[14], 7); in rmd128_transform()
94 ROUND(cc, dd, aa, bb, F2, K2, in[11], 13); in rmd128_transform()
95 ROUND(bb, cc, dd, aa, F2, K2, in[8], 12); in rmd128_transform()
98 ROUND(aa, bb, cc, dd, F3, K3, in[3], 11); in rmd128_transform()
99 ROUND(dd, aa, bb, cc, F3, K3, in[10], 13); in rmd128_transform()
100 ROUND(cc, dd, aa, bb, F3, K3, in[14], 6); in rmd128_transform()
101 ROUND(bb, cc, dd, aa, F3, K3, in[4], 7); in rmd128_transform()
102 ROUND(aa, bb, cc, dd, F3, K3, in[9], 14); in rmd128_transform()
103 ROUND(dd, aa, bb, cc, F3, K3, in[15], 9); in rmd128_transform()
104 ROUND(cc, dd, aa, bb, F3, K3, in[8], 13); in rmd128_transform()
105 ROUND(bb, cc, dd, aa, F3, K3, in[1], 15); in rmd128_transform()
106 ROUND(aa, bb, cc, dd, F3, K3, in[2], 14); in rmd128_transform()
107 ROUND(dd, aa, bb, cc, F3, K3, in[7], 8); in rmd128_transform()
108 ROUND(cc, dd, aa, bb, F3, K3, in[0], 13); in rmd128_transform()
109 ROUND(bb, cc, dd, aa, F3, K3, in[6], 6); in rmd128_transform()
110 ROUND(aa, bb, cc, dd, F3, K3, in[13], 5); in rmd128_transform()
111 ROUND(dd, aa, bb, cc, F3, K3, in[11], 12); in rmd128_transform()
112 ROUND(cc, dd, aa, bb, F3, K3, in[5], 7); in rmd128_transform()
113 ROUND(bb, cc, dd, aa, F3, K3, in[12], 5); in rmd128_transform()
116 ROUND(aa, bb, cc, dd, F4, K4, in[1], 11); in rmd128_transform()
117 ROUND(dd, aa, bb, cc, F4, K4, in[9], 12); in rmd128_transform()
118 ROUND(cc, dd, aa, bb, F4, K4, in[11], 14); in rmd128_transform()
119 ROUND(bb, cc, dd, aa, F4, K4, in[10], 15); in rmd128_transform()
120 ROUND(aa, bb, cc, dd, F4, K4, in[0], 14); in rmd128_transform()
121 ROUND(dd, aa, bb, cc, F4, K4, in[8], 15); in rmd128_transform()
122 ROUND(cc, dd, aa, bb, F4, K4, in[12], 9); in rmd128_transform()
123 ROUND(bb, cc, dd, aa, F4, K4, in[4], 8); in rmd128_transform()
124 ROUND(aa, bb, cc, dd, F4, K4, in[13], 9); in rmd128_transform()
125 ROUND(dd, aa, bb, cc, F4, K4, in[3], 14); in rmd128_transform()
126 ROUND(cc, dd, aa, bb, F4, K4, in[7], 5); in rmd128_transform()
127 ROUND(bb, cc, dd, aa, F4, K4, in[15], 6); in rmd128_transform()
128 ROUND(aa, bb, cc, dd, F4, K4, in[14], 8); in rmd128_transform()
129 ROUND(dd, aa, bb, cc, F4, K4, in[5], 6); in rmd128_transform()
130 ROUND(cc, dd, aa, bb, F4, K4, in[6], 5); in rmd128_transform()
131 ROUND(bb, cc, dd, aa, F4, K4, in[2], 12); in rmd128_transform()
134 ROUND(aaa, bbb, ccc, ddd, F4, KK1, in[5], 8); in rmd128_transform()
135 ROUND(ddd, aaa, bbb, ccc, F4, KK1, in[14], 9); in rmd128_transform()
136 ROUND(ccc, ddd, aaa, bbb, F4, KK1, in[7], 9); in rmd128_transform()
137 ROUND(bbb, ccc, ddd, aaa, F4, KK1, in[0], 11); in rmd128_transform()
138 ROUND(aaa, bbb, ccc, ddd, F4, KK1, in[9], 13); in rmd128_transform()
139 ROUND(ddd, aaa, bbb, ccc, F4, KK1, in[2], 15); in rmd128_transform()
140 ROUND(ccc, ddd, aaa, bbb, F4, KK1, in[11], 15); in rmd128_transform()
141 ROUND(bbb, ccc, ddd, aaa, F4, KK1, in[4], 5); in rmd128_transform()
142 ROUND(aaa, bbb, ccc, ddd, F4, KK1, in[13], 7); in rmd128_transform()
143 ROUND(ddd, aaa, bbb, ccc, F4, KK1, in[6], 7); in rmd128_transform()
144 ROUND(ccc, ddd, aaa, bbb, F4, KK1, in[15], 8); in rmd128_transform()
145 ROUND(bbb, ccc, ddd, aaa, F4, KK1, in[8], 11); in rmd128_transform()
146 ROUND(aaa, bbb, ccc, ddd, F4, KK1, in[1], 14); in rmd128_transform()
147 ROUND(ddd, aaa, bbb, ccc, F4, KK1, in[10], 14); in rmd128_transform()
148 ROUND(ccc, ddd, aaa, bbb, F4, KK1, in[3], 12); in rmd128_transform()
149 ROUND(bbb, ccc, ddd, aaa, F4, KK1, in[12], 6); in rmd128_transform()
152 ROUND(aaa, bbb, ccc, ddd, F3, KK2, in[6], 9); in rmd128_transform()
153 ROUND(ddd, aaa, bbb, ccc, F3, KK2, in[11], 13); in rmd128_transform()
154 ROUND(ccc, ddd, aaa, bbb, F3, KK2, in[3], 15); in rmd128_transform()
155 ROUND(bbb, ccc, ddd, aaa, F3, KK2, in[7], 7); in rmd128_transform()
156 ROUND(aaa, bbb, ccc, ddd, F3, KK2, in[0], 12); in rmd128_transform()
157 ROUND(ddd, aaa, bbb, ccc, F3, KK2, in[13], 8); in rmd128_transform()
158 ROUND(ccc, ddd, aaa, bbb, F3, KK2, in[5], 9); in rmd128_transform()
159 ROUND(bbb, ccc, ddd, aaa, F3, KK2, in[10], 11); in rmd128_transform()
160 ROUND(aaa, bbb, ccc, ddd, F3, KK2, in[14], 7); in rmd128_transform()
161 ROUND(ddd, aaa, bbb, ccc, F3, KK2, in[15], 7); in rmd128_transform()
162 ROUND(ccc, ddd, aaa, bbb, F3, KK2, in[8], 12); in rmd128_transform()
163 ROUND(bbb, ccc, ddd, aaa, F3, KK2, in[12], 7); in rmd128_transform()
164 ROUND(aaa, bbb, ccc, ddd, F3, KK2, in[4], 6); in rmd128_transform()
165 ROUND(ddd, aaa, bbb, ccc, F3, KK2, in[9], 15); in rmd128_transform()
166 ROUND(ccc, ddd, aaa, bbb, F3, KK2, in[1], 13); in rmd128_transform()
167 ROUND(bbb, ccc, ddd, aaa, F3, KK2, in[2], 11); in rmd128_transform()
170 ROUND(aaa, bbb, ccc, ddd, F2, KK3, in[15], 9); in rmd128_transform()
171 ROUND(ddd, aaa, bbb, ccc, F2, KK3, in[5], 7); in rmd128_transform()
172 ROUND(ccc, ddd, aaa, bbb, F2, KK3, in[1], 15); in rmd128_transform()
173 ROUND(bbb, ccc, ddd, aaa, F2, KK3, in[3], 11); in rmd128_transform()
174 ROUND(aaa, bbb, ccc, ddd, F2, KK3, in[7], 8); in rmd128_transform()
175 ROUND(ddd, aaa, bbb, ccc, F2, KK3, in[14], 6); in rmd128_transform()
176 ROUND(ccc, ddd, aaa, bbb, F2, KK3, in[6], 6); in rmd128_transform()
177 ROUND(bbb, ccc, ddd, aaa, F2, KK3, in[9], 14); in rmd128_transform()
178 ROUND(aaa, bbb, ccc, ddd, F2, KK3, in[11], 12); in rmd128_transform()
179 ROUND(ddd, aaa, bbb, ccc, F2, KK3, in[8], 13); in rmd128_transform()
180 ROUND(ccc, ddd, aaa, bbb, F2, KK3, in[12], 5); in rmd128_transform()
181 ROUND(bbb, ccc, ddd, aaa, F2, KK3, in[2], 14); in rmd128_transform()
182 ROUND(aaa, bbb, ccc, ddd, F2, KK3, in[10], 13); in rmd128_transform()
183 ROUND(ddd, aaa, bbb, ccc, F2, KK3, in[0], 13); in rmd128_transform()
184 ROUND(ccc, ddd, aaa, bbb, F2, KK3, in[4], 7); in rmd128_transform()
185 ROUND(bbb, ccc, ddd, aaa, F2, KK3, in[13], 5); in rmd128_transform()
188 ROUND(aaa, bbb, ccc, ddd, F1, KK4, in[8], 15); in rmd128_transform()
189 ROUND(ddd, aaa, bbb, ccc, F1, KK4, in[6], 5); in rmd128_transform()
190 ROUND(ccc, ddd, aaa, bbb, F1, KK4, in[4], 8); in rmd128_transform()
191 ROUND(bbb, ccc, ddd, aaa, F1, KK4, in[1], 11); in rmd128_transform()
192 ROUND(aaa, bbb, ccc, ddd, F1, KK4, in[3], 14); in rmd128_transform()
193 ROUND(ddd, aaa, bbb, ccc, F1, KK4, in[11], 14); in rmd128_transform()
194 ROUND(ccc, ddd, aaa, bbb, F1, KK4, in[15], 6); in rmd128_transform()
195 ROUND(bbb, ccc, ddd, aaa, F1, KK4, in[0], 14); in rmd128_transform()
196 ROUND(aaa, bbb, ccc, ddd, F1, KK4, in[5], 6); in rmd128_transform()
197 ROUND(ddd, aaa, bbb, ccc, F1, KK4, in[12], 9); in rmd128_transform()
198 ROUND(ccc, ddd, aaa, bbb, F1, KK4, in[2], 12); in rmd128_transform()
199 ROUND(bbb, ccc, ddd, aaa, F1, KK4, in[13], 9); in rmd128_transform()
200 ROUND(aaa, bbb, ccc, ddd, F1, KK4, in[9], 12); in rmd128_transform()
201 ROUND(ddd, aaa, bbb, ccc, F1, KK4, in[7], 5); in rmd128_transform()
202 ROUND(ccc, ddd, aaa, bbb, F1, KK4, in[10], 15); in rmd128_transform()
203 ROUND(bbb, ccc, ddd, aaa, F1, KK4, in[14], 8); in rmd128_transform()
217 rctx->byte_count = 0; in rmd128_init()
219 rctx->state[0] = RMD_H0; in rmd128_init()
220 rctx->state[1] = RMD_H1; in rmd128_init()
221 rctx->state[2] = RMD_H2; in rmd128_init()
222 rctx->state[3] = RMD_H3; in rmd128_init()
224 memset(rctx->buffer, 0, sizeof(rctx->buffer)); in rmd128_init()
233 const u32 avail = sizeof(rctx->buffer) - (rctx->byte_count & 0x3f); in rmd128_update()
235 rctx->byte_count += len; in rmd128_update()
237 /* Enough space in buffer? If so copy and we're done */ in rmd128_update()
239 memcpy((char *)rctx->buffer + (sizeof(rctx->buffer) - avail), in rmd128_update()
244 memcpy((char *)rctx->buffer + (sizeof(rctx->buffer) - avail), in rmd128_update()
247 rmd128_transform(rctx->state, rctx->buffer); in rmd128_update()
249 len -= avail; in rmd128_update()
251 while (len >= sizeof(rctx->buffer)) { in rmd128_update()
252 memcpy(rctx->buffer, data, sizeof(rctx->buffer)); in rmd128_update()
253 rmd128_transform(rctx->state, rctx->buffer); in rmd128_update()
254 data += sizeof(rctx->buffer); in rmd128_update()
255 len -= sizeof(rctx->buffer); in rmd128_update()
258 memcpy(rctx->buffer, data, len); in rmd128_update()
273 bits = cpu_to_le64(rctx->byte_count << 3); in rmd128_final()
276 index = rctx->byte_count & 0x3f; in rmd128_final()
277 padlen = (index < 56) ? (56 - index) : ((64+56) - index); in rmd128_final()
283 /* Store state in digest */ in rmd128_final()
285 dst[i] = cpu_to_le32p(&rctx->state[i]); in rmd128_final()
301 .cra_driver_name = "rmd128-generic",
321 MODULE_AUTHOR("Adrian-Ken Rueegsegger <ken@codelabs.ch>");
322 MODULE_DESCRIPTION("RIPEMD-128 Message Digest");