1/* $NetBSD: lutil_hash.h,v 1.3 2021/08/14 16:14:55 christos Exp $ */ 2 3/* $OpenLDAP$ */ 4/* This work is part of OpenLDAP Software <http://www.openldap.org/>. 5 * 6 * Copyright 1998-2021 The OpenLDAP Foundation. 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted only as authorized by the OpenLDAP 11 * Public License. 12 * 13 * A copy of this license is available in file LICENSE in the 14 * top-level directory of the distribution or, alternatively, at 15 * <http://www.OpenLDAP.org/license.html>. 16 */ 17 18#ifndef _LUTIL_HASH_H_ 19#define _LUTIL_HASH_H_ 20 21#include <lber_types.h> 22 23LDAP_BEGIN_DECL 24 25#define LUTIL_HASH_BYTES 4 26 27#ifdef HAVE_LONG_LONG 28 29typedef union lutil_HASHContext { 30 ber_uint_t hash; 31 unsigned long long hash64; 32} lutil_HASH_CTX; 33 34#else /* !HAVE_LONG_LONG */ 35 36typedef struct lutil_HASHContext { 37 ber_uint_t hash; 38} lutil_HASH_CTX; 39 40#endif /* HAVE_LONG_LONG */ 41 42LDAP_LUTIL_F( void ) 43lutil_HASHInit LDAP_P(( 44 lutil_HASH_CTX *context)); 45 46LDAP_LUTIL_F( void ) 47lutil_HASHUpdate LDAP_P(( 48 lutil_HASH_CTX *context, 49 unsigned char const *buf, 50 ber_len_t len)); 51 52LDAP_LUTIL_F( void ) 53lutil_HASHFinal LDAP_P(( 54 unsigned char digest[LUTIL_HASH_BYTES], 55 lutil_HASH_CTX *context)); 56 57#ifdef HAVE_LONG_LONG 58 59#define LUTIL_HASH64_BYTES 8 60 61LDAP_LUTIL_F( void ) 62lutil_HASH64Init LDAP_P(( 63 lutil_HASH_CTX *context)); 64 65LDAP_LUTIL_F( void ) 66lutil_HASH64Update LDAP_P(( 67 lutil_HASH_CTX *context, 68 unsigned char const *buf, 69 ber_len_t len)); 70 71LDAP_LUTIL_F( void ) 72lutil_HASH64Final LDAP_P(( 73 unsigned char digest[LUTIL_HASH64_BYTES], 74 lutil_HASH_CTX *context)); 75 76#endif /* HAVE_LONG_LONG */ 77 78LDAP_END_DECL 79 80#endif /* _LUTIL_HASH_H_ */ 81