Home | History | Annotate | Line # | Download | only in include
      1 /*	$NetBSD: lutil_hash.h,v 1.4 2025/09/05 21:16:19 christos Exp $	*/
      2 
      3 /* $OpenLDAP$ */
      4 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
      5  *
      6  * Copyright 1998-2024 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 
     23 LDAP_BEGIN_DECL
     24 
     25 #define LUTIL_HASH_BYTES 4
     26 
     27 #ifdef HAVE_LONG_LONG
     28 
     29 typedef union lutil_HASHContext {
     30 	ber_uint_t hash;
     31 	unsigned long long hash64;
     32 } lutil_HASH_CTX;
     33 
     34 #else /* !HAVE_LONG_LONG */
     35 
     36 typedef struct lutil_HASHContext {
     37 	ber_uint_t hash;
     38 } lutil_HASH_CTX;
     39 
     40 #endif /* HAVE_LONG_LONG */
     41 
     42 LDAP_LUTIL_F( void )
     43 lutil_HASHInit LDAP_P((
     44 	lutil_HASH_CTX *context));
     45 
     46 LDAP_LUTIL_F( void )
     47 lutil_HASHUpdate LDAP_P((
     48 	lutil_HASH_CTX *context,
     49 	unsigned char const *buf,
     50 	ber_len_t len));
     51 
     52 LDAP_LUTIL_F( void )
     53 lutil_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 
     61 LDAP_LUTIL_F( void )
     62 lutil_HASH64Init LDAP_P((
     63 	lutil_HASH_CTX *context));
     64 
     65 LDAP_LUTIL_F( void )
     66 lutil_HASH64Update LDAP_P((
     67 	lutil_HASH_CTX *context,
     68 	unsigned char const *buf,
     69 	ber_len_t len));
     70 
     71 LDAP_LUTIL_F( void )
     72 lutil_HASH64Final LDAP_P((
     73 	unsigned char digest[LUTIL_HASH64_BYTES],
     74 	lutil_HASH_CTX *context));
     75 
     76 #endif /* HAVE_LONG_LONG */
     77 
     78 LDAP_END_DECL
     79 
     80 #endif /* _LUTIL_HASH_H_ */
     81