diff options
Diffstat (limited to 'e2fsprogs/ext2fs/dirhash.c')
-rw-r--r-- | e2fsprogs/ext2fs/dirhash.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/e2fsprogs/ext2fs/dirhash.c b/e2fsprogs/ext2fs/dirhash.c index 4d18593f5..39678a628 100644 --- a/e2fsprogs/ext2fs/dirhash.c +++ b/e2fsprogs/ext2fs/dirhash.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * dirhash.c -- Calculate the hash of a directory entry | 2 | * dirhash.c -- Calculate the hash of a directory entry |
3 | * | 3 | * |
4 | * Copyright (c) 2001 Daniel Phillips | 4 | * Copyright (c) 2001 Daniel Phillips |
5 | * | 5 | * |
6 | * Copyright (c) 2002 Theodore Ts'o. | 6 | * Copyright (c) 2002 Theodore Ts'o. |
7 | * | 7 | * |
8 | * %Begin-Header% | 8 | * %Begin-Header% |
@@ -25,7 +25,7 @@ | |||
25 | * (see Applied Cryptography, 2nd edition, p448). | 25 | * (see Applied Cryptography, 2nd edition, p448). |
26 | * | 26 | * |
27 | * Jeremy Fitzhardinge <jeremy@zip.com.au> 1998 | 27 | * Jeremy Fitzhardinge <jeremy@zip.com.au> 1998 |
28 | * | 28 | * |
29 | * This code is made available under the terms of the GPL | 29 | * This code is made available under the terms of the GPL |
30 | */ | 30 | */ |
31 | #define DELTA 0x9E3779B9 | 31 | #define DELTA 0x9E3779B9 |
@@ -37,10 +37,10 @@ static void TEA_transform(__u32 buf[4], __u32 const in[]) | |||
37 | __u32 a = in[0], b = in[1], c = in[2], d = in[3]; | 37 | __u32 a = in[0], b = in[1], c = in[2], d = in[3]; |
38 | int n = 16; | 38 | int n = 16; |
39 | 39 | ||
40 | do { | 40 | do { |
41 | sum += DELTA; | 41 | sum += DELTA; |
42 | b0 += ((b1 << 4)+a) ^ (b1+sum) ^ ((b1 >> 5)+b); | 42 | b0 += ((b1 << 4)+a) ^ (b1+sum) ^ ((b1 >> 5)+b); |
43 | b1 += ((b0 << 4)+c) ^ (b0+sum) ^ ((b0 >> 5)+d); | 43 | b1 += ((b0 << 4)+c) ^ (b0+sum) ^ ((b0 >> 5)+d); |
44 | } while(--n); | 44 | } while(--n); |
45 | 45 | ||
46 | buf[0] += b0; | 46 | buf[0] += b0; |
@@ -121,7 +121,7 @@ static ext2_dirhash_t dx_hack_hash (const char *name, int len) | |||
121 | __u32 hash0 = 0x12a3fe2d, hash1 = 0x37abe8f9; | 121 | __u32 hash0 = 0x12a3fe2d, hash1 = 0x37abe8f9; |
122 | while (len--) { | 122 | while (len--) { |
123 | __u32 hash = hash1 + (hash0 ^ (*name++ * 7152373)); | 123 | __u32 hash = hash1 + (hash0 ^ (*name++ * 7152373)); |
124 | 124 | ||
125 | if (hash & 0x80000000) hash -= 0x7fffffff; | 125 | if (hash & 0x80000000) hash -= 0x7fffffff; |
126 | hash1 = hash0; | 126 | hash1 = hash0; |
127 | hash0 = hash; | 127 | hash0 = hash; |
@@ -160,11 +160,11 @@ static void str2hashbuf(const char *msg, int len, __u32 *buf, int num) | |||
160 | * Returns the hash of a filename. If len is 0 and name is NULL, then | 160 | * Returns the hash of a filename. If len is 0 and name is NULL, then |
161 | * this function can be used to test whether or not a hash version is | 161 | * this function can be used to test whether or not a hash version is |
162 | * supported. | 162 | * supported. |
163 | * | 163 | * |
164 | * The seed is an 4 longword (32 bits) "secret" which can be used to | 164 | * The seed is an 4 longword (32 bits) "secret" which can be used to |
165 | * uniquify a hash. If the seed is all zero's, then some default seed | 165 | * uniquify a hash. If the seed is all zero's, then some default seed |
166 | * may be used. | 166 | * may be used. |
167 | * | 167 | * |
168 | * A particular hash version specifies whether or not the seed is | 168 | * A particular hash version specifies whether or not the seed is |
169 | * represented, and whether or not the returned hash is 32 bits or 64 | 169 | * represented, and whether or not the returned hash is 32 bits or 64 |
170 | * bits. 32 bit hashes will return 0 for the minor hash. | 170 | * bits. 32 bit hashes will return 0 for the minor hash. |
@@ -178,7 +178,7 @@ errcode_t ext2fs_dirhash(int version, const char *name, int len, | |||
178 | __u32 minor_hash = 0; | 178 | __u32 minor_hash = 0; |
179 | const char *p; | 179 | const char *p; |
180 | int i; | 180 | int i; |
181 | __u32 in[8], buf[4]; | 181 | __u32 in[8], buf[4]; |
182 | 182 | ||
183 | /* Initialize the default seed for the hash checksum functions */ | 183 | /* Initialize the default seed for the hash checksum functions */ |
184 | buf[0] = 0x67452301; | 184 | buf[0] = 0x67452301; |
@@ -195,7 +195,7 @@ errcode_t ext2fs_dirhash(int version, const char *name, int len, | |||
195 | if (i < 4) | 195 | if (i < 4) |
196 | memcpy(buf, seed, sizeof(buf)); | 196 | memcpy(buf, seed, sizeof(buf)); |
197 | } | 197 | } |
198 | 198 | ||
199 | switch (version) { | 199 | switch (version) { |
200 | case EXT2_HASH_LEGACY: | 200 | case EXT2_HASH_LEGACY: |
201 | hash = dx_hack_hash(name, len); | 201 | hash = dx_hack_hash(name, len); |