Lines Matching +full:0 +full:- +full:9 +full:a +full:- +full:z
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>
37 #define F1(x, y, z) (x ^ y ^ z) /* XOR */ argument
38 #define F2(x, y, z) (z ^ (x & (y ^ z))) /* x ? y : z */ argument
39 #define F3(x, y, z) ((x | ~y) ^ z) argument
40 #define F4(x, y, z) (y ^ (z & (x ^ y))) /* z ? x : y */ argument
41 #define F5(x, y, z) (x ^ (y | ~z)) argument
43 #define ROUND(a, b, c, d, e, f, k, x, s) { \ argument
44 (a) += f((b), (c), (d)) + le32_to_cpup(&(x)) + (k); \
45 (a) = rol32((a), (s)) + (e); \
54 aa = state[0]; in rmd160_transform()
61 aaa = state[0]; in rmd160_transform()
68 ROUND(aa, bb, cc, dd, ee, F1, K1, in[0], 11); in rmd160_transform()
75 ROUND(dd, ee, aa, bb, cc, F1, K1, in[7], 9); in rmd160_transform()
77 ROUND(bb, cc, dd, ee, aa, F1, K1, in[9], 13); in rmd160_transform()
82 ROUND(bb, cc, dd, ee, aa, F1, K1, in[14], 9); in rmd160_transform()
91 ROUND(ee, aa, bb, cc, dd, F2, K2, in[6], 9); 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()
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()
114 ROUND(dd, ee, aa, bb, cc, F3, K3, in[0], 13); in rmd160_transform()
123 ROUND(bb, cc, dd, ee, aa, F4, K4, in[9], 12); in rmd160_transform()
126 ROUND(dd, ee, aa, bb, cc, F4, K4, in[0], 14); in rmd160_transform()
128 ROUND(bb, cc, dd, ee, aa, F4, K4, in[12], 9); in rmd160_transform()
130 ROUND(ee, aa, bb, cc, dd, F4, K4, in[13], 9); 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()
143 ROUND(dd, ee, aa, bb, cc, F5, K5, in[9], 11); 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()
176 ROUND(eee, aaa, bbb, ccc, ddd, F4, KK2, in[6], 9); in rmd160_transform()
180 ROUND(aaa, bbb, ccc, ddd, eee, F4, KK2, in[0], 12); in rmd160_transform()
182 ROUND(ddd, eee, aaa, bbb, ccc, F4, KK2, in[5], 9); in rmd160_transform()
189 ROUND(bbb, ccc, ddd, eee, aaa, F4, KK2, in[9], 15); in rmd160_transform()
194 ROUND(ddd, eee, aaa, bbb, ccc, F3, KK3, in[15], 9); in rmd160_transform()
201 ROUND(bbb, ccc, ddd, eee, aaa, F3, KK3, in[9], 14); in rmd160_transform()
207 ROUND(aaa, bbb, ccc, ddd, eee, F3, KK3, in[0], 13); in rmd160_transform()
219 ROUND(aaa, bbb, ccc, ddd, eee, F2, KK4, in[0], 14); in rmd160_transform()
221 ROUND(ddd, eee, aaa, bbb, ccc, F2, KK4, in[12], 9); 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()
233 ROUND(ddd, eee, aaa, bbb, ccc, F1, KK5, in[4], 9); in rmd160_transform()
242 ROUND(eee, aaa, bbb, ccc, ddd, F1, KK5, in[0], 15); in rmd160_transform()
244 ROUND(ccc, ddd, eee, aaa, bbb, F1, KK5, in[9], 11); in rmd160_transform()
248 ddd += cc + state[1]; /* final result for state[0] */ in rmd160_transform()
252 state[4] = state[0] + bb + ccc; in rmd160_transform()
253 state[0] = ddd; 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()
270 return 0; 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()
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()
305 return 0; in rmd160_update()
315 static const u8 padding[64] = { 0x80, }; in rmd160_final()
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()
328 for (i = 0; i < 5; i++) in rmd160_final()
329 dst[i] = cpu_to_le32p(&rctx->state[i]); in rmd160_final()
332 memset(rctx, 0, sizeof(*rctx)); in rmd160_final()
334 return 0; 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");