3 * Keyed 32-bit hash function using TEA in a Davis-Meyer function
5 * Hi = E Mi(Hi-1) + Hi-1
7 * (see Applied Cryptography, 2nd edition, p448).
9 * Jeremy Fitzhardinge <jeremy@zip.com.au> 1998
11 * Jeremy has agreed to the contents of reiserfs/README. -Hans
12 * Yura's function is added (04/07/2000)
21 #include <linux/kernel.h> /* for printk() as called by BUG() */
22 #include <asm/types.h>
27 #define DELTA 0x9E3779B9
28 #define FULLROUNDS 10 /* 32 is overkill, 16 is strong crypto */
29 #define PARTROUNDS 6 /* 6 gets complete mixing */
31 /* a, b, c, d - data; h0, h1 - accumulated hash */
32 #define TEACORE(rounds) \
44 b0 += ((b1 << 4)+a) ^ (b1+sum) ^ ((b1 >> 5)+b); \
45 b1 += ((b0 << 4)+c) ^ (b0+sum) ^ ((b0 >> 5)+d); \
53 u32 keyed_hash(const signed char *msg, int len)
55 u32 k[] = { 0x9464a485, 0x542e1a94, 0x3e846bff, 0xb75bcfc3};
57 u32 h0 = k[0], h1 = k[1];
62 // assert(len >= 0 && len < 256);
64 pad = (u32)len | ((u32)len << 8);
112 for(i = 12; i < len; i++)
133 for(i = 8; i < len; i++)
150 for(i = 4; i < len; i++)
162 for(i = 0; i < len; i++)
175 /* What follows in this file is copyright 2000-2002 by Hans Reiser, and the
176 * licensing of what follows is governed by reiserfs/README */
178 u32 yura_hash (const signed char *msg, int len)
184 for (pow=1,i=1; i < len; i++) pow = pow * 10;
189 a = (msg[0] - 48) * pow;
191 for (i=1; i < len; i++) {
193 for (pow=1,j=i; j < len-1; j++) pow = pow * 10;
197 for (; i < 40; i++) {
199 for (pow=1,j=i; j < len-1; j++) pow = pow * 10;
203 for (; i < 256; i++) {
205 for (pow=1,j=i; j < len-1; j++) pow = pow * 10;
213 u32 r5_hash (const signed char *msg, int len)