Back to index

openldap  2.4.31
Defines | Functions
hash.c File Reference
#include "portable.h"
#include <lutil_hash.h>

Go to the source code of this file.

Defines

#define HASH_OFFSET   0x811c9dc5U
#define HASH_PRIME   16777619

Functions

void lutil_HASHInit (struct lutil_HASHContext *ctx)
void lutil_HASHUpdate (struct lutil_HASHContext *ctx, const unsigned char *buf, ber_len_t len)
void lutil_HASHFinal (unsigned char *digest, struct lutil_HASHContext *ctx)

Define Documentation

#define HASH_OFFSET   0x811c9dc5U

Definition at line 27 of file hash.c.

#define HASH_PRIME   16777619

Definition at line 28 of file hash.c.


Function Documentation

void lutil_HASHFinal ( unsigned char *  digest,
struct lutil_HASHContext ctx 
)

Definition at line 69 of file hash.c.

{
       ber_uint_t h = ctx->hash;

       digest[0] = h & 0xffU;
       digest[1] = (h>>8) & 0xffU;
       digest[2] = (h>>16) & 0xffU;
       digest[3] = (h>>24) & 0xffU;
}

Definition at line 35 of file hash.c.

{
       ctx->hash = HASH_OFFSET;
}
void lutil_HASHUpdate ( struct lutil_HASHContext ctx,
const unsigned char *  buf,
ber_len_t  len 
)

Definition at line 44 of file hash.c.

{
       const unsigned char *p, *e;
       ber_uint_t h;

       p = buf;
       e = &buf[len];

       h = ctx->hash;

       while( p < e ) {
              h *= HASH_PRIME;
              h ^= *p++;
       }

       ctx->hash = h;
}