2 /* This implements the Fowler / Noll / Vo (FNV-1) hash algorithm.
3 * A summary of the algorithm can be found at:
4 * http://www.isthe.com/chongo/tech/comp/fnv/index.html
9 #include <lutil_hash.h>
11 /* offset and prime for 32-bit FNV-1 */
12 #define HASH_OFFSET 0x811c9dc5U
13 #define HASH_PRIME 16777619
20 lutil_HASHInit( struct lutil_HASHContext *ctx )
22 ctx->hash = HASH_OFFSET;
30 struct lutil_HASHContext *ctx,
31 const unsigned char *buf,
35 const unsigned char *p, *e;
55 lutil_HASHFinal( unsigned char *digest, struct lutil_HASHContext *ctx )
57 ber_uint_t h = ctx->hash;
59 digest[0] = h & 0xffU;
60 digest[1] = (h>>8) & 0xffU;
61 digest[2] = (h>>16) & 0xffU;
62 digest[3] = (h>>24) & 0xffU;